From ceed6d8ba30d8286ff6fc871db61cdbd46201e61 Mon Sep 17 00:00:00 2001 From: Jason Crist Date: Wed, 17 Aug 2022 17:46:11 -0400 Subject: [PATCH 1/6] Enable appearance tools via theme_support --- lib/experimental/class-wp-theme-json-resolver-gutenberg.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/experimental/class-wp-theme-json-resolver-gutenberg.php b/lib/experimental/class-wp-theme-json-resolver-gutenberg.php index a4d4e4dfc7066d..39db9b6e92c5d7 100644 --- a/lib/experimental/class-wp-theme-json-resolver-gutenberg.php +++ b/lib/experimental/class-wp-theme-json-resolver-gutenberg.php @@ -29,6 +29,7 @@ class WP_Theme_JSON_Resolver_Gutenberg extends WP_Theme_JSON_Resolver_6_1 { * @return WP_Theme_JSON_Gutenberg Entity that holds theme data. */ public static function get_theme_data( $deprecated = array(), $settings = array( 'with_supports' => true ) ) { + if ( ! empty( $deprecated ) ) { _deprecated_argument( __METHOD__, '5.9' ); } @@ -92,6 +93,11 @@ public static function get_theme_data( $deprecated = array(), $settings = 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_Gutenberg( $theme_support_data ); $with_theme_supports->merge( static::$theme ); From ff2670be0ea35982babe78223ef65f6bdee27ad3 Mon Sep 17 00:00:00 2001 From: Jason Crist Date: Wed, 17 Aug 2022 18:08:34 -0400 Subject: [PATCH 2/6] Add some documentation --- docs/how-to-guides/themes/theme-json.md | 1 + docs/how-to-guides/themes/theme-support.md | 13 +++++++++++++ .../class-wp-theme-json-resolver-gutenberg.php | 1 - 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/docs/how-to-guides/themes/theme-json.md b/docs/how-to-guides/themes/theme-json.md index 95befbd22df9c2..f75addf8da7591 100644 --- a/docs/how-to-guides/themes/theme-json.md +++ b/docs/how-to-guides/themes/theme-json.md @@ -325,6 +325,7 @@ To retain backward compatibility, the existing `add_theme_support` declarations | `editor-font-sizes` | Provide the list of font size via `typography.fontSizes`. | | `editor-gradient-presets` | Provide the list of gradients via `color.gradients`. | | `experimental-link-color` | Set `color.link` to `true`. `experimental-link-color` will be removed when the plugin requires WordPress 5.9 as the minimum version. | +| `appearance-tools` | Set `appearanceTools` to `true`. | #### Presets diff --git a/docs/how-to-guides/themes/theme-support.md b/docs/how-to-guides/themes/theme-support.md index 1d1f42cb7629a4..e7c015fe62113b 100644 --- a/docs/how-to-guides/themes/theme-support.md +++ b/docs/how-to-guides/themes/theme-support.md @@ -463,3 +463,16 @@ where - `` is either `var(--wp--preset--color--slug)` (if the user selected a preset value) or a raw color value (if the user selected a custom value) The block will get attached the class `.wp-elements-`. + +## Appearance Tools + +Use this setting to enable the following Global Styles settings: + +- border: color, radius, style, width +- color: link +- spacing: blockGap, margin, padding +- typography: lineHeight + +```php +add_theme_support( 'appearance-tools' ); +``` diff --git a/lib/experimental/class-wp-theme-json-resolver-gutenberg.php b/lib/experimental/class-wp-theme-json-resolver-gutenberg.php index 39db9b6e92c5d7..bcb4813f1f3d10 100644 --- a/lib/experimental/class-wp-theme-json-resolver-gutenberg.php +++ b/lib/experimental/class-wp-theme-json-resolver-gutenberg.php @@ -29,7 +29,6 @@ class WP_Theme_JSON_Resolver_Gutenberg extends WP_Theme_JSON_Resolver_6_1 { * @return WP_Theme_JSON_Gutenberg Entity that holds theme data. */ public static function get_theme_data( $deprecated = array(), $settings = array( 'with_supports' => true ) ) { - if ( ! empty( $deprecated ) ) { _deprecated_argument( __METHOD__, '5.9' ); } From 6de0b1f74a2c0f0cb1dc22d569260ae39d6d1f41 Mon Sep 17 00:00:00 2001 From: Jason Crist Date: Thu, 18 Aug 2022 08:59:07 -0400 Subject: [PATCH 3/6] Added appearance-tools to Type Supports --- packages/core-data/src/entity-types/theme.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/core-data/src/entity-types/theme.ts b/packages/core-data/src/entity-types/theme.ts index d5f7db3da573df..87815dcf59c149 100644 --- a/packages/core-data/src/entity-types/theme.ts +++ b/packages/core-data/src/entity-types/theme.ts @@ -78,6 +78,10 @@ declare module './base-entity-records' { * Whether theme opts in to wide alignment CSS class. */ 'align-wide': boolean; + /** + * Wether appearanceTools are enabled in Global Settings + */ + 'appearance-tools': boolean; /** * Whether posts and comments RSS feed links are added to head. */ From 1c954fa70ec9ba26cf6a520b2686bd5b51d4be24 Mon Sep 17 00:00:00 2001 From: Jason Crist Date: Thu, 18 Aug 2022 09:00:01 -0400 Subject: [PATCH 4/6] Fixed Typo --- packages/core-data/src/entity-types/theme.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core-data/src/entity-types/theme.ts b/packages/core-data/src/entity-types/theme.ts index 87815dcf59c149..4cf49211670a55 100644 --- a/packages/core-data/src/entity-types/theme.ts +++ b/packages/core-data/src/entity-types/theme.ts @@ -79,7 +79,7 @@ declare module './base-entity-records' { */ 'align-wide': boolean; /** - * Wether appearanceTools are enabled in Global Settings + * Wether appearanceTools are enabled in Global Styles */ 'appearance-tools': boolean; /** From 0c28e7f5507bdd277627026f53cfb5a39785f3ed Mon Sep 17 00:00:00 2001 From: Jason Crist Date: Fri, 19 Aug 2022 09:19:00 -0400 Subject: [PATCH 5/6] Comment formatting --- lib/experimental/class-wp-theme-json-resolver-gutenberg.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/experimental/class-wp-theme-json-resolver-gutenberg.php b/lib/experimental/class-wp-theme-json-resolver-gutenberg.php index bcb4813f1f3d10..138f9b8b865b4c 100644 --- a/lib/experimental/class-wp-theme-json-resolver-gutenberg.php +++ b/lib/experimental/class-wp-theme-json-resolver-gutenberg.php @@ -93,7 +93,7 @@ public static function get_theme_data( $deprecated = array(), $settings = 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 + // Allow themes to enable appearance tools via theme_support. if ( current_theme_supports( 'appearance-tools' ) ) { $theme_support_data['settings']['appearanceTools'] = true; } From 98b1144e63f6e20c50d048b2471a135fb7ee83ac Mon Sep 17 00:00:00 2001 From: Jason Crist Date: Mon, 22 Aug 2022 14:58:52 -0400 Subject: [PATCH 6/6] Update packages/core-data/src/entity-types/theme.ts Fix spelling and punctuation. Co-authored-by: Jeff Ong --- packages/core-data/src/entity-types/theme.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core-data/src/entity-types/theme.ts b/packages/core-data/src/entity-types/theme.ts index 4cf49211670a55..26d70a92007d5e 100644 --- a/packages/core-data/src/entity-types/theme.ts +++ b/packages/core-data/src/entity-types/theme.ts @@ -79,7 +79,7 @@ declare module './base-entity-records' { */ 'align-wide': boolean; /** - * Wether appearanceTools are enabled in Global Styles + * Whether appearanceTools are enabled in Global Styles. */ 'appearance-tools': boolean; /**