-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Global Styles: Lift classic block restrictions #10623
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
Changes from all commits
29f11d7
7d61223
957376a
e0c7362
1a9bfc8
668ee9c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -480,17 +480,6 @@ public static function get_user_data_from_wp_global_styles( $theme, $create_post | |
| $theme = wp_get_theme(); | ||
| } | ||
|
|
||
| /* | ||
| * Bail early if the theme does not support a theme.json. | ||
| * | ||
| * Since wp_theme_has_theme_json() only supports the active | ||
| * theme, the extra condition for whether $theme is the active theme is | ||
| * present here. | ||
| */ | ||
| if ( $theme->get_stylesheet() === get_stylesheet() && ! wp_theme_has_theme_json() ) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So now we query for all themes (active or inactive, classic or block), not just themes with theme.json support? Is the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I think the first part of the condition was unnecessary, we're explicitly passing a theme. I don't see why this particular function would need to only work for the current theme. |
||
| return array(); | ||
| } | ||
|
|
||
| $user_cpt = array(); | ||
| $post_type_filter = 'wp_global_styles'; | ||
| $stylesheet = $theme->get_stylesheet(); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,10 +39,7 @@ function wp_get_global_settings( $path = array(), $context = array() ) { | |
| * for clearing the cache appropriately. | ||
| */ | ||
| $origin = 'custom'; | ||
| if ( | ||
| ! wp_theme_has_theme_json() || | ||
| ( isset( $context['origin'] ) && 'base' === $context['origin'] ) | ||
| ) { | ||
| if ( isset( $context['origin'] ) && 'base' === $context['origin'] ) { | ||
| $origin = 'theme'; | ||
| } | ||
|
|
||
|
|
@@ -140,12 +137,12 @@ function wp_get_global_styles( $path = array(), $context = array() ) { | |
| * @since 5.9.0 | ||
| * @since 6.1.0 Added 'base-layout-styles' support. | ||
youknowriad marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| * @since 6.6.0 Resolves relative paths in theme.json styles to theme absolute paths. | ||
| * @since 7.0.0 Deprecated 'base-layout-styles' type; classic themes now receive full styles | ||
| * with layout-specific alignment rules skipped via `base_layout_styles` option. | ||
| * | ||
| * @param array $types Optional. Types of styles to load. | ||
| * See {@see 'WP_Theme_JSON::get_stylesheet'} for all valid types. | ||
| * If empty, it'll load the following: | ||
| * - for themes without theme.json: 'variables', 'presets', 'base-layout-styles'. | ||
| * - for themes with theme.json: 'variables', 'presets', 'styles'. | ||
| * If empty, will load: 'variables', 'presets', 'styles'. | ||
| * @return string Stylesheet. | ||
| */ | ||
| function wp_get_global_stylesheet( $types = array() ) { | ||
|
|
@@ -180,15 +177,21 @@ function wp_get_global_stylesheet( $types = array() ) { | |
| } | ||
| } | ||
|
|
||
| $tree = WP_Theme_JSON_Resolver::resolve_theme_file_uris( WP_Theme_JSON_Resolver::get_merged_data() ); | ||
| $supports_theme_json = wp_theme_has_theme_json(); | ||
| $tree = WP_Theme_JSON_Resolver::resolve_theme_file_uris( WP_Theme_JSON_Resolver::get_merged_data() ); | ||
|
|
||
| if ( empty( $types ) && ! $supports_theme_json ) { | ||
| $types = array( 'variables', 'presets', 'base-layout-styles' ); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just checking that things will still work for anyone using the deprecated 'base-layout-styles' type? Would a backwards compat test in pThemeJson.php be appropriate? |
||
| } elseif ( empty( $types ) ) { | ||
| if ( empty( $types ) ) { | ||
| $types = array( 'variables', 'styles', 'presets' ); | ||
| } | ||
|
|
||
| /* | ||
| * Enable base layout styles only mode for classic themes without theme.json. | ||
| * This skips alignment styles that target .wp-site-blocks which is only used by block themes. | ||
| */ | ||
| $options = array(); | ||
| if ( ! wp_is_block_theme() && ! wp_theme_has_theme_json() ) { | ||
| $options['base_layout_styles'] = true; | ||
| } | ||
|
|
||
| /* | ||
| * If variables are part of the stylesheet, then add them. | ||
| * This is so themes without a theme.json still work as before 5.9: | ||
|
|
@@ -204,7 +207,7 @@ function wp_get_global_stylesheet( $types = array() ) { | |
| * @see wp_add_global_styles_for_blocks | ||
| */ | ||
| $origins = array( 'default', 'theme', 'custom' ); | ||
| $styles_variables = $tree->get_stylesheet( array( 'variables' ), $origins ); | ||
| $styles_variables = $tree->get_stylesheet( array( 'variables' ), $origins, $options ); | ||
| $types = array_diff( $types, array( 'variables' ) ); | ||
| } | ||
|
|
||
|
|
@@ -222,17 +225,8 @@ function wp_get_global_stylesheet( $types = array() ) { | |
| * (i.e. in the render cycle). Here, only the ones in use are rendered. | ||
| * @see wp_add_global_styles_for_blocks | ||
| */ | ||
| $origins = array( 'default', 'theme', 'custom' ); | ||
| /* | ||
| * If the theme doesn't have theme.json but supports both appearance tools and color palette, | ||
| * the 'theme' origin should be included so color palette presets are also output. | ||
| */ | ||
| if ( ! $supports_theme_json && ( current_theme_supports( 'appearance-tools' ) || current_theme_supports( 'border' ) ) && current_theme_supports( 'editor-color-palette' ) ) { | ||
| $origins = array( 'default', 'theme' ); | ||
| } elseif ( ! $supports_theme_json ) { | ||
| $origins = array( 'default' ); | ||
| } | ||
| $styles_rest = $tree->get_stylesheet( $types, $origins ); | ||
| $origins = array( 'default', 'theme', 'custom' ); | ||
| $styles_rest = $tree->get_stylesheet( $types, $origins, $options ); | ||
| } | ||
|
|
||
| $stylesheet = $styles_variables . $styles_rest; | ||
|
|
||
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.
After the build change this will be duplicated between here and gutenberg block editor settings. We might have to move things around a bit in Gutenberg so
gutenberg_get_block_editor_settingsdoesn't end up being used in Core, or else we define Gutenberg as the source of truth for this and remove it from Core.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.
Yes, this could be an improvement at some point, but the change of build tool doesn't really impact this much outside making it easier to unify more things.