WP_Theme_JSON_Resolver::get_merged_data()public staticWP 5.8.0

Returns the data merged from multiple origins.

There are three sources of data (origins) for a site: default, theme, and custom. The custom's has higher priority than the theme's, and the theme'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 (user, theme, and core), 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{}

Хуков нет.

Возвращает

WP_Theme_JSON.

Использование

$result = WP_Theme_JSON_Resolver::get_merged_data( $origin );
$origin(строка)
To what level should we merge data. Valid values are 'theme' or 'custom'.
По умолчанию: '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.

Код WP_Theme_JSON_Resolver::get_merged_data() WP 6.1.1

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

	$result = static::get_core_data();
	$result->merge( static::get_block_data() );
	$result->merge( static::get_theme_data() );

	if ( 'custom' === $origin ) {
		$result->merge( static::get_user_data() );
	}

	// Generate the default spacingSizes array based on the merged spacingScale settings.
	$result->set_spacing_sizes();

	return $result;
}