From 03bca84760298f6b6a74f82e2d0eb3827b0ea9a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Ka=CC=88gy?= Date: Fri, 12 Nov 2021 14:09:25 +0100 Subject: [PATCH 1/6] add corePalette and coreGradients keys to theme.json schema --- schemas/json/theme.json | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/schemas/json/theme.json b/schemas/json/theme.json index 20b4950eb2bf6..982703a8b5332 100644 --- a/schemas/json/theme.json +++ b/schemas/json/theme.json @@ -45,6 +45,16 @@ "type": "boolean", "default": true }, + "corePalette": { + "description": "Allow users to choose colors from the Core palette. \nGutenberg plugin required.", + "type": "boolean", + "default": true + }, + "coreGradients": { + "description": "Allow users to choose colors from the Core gradients. \nGutenberg plugin required.", + "type": "boolean", + "default": true + }, "custom": { "description": "Allow users to select custom colors.\nSince 5.8.", "type": "boolean", From 0f3db6d3dcc3d32fcc5e97f6728be529ecd717bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Ka=CC=88gy?= Date: Fri, 12 Nov 2021 14:11:54 +0100 Subject: [PATCH 2/6] add corePalette and coreGradients to theme.json docs --- docs/how-to-guides/themes/theme-json.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/how-to-guides/themes/theme-json.md b/docs/how-to-guides/themes/theme-json.md index 3f3da4c9f4a75..bff8dfa4511f0 100644 --- a/docs/how-to-guides/themes/theme-json.md +++ b/docs/how-to-guides/themes/theme-json.md @@ -229,6 +229,8 @@ The settings section has the following structure: "custom": true, "customDuotone": true, "customGradient": true, + "corePalette": true, + "coreGradients": true, "duotone": [], "gradients": [], "link": false, From 61a0aa7e6d1bc38c2900f27982b9d45307f9f70a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Ka=CC=88gy?= Date: Mon, 15 Nov 2021 17:38:02 +0100 Subject: [PATCH 3/6] add `corePalette` and `coreGradients` to theme.json docs --- docs/how-to-guides/themes/theme-json.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/how-to-guides/themes/theme-json.md b/docs/how-to-guides/themes/theme-json.md index bff8dfa4511f0..24095cf2dd709 100644 --- a/docs/how-to-guides/themes/theme-json.md +++ b/docs/how-to-guides/themes/theme-json.md @@ -226,6 +226,8 @@ The settings section has the following structure: }, "color": { "background": true, + "corePalette": true, + "coreGradients": true, "custom": true, "customDuotone": true, "customGradient": true, From cebc43be6f154767fdb589db4cca57b59b11aebf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Ka=CC=88gy?= Date: Mon, 15 Nov 2021 17:38:22 +0100 Subject: [PATCH 4/6] add `corePalette` and `coreGradients` to allowed settings keys --- lib/class-wp-theme-json-gutenberg.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/class-wp-theme-json-gutenberg.php b/lib/class-wp-theme-json-gutenberg.php index 52d1cbbb643aa..2c1df8b309e79 100644 --- a/lib/class-wp-theme-json-gutenberg.php +++ b/lib/class-wp-theme-json-gutenberg.php @@ -89,6 +89,8 @@ class WP_Theme_JSON_Gutenberg { ), 'color' => array( 'background' => null, + 'corePalette' => null, + 'coreGradients' => null, 'custom' => null, 'customDuotone' => null, 'customGradient' => null, From b2780d161d3b9e1223944caa73eed0f26e008a77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Ka=CC=88gy?= Date: Mon, 15 Nov 2021 17:40:08 +0100 Subject: [PATCH 5/6] add defaults for `corePalette` and `coreGradients` to base `theme.json` --- lib/theme.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/theme.json b/lib/theme.json index 7629089219f8e..82e3b4fec9ee0 100644 --- a/lib/theme.json +++ b/lib/theme.json @@ -170,6 +170,8 @@ } ], "custom": true, + "corePalette": true, + "coreGradients": true, "customDuotone": true, "customGradient": true, "link": false, From fab8d6a55a34a991e3473ccefcbf272c4459e6f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Ka=CC=88gy?= Date: Mon, 15 Nov 2021 17:41:28 +0100 Subject: [PATCH 6/6] check `color.corePalette` and `color.coreGradients` settings before displaying colors --- .../colors-gradients/panel-color-gradient-settings.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/block-editor/src/components/colors-gradients/panel-color-gradient-settings.js b/packages/block-editor/src/components/colors-gradients/panel-color-gradient-settings.js index f3f0a9a68859b..d77447f9b726e 100644 --- a/packages/block-editor/src/components/colors-gradients/panel-color-gradient-settings.js +++ b/packages/block-editor/src/components/colors-gradients/panel-color-gradient-settings.js @@ -175,9 +175,11 @@ const PanelColorGradientSettingsMultipleSelect = ( props ) => { const userColors = useSetting( 'color.palette.user' ); const themeColors = useSetting( 'color.palette.theme' ); const coreColors = useSetting( 'color.palette.core' ); + const shouldDisplayCoreColors = useSetting( 'color.corePalette' ); + colorGradientSettings.colors = useMemo( () => { const result = []; - if ( coreColors && coreColors.length ) { + if ( shouldDisplayCoreColors && coreColors && coreColors.length ) { result.push( { name: __( 'Core' ), colors: coreColors, @@ -201,9 +203,14 @@ const PanelColorGradientSettingsMultipleSelect = ( props ) => { const userGradients = useSetting( 'color.gradients.user' ); const themeGradients = useSetting( 'color.gradients.theme' ); const coreGradients = useSetting( 'color.gradients.core' ); + const shouldDisplayCoreGradients = useSetting( 'color.coreGradients' ); colorGradientSettings.gradients = useMemo( () => { const result = []; - if ( coreGradients && coreGradients.length ) { + if ( + shouldDisplayCoreGradients && + coreGradients && + coreGradients.length + ) { result.push( { name: __( 'Core' ), gradients: coreGradients,