WP_Theme_JSON::get_name_from_defaults() – Get a `default`’s preset name by a provided slug.

You appear to be a bot. Output may be restricted

Description

Get a `default`'s preset name by a provided slug.

Usage

$string|null = WP_Theme_JSON::get_name_from_defaults( $slug, $base_path );

Parameters

$slug
( string ) required – The slug we want to find a match from default presets.
$base_path
( array ) required – The path to inspect. It's 'settings' by default.

Returns

string|null

Source

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

1 to 13 of 13
  protected function get_name_from_defaults( $slug, $base_path ) {
    $path            = array_merge( $base_path, array( 'default' ) );
    $default_content = _wp_array_get( $this->theme_json, $path, null );
    if ( ! $default_content ) {
      return null;
    }
    foreach ( $default_content as $item ) {
      if ( $slug === $item['slug'] ) {
        return $item['name'];
      }
    }
    return null;
  }
 

 View on GitHub View on Trac