Index: wp-admin/plugins.php
===================================================================
--- wp-admin/plugins.php	(revision 6006)
+++ wp-admin/plugins.php	(working copy)
@@ -36,17 +36,54 @@
 		update_option('active_plugins', $current);
 		do_action('deactivate_' . trim( $_GET['plugin'] ));
 		wp_redirect('plugins.php?deactivate=true');
-	} elseif ($_GET['action'] == 'deactivate-all') {
+	} elseif ('deactivate-all' == $_GET['action']) {
 		check_admin_referer('deactivate-all');
 		$current = get_option('active_plugins');
 
 		foreach ($current as $plugin) {
-			array_splice($current, array_search($plugin, $current), 1);
 			do_action('deactivate_' . $plugin);
 		}
-
+		
+		update_option('deactivated_plugins', $current); 
 		update_option('active_plugins', array());
 		wp_redirect('plugins.php?deactivate-all=true');
+	} elseif ('reactivate-all' == $_GET['action']) { 
+		check_admin_referer('reactivate-all'); 
+		$prev_plugins = get_option('deactivated_plugins'); 
+		$current = array(); 
+		$errors = array(); 
+		
+		// We'll keep track of errors in the $errors array, 
+		// and report them after we're done. 
+		foreach ($prev_plugins as $plugin) { 
+			if ( validate_file($plugin) ) 
+				$errors[$plugin] = __('Invalid plugin.'); 
+			elseif ( ! file_exists(ABSPATH . PLUGINDIR . '/' . $plugin) ) 
+				$errors[$plugin] = __('Plugin file does not exist.'); 
+			elseif (!in_array($plugin, $current)) { 
+				// A fatal error in any one plugin means NO 
+				// plugins will be reactivated. Sorry, but that's 
+				// just the way it is. :-/ 
+				wp_redirect(add_query_arg('_error_nonce', wp_create_nonce('plugin-activation-error_' . $plugin), 'plugins.php?error=true&plugin=' . $plugin)); // we'll override this later if the plugin can be included without fatal error
+				$errors[$plugin] = __('Plugin generated a fatal error.'); // we'll override this later if the plugin can be included without fatal error 
+				ob_start(); 
+				@include(ABSPATH . PLUGINDIR . '/' . $plugin); 
+				$current[] = $plugin; 
+				do_action('activate_' . $plugin); 
+				unset($errors[$plugin]); 
+				$output = ob_get_clean();
+				if( ! empty($output) ){
+					$errors[$plugin] = $output;
+				}
+			} 
+		} 
+		
+		sort($current); 
+		
+		update_option('deactivated_plugins', array()); 
+		update_option('active_plugins', $current); 
+		update_option('problem_plugins', $errors); 
+		wp_redirect('plugins.php?reactivate-all=true'); // overrides the ?error=true one above 
 	}
 	exit;
 }
@@ -96,6 +133,24 @@
 	<div id="message" class="updated fade"><p><?php _e('Plugin <strong>deactivated</strong>.') ?></p></div>
 <?php elseif (isset($_GET['deactivate-all'])) : ?>
 	<div id="message" class="updated fade"><p><?php _e('All plugins <strong>deactivated</strong>.'); ?></p></div>
+<?php elseif (isset($_GET['reactivate-all'])) : ?> 
+	<div id="message" class="updated fade"> 
+		<p><?php _e('All plugins <strong>reactivated</strong>.'); ?></p> 
+		<?php 
+		$errors = get_option('problem_plugins'); 
+		if (! empty($errors)) { 
+		// Display any errors: 
+		?> 
+		<p><?php _e('The following plugins generated errors:'); ?></p> 
+		<ul> 
+		<?php foreach ($errors as $plugin => $errmsg) { ?> 
+			<li><?php echo $plugin . ': ' . $errmsg ?></li> 
+		<?php }	?> 
+		</ul> 
+		<?php 
+		} 
+		?> 
+	</div> 
 <?php endif; ?>
 
 <div class="wrap">
@@ -169,7 +224,17 @@
 
 <tr>
 	<td colspan="3">&nbsp;</td>
-	<td colspan="2" style="width:12em;"><a href="<?php echo wp_nonce_url('plugins.php?action=deactivate-all', 'deactivate-all'); ?>" class="delete"><?php _e('Deactivate All Plugins'); ?></a></td>
+	<td colspan="2" style="width:12em;"> 
+	<?php  
+	$inactive = get_option('deactivated_plugins'); 
+	if (!empty($current_plugins)) { ?> 
+		<a href="<?php echo wp_nonce_url('plugins.php?action=deactivate-all', 'deactivate-all'); ?>" class="delete"><?php _e('Deactivate All Plugins'); ?></a> 
+	<?php } elseif (empty($active) && !empty($inactive)) { ?> 
+		<a href="<?php echo wp_nonce_url('plugins.php?action=reactivate-all', 'reactivate-all'); ?>" class="delete"><?php _e('Reactivate All Plugins'); ?></a> 
+	<?php 
+	} // endif active/inactive plugin check 
+	?> 
+	</td> 
 </tr>
 
 </table>
@@ -187,4 +252,4 @@
 
 <?php
 include('admin-footer.php');
-?>
+?>
\ No newline at end of file

