From c164facc1d150987d534f448f4ca5e8caba369f6 Mon Sep 17 00:00:00 2001 From: isabel_brison Date: Tue, 30 Apr 2024 01:48:09 +0000 Subject: [PATCH] =?UTF-8?q?Editor:=20skip=20outputting=20base=20layout=20r?= =?UTF-8?q?ules=20if=20content=20and=20wide=20size=20values=20don=E2=80=99?= =?UTF-8?q?t=20exist.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Skip outputting layout rules that reference content and wide sizes CSS variables, if no layout sizes exist in the current `theme.json`. Props andrewserong. Reviewed by jorbin. Merges [57948] to the 6.5 branch. Fixes #60936. Built from https://develop.svn.wordpress.org/branches/6.5@58056 git-svn-id: http://core.svn.wordpress.org/branches/6.5@57521 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-theme-json.php | 11 +++++++++++ wp-includes/version.php | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) 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 0b7357cfad..6837327dfa 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.5.3-alpha-58050'; +$wp_version = '6.5.3-alpha-58056'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.