From d8e8c28bafeebd67c586982edae8de6c9f632021 Mon Sep 17 00:00:00 2001 From: Carolina Nymark Date: Wed, 28 Jun 2023 10:25:11 +0200 Subject: [PATCH] Add link color theme support (#51775) --- docs/how-to-guides/themes/theme-json.md | 2 +- docs/how-to-guides/themes/theme-support.md | 8 ++++++++ lib/class-wp-theme-json-resolver-gutenberg.php | 12 ++++++++++++ packages/core-data/src/entity-types/theme.ts | 4 ++++ 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/docs/how-to-guides/themes/theme-json.md b/docs/how-to-guides/themes/theme-json.md index 4a3dc8f70a85e..2212f98a1c870 100644 --- a/docs/how-to-guides/themes/theme-json.md +++ b/docs/how-to-guides/themes/theme-json.md @@ -342,8 +342,8 @@ To retain backward compatibility, the existing `add_theme_support` declarations | `editor-color-palette` | Provide the list of colors via `color.palette`. | | `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`. | +| `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 423c8c6a4e281..45402691795cd 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' ); ``` +## Link color + +Use this to enable the link color setting: + +```php +add_theme_support( 'link-color' ); +``` + ## Block Based Template Parts Block Based Template parts allow administrators to edit parts of the site using blocks. This is off by default, and requires the theme to opt in by declaring support: diff --git a/lib/class-wp-theme-json-resolver-gutenberg.php b/lib/class-wp-theme-json-resolver-gutenberg.php index 33fd4defd5191..73cae004bfbad 100644 --- a/lib/class-wp-theme-json-resolver-gutenberg.php +++ b/lib/class-wp-theme-json-resolver-gutenberg.php @@ -319,6 +319,18 @@ 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 link colors via theme_support. + if ( current_theme_supports( 'link-color' ) ) { + $theme_support_data['settings']['color']['link'] = true; + } + if ( current_theme_supports( 'experimental-link-color' ) ) { + _doing_it_wrong( + current_theme_supports( 'experimental-link-color' ), + __( '`experimental-link-color` is no longer supported. Use `link-color` instead.', 'gutenberg' ), + '6.3.0' + ); + } + // BEGIN EXPERIMENTAL. // Allow themes to enable appearance tools via theme_support. // This feature was backported for WordPress 6.2 as of https://core.trac.wordpress.org/ticket/56487 diff --git a/packages/core-data/src/entity-types/theme.ts b/packages/core-data/src/entity-types/theme.ts index 04904ae2501f0..6e15738dd992e 100644 --- a/packages/core-data/src/entity-types/theme.ts +++ b/packages/core-data/src/entity-types/theme.ts @@ -141,6 +141,10 @@ declare module './base-entity-records' { * Post formats supported. */ formats: PostFormat[]; + /** + * Whether link colors are enabled. + */ + 'link-color': boolean; /** * The post types that support thumbnails or true if all post types are supported. */