[wp-trac] [WordPress Trac] #57599: `wp_theme_json_data_default` filter is not properly to setting `settings.spacing.padding` value
WordPress Trac
noreply at wordpress.org
Wed Feb 1 18:21:06 UTC 2023
#57599: `wp_theme_json_data_default` filter is not properly to setting
`settings.spacing.padding` value
--------------------------+-----------------------------
Reporter: fabiankaegy | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Editor | Version: 6.1.1
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
There appears to be an issue in how the `theme.json` filters get currently
applied. When trying to use the filter on the `default` layer to enable
the `settings.spacing.padding` option it doesn't work as expected.
Within a plugin I'm trying to call the filter like so:
{{{#!php
<?php
/**
* Plugin Name: Test
*/
add_filter( 'wp_theme_json_data_default', 'test_filter_core_theme_json' );
function test_filter_core_theme_json( $theme_json ) {
$new_data = [
'version' => 2,
'settings' => [
'spacing' => [
'margin' => true,
'padding' => true,
],
],
];
return $theme_json->update_with( $new_data );
};
}}}
And for Theme I'm using a completely empty theme that has this
`theme.json` file:
{{{#!json
{
"version": 2,
"$schema": "https://schemas.wp.org/trunk/theme.json"
}
}}}
The expected result is that the padding dimension panel in for example the
group block could be added. But that isn't the case. At the same time the
`margin` option which I've also added in the example above does work as
intended.
If you change the `theme.json` file to set the `padding` option to true it
does work. And also if you change the filter that gets used to the `theme`
layer it works as expected:
{{{#!php
<?php
/**
* Plugin Name: Test
*/
add_filter( 'wp_theme_json_data_theme', 'test_filter_core_theme_json' );
function test_filter_core_theme_json( $theme_json ) {
$new_data = [
'version' => 2,
'settings' => [
'spacing' => [
'margin' => true,
'padding' => true,
],
],
];
return $theme_json->update_with( $new_data );
};
}}}
or
{{{#!json
{
"version": 2,
"$schema": "https://schemas.wp.org/trunk/theme.json",
"settings": {
"spacing": {
"padding": true
}
}
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/57599>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list