Skip to content

Commit

Permalink
Add filter to shortcircuit the cache
Browse files Browse the repository at this point in the history
  • Loading branch information
mmtr committed Nov 16, 2022
1 parent 0f80d71 commit a845e85
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions lib/compat/wordpress-6.2/get-global-styles-and-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,18 @@ function wp_theme_clean_theme_json_cached_data() {
* @return string Stylesheet.
*/
function gutenberg_get_global_stylesheet( $types = array() ) {
// 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 = (
/**
* Filters whether the cached global stylesheet can be used.
*
* @since 14.6.0
*
* @param boolean $can_use_cached Whether the cached global stylesheet can be used.
*/
$can_use_cached = apply_filters(
'global_stylesheet_can_use_cache',
( empty( $types ) ) &&
( ! defined( 'WP_DEBUG' ) || ! WP_DEBUG ) &&
( ! defined( 'SCRIPT_DEBUG' ) || ! SCRIPT_DEBUG ) &&
( ! defined( 'REST_REQUEST' ) || ! REST_REQUEST ) &&
! is_admin()
( ! defined( 'SCRIPT_DEBUG' ) || ! SCRIPT_DEBUG )
);
$cache_key = 'gutenberg_get_global_stylesheet';
$cache_group = 'theme_json';
Expand Down

0 comments on commit a845e85

Please sign in to comment.