WP_Theme_JSON::get_name_from_defaults()
Get a default's preset name by a provided slug.
{} It's a method of the class: WP_Theme_JSON{}
No Hooks.
Return
String|null
.
Usage
// protected - for code of main (parent) or child class $result = $this->get_name_from_defaults( $slug, $base_path );
- $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.
Changelog
Since 5.9.0 | Introduced. |
Code of WP_Theme_JSON::get_name_from_defaults() WP Theme JSON::get name from defaults WP 6.0
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; }