WP_Theme_JSON::get_name_from_defaults( string $slug, array $base_path ): string|null
Gets 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
.
View all references
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;
}
Changelog
Version | Description |
---|---|
5.9.0 | Introduced. |