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' ) );
// => trueParameters
$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
Source
protected static function get_metadata_boolean( $data, $path, $default_value = false ) {
if ( is_bool( $path ) ) {
return $path;
}
if ( is_array( $path ) ) {
$value = _wp_array_get( $data, $path );
if ( null !== $value ) {
return $value;
}
}
return $default_value;
}
Changelog
| Version | Description |
|---|---|
| 6.0.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.