WP_Theme_JSON::get_metadata_boolean( array $data, bool|array $path, bool $default_value = false ): bool

For metadata values that can either be booleans or paths to booleans, gets the value.

Description

$data = array( ‘color’ => array( ‘defaultPalette’ => true ) );

static::get_metadata_boolean( $data, false );
// => false

static::get_metadata_boolean( $data, array( 'color', 'defaultPalette' ) );
// => true

Parameters

$dataarrayrequired
The data to inspect.
$pathbool|arrayrequired
Boolean or path to a boolean.
$default_valuebooloptional
Default value if the referenced path is missing.

Default:false

Return

bool Value of boolean metadata.

Source

 *     // => false
 *
 *     static::get_metadata_boolean( $data, array( 'color', 'defaultPalette' ) );
 *     // => true
 *
 * @since 6.0.0
 *
 * @param array      $data          The data to inspect.
 * @param bool|array $path          Boolean or path to a boolean.
 * @param bool       $default_value Default value if the referenced path is missing.
 *                                  Default false.
 * @return bool Value of boolean metadata.
 */
protected static function get_metadata_boolean( $data, $path, $default_value = false ) {

Changelog

VersionDescription
6.0.0Introduced.

User Contributed Notes

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