WP_Duotone::add_editor_settings
Adds the duotone SVGs and CSS custom properties to the editor settings.
This allows the properties to be pulled in by the EditorStyles component in JS and rendered in the post editor.
Method of the class: WP_Duotone{}
No Hooks.
Returns
Array
. The editor settings with duotone SVGs and CSS custom properties.
Usage
$result = WP_Duotone::add_editor_settings( $settings );
- $settings(array) (required)
- The block editor settings from the block_editor_settings_all
Changelog
Since 6.3.0 | Introduced. |
WP_Duotone::add_editor_settings() WP Duotone::add editor settings code WP 6.8.1
public static function add_editor_settings( $settings ) { $global_styles_presets = self::get_all_global_styles_presets(); if ( ! empty( $global_styles_presets ) ) { if ( ! isset( $settings['styles'] ) ) { $settings['styles'] = array(); } $settings['styles'][] = array( // For the editor we can add all of the presets by default. 'assets' => self::get_svg_definitions( $global_styles_presets ), // The 'svgs' type is new in 6.3 and requires the corresponding JS changes in the EditorStyles component to work. '__unstableType' => 'svgs', // These styles not generated by global styles, so this must be false or they will be stripped out in wp_get_block_editor_settings. 'isGlobalStyles' => false, ); $settings['styles'][] = array( // For the editor we can add all of the presets by default. 'css' => self::get_global_styles_presets( $global_styles_presets ), // This must be set and must be something other than 'theme' or they will be stripped out in the post editor <Editor> component. '__unstableType' => 'presets', // These styles are no longer generated by global styles, so this must be false or they will be stripped out in wp_get_block_editor_settings. 'isGlobalStyles' => false, ); } return $settings; }