From 22c3a54fd480827105ade987cfad47b85072a3f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= Date: Fri, 2 Jul 2021 10:47:40 +0200 Subject: [PATCH 1/3] Document link color as stable --- docs/how-to-guides/themes/theme-support.md | 30 +++++++++++++++++----- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/docs/how-to-guides/themes/theme-support.md b/docs/how-to-guides/themes/theme-support.md index d09287500bd45c..7391adafc58a89 100644 --- a/docs/how-to-guides/themes/theme-support.md +++ b/docs/how-to-guides/themes/theme-support.md @@ -391,20 +391,38 @@ Some blocks can have padding controls. This is off by default, and requires the add_theme_support('custom-spacing'); ``` -## Experimental — Link color control +## Link color control + +Link support has been made stable as part of WordPress 5.8. It's `false` by default and themes can enable it via the [theme.json file](./theme-json.md): + +```json +{ + "version": 1, + "settings": { + "color": { + "link": true + } + } +} +``` -Using the Gutenberg plugin (version 8.3 or later), link color control is available to a number of blocks including Paragraph, Heading, Group, Columns, and Media & Text blocks. This is off by default, and requires the theme to opt in by declaring support: +Alternatively, opt-in via the old legacy support would also work: ```php add_theme_support('experimental-link-color'); ``` - If a theme opts in, it can [define link colors](/docs/how-to-guides/themes/theme-json.md#color-properties) by using the `theme.json`. If the theme doesn't use the `theme.json` it can configure the color of links by settings the value of the `--wp--style--color--link` CSS Custom Property such as: +When the user sets the link color of a block, a new style will be added in the form of: ```css -:root { - --wp--style--color--link: ; +.wp-elements- a { + color: !important; } ``` -The framework will take care of enqueing the necessary rules for this to work. Whether or not the theme supports `theme.json` the presets will also be enqueued as CSS Custom Properties, so themes can also use `--wp--style--color-link: var(--wp--preset--color--)`. See [the docs](/docs/how-to-guides/themes/theme-json.md#color-properties) for details. +where + +- `` is a random number +- `` 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-`. From 25d8382ea2c3f14eadad3f741105ae0c5def1e63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= Date: Fri, 2 Jul 2021 10:57:45 +0200 Subject: [PATCH 2/3] Clarify old legacy support status --- docs/how-to-guides/themes/theme-support.md | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/docs/how-to-guides/themes/theme-support.md b/docs/how-to-guides/themes/theme-support.md index 7391adafc58a89..5ebfe2cc0daa96 100644 --- a/docs/how-to-guides/themes/theme-support.md +++ b/docs/how-to-guides/themes/theme-support.md @@ -406,11 +406,7 @@ Link support has been made stable as part of WordPress 5.8. It's `false` by defa } ``` -Alternatively, opt-in via the old legacy support would also work: - -```php -add_theme_support('experimental-link-color'); -``` +> Alternatively, with the Gutenberg plugin active, the old legacy support `add_theme_support('experimental-link-color')` would also work. This fallback would be removed when the Gutenberg plugin requires WordPress 5.8 as the minimum version. When the user sets the link color of a block, a new style will be added in the form of: From 8e3614477615cec74f757cfd7e41713023f96cd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= Date: Fri, 2 Jul 2021 11:04:32 +0200 Subject: [PATCH 3/3] Add comment in the plugin --- lib/class-wp-theme-json-gutenberg.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/class-wp-theme-json-gutenberg.php b/lib/class-wp-theme-json-gutenberg.php index 4f6f7db7384d78..6681e93bd184da 100644 --- a/lib/class-wp-theme-json-gutenberg.php +++ b/lib/class-wp-theme-json-gutenberg.php @@ -1348,6 +1348,10 @@ public static function get_from_editor_settings( $settings ) { } // Things that didn't land in core yet, so didn't have a setting assigned. + // This should be removed when the plugin minimum WordPress version + // is bumped to 5.8. + // + // Do not port this to WordPress core. if ( current( (array) get_theme_support( 'experimental-link-color' ) ) ) { if ( ! isset( $theme_settings['settings']['color'] ) ) { $theme_settings['settings']['color'] = array();