Make WordPress Core


Ignore:
Timestamp:
02/17/2022 08:49:37 PM (2 years ago)
Author:
hellofromTonya
Message:

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.
Merges [52768] to the 5.9 branch.
Fixes #55190.

Location:
branches/5.9
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.9

  • branches/5.9/src/wp-includes/script-loader.php

    r52762 r52769  
    23382338
    23392339/**
     2340 * Render the SVG filters supplied by theme.json.
     2341 *
     2342 * Note that this doesn't render the per-block user-defined
     2343 * filters which are handled by wp_render_duotone_support,
     2344 * but it should be rendered before the filtered content
     2345 * in the body to satisfy Safari's rendering quirks.
     2346 *
     2347 * @since 5.9.1
     2348 */
     2349function wp_global_styles_render_svg_filters() {
     2350    /*
     2351     * When calling via the in_admin_header action, we only want to render the
     2352     * SVGs on block editor pages.
     2353     */
     2354    if (
     2355        is_admin() &&
     2356        ! get_current_screen()->is_block_editor()
     2357    ) {
     2358        return;
     2359    }
     2360
     2361    $filters = wp_get_global_styles_svg_filters();
     2362    if ( ! empty( $filters ) ) {
     2363        echo $filters;
     2364    }
     2365}
     2366
     2367/**
    23402368 * Checks if the editor scripts and styles for all registered block types
    23412369 * should be enqueued on the current screen.
Note: See TracChangeset for help on using the changeset viewer.