WP_Theme_JSON::merge_spacing_sizes()private staticWP 6.6.0

Merges two sets of spacing size presets.

Method of the class: WP_Theme_JSON{}

No Hooks.

Return

Array. The merged set of spacing sizes.

Usage

$result = WP_Theme_JSON::merge_spacing_sizes( $base, $incoming );
$base(array) (required)
The base set of spacing sizes.
$incoming(array) (required)
The set of spacing sizes to merge with the base. Duplicate slugs will override the base values.

Changelog

Since 6.6.0 Introduced.

WP_Theme_JSON::merge_spacing_sizes() code WP 6.6.2

private static function merge_spacing_sizes( $base, $incoming ) {
	// Preserve the order if there are no base (spacingScale) values.
	if ( empty( $base ) ) {
		return $incoming;
	}
	$merged = array();
	foreach ( $base as $item ) {
		$merged[ $item['slug'] ] = $item;
	}
	foreach ( $incoming as $item ) {
		$merged[ $item['slug'] ] = $item;
	}
	ksort( $merged, SORT_NUMERIC );
	return array_values( $merged );
}