Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion lib/class-wp-theme-json-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -871,6 +871,8 @@ protected static function sanitize( $input, $valid_block_names, $valid_element_n
$schema['settings']['blocks'] = $schema_settings_blocks;
$schema['settings']['typography']['fontFamilies'] = static::schema_in_root_and_per_origin( static::FONT_FAMILY_SCHEMA );

// $schema['settings']['shadow'] = null;

// Remove anything that's not present in the schema.
foreach ( array( 'styles', 'settings' ) as $subtree ) {
if ( ! isset( $input[ $subtree ] ) ) {
Expand Down Expand Up @@ -1075,7 +1077,13 @@ protected static function remove_keys_not_in_schema( $tree, $schema ) {
}
}
} elseif ( is_array( $schema[ $key ] ) && ! is_array( $tree[ $key ] ) ) {
unset( $tree[ $key ] );
// special case for shadow, it can either be boolean or object
if ( 'shadow' === $key && ! $tree[ $key ] ) {
// Do not unset
} else {
// If the schema is an array and the value is not, remove the key.
unset( $tree[ $key ] );
}
}
}

Expand Down
3 changes: 3 additions & 0 deletions lib/class-wp-theme-json-resolver-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,9 @@ public static function get_theme_data( $deprecated = array(), $options = array()
);
}

// Disable shadow support for themes without theme.json.
$theme_support_data['settings']['shadow'] = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than setting shadow to false, could we set settings.shadow.defaultPresets to false?


// 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
Expand Down
69 changes: 39 additions & 30 deletions schemas/json/theme.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,38 +72,47 @@
"properties": {
"shadow": {
"description": "Settings related to shadows.",
"type": "object",
"properties": {
"defaultPresets": {
"description": "Allow users to choose shadows from the default shadow presets.",
"type": "boolean",
"default": true
},
"presets": {
"description": "Shadow presets for the shadow picker.\nGenerates a single custom property (`--wp--preset--shadow--{slug}`) per preset value.",
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"description": "Name of the shadow preset, translatable.",
"type": "string"
},
"slug": {
"description": "Kebab-case unique identifier for the shadow preset.",
"type": "string"
},
"shadow": {
"description": "CSS box-shadow value",
"type": "string"
}
"oneOf": [
{ "type": "boolean" },
{
"type": "object",
"properties": {
"defaultPresets": {
"description": "Allow users to choose shadows from the default shadow presets.",
"type": "boolean",
"default": true
},
"required": [ "name", "slug", "shadow" ],
"additionalProperties": false
}
"presets": {
"description": "Shadow presets for the shadow picker.\nGenerates a single custom property (`--wp--preset--shadow--{slug}`) per preset value.",
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"description": "Name of the shadow preset, translatable.",
"type": "string"
},
"slug": {
"description": "Kebab-case unique identifier for the shadow preset.",
"type": "string"
},
"shadow": {
"description": "CSS box-shadow value",
"type": "string"
}
},
"required": [
"name",
"slug",
"shadow"
],
"additionalProperties": false
}
}
},
"additionalProperties": false
}
},
"additionalProperties": false
]
}
}
},
Expand Down