WP_Theme_JSON::scope_selector()protected staticWP 5.9.0

Function that scopes a selector with another one. This works a bit like SCSS nesting except the & operator isn't supported.

$scope = '.a, .b .c';
$selector = '> .x, .y';
$merged = scope_selector( $scope, $selector );
// $merged is '.a > .x, .a .y, .b .c > .x, .b .c .y'

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

Хуков нет.

Возвращает

Строку. Scoped selector.

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

$result = WP_Theme_JSON::scope_selector( $scope, $selector );
$scope(строка) (обязательный)
Selector to scope to.
$selector(строка) (обязательный)
Original selector.

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

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

Код WP_Theme_JSON::scope_selector() WP 6.0.2

protected static function scope_selector( $scope, $selector ) {
	$scopes    = explode( ',', $scope );
	$selectors = explode( ',', $selector );

	$selectors_scoped = array();
	foreach ( $scopes as $outer ) {
		foreach ( $selectors as $inner ) {
			$selectors_scoped[] = trim( $outer ) . ' ' . trim( $inner );
		}
	}

	return implode( ', ', $selectors_scoped );
}