WP_Theme_JSON::get_name_from_defaults() WordPress Method
The WP_Theme_JSON::get_name_from_defaults() function is used to retrieve the name of a theme from its default values. This function is useful for themes that don't have a name assigned to them.
WP_Theme_JSON::get_name_from_defaults( string $slug, array $base_path ) #
Get a default
‘s preset name by a provided slug.
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.
Return
(string|null)
Source
File: wp-includes/class-wp-theme-json.php
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; }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
5.9.0 | Introduced. |