From 0c46216a7b0423950f8c5fa113a65a74a6b13646 Mon Sep 17 00:00:00 2001 From: Luis Felipe Zaguini Date: Fri, 11 Mar 2022 18:53:32 -0300 Subject: [PATCH] Invalidate global styles webfonts cache on save --- lib/compat/wordpress-6.0/class-wp-webfonts.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/compat/wordpress-6.0/class-wp-webfonts.php b/lib/compat/wordpress-6.0/class-wp-webfonts.php index dbb42da76acc94..a3671d4ec75923 100644 --- a/lib/compat/wordpress-6.0/class-wp-webfonts.php +++ b/lib/compat/wordpress-6.0/class-wp-webfonts.php @@ -81,11 +81,21 @@ public function init() { add_action( 'save_post_wp_template', array( $this, 'invalidate_template_webfonts_cache' ) ); add_action( 'save_post_wp_template_part', array( $this, 'invalidate_template_webfonts_cache' ) ); + add_action( 'save_post_wp_global_styles', array( $this, 'invalidate_global_styles_webfonts_cache' ) ); // Enqueue webfonts in the block editor. add_action( 'admin_init', array( $this, 'generate_and_enqueue_editor_styles' ) ); } + /** + * Invalidate global styles webfonts cache. + */ + public function invalidate_global_styles_webfonts_cache() { + $global_styles_post_id = WP_Theme_JSON_Resolver_Gutenberg::get_user_global_styles_post_id(); + + delete_post_meta( $global_styles_post_id, self::$webfonts_cache_meta_attribute ); + } + /** * Enqueue the webfonts used in global styles by scanning the settings. */