From fd5a3c78cee360896cf1551597994e25617fdf8d Mon Sep 17 00:00:00 2001 From: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com> Date: Fri, 26 Apr 2024 18:01:08 +1000 Subject: [PATCH] Relocate scope_style_node_selectors beside scope_selector --- lib/class-wp-theme-json-gutenberg.php | 66 +++++++++++++-------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/lib/class-wp-theme-json-gutenberg.php b/lib/class-wp-theme-json-gutenberg.php index e6e53c5a04ce6..78a5815d6726c 100644 --- a/lib/class-wp-theme-json-gutenberg.php +++ b/lib/class-wp-theme-json-gutenberg.php @@ -1856,6 +1856,39 @@ public static function scope_selector( $scope, $selector ) { 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. * @@ -4039,37 +4072,4 @@ function ( $matches ) use ( $variation_class ) { return implode( ',', $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; - } }