Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Add ability to opt out of Core color palette V2 #36492

Merged
merged 6 commits into from Nov 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/how-to-guides/themes/theme-json.md
Expand Up @@ -226,9 +226,13 @@ The settings section has the following structure:
},
"color": {
"background": true,
"corePalette": true,
"coreGradients": true,
"custom": true,
"customDuotone": true,
"customGradient": true,
"corePalette": true,
"coreGradients": true,
"duotone": [],
"gradients": [],
"link": false,
Expand Down
2 changes: 2 additions & 0 deletions lib/class-wp-theme-json-gutenberg.php
Expand Up @@ -89,6 +89,8 @@ class WP_Theme_JSON_Gutenberg {
),
'color' => array(
'background' => null,
'corePalette' => null,
'coreGradients' => null,
'custom' => null,
'customDuotone' => null,
'customGradient' => null,
Expand Down
2 changes: 2 additions & 0 deletions lib/theme.json
Expand Up @@ -170,6 +170,8 @@
}
],
"custom": true,
"corePalette": true,
"coreGradients": true,
"customDuotone": true,
"customGradient": true,
"link": false,
Expand Down
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
10 changes: 10 additions & 0 deletions schemas/json/theme.json
Expand Up @@ -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",
Expand Down