Skip to content

Commit d639f38

Browse files
andrewserongramonjd
authored andcommitted
Layout: Skip outputting base layout rules that reference content or wide sizes if no layout sizes exist (#60489)
* Layout: Skip outputting base layout rules that reference content or wide sizes if no content or wide sizes exist * Update tests
1 parent 3ec694a commit d639f38

File tree

2 files changed

+41
-11
lines changed

2 files changed

+41
-11
lines changed

lib/class-wp-theme-json-gutenberg.php

+10
Original file line numberDiff line numberDiff line change
@@ -1614,6 +1614,16 @@ protected function get_layout_styles( $block_metadata ) {
16141614
! empty( $base_style_rule['rules'] )
16151615
) {
16161616
foreach ( $base_style_rule['rules'] as $css_property => $css_value ) {
1617+
// Skip rules that reference content size or wide size if they are not defined in the theme.json.
1618+
if (
1619+
is_string( $css_value ) &&
1620+
( str_contains( $css_value, '--global--content-size' ) || str_contains( $css_value, '--global--wide-size' ) ) &&
1621+
! isset( $this->theme_json['settings']['layout']['contentSize'] ) &&
1622+
! isset( $this->theme_json['settings']['layout']['wideSize'] )
1623+
) {
1624+
continue;
1625+
}
1626+
16171627
if ( static::is_safe_css_declaration( $css_property, $css_value ) ) {
16181628
$declarations[] = array(
16191629
'name' => $css_property,

0 commit comments

Comments
 (0)