From 07fe72c6b3c1f18cbcc3986c00a5d8ed1af354ca Mon Sep 17 00:00:00 2001 From: isabel_brison Date: Tue, 30 Apr 2024 03:19:10 +0000 Subject: [PATCH] Editor: limit layout rules on themes without theme.json. Removes output of base rules for flow and constrained layout types on themes without theme.json. Props evanltd, poena, isabel_brison, andrewserong, oandregal. Reviewed by jorbin. Merges [58028] to the 6.5 branch. See #60981. Built from https://develop.svn.wordpress.org/branches/6.5@58057 git-svn-id: http://core.svn.wordpress.org/branches/6.5@57522 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-theme-json.php | 11 +++++++++-- wp-includes/version.php | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/wp-includes/class-wp-theme-json.php b/wp-includes/class-wp-theme-json.php index 7ab626ce8f..40931e54b5 100644 --- a/wp-includes/class-wp-theme-json.php +++ b/wp-includes/class-wp-theme-json.php @@ -1227,7 +1227,7 @@ class WP_Theme_JSON { ); foreach ( $base_styles_nodes as $base_style_node ) { - $stylesheet .= $this->get_layout_styles( $base_style_node ); + $stylesheet .= $this->get_layout_styles( $base_style_node, $types ); } } @@ -1389,11 +1389,13 @@ 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. + * @since 6.5.3 Add types parameter to check if only base layout styles are needed. * * @param array $block_metadata Metadata about the block to get styles for. + * @param array $types Optional. Types of styles to output. If empty, all styles will be output. * @return string Layout styles for the block. */ - protected function get_layout_styles( $block_metadata ) { + protected function get_layout_styles( $block_metadata, $types = array() ) { $block_rules = ''; $block_type = null; @@ -1543,6 +1545,11 @@ class WP_Theme_JSON { foreach ( $base_style_rules as $base_style_rule ) { $declarations = array(); + // Skip outputting base styles for flow and constrained layout types if theme doesn't support theme.json. The 'base-layout-styles' type flags this. + if ( in_array( 'base-layout-styles', $types, true ) && ( 'default' === $layout_definition['name'] || 'constrained' === $layout_definition['name'] ) ) { + continue; + } + if ( isset( $base_style_rule['selector'] ) && preg_match( $layout_selector_pattern, $base_style_rule['selector'] ) && diff --git a/wp-includes/version.php b/wp-includes/version.php index 6837327dfa..0b6029ac8a 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-58056'; +$wp_version = '6.5.3-alpha-58057'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.