Commit 8052e91de3 for wordpress.org
commit 8052e91de322cfe0734cee98c8633e77b17b74bf
Author: isabel_brison <isabel_brison@git.wordpress.org>
Date: Wed Oct 14 05:13:48 2026 +0000
Editor: fix block style variation custom CSS selector
Ensures block style variations use the feature selector for custom CSS if the block defines one.
Props isabel_brison, andrewserong.
Fixes #66297.
Built from https://develop.svn.wordpress.org/trunk@64340
git-svn-id: http://core.svn.wordpress.org/trunk@63490 1a063a9b-81f0-0310-95a4-ce76da25c4cd
diff --git a/wp-includes/class-wp-theme-json.php b/wp-includes/class-wp-theme-json.php
index 2f80a256b8..f665f9acd1 100644
--- a/wp-includes/class-wp-theme-json.php
+++ b/wp-includes/class-wp-theme-json.php
@@ -3916,6 +3916,14 @@ class WP_Theme_JSON {
$media_query = $block_metadata['media_query'] ?? null;
$responsive_media_queries = static::get_viewport_media_queries( $settings['viewport'] ?? null );
+ $css_feature_selector = $block_metadata['selectors']['css'] ?? null;
+ if ( is_array( $css_feature_selector ) ) {
+ $css_feature_selector = $css_feature_selector['root'] ?? null;
+ }
+ if ( ! is_string( $css_feature_selector ) ) {
+ $css_feature_selector = null;
+ }
+
// Update text indent selector for paragraph blocks based on the textIndent setting.
$block_name = $block_metadata['name'] ?? null;
$feature_declarations = self::update_paragraph_text_indent_selector( $feature_declarations, $settings, $block_name );
@@ -3965,9 +3973,14 @@ class WP_Theme_JSON {
$variation_pseudo_declarations = $this->process_pseudo_selectors( $style_variation_node, $style_variation['selector'], $settings, $block_name, $block_metadata, $style_variation );
$style_variation_declarations = array_merge( $style_variation_declarations, $variation_pseudo_declarations );
+ // Custom CSS targets the block's `css` feature selector, if any.
+ $variation_css_selector = null !== $css_feature_selector
+ ? static::get_block_style_variation_feature_selector( $style_variation, $css_feature_selector )
+ : $style_variation['selector'];
+
// Store custom CSS for the style variation.
if ( isset( $style_variation_node['css'] ) ) {
- $style_variation_custom_css[ $style_variation['selector'] ] = $this->process_blocks_custom_css( $style_variation_node['css'], $style_variation['selector'] );
+ $style_variation_custom_css[ $style_variation['selector'] ] = $this->process_blocks_custom_css( $style_variation_node['css'], $variation_css_selector );
}
// Store variation metadata and node for layout styles generation.
@@ -4033,7 +4046,7 @@ class WP_Theme_JSON {
// Process custom CSS for this breakpoint.
if ( isset( $breakpoint_node['css'] ) ) {
- $breakpoint_custom_css = static::process_blocks_custom_css( $breakpoint_node['css'], $style_variation['selector'] );
+ $breakpoint_custom_css = static::process_blocks_custom_css( $breakpoint_node['css'], $variation_css_selector );
$variation_responsive_css .= $breakpoint_media . '{' . $breakpoint_custom_css . '}';
}
@@ -4277,11 +4290,7 @@ class WP_Theme_JSON {
// 7. Generate and append any custom CSS rules.
if ( isset( $node['css'] ) && ! $is_root_selector ) {
- $css_feature_selector = $block_metadata['selectors']['css'] ?? null;
- if ( is_array( $css_feature_selector ) ) {
- $css_feature_selector = $css_feature_selector['root'] ?? null;
- }
- $css_selector = is_string( $css_feature_selector ) ? $css_feature_selector : $selector;
+ $css_selector = $css_feature_selector ?? $selector;
$block_rules .= $this->process_blocks_custom_css( $node['css'], $css_selector );
}
diff --git a/wp-includes/version.php b/wp-includes/version.php
index b1d33b8960..b82c38c52b 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
-$wp_version = '7.2-alpha-64339';
+$wp_version = '7.2-alpha-64340';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.