Editor: Automatically apply global styles duotone filters to render in post editor.

Global styles duotone filters were not rendering in the post editor. This fixes that by adding `wp_global_styles_render_svg_filters` to the `in_admin_header` so it renders in the body before the editor.

Follow-up [52757].

Props ajlende, abhanonstopnewsuk.
Fixes #55190.

git-svn-id: https://develop.svn.wordpress.org/trunk@52768 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Tonya Mork
2022-02-17 20:43:39 +00:00
parent 5c845102ac
commit a3cbbc419d
3 changed files with 32 additions and 18 deletions

View File

@@ -2336,6 +2336,34 @@ function wp_enqueue_global_styles() {
wp_enqueue_style( 'global-styles' );
}
/**
* Render the SVG filters supplied by theme.json.
*
* Note that this doesn't render the per-block user-defined
* filters which are handled by wp_render_duotone_support,
* but it should be rendered before the filtered content
* in the body to satisfy Safari's rendering quirks.
*
* @since 5.9.1
*/
function wp_global_styles_render_svg_filters() {
/*
* When calling via the in_admin_header action, we only want to render the
* SVGs on block editor pages.
*/
if (
is_admin() &&
! get_current_screen()->is_block_editor()
) {
return;
}
$filters = wp_get_global_styles_svg_filters();
if ( ! empty( $filters ) ) {
echo $filters;
}
}
/**
* Checks if the editor scripts and styles for all registered block types
* should be enqueued on the current screen.