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

}

/**
 * Determines whether a presets should be overridden or not.
 *
 * @since 5.9.0
 * @deprecated 6.0.0 Use 'get_metadata_boolean' instead.
 *
 * @param array      $theme_json The theme.json like structure to inspect.
 * @param array      $path       Path to inspect.
 * @param bool|array $override   Data to compute whether to override the preset.
 * @return bool
 */
protected static function should_override_preset( $theme_json, $path, $override ) {
	_deprecated_function( __METHOD__, '6.0.0', 'get_metadata_boolean' );

	if ( is_bool( $override ) ) {
		return $override;
	}

	/*
	 * The relationship between whether to override the defaults
	 * and whether the defaults are enabled is inverse:
	 *
	 * - If defaults are enabled  => theme presets should not be overridden
	 * - If defaults are disabled => theme presets should be overridden
	 *
	 * For example, a theme sets defaultPalette to false,
	 * making the default palette hidden from the user.
	 * In that case, we want all the theme presets to be present,
	 * so they should override the defaults.
	 */
	if ( is_array( $override ) ) {
		$value = _wp_array_get( $theme_json, array_merge( $path, $override ) );

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.