-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix theme supports for themes without theme.json #34955
Conversation
With this PR the stylesheet would contain the theme presets as well, which is not the expected behavior #34334
I'm looking at alternatives. |
e47406f
to
12d644a
Compare
Pushed the necessary changes to make it work in all scenarios. |
* @return string Stylesheet. | ||
*/ | ||
public function get_stylesheet( $type = 'all' ) { | ||
public function get_stylesheet( $type = 'all', $origins = self::VALID_ORIGINS ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we adding more complexity to the caller by adding new options here instead of absorbing the logic inside the class? Maybe this is not the right level of abstraction I'm looking for. When I want the stylesheet of a theme, why should I need to specify a "type" (meaning do we have dedicated use case to retrieve two different stylesheets for the same theme) or "origins"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
meaning do we have a dedicated use case to retrieve two different stylesheets for the same theme
Yeah, we have. The front enqueues a single stylesheet with all styles but the block editor needs two different stylesheets: one with the block styles that will be wrapped by .editor-styes-wrapper
and the other with the CSS Custom Properties that won't be wrapped so they're available to the UI controls in the sidebar.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm troubled about the origins
as well. However, this is the result of having added them to the existing format for each preset. We still have use cases when we only want one preset (stylesheet for themes without theme.json support, settings from the theme, etc).
I'll continue with the explorations at #34843 to create a higher-level API for consumers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How can we test this to avoid regressions?
The block gap styles are not there but I think it's the right thing since now they are opt-in. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is working as advertised (testing instructions).
A think some documentation or effort to clarify the backend APIs for themes would be great. #34843 is a good start in that aspect.
Being newer to the code base, I won't speak to the specifics of how the change is implemented, but it does test well, and fixes the issue raised with Thanks @oandregal! |
* Pull theme supports for all themes * Enqueue only core presets for themes without theme.json * Fix lint issue * Fix lint issues
This has been cherry-picked to the |
Thanks folks, this really saved us hours of overtime and helps planning for theme.json implementation in our theme. |
I'm adding tests for this at #34998 |
Fixes #34931
Fixes https://wordpress.org/support/topic/gutenberg-plugin-over-rides-custom-editor-color-palette/
#34334 introduced a bug by which settings provided via theme supports were not passed to the editor for themes without
theme.json
supports. This resulted in bugs like the palette of the theme not showing in the editor (it was shown the core palette instead) or that a plugin could not enable thecustom-line-height
support.Tests
Activate TT1-blocks: a theme with
theme.json
support.global-styles-inline-css
is: both core & theme presets (classes and variables), the block gap styles (see), the theme styles.Activate the TwentyTwentyOne theme: a theme without theme.json but with
experimental-link-color
support.global-styles-inline-css
is both core & theme presets (classes and variables).Activate the TwentyTwenty theme: a theme without theme.json and no
experimental-link-color
support.global-styles-inline-css
is the core presets (classes & variables).custom-line-height
and verify the control is shown in the editor. See full instructions or paste the following code in theglobal-styles.php
file: