WP_Duotone::get_all_global_styles_presets(): 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 in other core functions. It is listed here for completeness.

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.


array An array of global styles presets, keyed on the filter ID.


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;



User Contributed Notes

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