From 703e7a028a763f9c46f19c347601522827873d98 Mon Sep 17 00:00:00 2001 From: Marin Atanasov Date: Thu, 19 May 2022 17:38:14 +0300 Subject: [PATCH] Global Styles: Introduce a filter for toggling stylesheet cache --- src/wp-includes/global-styles-and-settings.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/global-styles-and-settings.php b/src/wp-includes/global-styles-and-settings.php index efc2edcaaa354..49fccc7a3e37a 100644 --- a/src/wp-includes/global-styles-and-settings.php +++ b/src/wp-includes/global-styles-and-settings.php @@ -93,7 +93,15 @@ function wp_get_global_stylesheet( $types = array() ) { ( ! defined( 'WP_DEBUG' ) || ! WP_DEBUG ) && ( ! defined( 'SCRIPT_DEBUG' ) || ! SCRIPT_DEBUG ) && ( ! defined( 'REST_REQUEST' ) || ! REST_REQUEST ) && - ! is_admin() + ! is_admin() && + /** + * Whether to enable the global styles stylesheet cache. + * + * @since 6.0.0 + * + * @param bool $enable True to enable transient cache, false otherwise. + */ + apply_filters( 'global_styles_enable_cache', true ) ); $transient_name = 'global_styles_' . get_stylesheet(); if ( $can_use_cached ) { @@ -165,7 +173,9 @@ function wp_get_global_styles_svg_filters() { ( ! defined( 'WP_DEBUG' ) || ! WP_DEBUG ) && ( ! defined( 'SCRIPT_DEBUG' ) || ! SCRIPT_DEBUG ) && ( ! defined( 'REST_REQUEST' ) || ! REST_REQUEST ) && - ! is_admin() + ! is_admin() && + /** This filter is documented in wp-includes/global-styles-and-settings.php */ + apply_filters( 'global_styles_enable_cache', true ) ); $transient_name = 'global_styles_svg_filters_' . get_stylesheet(); if ( $can_use_cached ) {