WP_Theme_JSON::get_settings_slugs()protected staticWP 5.9.0

Similar to get_settings_values_by_slug, but doesn't compute the value.

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

Хуков нет.

Возвращает

Массив. Array of presets where the key and value are both the slug.

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

$result = WP_Theme_JSON::get_settings_slugs( $settings, $preset_metadata, $origins );
$settings(массив) (обязательный)
Settings to process.
$preset_metadata(массив) (обязательный)
One of the PRESETS_METADATA values.
$origins(массив)
List of origins to process.
По умолчанию: null

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

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

Код WP_Theme_JSON::get_settings_slugs() WP 6.0.2

protected static function get_settings_slugs( $settings, $preset_metadata, $origins = null ) {
	if ( null === $origins ) {
		$origins = static::VALID_ORIGINS;
	}

	$preset_per_origin = _wp_array_get( $settings, $preset_metadata['path'], array() );

	$result = array();
	foreach ( $origins as $origin ) {
		if ( ! isset( $preset_per_origin[ $origin ] ) ) {
			continue;
		}
		foreach ( $preset_per_origin[ $origin ] as $preset ) {
			$slug = _wp_to_kebab_case( $preset['slug'] );

			// Use the array as a set so we don't get duplicates.
			$result[ $slug ] = $slug;
		}
	}
	return $result;
}