Skip to content

Commit

Permalink
Clear cache upon upgrading the active theme
Browse files Browse the repository at this point in the history
  • Loading branch information
oandregal committed Nov 10, 2022
1 parent 0c888a4 commit c6733b0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/compat/wordpress-6.2/default-filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@

add_action( 'switch_theme', 'wp_theme_has_theme_json_clean_cache' );
add_action( 'start_previewing_theme', 'wp_theme_has_theme_json_clean_cache' );
// TODO: clean cache when theme is updated
add_action( 'upgrader_process_complete', '_wp_theme_has_theme_json_clean_cache_upon_upgrading_active_theme' );
13 changes: 13 additions & 0 deletions lib/compat/wordpress-6.2/get-global-styles-and-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,16 @@ function wp_theme_has_theme_json_clean_cache() {
wp_cache_delete( 'wp_theme_has_theme_json', 'theme_json' );
}
}

if ( ! function_exists( '_wp_theme_has_theme_json_clean_cache_upon_upgrading_active_theme' ) ) {
function _wp_theme_has_theme_json_clean_cache_upon_upgrading_active_theme( $upgrader, $options ) {
// The cache only needs cleaning when the active theme was updated.
if (
'update' === $options[ 'action' ] &&
'theme' === $options[ 'type' ] &&
array_key_exists( get_stylesheet(), $options[ 'themes' ] )
) {
wp_theme_has_theme_json_clean_cache();
}
}
}

0 comments on commit c6733b0

Please sign in to comment.