From 44191ec5f3009804bece7a4d9885586a92128155 Mon Sep 17 00:00:00 2001 From: Carolina Nymark Date: Wed, 28 Jun 2023 10:58:37 +0200 Subject: [PATCH] Add border theme_support (#51777) --- docs/how-to-guides/themes/theme-json.md | 1 + docs/how-to-guides/themes/theme-support.md | 8 ++++++++ lib/class-wp-theme-json-resolver-gutenberg.php | 8 ++++++++ packages/core-data/src/entity-types/theme.ts | 4 ++++ 4 files changed, 21 insertions(+) diff --git a/docs/how-to-guides/themes/theme-json.md b/docs/how-to-guides/themes/theme-json.md index 2212f98a1c870c..697592adf3236c 100644 --- a/docs/how-to-guides/themes/theme-json.md +++ b/docs/how-to-guides/themes/theme-json.md @@ -343,6 +343,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`. | | `appearance-tools` | Set `appearanceTools` to `true`. | +| `border` | Set `border: color, radius, style, width` to `true`. | | `link-color ` | Set `color.link` to `true`. | #### Presets diff --git a/docs/how-to-guides/themes/theme-support.md b/docs/how-to-guides/themes/theme-support.md index 45402691795cdc..eae72f255fac2c 100644 --- a/docs/how-to-guides/themes/theme-support.md +++ b/docs/how-to-guides/themes/theme-support.md @@ -477,6 +477,14 @@ Use this setting to enable the following Global Styles settings: add_theme_support( 'appearance-tools' ); ``` +## Border + +Use this to enable all border settings: + +```php +add_theme_support( 'border' ); +``` + ## Link color Use this to enable the link color setting: diff --git a/lib/class-wp-theme-json-resolver-gutenberg.php b/lib/class-wp-theme-json-resolver-gutenberg.php index 73cae004bfbad2..6e9d05cd7f238b 100644 --- a/lib/class-wp-theme-json-resolver-gutenberg.php +++ b/lib/class-wp-theme-json-resolver-gutenberg.php @@ -319,6 +319,14 @@ 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 all border settings via theme_support. + if ( current_theme_supports( 'border' ) ) { + $theme_support_data['settings']['border']['color'] = true; + $theme_support_data['settings']['border']['radius'] = true; + $theme_support_data['settings']['border']['style'] = true; + $theme_support_data['settings']['border']['width'] = true; + } + // Allow themes to enable link colors via theme_support. if ( current_theme_supports( 'link-color' ) ) { $theme_support_data['settings']['color']['link'] = true; diff --git a/packages/core-data/src/entity-types/theme.ts b/packages/core-data/src/entity-types/theme.ts index 6e15738dd992e0..761c6461d4aca8 100644 --- a/packages/core-data/src/entity-types/theme.ts +++ b/packages/core-data/src/entity-types/theme.ts @@ -85,6 +85,10 @@ declare module './base-entity-records' { * Whether posts and comments RSS feed links are added to head. */ 'automatic-feed-links': boolean; + /** + * Whether border settings are enabled. + */ + border: boolean; /** * Custom background if defined by the theme. */