From ebbfcc65a5b5a8dad7a0d5882e062f8c70ef3c64 Mon Sep 17 00:00:00 2001 From: Ben Dwyer Date: Fri, 16 Sep 2022 11:35:19 +0100 Subject: [PATCH 1/4] Output base styles on classic themes --- lib/compat/wordpress-6.1/block-editor-settings.php | 4 ++-- lib/compat/wordpress-6.1/get-global-styles-and-settings.php | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/compat/wordpress-6.1/block-editor-settings.php b/lib/compat/wordpress-6.1/block-editor-settings.php index 3181329475df4..fc99526eb1098 100644 --- a/lib/compat/wordpress-6.1/block-editor-settings.php +++ b/lib/compat/wordpress-6.1/block-editor-settings.php @@ -82,8 +82,8 @@ function gutenberg_get_block_editor_settings( $settings ) { } else { // If there is no `theme.json` file, ensure base layout styles are still available. $block_classes = array( - 'css' => 'base-layout-styles', - '__unstableType' => 'base-layout', + 'css' => 'styles', + '__unstableType' => 'base-styles', // setting this to something other than `theme` means that the editor will not consider these styles as part of "theme" styles. 'isGlobalStyles' => true, ); $actual_css = gutenberg_get_global_stylesheet( array( $block_classes['css'] ) ); diff --git a/lib/compat/wordpress-6.1/get-global-styles-and-settings.php b/lib/compat/wordpress-6.1/get-global-styles-and-settings.php index ccccdad9a814b..686741162b5e5 100644 --- a/lib/compat/wordpress-6.1/get-global-styles-and-settings.php +++ b/lib/compat/wordpress-6.1/get-global-styles-and-settings.php @@ -84,9 +84,7 @@ function gutenberg_get_global_stylesheet( $types = array() ) { } $tree = WP_Theme_JSON_Resolver_Gutenberg::get_merged_data(); $supports_theme_json = WP_Theme_JSON_Resolver_Gutenberg::theme_has_support(); - if ( empty( $types ) && ! $supports_theme_json ) { - $types = array( 'variables', 'presets', 'base-layout-styles' ); - } elseif ( empty( $types ) ) { + if ( empty( $types ) ) { $types = array( 'variables', 'styles', 'presets' ); } From d4ff87ff07e0034903b5c2dc4b7b79e9e3915976 Mon Sep 17 00:00:00 2001 From: Ben Dwyer Date: Mon, 19 Sep 2022 09:08:39 +0100 Subject: [PATCH 2/4] lower specificity of the link and button element selectors --- lib/compat/wordpress-6.1/class-wp-theme-json-6-1.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/compat/wordpress-6.1/class-wp-theme-json-6-1.php b/lib/compat/wordpress-6.1/class-wp-theme-json-6-1.php index 31ce6d6964b55..0a82b4f087da6 100644 --- a/lib/compat/wordpress-6.1/class-wp-theme-json-6-1.php +++ b/lib/compat/wordpress-6.1/class-wp-theme-json-6-1.php @@ -100,7 +100,7 @@ class WP_Theme_JSON_6_1 extends WP_Theme_JSON_6_0 { 'h4' => 'h4', 'h5' => 'h5', 'h6' => 'h6', - 'button' => '.wp-element-button, .wp-block-button__link', // We have the .wp-block-button__link class so that this will target older buttons that have been serialized. + 'button' => ':where(.wp-element-button), :where(.wp-block-button__link)', // We have the .wp-block-button__link class so that this will target older buttons that have been serialized. 'caption' => '.wp-element-caption, .wp-block-audio figcaption, .wp-block-embed figcaption, .wp-block-gallery figcaption, .wp-block-image figcaption, .wp-block-table figcaption, .wp-block-video figcaption', // The block classes are necessary to target older content that won't use the new class names. 'cite' => 'cite', ); From 321da22515ac8d89ceffc5480a777f829b181f1d Mon Sep 17 00:00:00 2001 From: Ben Dwyer Date: Mon, 19 Sep 2022 13:38:17 +0100 Subject: [PATCH 3/4] fix tests --- phpunit/class-wp-theme-json-test.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/phpunit/class-wp-theme-json-test.php b/phpunit/class-wp-theme-json-test.php index 35c4bf153ddb2..bd47abadbe247 100644 --- a/phpunit/class-wp-theme-json-test.php +++ b/phpunit/class-wp-theme-json-test.php @@ -834,7 +834,7 @@ function test_get_property_value_valid() { ) ); - $expected = 'body { margin: 0;}.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }.wp-site-blocks > .alignright { float: right; margin-left: 2em; }.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }body{background-color: #ffffff;color: #000000;}.wp-element-button, .wp-block-button__link{background-color: #000000;color: #ffffff;}'; + $expected = 'body { margin: 0;}.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }.wp-site-blocks > .alignright { float: right; margin-left: 2em; }.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }body{background-color: #ffffff;color: #000000;}:where(.wp-element-button), :where(.wp-block-button__link){background-color: #000000;color: #ffffff;}'; $this->assertEquals( $expected, $theme_json->get_stylesheet() ); } @@ -866,7 +866,7 @@ function test_get_property_value_loop() { ) ); - $expected = 'body { margin: 0;}.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }.wp-site-blocks > .alignright { float: right; margin-left: 2em; }.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }body{background-color: #ffffff;}.wp-element-button, .wp-block-button__link{color: #ffffff;}'; + $expected = 'body { margin: 0;}.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }.wp-site-blocks > .alignright { float: right; margin-left: 2em; }.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }body{background-color: #ffffff;}:where(.wp-element-button), :where(.wp-block-button__link){color: #ffffff;}'; $this->assertSame( $expected, $theme_json->get_stylesheet() ); } @@ -897,7 +897,7 @@ function test_get_property_value_recursion() { ) ); - $expected = 'body { margin: 0;}.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }.wp-site-blocks > .alignright { float: right; margin-left: 2em; }.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }body{background-color: #ffffff;color: #ffffff;}.wp-element-button, .wp-block-button__link{color: #ffffff;}'; + $expected = 'body { margin: 0;}.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }.wp-site-blocks > .alignright { float: right; margin-left: 2em; }.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }body{background-color: #ffffff;color: #ffffff;}:where(.wp-element-butto), :where(.wp-block-button__link){color: #ffffff;}'; $this->assertEquals( $expected, $theme_json->get_stylesheet() ); } From f926b9ddf66b79f58df72adb88310e17f5a7323a Mon Sep 17 00:00:00 2001 From: Ben Dwyer Date: Mon, 19 Sep 2022 13:53:13 +0100 Subject: [PATCH 4/4] fix tests --- phpunit/class-wp-theme-json-test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpunit/class-wp-theme-json-test.php b/phpunit/class-wp-theme-json-test.php index bd47abadbe247..96b34ff0c6b2e 100644 --- a/phpunit/class-wp-theme-json-test.php +++ b/phpunit/class-wp-theme-json-test.php @@ -897,7 +897,7 @@ function test_get_property_value_recursion() { ) ); - $expected = 'body { margin: 0;}.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }.wp-site-blocks > .alignright { float: right; margin-left: 2em; }.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }body{background-color: #ffffff;color: #ffffff;}:where(.wp-element-butto), :where(.wp-block-button__link){color: #ffffff;}'; + $expected = 'body { margin: 0;}.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }.wp-site-blocks > .alignright { float: right; margin-left: 2em; }.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }body{background-color: #ffffff;color: #ffffff;}:where(.wp-element-button), :where(.wp-block-button__link){color: #ffffff;}'; $this->assertEquals( $expected, $theme_json->get_stylesheet() ); }