Make WordPress Core


Ignore:
Timestamp:
02/17/2022 05:29:04 PM (4 years ago)
Author:
audrasjb
Message:

Editor: Backport Duotone fixes for 5.9.1.

This changeset is a backport for the following Gutenberg PRs:

Props oandregal, scruffian, Mamaduka.
Merges [52757] to the 5.9 branch.
See #55179.

Location:
branches/5.9
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.9

  • branches/5.9/src/wp-includes/global-styles-and-settings.php

    r52678 r52759  
    151151        return $stylesheet;
    152152}
     153
     154/**
     155 * Returns a string containing the SVGs to be referenced as filters (duotone).
     156 *
     157 * @since 5.9.1
     158 *
     159 * @return string
     160 */
     161function wp_get_global_styles_svg_filters() {
     162        // Return cached value if it can be used and exists.
     163        // It's cached by theme to make sure that theme switching clears the cache.
     164        $can_use_cached = (
     165                ( ! defined( 'WP_DEBUG' ) || ! WP_DEBUG ) &&
     166                ( ! defined( 'SCRIPT_DEBUG' ) || ! SCRIPT_DEBUG ) &&
     167                ( ! defined( 'REST_REQUEST' ) || ! REST_REQUEST ) &&
     168                ! is_admin()
     169        );
     170        $transient_name = 'global_styles_svg_filters_' . get_stylesheet();
     171        if ( $can_use_cached ) {
     172                $cached = get_transient( $transient_name );
     173                if ( $cached ) {
     174                        return $cached;
     175                }
     176        }
     177
     178        $supports_theme_json = WP_Theme_JSON_Resolver::theme_has_support();
     179
     180        $origins = array( 'default', 'theme', 'custom' );
     181        if ( ! $supports_theme_json ) {
     182                $origins = array( 'default' );
     183        }
     184
     185        $tree = WP_Theme_JSON_Resolver::get_merged_data();
     186        $svgs = $tree->get_svg_filters( $origins );
     187
     188        if ( $can_use_cached ) {
     189                // Cache for a minute, same as wp_get_global_stylesheet.
     190                set_transient( $transient_name, $svgs, MINUTE_IN_SECONDS );
     191        }
     192
     193        return $svgs;
     194}
Note: See TracChangeset for help on using the changeset viewer.