Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Rename variable
  • Loading branch information
mmtr committed Nov 2, 2022
commit 273aeb5972580ffd04a40246464602eb55b05e92
Original file line number Diff line number Diff line change
Expand Up @@ -306,13 +306,13 @@ function wpcom_display_global_styles_banner_extra_tooltip() {
* Invalidates the cached Global Styles after changing them or when previewing them.
*/
function wpcom_invalidate_global_styles_cache() {
$transient_name = 'gutenberg_global_styles_' . get_stylesheet();
$gutenberg_global_styles_transient_name = 'gutenberg_global_styles_' . get_stylesheet();

if ( wpcom_should_limit_global_styles() && wpcom_is_previewing_global_styles() ) {
add_filter( 'pre_transient_' . $transient_name, '__return_null' );
add_filter( 'pre_set_transient_' . $transient_name, '__return_false' );
add_filter( 'pre_transient_' . $gutenberg_global_styles_transient_name, '__return_null' );
add_filter( 'pre_set_transient_' . $gutenberg_global_styles_transient_name, '__return_false' );
}

add_action( 'save_post_wp_global_styles', fn() => delete_transient( $transient_name ) );
add_action( 'save_post_wp_global_styles', fn() => delete_transient( $gutenberg_global_styles_transient_name ) );
}
add_action( 'init', 'wpcom_invalidate_global_styles_cache' );