WP_Theme_JSON::should_override_preset( array $theme_json, array $path, bool|array $override ): boolean

In this article

This method has been deprecated. Use {@see ‘get_metadata_boolean’} instead.

Determines whether a presets should be overridden or not.

Parameters

$theme_jsonarrayrequired
The theme.json like structure to inspect.
$patharrayrequired
Path to inspect.
$overridebool|arrayrequired
Data to compute whether to override the preset.

Return

boolean

Source


// If only node paths are to be returned, skip selector assignment.
if ( ! $include_node_paths_only ) {
	$selectors = empty( $selectors ) ? static::get_blocks_metadata() : $selectors;
}

foreach ( $theme_json['styles']['blocks'] as $name => $node ) {
	$node_path = array( 'styles', 'blocks', $name );
	if ( $include_node_paths_only ) {
		$nodes[] = array(
			'path' => $node_path,
		);
	} else {
		$selector = null;
		if ( isset( $selectors[ $name ]['selector'] ) ) {
			$selector = $selectors[ $name ]['selector'];
		}

		$duotone_selector = null;
		if ( isset( $selectors[ $name ]['duotone'] ) ) {
			$duotone_selector = $selectors[ $name ]['duotone'];
		}

		$feature_selectors = null;
		if ( isset( $selectors[ $name ]['selectors'] ) ) {
			$feature_selectors = $selectors[ $name ]['selectors'];
		}

		$variation_selectors = array();
		if ( $include_variations && isset( $node['variations'] ) ) {
			foreach ( $node['variations'] as $variation => $node ) {
				$variation_selectors[] = array(
					'path'     => array( 'styles', 'blocks', $name, 'variations', $variation ),
					'selector' => $selectors[ $name ]['styleVariations'][ $variation ],

Changelog

VersionDescription
6.0.0Use 'get_metadata_boolean' instead.
5.9.0Introduced.

User Contributed Notes

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