From 93116684b880edec129809e997f1dbe2a17265df Mon Sep 17 00:00:00 2001 From: ramon Date: Wed, 21 Jun 2023 15:08:06 +1000 Subject: [PATCH] Changes from https://github.com/WordPress/gutenberg/pull/49427 --- src/wp-includes/block-supports/settings.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/wp-includes/block-supports/settings.php b/src/wp-includes/block-supports/settings.php index 1c9b467284b6a..827faad01537e 100644 --- a/src/wp-includes/block-supports/settings.php +++ b/src/wp-includes/block-supports/settings.php @@ -66,6 +66,7 @@ function _wp_add_block_level_presets_class( $block_content, $block ) { * @internal * * @since 6.2.0 + * @since 6.3.0 Updates preset styles to use Selectors API. * @access private * * @param string|null $pre_render The pre-rendered content. Default null. @@ -95,11 +96,14 @@ function _wp_add_block_level_preset_styles( $pre_render, $block ) { $registry = WP_Block_Type_Registry::get_instance(); $blocks = $registry->get_all_registered(); foreach ( $blocks as $block_type ) { - if ( - isset( $block_type->supports['__experimentalSelector'] ) && - is_string( $block_type->supports['__experimentalSelector'] ) - ) { - $variables_root_selector .= ',' . $block_type->supports['__experimentalSelector']; + // We only want to append selectors for block's using custom selectors + // i.e. not `wp-block-`. + $has_custom_selector = + ( isset( $block_type->supports['__experimentalSelector'] ) && is_string( $block_type->supports['__experimentalSelector'] ) ) || + ( isset( $block_type->selectors['root'] ) && is_string( $block_type->selectors['root'] ) ); + + if ( $has_custom_selector ) { + $variables_root_selector .= ',' . wp_get_block_css_selector( $block_type ); } } $variables_root_selector = WP_Theme_JSON::scope_selector( $class_name, $variables_root_selector );