[wp-trac] [WordPress Trac] #54975: Allow filtering global styles
WordPress Trac
noreply at wordpress.org
Wed Feb 9 18:23:53 UTC 2022
#54975: Allow filtering global styles
--------------------------+------------------------------
Reporter: webmandesign | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Editor | Version: 5.9
Severity: normal | Resolution:
Keywords: | Focuses: css
--------------------------+------------------------------
Comment (by webmandesign):
Hi @oandregal,
> When we do filters for this code, I'd think we do it much earlier in the
processing chain: we want consumers to have structured data to work with
and not a blob string difficult to parse and modify.
That's a great idea!
I think it would still be beneficial to have a filter on the actual CSS
string though. That way it's much easier for a theme to remove
`!important` from the CSS, for example, or add its own CSS string if
necessary.
> The editor styles and the front will be the same. If themes want to do
further modifications (editor & front using different styles), they can
tap into the CSS hooks in place
So, if I understand correctly, we are still stuck with `!important` styles
and the only way is to set `--wp--preset--<PRESET_TYPE>--<PRESET_SLUG>` in
the theme :)
You see, the 5.9.1 fix will not really be beneficial for my usecase as I
apply responsive typography in my themes on front-end only (it is not
possible to do so in editor, unfortunately). So I have to set up `--wp--
preset--<PRESET_TYPE>--<PRESET_SLUG>` CSS variables if I don't get rid of
`!important`.
> If the goal is to stop enqueuing the default styles (colors, font sizes,
etc), there's an existing API for that: wp_dequeue_styles. As I mentioned
in other places this can have unintended side-effects as there're pieces
that use the defaults (patterns, existing content, etc).
I do not want to dequeue the global styles. I understand their importance
and surely want to keep them for backwards compatibility if they were used
in the existing content in the past. I just want a way to control the
output of the styles and remove (in my opinion) redundant `!important` as
my theme takes care of styles.
I came up with
[https://github.com/WordPress/gutenberg/issues/38252#issuecomment-1024348024
this code] for the time. But it feels really hacky to dequeue global
styles, process them, and enqueue again - I agree with you it may have
side-effects I'm not aware of currently and that's why I don't want to
"fix" them using that code.
Having a filter would be much better approach in my opinion.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/54975#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list