Skip to content

Commit 44e0b6f

Browse files
authored
Merge branch 'WordPress:trunk' into trunk
2 parents 797781c + 3f456ac commit 44e0b6f

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

src/wp-includes/class-wp-theme-json.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5662,11 +5662,22 @@ protected static function get_block_style_variation_selector( $variation_name, $
56625662
$selector_parts = static::split_selector_list( $block_selector );
56635663
$result = array();
56645664

5665+
/*
5666+
* Append the variation class to each selector's ancestor: the first
5667+
* run of characters before any combinator (whitespace) or pseudo-class
5668+
* (`:`). Only the first match is replaced.
5669+
*
5670+
* Examples ("custom" variation):
5671+
* - `.wp-block` => `.wp-block.is-style-custom`
5672+
* - `.wp-block .inner` => `.wp-block.is-style-custom .inner`
5673+
* - `.wp-block:where(.a .b)` => `.wp-block.is-style-custom:where(.a .b)`
5674+
* - `:where(.outer .inner)` => `:where(.outer.is-style-custom .inner)`
5675+
*/
56655676
foreach ( $selector_parts as $part ) {
56665677
$result[] = preg_replace_callback(
5667-
'/((?::\([^)]+\))?\s*)([^\s:]+)/',
5678+
'/[^\s:]+/',
56685679
function ( $matches ) use ( $variation_class ) {
5669-
return $matches[1] . $matches[2] . $variation_class;
5680+
return $matches[0] . $variation_class;
56705681
},
56715682
$part,
56725683
$limit

0 commit comments

Comments
 (0)