WP_Theme_JSON::get_merged_preset_by_slug( array $preset_per_origin, string $value_key )

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

Given an array of presets keyed by origin and the value key of the preset, it returns an array where each key is the preset slug and each value the preset value.

Parameters

$preset_per_origin

(array) (Required) Array of presets keyed by origin.

$value_key

(string) (Required) The property of the preset that contains its value.

Return

(array) Array of presets where each key is a slug and each value is the preset value.

Source

File: wp-includes/class-wp-theme-json.php

private static function get_merged_preset_by_slug( $preset_per_origin, $value_key ) {
		$result = array();
		foreach ( self::VALID_ORIGINS as $origin ) {
			if ( ! isset( $preset_per_origin[ $origin ] ) ) {
				continue;
			}
			foreach ( $preset_per_origin[ $origin ] as $preset ) {
				/*
				 * We don't want to use kebabCase here,
				 * see https://github.com/WordPress/gutenberg/issues/32347
				 * However, we need to make sure the generated class or CSS variable
				 * doesn't contain spaces.
				 */
				$result[ preg_replace( '/\s+/', '-', $preset['slug'] ) ] = $preset[ $value_key ];
			}
		}
		return $result;
	}

Changelog

Version Description
5.8.0 Introduced.

© 2003–2021 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_theme_json/get_merged_preset_by_slug