[wp-trac] [WordPress Trac] #55330: Set global_styles_svg_filters transient to return true causing symbol `1` to be appeared on the screen in a production mode
WordPress Trac
noreply at wordpress.org
Mon Mar 7 18:14:13 UTC 2022
#55330: Set global_styles_svg_filters transient to return true causing symbol `1`
to be appeared on the screen in a production mode
------------------------------+-----------------------------
Reporter: aliakseyenkaihar | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 5.9.1
Severity: trivial | Keywords:
Focuses: |
------------------------------+-----------------------------
WordPress 5.9.1
PHP 8.0.15
When I set `global_styles_svg_filters` to return true (to prevent from
being set - I don't use `theme.json` but request is sending so I want to
disable it) it renders `1` at the top of the website
Steps to reproduce on TwentyTwentyTwo theme:
1. Paste these lines in `functions.php`
{{{#!php
<?php
// @see https://github.com/WordPress/WordPress/blob/master/wp-
includes/option.php#L131
$theme = get_stylesheet();
add_filter( "pre_transient_global_styles_svg_filters_{$theme}",
'__return_true' );
}}}
You will see `1` at the top of any screen on site's front
If you define `WP_DEBUG` as `true` or `WP_ENVIRONMENT_TYPE` as
`development` it will dissapear
It happens [here](https://github.com/WordPress/WordPress/blob/master/wp-
includes/script-loader.php#L2361) - `wp_get_global_styles_svg_filters()`
function will return `true` (as I manually set transient) so `$cached`
[will](https://github.com/WordPress/WordPress/blob/2399966d8ce0f89e3989360929fa01edf86e15c0
/wp-includes/global-styles-and-settings.php#L172) be `true` as well.
Therefore it echoing as 1
It is so minor and specific but it happened to me :) So because I may set
any return type for this transient my guess there is no need for extra
check but for a filter. For example
{{{#!php
<?php
// script-loader.php
$svg_filters = wp_get_global_styles_svg_filters();
$filters = apply_filters( 'wp_get_global_styles_svg_filters', $svg_filters
);
}}}
This way I will control svg filters output myself
--
Ticket URL: <https://core.trac.wordpress.org/ticket/55330>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list