WP_Duotone::get_all_global_styles_presets
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.
Method of the class: WP_Duotone{}
No Hooks.
Returns
Array. An array of global styles presets, keyed on the filter ID.
Usage
$result = WP_Duotone::get_all_global_styles_presets();
Changelog
| Since 6.3.0 | Introduced. |
WP_Duotone::get_all_global_styles_presets() WP Duotone::get all global styles presets code WP 6.8.3
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;
}