diff --git a/wp-includes/class-wp-theme-json.php b/wp-includes/class-wp-theme-json.php index 3dba653520..7cc87759ab 100644 --- a/wp-includes/class-wp-theme-json.php +++ b/wp-includes/class-wp-theme-json.php @@ -1199,7 +1199,7 @@ class WP_Theme_JSON { $node['selector'] = static::scope_selector( $options['scope'], $node['selector'] ); } foreach ( $style_nodes as &$node ) { - $node['selector'] = static::scope_selector( $options['scope'], $node['selector'] ); + $node = static::scope_style_node_selectors( $options['scope'], $node ); } unset( $node ); } @@ -1825,6 +1825,39 @@ class WP_Theme_JSON { return $result; } + /** + * Scopes the selectors for a given style node. + * + * This includes the primary selector, i.e. `$node['selector']`, as well as any custom + * selectors for features and subfeatures, e.g. `$node['selectors']['border']` etc. + * + * @since 6.6.0 + * + * @param string $scope Selector to scope to. + * @param array $node Style node with selectors to scope. + * @return array Node with updated selectors. + */ + protected static function scope_style_node_selectors( $scope, $node ) { + $node['selector'] = static::scope_selector( $scope, $node['selector'] ); + + if ( empty( $node['selectors'] ) ) { + return $node; + } + + foreach ( $node['selectors'] as $feature => $selector ) { + if ( is_string( $selector ) ) { + $node['selectors'][ $feature ] = static::scope_selector( $scope, $selector ); + } + if ( is_array( $selector ) ) { + foreach ( $selector as $subfeature => $subfeature_selector ) { + $node['selectors'][ $feature ][ $subfeature ] = static::scope_selector( $scope, $subfeature_selector ); + } + } + } + + return $node; + } + /** * Gets preset values keyed by slugs based on settings and metadata. * diff --git a/wp-includes/version.php b/wp-includes/version.php index 79a32170cc..8373aff672 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.6-alpha-58243'; +$wp_version = '6.6-alpha-58244'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.