Add global styles#1287
Conversation
|
Need to update the unit tests and prepare the corresponding Gutenberg PR, but the code is ready for review. |
| * @return void | ||
| */ | ||
| function wp_enqueue_global_styles() { | ||
| if ( ! WP_Theme_JSON_Resolver::theme_has_support() ) { |
There was a problem hiding this comment.
In cases where there is link color enabled add_theme_support('experimental-link-color'); we need to output the preset classes, should we have a condition for that here?
There was a problem hiding this comment.
I'm not familiar with prior context on how to deal with this so I'd welcome advice. My thinking is that we should do the following:
- We shouldn't port
experimental-link-colorto WordPress core. Themes that want that should use enable it viatheme.json. - In the plugin, I'd expect we remove support for
experimental-link-colorat some point. Probably when the minimum WordPress version for the plugin is 5.8.
Thoughts?
There was a problem hiding this comment.
Yes this seems like a plan 👍
| $stylesheet = $theme_json->get_stylesheet(); | ||
|
|
||
| if ( $can_use_cache ) { | ||
| set_transient( 'global_styles', $stylesheet, MINUTE_IN_SECONDS ); |
jorgefilipecosta
left a comment
There was a problem hiding this comment.
This worked well on my tests and should be ready to merge 👍
I found some issues setting an empty color palette does not work (it defaults to core) but that's a regression setting an empty color palette is a way to disable the color picker. I guess we should look into these issues separately.
|
Committed in 3d3aa3c this PR can be closed. |
Part of https://core.trac.wordpress.org/ticket/53175
Follow-up to #1262
To do
How to test
A theme without theme.json (use the TwentyTwentyOne theme):
global-styles-inline-cssembedded stylesheet. The expected result is that none should be found.--wp--preset--color. The expected result is that none should be found.A theme with theme.json support:
global-styles-inline-cssembedded stylesheet. The expected result is that there's a stylesheet that contains the CSS generated by the engine. Depending on the theme's theme.json, it should be something along these lines:--wp--preset--color. The expected result is that there's an embedded stylesheet that contains the CSS Custom Properties..has-black-color{ ... }. The expected result is that there's an embedded stylesheet that contains the classes for the presets as well as any other block styles defined by the theme viatheme.json.