WP_Theme_JSON::scope_style_node_selectors()
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.
Method of the class: WP_Theme_JSON{}
No Hooks.
Return
Array
. Node with updated selectors.
Usage
$result = WP_Theme_JSON::scope_style_node_selectors( $scope, $node );
- $scope(string) (required)
- Selector to scope to.
- $node(array) (required)
- Style node with selectors to scope.
Changelog
Since 6.6.0 | Introduced. |
WP_Theme_JSON::scope_style_node_selectors() WP Theme JSON::scope style node selectors code WP 6.6.2
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; }