WP_Theme_JSON::merge( WP_Theme_JSON $incoming )

In this article

Merges new incoming data.

Parameters

$incomingWP_Theme_JSONrequired
Data to merge.

Source

	}

	// Top-level.
	$nodes[] = array(
		'path'     => array( 'styles' ),
		'selector' => static::ROOT_BLOCK_SELECTOR,
	);

	if ( isset( $theme_json['styles']['elements'] ) ) {
		foreach ( self::ELEMENTS as $element => $selector ) {
			if ( ! isset( $theme_json['styles']['elements'][ $element ] ) ) {
				continue;
			}
			$nodes[] = array(
				'path'     => array( 'styles', 'elements', $element ),
				'selector' => static::ELEMENTS[ $element ],
			);

			// Handle any pseudo selectors for the element.
			if ( isset( static::VALID_ELEMENT_PSEUDO_SELECTORS[ $element ] ) ) {
				foreach ( static::VALID_ELEMENT_PSEUDO_SELECTORS[ $element ] as $pseudo_selector ) {

					if ( isset( $theme_json['styles']['elements'][ $element ][ $pseudo_selector ] ) ) {
						$nodes[] = array(
							'path'     => array( 'styles', 'elements', $element ),
							'selector' => static::append_to_selector( static::ELEMENTS[ $element ], $pseudo_selector ),
						);
					}
				}
			}
		}
	}

	// Blocks.
	if ( ! isset( $theme_json['styles']['blocks'] ) ) {
		return $nodes;
	}

	$block_nodes = static::get_block_nodes( $theme_json, $selectors, $options );
	foreach ( $block_nodes as $block_node ) {
		$nodes[] = $block_node;
	}

	/**
	 * Filters the list of style nodes with metadata.
	 *
	 * This allows for things like loading block CSS independently.
	 *
	 * @since 6.1.0
	 *
	 * @param array $nodes Style nodes with metadata.
	 */
	return apply_filters( 'wp_theme_json_get_style_nodes', $nodes );
}

/**
 * A public helper to get the block nodes from a theme.json file.
 *
 * @since 6.1.0
 *
 * @return array The block nodes in theme.json.
 */
public function get_styles_block_nodes() {
	return static::get_block_nodes( $this->theme_json );
}

/**
 * Returns a filtered declarations array if there is a separator block with only a background
 * style defined in theme.json by adding a color attribute to reflect the changes in the front.
 *
 * @since 6.1.1
 *
 * @param array $declarations List of declarations.
 * @return array $declarations List of declarations filtered.
 */
private static function update_separator_declarations( $declarations ) {
	$background_color     = '';
	$border_color_matches = false;
	$text_color_matches   = false;

	foreach ( $declarations as $declaration ) {
		if ( 'background-color' === $declaration['name'] && ! $background_color && isset( $declaration['value'] ) ) {
			$background_color = $declaration['value'];
		} elseif ( 'border-color' === $declaration['name'] ) {
			$border_color_matches = true;

Changelog

VersionDescription
5.9.0Duotone preset also has origins.
5.8.0Introduced.

User Contributed Notes

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