From 520840e84cbe54b99dce5631e7294f36c99d6dc2 Mon Sep 17 00:00:00 2001 From: Dion Hulse Date: Tue, 19 Nov 2013 04:07:47 +0000 Subject: [PATCH] Plugin Deletion: Properly clear the cache when multiple plugins are deleted. Props jdgrimes. Fixes #26065 git-svn-id: https://develop.svn.wordpress.org/trunk@26262 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/plugin.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/wp-admin/includes/plugin.php b/src/wp-admin/includes/plugin.php index 4e2126a368..9a25da5eae 100644 --- a/src/wp-admin/includes/plugin.php +++ b/src/wp-admin/includes/plugin.php @@ -803,15 +803,21 @@ function delete_plugins($plugins, $redirect = '' ) { $errors[] = $plugin_file; } + // Remove deleted plugins from the plugin updates list. + if ( $current = get_site_transient('update_plugins') ) { + // Don't remove the plugins that weren't deleted. + $deleted = array_diff( $plugins, $errors ); + + foreach ( $deleted as $plugin_file ) { + unset( $current->response[ $plugin_file ] ); + } + + set_site_transient( 'update_plugins', $current ); + } + if ( ! empty($errors) ) return new WP_Error('could_not_remove_plugin', sprintf(__('Could not fully remove the plugin(s) %s.'), implode(', ', $errors)) ); - // Force refresh of plugin update information - if ( $current = get_site_transient('update_plugins') ) { - unset( $current->response[ $plugin_file ] ); - set_site_transient('update_plugins', $current); - } - return true; }