WordPress.org

Make WordPress Core

Changeset 51819


Ignore:
Timestamp:
09/16/2021 06:03:04 PM (5 weeks ago)
Author:
jorgefilipecosta
Message:

Block editor: Cache global stylesheet by theme key.

Global styles are used in a few different contexts (front, editor, customizer, the theme directory). In the last two contexts, it's important that switching themes immediately refreshes the global stylesheet, to avoid situations in which the styles of the previous theme load with the new one. This was brought up at WordPress/gutenberg#34531 (customizer) and at meta.trac.wordpress.org/ticket/5818 (theme directory).
This commit makes sure the stylesheet is regenerated upon switching themes.

Props oandregal, dd32.
See #53175.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/script-loader.php

    r51794 r51819  
    23012301
    23022302    $stylesheet = null;
     2303    $transient_name = 'global_styles_' . get_stylesheet();
    23032304    if ( $can_use_cache ) {
    2304         $cache = get_transient( 'global_styles' );
     2305        $cache = get_transient( $transient_name );
    23052306        if ( $cache ) {
    23062307            $stylesheet = $cache;
     
    23142315
    23152316        if ( $can_use_cache ) {
    2316             set_transient( 'global_styles', $stylesheet, MINUTE_IN_SECONDS );
     2317            set_transient( $transient_name, $stylesheet, MINUTE_IN_SECONDS );
    23172318        }
    23182319    }
Note: See TracChangeset for help on using the changeset viewer.