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
Invalidate global styles webfonts cache on save
  • Loading branch information
zaguiini committed Mar 17, 2022
commit 0c46216a7b0423950f8c5fa113a65a74a6b13646
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