WP_Theme_JSON::merge_spacing_sizes( array $base, array $incoming ): array

In this article

This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only by core. It is listed here for completeness.

Merges two sets of spacing size presets.

Parameters

$basearrayrequired
The base set of spacing sizes.
$incomingarrayrequired
The set of spacing sizes to merge with the base. Duplicate slugs will override the base values.

Return

array The merged set of spacing sizes.

Source

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 );
}

Changelog

VersionDescription
6.6.0Introduced.

User Contributed Notes

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