WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

WP_Theme_JSON::merge() public WP 5.8.0

Merge new incoming data.

{} Это метод класса: WP_Theme_JSON{}

Хуков нет.

Возвращает

null. Ничего.

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

$WP_Theme_JSON = new WP_Theme_JSON();
$WP_Theme_JSON->merge( $incoming );
$incoming(WP_Theme_JSON) (обязательный)
Data to merge.

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

С версии 5.8.0 Введена.

Код WP_Theme_JSON::merge() WP 5.8.1

public function merge( $incoming ) {
	$incoming_data    = $incoming->get_raw_data();
	$this->theme_json = array_replace_recursive( $this->theme_json, $incoming_data );

	/*
	 * The array_replace_recursive() algorithm merges at the leaf level.
	 * For leaf values that are arrays it will use the numeric indexes for replacement.
	 * In those cases, we want to replace the existing with the incoming value, if it exists.
	 */
	$to_replace   = array();
	$to_replace[] = array( 'spacing', 'units' );
	$to_replace[] = array( 'color', 'duotone' );
	foreach ( self::VALID_ORIGINS as $origin ) {
		$to_replace[] = array( 'color', 'palette', $origin );
		$to_replace[] = array( 'color', 'gradients', $origin );
		$to_replace[] = array( 'typography', 'fontSizes', $origin );
		$to_replace[] = array( 'typography', 'fontFamilies', $origin );
	}

	$nodes = self::get_setting_nodes( $this->theme_json );
	foreach ( $nodes as $metadata ) {
		foreach ( $to_replace as $property_path ) {
			$path = array_merge( $metadata['path'], $property_path );
			$node = _wp_array_get( $incoming_data, $path, null );
			if ( isset( $node ) ) {
				_wp_array_set( $this->theme_json, $path, $node );
			}
		}
	}
}