WP_Theme_JSON::get_metadata_boolean() – For metadata values that can either be booleans or paths to booleans, gets the value.

You appear to be a bot. Output may be restricted

Description

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

“`php $data = array(

  • 'color' => array(
  • 'defaultPalette' => true
  • )

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

Usage

$bool = WP_Theme_JSON::get_metadata_boolean( $data, $path, $default );

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 false.

Returns

bool Value of boolean metadata.

Source

File name: wordpress/wp-includes/class-wp-theme-json.php


Lines:

1 to 15 of 15
  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;
  }
 

 View on GitHub View on Trac