diff --git a/wp-includes/class-wp-theme-json.php b/wp-includes/class-wp-theme-json.php index d754da957a..7ab626ce8f 100644 --- a/wp-includes/class-wp-theme-json.php +++ b/wp-includes/class-wp-theme-json.php @@ -1388,6 +1388,7 @@ class WP_Theme_JSON { * * @since 6.1.0 * @since 6.3.0 Reduced specificity for layout margin rules. + * @since 6.5.1 Only output rules referencing content and wide sizes when values exist. * * @param array $block_metadata Metadata about the block to get styles for. * @return string Layout styles for the block. @@ -1548,6 +1549,16 @@ class WP_Theme_JSON { ! 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, diff --git a/wp-includes/version.php b/wp-includes/version.php index a8a80ca2f9..d531da6969 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.6-alpha-57946'; +$wp_version = '6.6-alpha-57948'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.