WP_Theme_JSON::scope_selector( string $scope, string $selector ): string

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

Description

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

Parameters

$scopestringrequired
Selector to scope to.
$selectorstringrequired
Original selector.

Return

string Scoped selector.

Source

						array(
							'name'  => $property,
							'value' => 'var(' . $css_var . ') !important',
						),
					)
				);
			}
		}
	}

	return $stylesheet;
}

/**
 * Function that scopes a selector with another one. This works a bit like
 * SCSS nesting except the `&` operator isn't supported.
 *
 * <code>
 * $scope = '.a, .b .c';
 * $selector = '> .x, .y';
 * $merged = scope_selector( $scope, $selector );
 * // $merged is '.a > .x, .a .y, .b .c > .x, .b .c .y'

Changelog

VersionDescription
5.9.0Introduced.

User Contributed Notes

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