Skip to content

Commit

Permalink
Invalidate global styles webfonts cache on save
Browse files Browse the repository at this point in the history
  • Loading branch information
zaguiini committed Mar 17, 2022
1 parent 371f3d6 commit 0c46216
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/compat/wordpress-6.0/class-wp-webfonts.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down

0 comments on commit 0c46216

Please sign in to comment.