diff --git a/src/wp-admin/includes/class-plugin-upgrader.php b/src/wp-admin/includes/class-plugin-upgrader.php index ffb46204f2..1327d28c11 100644 --- a/src/wp-admin/includes/class-plugin-upgrader.php +++ b/src/wp-admin/includes/class-plugin-upgrader.php @@ -101,8 +101,10 @@ 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 ); + if ( $parsed_args['clear_update_cache'] ) { + // 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, @@ -168,8 +170,10 @@ class Plugin_Upgrader extends WP_Upgrader { add_filter('upgrader_pre_install', array($this, 'deactivate_plugin_before_upgrade'), 10, 2); add_filter('upgrader_clear_destination', array($this, 'delete_old_plugin'), 10, 4); //'source_selection' => array($this, 'source_selection'), //there's a trac ticket to move up the directory for zip's which are made a bit differently, useful for non-.org plugins. - // Clear cache so wp_update_plugins() knows about the new plugin. - add_action( 'upgrader_process_complete', 'wp_clean_plugins_cache', 9, 0 ); + if ( $parsed_args['clear_update_cache'] ) { + // 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' => $r->package, @@ -227,7 +231,6 @@ class Plugin_Upgrader extends WP_Upgrader { $current = get_site_transient( 'update_plugins' ); add_filter('upgrader_clear_destination', array($this, 'delete_old_plugin'), 10, 4); - add_action( 'upgrader_process_complete', 'wp_clean_plugins_cache', 9, 0 ); $this->skin->header(); @@ -294,6 +297,9 @@ class Plugin_Upgrader extends WP_Upgrader { $this->maintenance_mode(false); + // Force refresh of plugin update information. + wp_clean_plugins_cache( $parsed_args['clear_update_cache'] ); + /** This action is documented in wp-admin/includes/class-wp-upgrader.php */ do_action( 'upgrader_process_complete', $this, array( 'action' => 'update', @@ -307,12 +313,8 @@ class Plugin_Upgrader extends WP_Upgrader { $this->skin->footer(); // Cleanup our hooks, in case something else does a upgrade on this connection. - remove_action( 'upgrader_process_complete', 'wp_clean_plugins_cache', 9 ); remove_filter('upgrader_clear_destination', array($this, 'delete_old_plugin')); - // Force refresh of plugin update information. - wp_clean_plugins_cache( $parsed_args['clear_update_cache'] ); - return $results; } diff --git a/src/wp-admin/includes/class-theme-upgrader.php b/src/wp-admin/includes/class-theme-upgrader.php index 76129e3409..b2571ee7f4 100644 --- a/src/wp-admin/includes/class-theme-upgrader.php +++ b/src/wp-admin/includes/class-theme-upgrader.php @@ -201,8 +201,10 @@ 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 ); + if ( $parsed_args['clear_update_cache'] ) { + // 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, @@ -269,8 +271,10 @@ class Theme_Upgrader extends WP_Upgrader { add_filter('upgrader_pre_install', array($this, 'current_before'), 10, 2); add_filter('upgrader_post_install', array($this, 'current_after'), 10, 2); add_filter('upgrader_clear_destination', array($this, 'delete_old_theme'), 10, 4); - // Clear cache so wp_update_themes() knows about the new theme. - add_action( 'upgrader_process_complete', 'wp_clean_themes_cache', 9, 0 ); + if ( $parsed_args['clear_update_cache'] ) { + // 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' => $r['package'], @@ -329,8 +333,6 @@ class Theme_Upgrader extends WP_Upgrader { add_filter('upgrader_pre_install', array($this, 'current_before'), 10, 2); add_filter('upgrader_post_install', array($this, 'current_after'), 10, 2); add_filter('upgrader_clear_destination', array($this, 'delete_old_theme'), 10, 4); - // Clear cache so wp_update_themes() knows about the new theme. - add_action( 'upgrader_process_complete', 'wp_clean_themes_cache', 9, 0 ); $this->skin->header(); @@ -394,6 +396,9 @@ class Theme_Upgrader extends WP_Upgrader { $this->maintenance_mode(false); + // Refresh the Theme Update information + wp_clean_themes_cache( $parsed_args['clear_update_cache'] ); + /** This action is documented in wp-admin/includes/class-wp-upgrader.php */ do_action( 'upgrader_process_complete', $this, array( 'action' => 'update', @@ -407,14 +412,10 @@ class Theme_Upgrader extends WP_Upgrader { $this->skin->footer(); // Cleanup our hooks, in case something else does a upgrade on this connection. - remove_action( 'upgrader_process_complete', 'wp_clean_themes_cache', 9 ); remove_filter('upgrader_pre_install', array($this, 'current_before')); remove_filter('upgrader_post_install', array($this, 'current_after')); remove_filter('upgrader_clear_destination', array($this, 'delete_old_theme')); - // Refresh the Theme Update information - wp_clean_themes_cache( $parsed_args['clear_update_cache'] ); - return $results; }