From 00762410b04e9eaba7681c93dce3e576e5d77d8e Mon Sep 17 00:00:00 2001 From: "Dominik Schilling (ocean90)" Date: Thu, 1 Oct 2015 21:20:09 +0000 Subject: [PATCH] Upgrader: Clear plugin/theme caches directly after a plugin/theme has been installed. `wp_update_plugins()` and `wp_update_themes()` are both hooked into `upgrader_process_complete` with priority 10. But at this stage the caches in `get_plugins()`, `search_theme_directories()`, and `wp_get_themes()` aren't refreshed yet so both functions couldn't fetch any translations for the new plugin/theme. To reset the caches `wp_clean_themes_cache()` and `wp_clean_plugins_cache()` are now hooked into `upgrader_process_complete` with priority 9. Fixes #34029. git-svn-id: https://develop.svn.wordpress.org/trunk@34751 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/class-wp-upgrader.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/wp-admin/includes/class-wp-upgrader.php b/src/wp-admin/includes/class-wp-upgrader.php index 89f966cd60..ff25249a92 100644 --- a/src/wp-admin/includes/class-wp-upgrader.php +++ b/src/wp-admin/includes/class-wp-upgrader.php @@ -844,6 +844,8 @@ class Plugin_Upgrader extends WP_Upgrader { $this->install_strings(); add_filter('upgrader_source_selection', array($this, 'check_package') ); + // Clear cache so wp_update_plugins() knows about the new plugin. + add_action( 'upgrader_process_complete', 'wp_clean_plugins_cache', 9, 0 ); $this->run( array( 'package' => $package, @@ -856,6 +858,7 @@ class Plugin_Upgrader extends WP_Upgrader { ) ) ); + remove_action( 'upgrader_process_complete', 'wp_clean_plugins_cache', 9 ); remove_filter('upgrader_source_selection', array($this, 'check_package') ); if ( ! $this->result || is_wp_error($this->result) ) @@ -1408,6 +1411,8 @@ class Theme_Upgrader extends WP_Upgrader { add_filter('upgrader_source_selection', array($this, 'check_package') ); add_filter('upgrader_post_install', array($this, 'check_parent_theme_filter'), 10, 3); + // Clear cache so wp_update_themes() knows about the new theme. + add_action( 'upgrader_process_complete', 'wp_clean_themes_cache', 9, 0 ); $this->run( array( 'package' => $package, @@ -1420,6 +1425,7 @@ class Theme_Upgrader extends WP_Upgrader { ), ) ); + remove_action( 'upgrader_process_complete', 'wp_clean_themes_cache', 9 ); remove_filter('upgrader_source_selection', array($this, 'check_package') ); remove_filter('upgrader_post_install', array($this, 'check_parent_theme_filter'));