wp-includes/class-wp-theme-json.php:5866Generates a selector for a block style variation.
$variation_namestring$block_selectorstringstring protected static function get_block_style_variation_selector( $variation_name, $block_selector ) { $variation_class = ".is-style-$variation_name"; if ( ! $block_selector ) { return $variation_class; } $limit = 1; $selector_parts = static::split_selector_list( $block_selector ); $result = array(); /* * Append the variation class to each selector's ancestor: the first * run of characters before any combinator (whitespace) or pseudo-class * (`:`). Only the first match is replaced. * * Examples ("custom" variation): * - `.wp-block` => `.wp-block.is-style-custom` * - `.wp-block .inner` => `.wp-block.is-style-custom .inner` * - `.wp-block:where(.a .b)` => `.wp-block.is-style-custom:where(.a .b)` * - `:where(.outer .inner)` => `:where(.outer.is-style-custom .inner)` */ foreach ( $selector_parts as $part ) { $result[] = preg_replace_callback( '/[^\s:]+/', function ( $matches ) use ( $variation_class ) { return $matches[0] . $variation_class; }, $part, $limit ); } return implode( ', ', $result ); }Introduced in 6.5.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
src/wp-includes/class-wp-theme-json.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.