On this page
WP_Theme_JSON::get_metadata_boolean( array $data, bool|array $path, bool $default = 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[/code]
Parameters
$dataarray Required-
The data to inspect.
$pathbool|array Required-
Boolean or path to a boolean.
$defaultbool Optional-
Default value if the referenced path is missing.
Default:
false
Return
bool Value of boolean metadata.
Source
File: wp-includes/class-wp-theme-json.php. View all references
protected static function get_metadata_boolean( $data, $path, $default = false ) {
if ( is_bool( $path ) ) {
return $path;
}
if ( is_array( $path ) ) {
$value = _wp_array_get( $data, $path );
if ( null !== $value ) {
return $value;
}
}
return $default;
}
Related
Uses
| Uses | Description |
|---|---|
| _wp_array_get() wp-includes/functions.php | Accesses an array in depth based on a path of keys. |
Changelog
| Version | Description |
|---|---|
| 6.0.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_theme_json/get_metadata_boolean