WP_Theme_JSON::scope_style_node_selectorsprotected staticWP 6.6.0

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.

Метод класса: WP_Theme_JSON{}

Хуков нет.

Возвращает

Массив. Node with updated selectors.

Использование

$result = WP_Theme_JSON::scope_style_node_selectors( $scope, $node );
$scope(строка) (обязательный)
Selector to scope to.
$node(массив) (обязательный)
Style node with selectors to scope.

Список изменений

С версии 6.6.0 Введена.

Код WP_Theme_JSON::scope_style_node_selectors() WP 7.0

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