From 331e060fd98181aa02bc9e2529d555262fbb63ea Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Tue, 27 Sep 2022 09:53:22 +0200 Subject: [PATCH 1/5] Backport appearance tools theme_support --- src/wp-includes/class-wp-theme-json-resolver.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/wp-includes/class-wp-theme-json-resolver.php b/src/wp-includes/class-wp-theme-json-resolver.php index b1f15897b1af5..e4afc3c1489d8 100644 --- a/src/wp-includes/class-wp-theme-json-resolver.php +++ b/src/wp-includes/class-wp-theme-json-resolver.php @@ -322,6 +322,11 @@ public static function get_theme_data( $deprecated = array(), $options = array() // Classic themes without a theme.json don't support global duotone. $theme_support_data['settings']['color']['defaultDuotone'] = false; + + // Allow themes to enable appearance tools via theme_support. + if ( current_theme_supports( 'appearance-tools' ) ) { + $theme_support_data['settings']['appearanceTools'] = true; + } } $with_theme_supports = new WP_Theme_JSON( $theme_support_data ); $with_theme_supports->merge( static::$theme ); From bda7e25f45e21ed8b36029c3c2d659c6e35a1f67 Mon Sep 17 00:00:00 2001 From: Brian Alexander <824344+ironprogrammer@users.noreply.github.com> Date: Fri, 13 Jan 2023 13:19:17 -0800 Subject: [PATCH 2/5] Add and remove appearance-tools support --- tests/phpunit/tests/theme/wpThemeJsonResolver.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/phpunit/tests/theme/wpThemeJsonResolver.php b/tests/phpunit/tests/theme/wpThemeJsonResolver.php index cd71b889e1c97..8133ddedcbde8 100644 --- a/tests/phpunit/tests/theme/wpThemeJsonResolver.php +++ b/tests/phpunit/tests/theme/wpThemeJsonResolver.php @@ -471,11 +471,13 @@ public function test_add_theme_supports_are_loaded_for_themes_without_theme_json ); add_theme_support( 'editor-color-palette', $color_palette ); add_theme_support( 'custom-line-height' ); + add_theme_support( 'appearance-tools' ); $settings = WP_Theme_JSON_Resolver::get_theme_data()->get_settings(); remove_theme_support( 'custom-line-height' ); remove_theme_support( 'editor-color-palette' ); + remove_theme_support( 'appearance-tools' ); $this->assertFalse( WP_Theme_JSON_Resolver::theme_has_support() ); $this->assertTrue( $settings['typography']['lineHeight'] ); From 99c29e4767e2fd2e163af10094e4260fa43116c1 Mon Sep 17 00:00:00 2001 From: Brian Alexander <824344+ironprogrammer@users.noreply.github.com> Date: Fri, 13 Jan 2023 13:21:41 -0800 Subject: [PATCH 3/5] Test that opt-in support is added Border color is an example opt-in from src/wp-includes/class-wp-theme-json.php:L493. --- 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 8133ddedcbde8..5808e7f5f4b53 100644 --- a/tests/phpunit/tests/theme/wpThemeJsonResolver.php +++ b/tests/phpunit/tests/theme/wpThemeJsonResolver.php @@ -482,6 +482,7 @@ public function test_add_theme_supports_are_loaded_for_themes_without_theme_json $this->assertFalse( WP_Theme_JSON_Resolver::theme_has_support() ); $this->assertTrue( $settings['typography']['lineHeight'] ); $this->assertSame( $color_palette, $settings['color']['palette']['theme'] ); + $this->assertTrue( $settings['border']['color'], 'Support for appearance-tools was not added.' ); } /** From 5a32ede909314d3bcb49f72aa12f559da0d5b594 Mon Sep 17 00:00:00 2001 From: Brian Alexander <824344+ironprogrammer@users.noreply.github.com> Date: Fri, 13 Jan 2023 13:22:23 -0800 Subject: [PATCH 4/5] Reference related backports ticket --- 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 5808e7f5f4b53..87a734e76d6db 100644 --- a/tests/phpunit/tests/theme/wpThemeJsonResolver.php +++ b/tests/phpunit/tests/theme/wpThemeJsonResolver.php @@ -449,6 +449,7 @@ public function test_switching_themes_recalculates_data() { /** * @ticket 54336 + * @ticket 56467 */ public function test_add_theme_supports_are_loaded_for_themes_without_theme_json() { switch_theme( 'default' ); From 008aaa8323f504fab405be4275618a6895ef3bd9 Mon Sep 17 00:00:00 2001 From: Brian Alexander <824344+ironprogrammer@users.noreply.github.com> Date: Fri, 13 Jan 2023 13:33:39 -0800 Subject: [PATCH 5/5] Add `@covers` --- tests/phpunit/tests/theme/wpThemeJsonResolver.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/phpunit/tests/theme/wpThemeJsonResolver.php b/tests/phpunit/tests/theme/wpThemeJsonResolver.php index 87a734e76d6db..541699c686172 100644 --- a/tests/phpunit/tests/theme/wpThemeJsonResolver.php +++ b/tests/phpunit/tests/theme/wpThemeJsonResolver.php @@ -450,6 +450,8 @@ public function test_switching_themes_recalculates_data() { /** * @ticket 54336 * @ticket 56467 + * + * @covers ::add_theme_support */ public function test_add_theme_supports_are_loaded_for_themes_without_theme_json() { switch_theme( 'default' );