Skip to content

Commit

Permalink
Layout: Skip outputting base layout rules that reference content or w…
Browse files Browse the repository at this point in the history
…ide 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
  • Loading branch information
andrewserong authored and aaronjorbin committed May 2, 2024
1 parent cfb3b2b commit dae97e8
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 32 deletions.
10 changes: 10 additions & 0 deletions lib/class-wp-theme-json-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -1549,6 +1549,16 @@ protected function get_layout_styles( $block_metadata, $types = array() ) {
! empty( $base_style_rule['rules'] )
) {
foreach ( $base_style_rule['rules'] as $css_property => $css_value ) {
// Skip rules that reference content size or wide size if they are not defined in the theme.json.
if (
is_string( $css_value ) &&
( str_contains( $css_value, '--global--content-size' ) || str_contains( $css_value, '--global--wide-size' ) ) &&
! isset( $this->theme_json['settings']['layout']['contentSize'] ) &&
! isset( $this->theme_json['settings']['layout']['wideSize'] )
) {
continue;
}

if ( static::is_safe_css_declaration( $css_property, $css_value ) ) {
$declarations[] = array(
'name' => $css_property,
Expand Down
Loading

0 comments on commit dae97e8

Please sign in to comment.