WP_Theme_JSON_Resolver::get_theme_data( array $theme_support_data = array() )
Returns the theme’s data.
Description
Data from theme.json can be augmented via the $theme_support_data variable. This is useful, for example, to backfill the gaps in theme.json that a theme has declared via add_theme_supports.
Note that if the same data is present in theme.json and in $theme_support_data, the theme.json’s is not overwritten.
Parameters
- $theme_support_data
-
(array) (Optional) Theme support data in theme.json format.
Default value: array()
Return
(WP_Theme_JSON) Entity that holds theme data.
Source
File: wp-includes/class-wp-theme-json-resolver.php
public static function get_theme_data( $theme_support_data = array() ) { if ( null === self::$theme ) { $theme_json_data = self::read_json_file( self::get_file_path_from_theme( 'theme.json' ) ); $theme_json_data = self::translate( $theme_json_data, wp_get_theme()->get( 'TextDomain' ) ); self::$theme = new WP_Theme_JSON( $theme_json_data ); } if ( empty( $theme_support_data ) ) { return self::$theme; } /* * We want the presets and settings declared in theme.json * to override the ones declared via add_theme_support. */ $with_theme_supports = new WP_Theme_JSON( $theme_support_data ); $with_theme_supports->merge( self::$theme ); return $with_theme_supports; }
Changelog
Version | Description |
---|---|
5.8.0 | Introduced. |
© 2003–2021 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_theme_json_resolver/get_theme_data