WP_Theme_JSON::scope_style_node_selectors( string $scope, array $node ): array

In this article

Scopes the selectors for a given style node.

Description

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.

Parameters

$scopestringrequired
Selector to scope to.
$nodearrayrequired
Style node with selectors to scope.

Return

array Node with updated selectors.

Source

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;
}

Changelog

VersionDescription
6.6.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.