diff --git a/docs/how-to-guides/themes/theme-json.md b/docs/how-to-guides/themes/theme-json.md
index 0990c618ea9f4e..6e751aa2e19ff8 100644
--- a/docs/how-to-guides/themes/theme-json.md
+++ b/docs/how-to-guides/themes/theme-json.md
@@ -169,6 +169,7 @@ The settings section has the following structure:
"settings": {
"color": {
"custom": true,
+ "customDuotone": true,
"customGradient": true,
"duotone": [],
"gradients": [],
@@ -220,6 +221,7 @@ The settings section has the following structure:
},
"color": {
"custom": true,
+ "customDuotone": true,
"customGradient": true,
"duotone": [],
"gradients": [],
diff --git a/lib/class-wp-theme-json-gutenberg.php b/lib/class-wp-theme-json-gutenberg.php
index 0b4ae918037a14..335d461b695f26 100644
--- a/lib/class-wp-theme-json-gutenberg.php
+++ b/lib/class-wp-theme-json-gutenberg.php
@@ -85,6 +85,7 @@ class WP_Theme_JSON_Gutenberg {
),
'color' => array(
'custom' => null,
+ 'customDuotone' => null,
'customGradient' => null,
'duotone' => null,
'gradients' => null,
diff --git a/lib/experimental-default-theme.json b/lib/experimental-default-theme.json
index e12e4231018a36..bf7ef9ef5147ba 100644
--- a/lib/experimental-default-theme.json
+++ b/lib/experimental-default-theme.json
@@ -169,8 +169,9 @@
}
],
"custom": true,
- "link": false,
- "customGradient": true
+ "customDuotone": true,
+ "customGradient": true,
+ "link": false
},
"typography": {
"dropCap": true,
diff --git a/packages/block-editor/src/components/duotone-control/duotone-picker-popover.js b/packages/block-editor/src/components/duotone-control/duotone-picker-popover.js
index c277b07ad1487a..64f4c1cf225c2b 100644
--- a/packages/block-editor/src/components/duotone-control/duotone-picker-popover.js
+++ b/packages/block-editor/src/components/duotone-control/duotone-picker-popover.js
@@ -11,6 +11,7 @@ function DuotonePickerPopover( {
duotonePalette,
colorPalette,
disableCustomColors,
+ disableCustomDuotone,
} ) {
return (
diff --git a/packages/block-editor/src/components/duotone-control/index.js b/packages/block-editor/src/components/duotone-control/index.js
index eb675639a5f143..757e83803e86b7 100644
--- a/packages/block-editor/src/components/duotone-control/index.js
+++ b/packages/block-editor/src/components/duotone-control/index.js
@@ -15,15 +15,12 @@ function DuotoneControl( {
colorPalette,
duotonePalette,
disableCustomColors,
+ disableCustomDuotone,
value,
onChange,
} ) {
const [ isOpen, setIsOpen ] = useState( false );
- if ( ! duotonePalette ) {
- return null;
- }
-
const onToggle = () => {
setIsOpen( ( prev ) => ! prev );
};
@@ -55,6 +52,7 @@ function DuotoneControl( {
duotonePalette={ duotonePalette }
colorPalette={ colorPalette }
disableCustomColors={ disableCustomColors }
+ disableCustomDuotone={ disableCustomDuotone }
/>
) }
>
diff --git a/packages/block-editor/src/hooks/duotone.js b/packages/block-editor/src/hooks/duotone.js
index 6e5a79766cae86..c0de112b020d8d 100644
--- a/packages/block-editor/src/hooks/duotone.js
+++ b/packages/block-editor/src/hooks/duotone.js
@@ -21,6 +21,8 @@ import {
useSetting,
} from '../components';
+const EMPTY_ARRAY = [];
+
/**
* Convert a list of colors to an object of R, G, and B values.
*
@@ -124,15 +126,23 @@ function DuotonePanel( { attributes, setAttributes } ) {
const style = attributes?.style;
const duotone = style?.color?.duotone;
- const duotonePalette = useSetting( 'color.duotone' );
- const colorPalette = useSetting( 'color.palette' );
+ const duotonePalette = useSetting( 'color.duotone' ) || EMPTY_ARRAY;
+ const colorPalette = useSetting( 'color.palette' ) || EMPTY_ARRAY;
const disableCustomColors = ! useSetting( 'color.custom' );
+ const disableCustomDuotone =
+ ! useSetting( 'color.customDuotone' ) ||
+ ( colorPalette?.length === 0 && disableCustomColors );
+
+ if ( duotonePalette?.length === 0 && disableCustomDuotone ) {
+ return null;
+ }
return (
{
diff --git a/packages/components/src/duotone-picker/duotone-picker.js b/packages/components/src/duotone-picker/duotone-picker.js
index bbc546acec1c46..fa01fd82707671 100644
--- a/packages/components/src/duotone-picker/duotone-picker.js
+++ b/packages/components/src/duotone-picker/duotone-picker.js
@@ -22,6 +22,7 @@ function DuotonePicker( {
colorPalette,
duotonePalette,
disableCustomColors,
+ disableCustomDuotone,
value,
onChange,
} ) {
@@ -29,6 +30,7 @@ function DuotonePicker( {
() => getDefaultColors( colorPalette ),
[ colorPalette ]
);
+
return (
{
@@ -74,10 +76,10 @@ function DuotonePicker( {
}
>
- { ! disableCustomColors && (
+ { ! disableCustomColors && ! disableCustomDuotone && (
) }
- { colorPalette && (
+ { ! disableCustomDuotone && (