From 4602c37d10ab57e7701ba85d733372d162886c23 Mon Sep 17 00:00:00 2001 From: tellthemachines Date: Fri, 22 Dec 2023 16:23:41 +1100 Subject: [PATCH 1/5] Allow default duotone styles in themes that don't disable them. --- src/wp-includes/class-wp-theme-json-resolver.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/wp-includes/class-wp-theme-json-resolver.php b/src/wp-includes/class-wp-theme-json-resolver.php index 5a785612ce185..44db8364f1092 100644 --- a/src/wp-includes/class-wp-theme-json-resolver.php +++ b/src/wp-includes/class-wp-theme-json-resolver.php @@ -312,9 +312,6 @@ public static function get_theme_data( $deprecated = array(), $options = array() } $theme_support_data['settings']['color']['defaultGradients'] = $default_gradients; - // Classic themes without a theme.json don't support global duotone. - $theme_support_data['settings']['color']['defaultDuotone'] = false; - // Allow themes to enable link color setting via theme_support. if ( current_theme_supports( 'link-color' ) ) { $theme_support_data['settings']['color']['link'] = true; From 1186fa721eb013412fdc1c0266c43ab128f49cd8 Mon Sep 17 00:00:00 2001 From: tellthemachines Date: Thu, 4 Jan 2024 18:29:05 +1100 Subject: [PATCH 2/5] Add test to check for default color settings in classic themes. --- .../phpunit/tests/theme/wpThemeJsonResolver.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/phpunit/tests/theme/wpThemeJsonResolver.php b/tests/phpunit/tests/theme/wpThemeJsonResolver.php index dd5fff2bff8ef..7b86f7810c14e 100644 --- a/tests/phpunit/tests/theme/wpThemeJsonResolver.php +++ b/tests/phpunit/tests/theme/wpThemeJsonResolver.php @@ -472,6 +472,22 @@ public function test_add_theme_supports_are_loaded_for_themes_without_theme_json $this->assertTrue( $settings['border']['color'], 'Support for "appearance-tools" was not added.' ); } + /** + * Tests that classic themes still get core default settings such as color palette and duotone. + * + * @ticket 60136 + */ + public function test_core_default_settings_are_loaded_for_themes_without_theme_json() { + switch_theme('default'); + + $settings = WP_Theme_JSON_Resolver::get_merged_data( 'theme' )->get_settings(); + + $this->assertFalse( wp_theme_has_theme_json() ); + $this->assertTrue( $settings['color']['defaultPalette'] ); + $this->assertTrue( $settings['color']['defaultDuotone'] ); + $this->assertTrue( $settings['color']['defaultGradients'] ); + } + /** * @ticket 54336 * @ticket 56611 From a7c85913a8b9aa699fcd87be00999ebcef46f155 Mon Sep 17 00:00:00 2001 From: tellthemachines Date: Thu, 4 Jan 2024 18:34:47 +1100 Subject: [PATCH 3/5] Fix link errors --- tests/phpunit/tests/theme/wpThemeJsonResolver.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/phpunit/tests/theme/wpThemeJsonResolver.php b/tests/phpunit/tests/theme/wpThemeJsonResolver.php index 7b86f7810c14e..d595b3a908ae1 100644 --- a/tests/phpunit/tests/theme/wpThemeJsonResolver.php +++ b/tests/phpunit/tests/theme/wpThemeJsonResolver.php @@ -474,11 +474,11 @@ public function test_add_theme_supports_are_loaded_for_themes_without_theme_json /** * Tests that classic themes still get core default settings such as color palette and duotone. - * + * * @ticket 60136 */ public function test_core_default_settings_are_loaded_for_themes_without_theme_json() { - switch_theme('default'); + switch_theme( 'default' ); $settings = WP_Theme_JSON_Resolver::get_merged_data( 'theme' )->get_settings(); From 5b1cdcae7d67fb5570933d610caef3e77a6a3adf Mon Sep 17 00:00:00 2001 From: tellthemachines Date: Thu, 4 Jan 2024 19:12:36 +1100 Subject: [PATCH 4/5] Temp fix for theme support bug --- tests/phpunit/tests/theme/wpThemeJsonResolver.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/phpunit/tests/theme/wpThemeJsonResolver.php b/tests/phpunit/tests/theme/wpThemeJsonResolver.php index d595b3a908ae1..60675679804da 100644 --- a/tests/phpunit/tests/theme/wpThemeJsonResolver.php +++ b/tests/phpunit/tests/theme/wpThemeJsonResolver.php @@ -479,6 +479,7 @@ public function test_add_theme_supports_are_loaded_for_themes_without_theme_json */ public function test_core_default_settings_are_loaded_for_themes_without_theme_json() { switch_theme( 'default' ); + remove_theme_support( 'editor-gradient-presets' ); $settings = WP_Theme_JSON_Resolver::get_merged_data( 'theme' )->get_settings(); From 6d7ea3b386657096a7e31f19eb6a5d8a0c089ec3 Mon Sep 17 00:00:00 2001 From: tellthemachines Date: Wed, 10 Jan 2024 10:52:07 +1100 Subject: [PATCH 5/5] Remove temporary patch to make tests pass. --- tests/phpunit/tests/theme/wpThemeJsonResolver.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/phpunit/tests/theme/wpThemeJsonResolver.php b/tests/phpunit/tests/theme/wpThemeJsonResolver.php index 60675679804da..d595b3a908ae1 100644 --- a/tests/phpunit/tests/theme/wpThemeJsonResolver.php +++ b/tests/phpunit/tests/theme/wpThemeJsonResolver.php @@ -479,7 +479,6 @@ public function test_add_theme_supports_are_loaded_for_themes_without_theme_json */ public function test_core_default_settings_are_loaded_for_themes_without_theme_json() { switch_theme( 'default' ); - remove_theme_support( 'editor-gradient-presets' ); $settings = WP_Theme_JSON_Resolver::get_merged_data( 'theme' )->get_settings();