WP_Theme_JSON_Resolver::style_variation_has_scope( array $variation, string $scope ): boolean

In this article

This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

Determines if a supplied style variation matches the provided scope.

Description

For backwards compatibility, if a variation does not define any scope related property, e.g. blockTypes, it is assumed to be a theme style variation.

Parameters

$variationarrayrequired
Theme.json shaped style variation object.
$scopestringrequired
Scope to check e.g. theme, block etc.

Return

boolean

Source

private static function style_variation_has_scope( $variation, $scope ) {
	if ( 'block' === $scope ) {
		return isset( $variation['blockTypes'] );
	}

	if ( 'theme' === $scope ) {
		return ! isset( $variation['blockTypes'] );
	}

	return false;
}

Changelog

VersionDescription
6.6.0Introduced.

User Contributed Notes

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