Opened 21 months ago
Last modified 20 months ago
#57599 new defect (bug)
`wp_theme_json_data_default` filter is not properly to setting `settings.spacing.padding` value
Reported by: | fabiankaegy | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 6.1.1 |
Component: | Editor | Keywords: | has-unit-tests |
Focuses: | Cc: |
Description
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 /** * 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:
{ "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 /** * 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
{ "version": 2, "$schema": "https://schemas.wp.org/trunk/theme.json", "settings": { "spacing": { "padding": true } } }
Change History (5)
This ticket was mentioned in Slack in #core-editor by fabiankaegy. View the logs.
21 months ago
This ticket was mentioned in PR #3969 on WordPress/wordpress-develop by @fabiankaegy.
20 months ago
#3
- Keywords has-patch has-unit-tests added
Trac ticket: https://core.trac.wordpress.org/ticket/57599
You can also verify that the setting isn't getting applied correctly using:
with XDebug for example