WP_Theme_JSON::get_metadata_boolean() WordPress Method
The WP_Theme_JSON::get_metadata_boolean() function is used to get the value of a theme's metadata field. The value is returned as a boolean (true/false).
WP_Theme_JSON::get_metadata_boolean( array $data, bool|array $path, bool $default = false ) #
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
- $data
(array)(Required)The data to inspect.
- $path
(bool|array)(Required)Boolean or path to a boolean.
- $default
(bool)(Optional)Default value if the referenced path is missing.
Default value: false
Return
(bool) Value of boolean metadata.
Source
File: wp-includes/class-wp-theme-json.php
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; }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
6.0.0 | Introduced. |