wp_get_global_styles_svg_filters

The timeline below displays how wordpress function wp_get_global_styles_svg_filters has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.3

/**
 * Returns a string containing the SVGs to be referenced as filters (duotone).
 *
 * @since 5.9.1
 * @deprecated 6.3.0 SVG generation is handled on a per-block basis in block supports.
 *
 * @return string
 */
function wp_get_global_styles_svg_filters()
{
    _deprecated_function(__FUNCTION__, '6.3.0');
    /*
     * Ignore cache when the development mode is set to 'theme', so it doesn't interfere with the theme
     * developer's workflow.
     */
    $can_use_cached = !wp_is_development_mode('theme');
    $cache_group = 'theme_json';
    $cache_key = 'wp_get_global_styles_svg_filters';
    if ($can_use_cached) {
        $cached = wp_cache_get($cache_key, $cache_group);
        if ($cached) {
            return $cached;
        }
    }
    $supports_theme_json = wp_theme_has_theme_json();
    $origins = array('default', 'theme', 'custom');
    if (!$supports_theme_json) {
        $origins = array('default');
    }
    $tree = WP_Theme_JSON_Resolver::get_merged_data();
    $svgs = $tree->get_svg_filters($origins);
    if ($can_use_cached) {
        wp_cache_set($cache_key, $svgs, $cache_group);
    }
    return $svgs;
}

WordPress Version: 6.2

/**
 * Returns a string containing the SVGs to be referenced as filters (duotone).
 *
 * @since 5.9.1
 *
 * @return string
 */
function wp_get_global_styles_svg_filters()
{
    /*
     * Ignore cache when `WP_DEBUG` is enabled, so it doesn't interfere with the theme
     * developer's workflow.
     *
     * @todo Replace `WP_DEBUG` once an "in development mode" check is available in Core.
     */
    $can_use_cached = !WP_DEBUG;
    $cache_group = 'theme_json';
    $cache_key = 'wp_get_global_styles_svg_filters';
    if ($can_use_cached) {
        $cached = wp_cache_get($cache_key, $cache_group);
        if ($cached) {
            return $cached;
        }
    }
    $supports_theme_json = wp_theme_has_theme_json();
    $origins = array('default', 'theme', 'custom');
    if (!$supports_theme_json) {
        $origins = array('default');
    }
    $tree = WP_Theme_JSON_Resolver::get_merged_data();
    $svgs = $tree->get_svg_filters($origins);
    if ($can_use_cached) {
        wp_cache_set($cache_key, $svgs, $cache_group);
    }
    return $svgs;
}

WordPress Version: 9.1

/**
 * Returns a string containing the SVGs to be referenced as filters (duotone).
 *
 * @since 5.9.1
 *
 * @return string
 */
function wp_get_global_styles_svg_filters()
{
    // Return cached value if it can be used and exists.
    // It's cached by theme to make sure that theme switching clears the cache.
    $can_use_cached = (!defined('WP_DEBUG') || !WP_DEBUG) && (!defined('SCRIPT_DEBUG') || !SCRIPT_DEBUG) && (!defined('REST_REQUEST') || !REST_REQUEST) && !is_admin();
    $transient_name = 'global_styles_svg_filters_' . get_stylesheet();
    if ($can_use_cached) {
        $cached = get_transient($transient_name);
        if ($cached) {
            return $cached;
        }
    }
    $supports_theme_json = WP_Theme_JSON_Resolver::theme_has_support();
    $origins = array('default', 'theme', 'custom');
    if (!$supports_theme_json) {
        $origins = array('default');
    }
    $tree = WP_Theme_JSON_Resolver::get_merged_data();
    $svgs = $tree->get_svg_filters($origins);
    if ($can_use_cached) {
        // Cache for a minute, same as wp_get_global_stylesheet.
        set_transient($transient_name, $svgs, MINUTE_IN_SECONDS);
    }
    return $svgs;
}