WP_Theme_JSON_Resolver::get_merged_data()public staticWP 5.8.0

Returns the data merged from multiple origins.

There are four sources of data (origins) for a site:

  • default => WordPress
  • blocks => each one of the blocks provides data for itself
  • theme => the active theme
  • custom => data provided by the user

The custom's has higher priority than the theme's, the theme's higher than blocks', and block's higher than default's.

Unlike the getters get_core_data, get_theme_data, and get_user_data, this method returns data after it has been merged with the previous origins. This means that if the same piece of data is declared in different origins (default, blocks, theme, custom), the last origin overrides the previous.

For example, if the user has set a background color for the paragraph block, and the theme has done it as well, the user preference wins.

Метод класса: WP_Theme_JSON_Resolver{}

Хуков нет.




$result = WP_Theme_JSON_Resolver::get_merged_data( $origin );
To what level should we merge data: 'default', 'blocks', 'theme' or 'custom'. 'custom' is used as default value as well as fallback value if the origin is unknown.
По умолчанию: 'custom'

Список изменений

С версии 5.8.0 Введена.
С версии 5.9.0 Added user data, removed the $settings parameter, added the $origin parameter.
С версии 6.1.0 Added block data and generation of spacingSizes array.
С версии 6.2.0 Changed ' $origin' parameter values to 'default', 'blocks', 'theme' or 'custom'.

Код WP_Theme_JSON_Resolver::get_merged_data() WP 6.5.3

public static function get_merged_data( $origin = 'custom' ) {
	if ( is_array( $origin ) ) {
		_deprecated_argument( __FUNCTION__, '5.9.0' );

	$result = new WP_Theme_JSON();
	$result->merge( static::get_core_data() );
	if ( 'default' === $origin ) {
		return $result;

	$result->merge( static::get_block_data() );
	if ( 'blocks' === $origin ) {
		return $result;

	$result->merge( static::get_theme_data() );
	if ( 'theme' === $origin ) {
		return $result;

	$result->merge( static::get_user_data() );

	return $result;