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 ( isset( $theme_json['styles']['blocks'][ $name ]['elements'] ) ) {
			foreach ( $theme_json['styles']['blocks'][ $name ]['elements'] as $element => $node ) {
				$nodes[] = array(
					'path'     => array( 'styles', 'blocks', $name, 'elements', $element ),
					'selector' => $selectors[ $name ]['elements'][ $element ],
				);

				// Handle any pseudo selectors for the element.
				if ( isset( static::VALID_ELEMENT_PSEUDO_SELECTORS[ $element ] ) ) {
					foreach ( static::VALID_ELEMENT_PSEUDO_SELECTORS[ $element ] as $pseudo_selector ) {
						if ( isset( $theme_json['styles']['blocks'][ $name ]['elements'][ $element ][ $pseudo_selector ] ) ) {
							$nodes[] = array(
								'path'     => array( 'styles', 'blocks', $name, 'elements', $element ),
								'selector' => static::append_to_selector( $selectors[ $name ]['elements'][ $element ], $pseudo_selector ),
							);
						}
					}
				}
			}
		}
	}

	return $nodes;
}

/**
 * Gets the CSS rules for a particular block from theme.json.
 *
 * @since 6.1.0
 * @since 6.6.0 Setting a min-height of HTML when root styles have a background gradient or image.
 *              Updated general global styles specificity to 0-1-0.
 *              Fixed custom CSS output in block style variations.
 *
 * @param array $block_metadata Metadata about the block to get styles for.

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.