Adds the duotone SVGs and CSS custom properties to the editor settings.
Description
This allows the properties to be pulled in by the EditorStyles component in JS and rendered in the post editor.
Parameters
$settings
arrayrequired- The block editor settings from the
block_editor_settings_all
filter.
Source
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;
}
Changelog
Version | Description |
---|---|
6.3.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.