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

$include_node_paths_only = $options['include_node_paths_only'] ?? false;

// 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 ) {
		$variation_paths = array();
		if ( $include_variations && isset( $node['variations'] ) ) {
			foreach ( $node['variations'] as $variation => $variation_node ) {
				$variation_paths[] = array(
					'path' => array( 'styles', 'blocks', $name, 'variations', $variation ),
				);
			}
		}
		$node = array(
			'path' => $node_path,
		);
		if ( ! empty( $variation_paths ) ) {
			$node['variations'] = $variation_paths;
		}
		$nodes[] = $node;
	} 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'];

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.