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

In this article

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


if ( isset( $block_metadata['name'] ) ) {
	$block_type = WP_Block_Type_Registry::get_instance()->get_registered( $block_metadata['name'] );
	if ( ! block_has_support( $block_type, 'layout', false ) && ! block_has_support( $block_type, '__experimentalLayout', false ) ) {
		return $block_rules;
	}
}

$selector                 = isset( $block_metadata['selector'] ) ? $block_metadata['selector'] : '';
$has_block_gap_support    = isset( $this->theme_json['settings']['spacing']['blockGap'] );
$has_fallback_gap_support = ! $has_block_gap_support; // This setting isn't useful yet: it exists as a placeholder for a future explicit fallback gap styles support.
$node                     = _wp_array_get( $this->theme_json, $block_metadata['path'], array() );
$layout_definitions       = wp_get_layout_definitions();
$layout_selector_pattern  = '/^[a-zA-Z0-9\-\.\,\ *+>:\(\)]*$/'; // Allow alphanumeric classnames, spaces, wildcard, sibling, child combinator and pseudo class selectors.

/*
 * Gap styles will only be output if the theme has block gap support, or supports a fallback gap.
 * Default layout gap styles will be skipped for themes that do not explicitly opt-in to blockGap with a `true` or `false` value.
 */
if ( $has_block_gap_support || $has_fallback_gap_support ) {
	$block_gap_value = null;
	// Use a fallback gap value if block gap support is not available.

Changelog

VersionDescription
5.9.0Introduced.

User Contributed Notes

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