WP_Theme_JSON_Resolver::get_theme_data( array $theme_support_data = array() )

Returns the theme’s data.


Description 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.


Top ↑

Parameters Parameters

$theme_support_data

(array) (Optional) Theme support data in theme.json format.

Default value: array()


Top ↑

Return Return

(WP_Theme_JSON) Entity that holds theme data.


Top ↑

Source 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;
	}


Top ↑

Changelog Changelog

Changelog
Version Description
5.8.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.