WP_Duotone::get_all_global_styles_presets()private staticWP 6.3.0

Scrape all possible duotone presets from global and theme styles and store them in self::$global_styles_presets.

Used in conjunction with self::render_duotone_support for blocks that use duotone preset filters.

Метод класса: WP_Duotone{}

Хуков нет.

Возвращает

Массив. An array of global styles presets, keyed on the filter ID.

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

$result = WP_Duotone::get_all_global_styles_presets();

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

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

Код WP_Duotone::get_all_global_styles_presets() WP 6.6.2

private static function get_all_global_styles_presets() {
	if ( isset( self::$global_styles_presets ) ) {
		return self::$global_styles_presets;
	}
	// Get the per block settings from the theme.json.
	$tree              = wp_get_global_settings();
	$presets_by_origin = isset( $tree['color']['duotone'] ) ? $tree['color']['duotone'] : array();

	self::$global_styles_presets = array();
	foreach ( $presets_by_origin as $presets ) {
		foreach ( $presets as $preset ) {
			$filter_id = self::get_filter_id( _wp_to_kebab_case( $preset['slug'] ) );

			self::$global_styles_presets[ $filter_id ] = $preset;
		}
	}

	return self::$global_styles_presets;
}