<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[20525] trunk/wp-admin: Clean up plugins.php with regards to recently edited files, deactivations, and the network admin.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg > ul, #logmsg > ol { margin-left: 0; margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://core.trac.wordpress.org/changeset/20525">20525</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2012-04-19 03:41:29 +0000 (Thu, 19 Apr 2012)</dd>
</dl>
<h3>Log Message</h3>
<pre>Clean up plugins.php with regards to recently edited files, deactivations, and the network admin. see <a href="http://core.trac.wordpress.org/ticket/20468">#20468</a>, <a href="http://core.trac.wordpress.org/ticket/20104">#20104</a>.
* Limit recently_activated to the site dashboard, and properly remove bulk-activated plugins from the array.
* Remove code used from before the network admin, such as the unused 'network' plugin_status.
* Don't try to deactivate a plugin already deactivated.
* Use more specific caps (manage_network_plugins) rather than is_super_admin().</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminincludesclasswppluginslisttablephp">trunk/wp-admin/includes/class-wp-plugins-list-table.php</a></li>
<li><a href="#trunkwpadminincludespluginphp">trunk/wp-admin/includes/plugin.php</a></li>
<li><a href="#trunkwpadminplugineditorphp">trunk/wp-admin/plugin-editor.php</a></li>
<li><a href="#trunkwpadminpluginsphp">trunk/wp-admin/plugins.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminincludesclasswppluginslisttablephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/class-wp-plugins-list-table.php (20524 => 20525)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/class-wp-plugins-list-table.php        2012-04-19 03:33:42 UTC (rev 20524)
+++ trunk/wp-admin/includes/class-wp-plugins-list-table.php        2012-04-19 03:41:29 UTC (rev 20525)
</span><span class="lines">@@ -13,7 +13,7 @@
</span><span class="cx">                 global $status, $page;
</span><span class="cx">
</span><span class="cx">                 $status = 'all';
</span><del>-                if ( isset( $_REQUEST['plugin_status'] ) && in_array( $_REQUEST['plugin_status'], array( 'active', 'inactive', 'recently_activated', 'upgrade', 'network', 'mustuse', 'dropins', 'search' ) ) )
</del><ins>+                if ( isset( $_REQUEST['plugin_status'] ) && in_array( $_REQUEST['plugin_status'], array( 'active', 'inactive', 'recently_activated', 'upgrade', 'mustuse', 'dropins', 'search' ) ) )
</ins><span class="cx">                         $status = $_REQUEST['plugin_status'];
</span><span class="cx">
</span><span class="cx">                 if ( isset($_REQUEST['s']) )
</span><span class="lines">@@ -78,23 +78,21 @@
</span><span class="cx">
</span><span class="cx">                 set_transient( 'plugin_slugs', array_keys( $plugins['all'] ), 86400 );
</span><span class="cx">
</span><del>-                $recently_activated = get_option( 'recently_activated', array() );
</del><ins>+                if ( ! $screen->is_network ) {
+                        $recently_activated = get_option( 'recently_activated', array() );
</ins><span class="cx">
</span><del>-                $one_week = 7*24*60*60;
-                foreach ( $recently_activated as $key => $time )
-                        if ( $time + $one_week < time() )
-                                unset( $recently_activated[$key] );
-                update_option( 'recently_activated', $recently_activated );
</del><ins>+                        $one_week = 7*24*60*60;
+                        foreach ( $recently_activated as $key => $time )
+                                if ( $time + $one_week < time() )
+                                        unset( $recently_activated[$key] );
+                        update_option( 'recently_activated', $recently_activated );
+                }
</ins><span class="cx">
</span><span class="cx">                 foreach ( (array) $plugins['all'] as $plugin_file => $plugin_data ) {
</span><span class="cx">                         // Filter into individual sections
</span><del>-                        if ( is_multisite() && is_network_only_plugin( $plugin_file ) && !$screen->is_network ) {
-                                unset( $plugins['all'][ $plugin_file] );
-                        } elseif ( is_plugin_active_for_network($plugin_file) && !$screen->is_network ) {
</del><ins>+                        if ( ! $screen->is_network && is_plugin_active_for_network( $plugin_file ) ) {
</ins><span class="cx">                                 unset( $plugins['all'][ $plugin_file ] );
</span><del>-                        } elseif ( is_multisite() && is_network_only_plugin( $plugin_file ) && !current_user_can( 'manage_network_plugins' ) ) {
-                                $plugins['network'][ $plugin_file ] = $plugin_data;
-                        } elseif ( ( !$screen->is_network && is_plugin_active( $plugin_file ) )
</del><ins>+                        } elseif ( ( ! $screen->is_network && is_plugin_active( $plugin_file ) )
</ins><span class="cx">                                 || ( $screen->is_network && is_plugin_active_for_network( $plugin_file ) ) ) {
</span><span class="cx">                                 $plugins['active'][ $plugin_file ] = $plugin_data;
</span><span class="cx">                         } else {
</span><span class="lines">@@ -215,9 +213,6 @@
</span><span class="cx">                                 case 'inactive':
</span><span class="cx">                                         $text = _n( 'Inactive <span class="count">(%s)</span>', 'Inactive <span class="count">(%s)</span>', $count );
</span><span class="cx">                                         break;
</span><del>-                                case 'network':
-                                        $text = _n( 'Network <span class="count">(%s)</span>', 'Network <span class="count">(%s)</span>', $count );
-                                        break;
</del><span class="cx">                                 case 'mustuse':
</span><span class="cx">                                         $text = _n( 'Must-Use <span class="count">(%s)</span>', 'Must-Use <span class="count">(%s)</span>', $count );
</span><span class="cx">                                         break;
</span><span class="lines">@@ -248,10 +243,8 @@
</span><span class="cx">
</span><span class="cx">                 $screen = get_current_screen();
</span><span class="cx">
</span><del>-                if ( 'active' != $status ) {
-                        $action = $screen->is_network ? 'network-activate-selected' : 'activate-selected';
-                        $actions[ $action ] = $screen->is_network ? __( 'Network Activate' ) : __( 'Activate' );
-                }
</del><ins>+                if ( 'active' != $status )
+                        $actions['activate-selected'] = $screen->is_network ? __( 'Network Activate' ) : __( 'Activate' );
</ins><span class="cx">
</span><span class="cx">                 if ( 'inactive' != $status && 'recent' != $status )
</span><span class="cx">                         $actions['deactivate-selected'] = $screen->is_network ? __( 'Network Deactivate' ) : __( 'Deactivate' );
</span><span class="lines">@@ -283,7 +276,9 @@
</span><span class="cx">
</span><span class="cx">                 echo '<div class="alignleft actions">';
</span><span class="cx">
</span><del>-                if ( 'recently_activated' == $status )
</del><ins>+                $screen = get_current_screen();
+
+                if ( ! $screen->is_network && 'recently_activated' == $status )
</ins><span class="cx">                         submit_button( __( 'Clear List' ), 'secondary', 'clear-recent-list', false );
</span><span class="cx">                 elseif ( 'top' == $which && 'mustuse' == $status )
</span><span class="cx">                         echo '<p>' . sprintf( __( 'Files in the <code>%s</code> directory are executed automatically.' ), str_replace( ABSPATH, '/', WPMU_PLUGIN_DIR ) ) . '</p>';
</span><span class="lines">@@ -321,9 +316,8 @@
</span><span class="cx">
</span><span class="cx">                 // preorder
</span><span class="cx">                 $actions = array(
</span><del>-                        'network_deactivate' => '', 'deactivate' => '',
-                        'network_only' => '', 'activate' => '',
-                        'network_activate' => '',
</del><ins>+                        'deactivate' => '',
+                        'activate' => '',
</ins><span class="cx">                         'edit' => '',
</span><span class="cx">                         'delete' => '',
</span><span class="cx">                 );
</span><span class="lines">@@ -348,22 +342,18 @@
</span><span class="cx">                         if ( $plugin_data['Description'] )
</span><span class="cx">                                 $description .= '<p>' . $plugin_data['Description'] . '</p>';
</span><span class="cx">                 } else {
</span><del>-                        $is_active_for_network = is_plugin_active_for_network($plugin_file);
</del><span class="cx">                         if ( $screen->is_network )
</span><del>-                                $is_active = $is_active_for_network;
</del><ins>+                                $is_active = is_plugin_active_for_network( $plugin_file );
</ins><span class="cx">                         else
</span><span class="cx">                                 $is_active = is_plugin_active( $plugin_file );
</span><span class="cx">
</span><del>-                        if ( $is_active_for_network && !is_super_admin() && !$screen->is_network )
-                                return;
-
</del><span class="cx">                         if ( $screen->is_network ) {
</span><del>-                                if ( $is_active_for_network ) {
</del><ins>+                                if ( $is_active ) {
</ins><span class="cx">                                         if ( current_user_can( 'manage_network_plugins' ) )
</span><del>-                                                $actions['network_deactivate'] = '<a href="' . wp_nonce_url('plugins.php?action=deactivate&amp;networkwide=1&amp;plugin=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'deactivate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Deactivate this plugin') . '">' . __('Network Deactivate') . '</a>';
</del><ins>+                                                $actions['deactivate'] = '<a href="' . wp_nonce_url('plugins.php?action=deactivate&amp;plugin=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'deactivate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Deactivate this plugin') . '">' . __('Network Deactivate') . '</a>';
</ins><span class="cx">                                 } else {
</span><span class="cx">                                         if ( current_user_can( 'manage_network_plugins' ) )
</span><del>-                                                $actions['network_activate'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&amp;networkwide=1&amp;plugin=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'activate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Activate this plugin for all sites in this network') . '" class="edit">' . __('Network Activate') . '</a>';
</del><ins>+                                                $actions['activate'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&amp;plugin=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'activate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Activate this plugin for all sites in this network') . '" class="edit">' . __('Network Activate') . '</a>';
</ins><span class="cx">                                         if ( current_user_can( 'delete_plugins' ) && ! is_plugin_active( $plugin_file ) )
</span><span class="cx">                                                 $actions['delete'] = '<a href="' . wp_nonce_url('plugins.php?action=delete-selected&amp;checked[]=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'bulk-plugins') . '" title="' . esc_attr__('Delete this plugin') . '" class="delete">' . __('Delete') . '</a>';
</span><span class="cx">                                 }
</span></span></pre></div>
<a id="trunkwpadminincludespluginphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/plugin.php (20524 => 20525)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/plugin.php        2012-04-19 03:33:42 UTC (rev 20524)
+++ trunk/wp-admin/includes/plugin.php        2012-04-19 03:41:29 UTC (rev 20525)
</span><span class="lines">@@ -572,9 +572,11 @@
</span><span class="cx"> * @since 2.5.0
</span><span class="cx"> *
</span><span class="cx"> * @param string|array $plugins Single plugin or list of plugins to deactivate.
</span><ins>+ * @param mixed $network_wide Whether to deactivate the plugin for all sites in the network.
+ *         A value of null (the default) will deactivate plugins for both the site and the network.
</ins><span class="cx"> * @param bool $silent Prevent calling deactivation hooks. Default is false.
</span><span class="cx"> */
</span><del>-function deactivate_plugins( $plugins, $silent = false ) {
</del><ins>+function deactivate_plugins( $plugins, $silent = false, $network_wide = null ) {
</ins><span class="cx">         if ( is_multisite() )
</span><span class="cx">                 $network_current = get_site_option( 'active_sitewide_plugins', array() );
</span><span class="cx">         $current = get_option( 'active_plugins', array() );
</span><span class="lines">@@ -585,15 +587,19 @@
</span><span class="cx">                 if ( ! is_plugin_active($plugin) )
</span><span class="cx">                         continue;
</span><span class="cx">
</span><del>-                $network_wide = is_plugin_active_for_network( $plugin );
</del><ins>+                $network_deactivating = false !== $network_wide && is_plugin_active_for_network( $plugin );
</ins><span class="cx">
</span><span class="cx">                 if ( ! $silent )
</span><del>-                        do_action( 'deactivate_plugin', $plugin, $network_wide );
</del><ins>+                        do_action( 'deactivate_plugin', $plugin, $network_deactivating );
</ins><span class="cx">
</span><del>-                if ( $network_wide ) {
</del><ins>+                if ( false !== $network_wide ) {
+                        if ( ! is_plugin_active_for_network( $plugin ) )
+                                continue;
</ins><span class="cx">                         $do_network = true;
</span><span class="cx">                         unset( $network_current[ $plugin ] );
</span><del>-                } else {
</del><ins>+                }
+
+                if ( true !== $network_wide ) {
</ins><span class="cx">                         $key = array_search( $plugin, $current );
</span><span class="cx">                         if ( false !== $key ) {
</span><span class="cx">                                 $do_blog = true;
</span><span class="lines">@@ -602,8 +608,8 @@
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 if ( ! $silent ) {
</span><del>-                        do_action( 'deactivate_' . $plugin, $network_wide );
-                        do_action( 'deactivated_plugin', $plugin, $network_wide );
</del><ins>+                        do_action( 'deactivate_' . $plugin, $network_deactivating );
+                        do_action( 'deactivated_plugin', $plugin, $network_deactivating );
</ins><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkwpadminplugineditorphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/plugin-editor.php (20524 => 20525)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/plugin-editor.php        2012-04-19 03:33:42 UTC (rev 20524)
+++ trunk/wp-admin/plugin-editor.php        2012-04-19 03:41:29 UTC (rev 20525)
</span><span class="lines">@@ -65,7 +65,8 @@
</span><span class="cx">                         if ( is_plugin_active($file) )
</span><span class="cx">                                 deactivate_plugins($file, true);
</span><span class="cx">
</span><del>-                        update_option('recently_activated', array($file => time()) + (array)get_option('recently_activated'));
</del><ins>+                        if ( ! is_network_admin() )
+                                update_option( 'recently_activated', array( $file => time() ) + (array) get_option( 'recently_activated' ) );
</ins><span class="cx">
</span><span class="cx">                         wp_redirect(add_query_arg('_wpnonce', wp_create_nonce('edit-plugin-test_' . $file), "plugin-editor.php?file=$file&liveupdate=1&scrollto=$scrollto&networkwide=" . $network_wide));
</span><span class="cx">                         exit;
</span></span></pre></div>
<a id="trunkwpadminpluginsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/plugins.php (20524 => 20525)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/plugins.php        2012-04-19 03:33:42 UTC (rev 20524)
+++ trunk/wp-admin/plugins.php        2012-04-19 03:41:29 UTC (rev 20525)
</span><span class="lines">@@ -12,7 +12,7 @@
</span><span class="cx"> if ( is_multisite() ) {
</span><span class="cx">         $menu_perms = get_site_option( 'menu_items', array() );
</span><span class="cx">
</span><del>-        if ( empty( $menu_perms['plugins'] ) && ! is_super_admin() )
</del><ins>+        if ( empty( $menu_perms['plugins'] ) && ! current_user_can( 'manage_network_plugins' ) )
</ins><span class="cx">                 wp_die( __( 'Cheatin&#8217; uh?' ) );
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -31,9 +31,6 @@
</span><span class="cx"> $_SERVER['REQUEST_URI'] = remove_query_arg(array('error', 'deleted', 'activate', 'activate-multi', 'deactivate', 'deactivate-multi', '_error_nonce'), $_SERVER['REQUEST_URI']);
</span><span class="cx">
</span><span class="cx"> if ( $action ) {
</span><del>-        $network_wide = false;
-        if ( ( isset( $_GET['networkwide'] ) || 'network-activate-selected' == $action ) && is_multisite() && current_user_can( 'manage_network_plugins' ) )
-                $network_wide = true;
</del><span class="cx">
</span><span class="cx">         switch ( $action ) {
</span><span class="cx">                 case 'activate':
</span><span class="lines">@@ -42,7 +39,7 @@
</span><span class="cx">
</span><span class="cx">                         check_admin_referer('activate-plugin_' . $plugin);
</span><span class="cx">
</span><del>-                        $result = activate_plugin($plugin, self_admin_url('plugins.php?error=true&plugin=' . $plugin), $network_wide);
</del><ins>+                        $result = activate_plugin($plugin, self_admin_url('plugins.php?error=true&plugin=' . $plugin), is_network_admin() );
</ins><span class="cx">                         if ( is_wp_error( $result ) ) {
</span><span class="cx">                                 if ( 'unexpected_output' == $result->get_error_code() ) {
</span><span class="cx">                                         $redirect = self_admin_url('plugins.php?error=true&charsout=' . strlen($result->get_error_data()) . '&plugin=' . $plugin . "&plugin_status=$status&paged=$page&s=$s");
</span><span class="lines">@@ -53,11 +50,12 @@
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="cx">
</span><del>-                        $recent = (array)get_option('recently_activated');
-                        if ( isset($recent[ $plugin ]) ) {
-                                unset($recent[ $plugin ]);
-                                update_option('recently_activated', $recent);
</del><ins>+                        if ( ! is_network_admin() ) {
+                                $recent = (array) get_option( 'recently_activated' );
+                                unset( $recent[ $plugin ] );
+                                update_option( 'recently_activated', $recent );
</ins><span class="cx">                         }
</span><ins>+
</ins><span class="cx">                         if ( isset($_GET['from']) && 'import' == $_GET['from'] ) {
</span><span class="cx">                                 wp_redirect( self_admin_url("import.php?import=" . str_replace('-importer', '', dirname($plugin))) ); // overrides the ?error=true one above and redirects to the Imports page, stripping the -importer suffix
</span><span class="cx">                         } else {
</span><span class="lines">@@ -66,7 +64,6 @@
</span><span class="cx">                         exit;
</span><span class="cx">                         break;
</span><span class="cx">                 case 'activate-selected':
</span><del>-                case 'network-activate-selected':
</del><span class="cx">                         if ( ! current_user_can('activate_plugins') )
</span><span class="cx">                                 wp_die(__('You do not have sufficient permissions to activate plugins for this site.'));
</span><span class="cx">
</span><span class="lines">@@ -75,7 +72,7 @@
</span><span class="cx">                         $plugins = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array();
</span><span class="cx">
</span><span class="cx">                         // Only activate plugins which are not already active.
</span><del>-                        $check = $network_wide ? 'is_plugin_active_for_network' : 'is_plugin_active';
</del><ins>+                        $check = is_network_admin() ? 'is_plugin_active_for_network' : 'is_plugin_active';
</ins><span class="cx">                         foreach ( $plugins as $i => $plugin )
</span><span class="cx">                                 if ( $check( $plugin ) )
</span><span class="cx">                                         unset( $plugins[ $i ] );
</span><span class="lines">@@ -85,15 +82,15 @@
</span><span class="cx">                                 exit;
</span><span class="cx">                         }
</span><span class="cx">
</span><del>-                        activate_plugins($plugins, self_admin_url('plugins.php?error=true'), $network_wide);
</del><ins>+                        activate_plugins($plugins, self_admin_url('plugins.php?error=true'), is_network_admin() );
</ins><span class="cx">
</span><del>-                        $recent = (array)get_option('recently_activated');
-                        foreach ( $plugins as $plugin => $time)
-                                if ( isset($recent[ $plugin ]) )
-                                        unset($recent[ $plugin ]);
</del><ins>+                        if ( ! is_network_admin() ) {
+                                $recent = (array) get_option('recently_activated' );
+                                foreach ( $plugins as $plugin )
+                                        unset( $recent[ $plugin ] );
+                                update_option( 'recently_activated', $recent );
+                        }
</ins><span class="cx">
</span><del>-                        update_option('recently_activated', $recent);
-
</del><span class="cx">                         wp_redirect( self_admin_url("plugins.php?activate-multi=true&plugin_status=$status&paged=$page&s=$s") );
</span><span class="cx">                         exit;
</span><span class="cx">                         break;
</span><span class="lines">@@ -153,8 +150,15 @@
</span><span class="cx">                                 wp_die(__('You do not have sufficient permissions to deactivate plugins for this site.'));
</span><span class="cx">
</span><span class="cx">                         check_admin_referer('deactivate-plugin_' . $plugin);
</span><del>-                        deactivate_plugins($plugin);
-                        update_option('recently_activated', array($plugin => time()) + (array)get_option('recently_activated'));
</del><ins>+
+                        if ( ! is_network_admin() && is_plugin_active_for_network() ) {
+                                wp_redirect( self_admin_url("plugins.php?plugin_status=$status&paged=$page&s=$s") );
+                                exit;
+                        }
+
+                        deactivate_plugins( $plugin, false, is_network_admin() );
+                        if ( ! is_network_admin() )
+                                update_option( 'recently_activated', array( $plugin => time() ) + (array) get_option( 'recently_activated' ) );
</ins><span class="cx">                         if ( headers_sent() )
</span><span class="cx">                                 echo "<meta http-equiv='refresh' content='" . esc_attr( "0;url=plugins.php?deactivate=true&plugin_status=$status&paged=$page&s=$s" ) . "' />";
</span><span class="cx">                         else
</span><span class="lines">@@ -168,19 +172,27 @@
</span><span class="cx">                         check_admin_referer('bulk-plugins');
</span><span class="cx">
</span><span class="cx">                         $plugins = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array();
</span><del>-                        $plugins = array_filter($plugins, 'is_plugin_active'); //Do not deactivate plugins which are already deactivated.
</del><ins>+                        // Do not deactivate plugins which are already deactivated.
+                        if ( is_network_admin() ) {
+                                $plugins = array_filter( $plugins, 'is_plugin_active_for_network' );
+                        } else {
+                                $plugins = array_filter( $plugins, 'is_plugin_active' );
+                                $plugins = array_diff( $plugins, array_filter( $plugins, 'is_plugin_active_for_network' ) );
+                        }
</ins><span class="cx">                         if ( empty($plugins) ) {
</span><span class="cx">                                 wp_redirect( self_admin_url("plugins.php?plugin_status=$status&paged=$page&s=$s") );
</span><span class="cx">                                 exit;
</span><span class="cx">                         }
</span><span class="cx">
</span><del>-                        deactivate_plugins($plugins);
</del><ins>+                        deactivate_plugins( $plugins, false, is_network_admin() );
</ins><span class="cx">
</span><del>-                        $deactivated = array();
-                        foreach ( $plugins as $plugin )
-                                $deactivated[ $plugin ] = time();
</del><ins>+                        if ( ! is_network_admin() ) {
+                                $deactivated = array();
+                                foreach ( $plugins as $plugin )
+                                        $deactivated[ $plugin ] = time();
+                                update_option( 'recently_activated', $deactivated + (array) get_option( 'recently_activated' ) );
+                        }
</ins><span class="cx">
</span><del>-                        update_option('recently_activated', $deactivated + (array)get_option('recently_activated'));
</del><span class="cx">                         wp_redirect( self_admin_url("plugins.php?deactivate-multi=true&plugin_status=$status&paged=$page&s=$s") );
</span><span class="cx">                         exit;
</span><span class="cx">                         break;
</span><span class="lines">@@ -305,7 +317,8 @@
</span><span class="cx">                         exit;
</span><span class="cx">                         break;
</span><span class="cx">                 case 'clear-recent-list':
</span><del>-                        update_option('recently_activated', array());
</del><ins>+                        if ( ! is_network_admin() )
+                                update_option( 'recently_activated', array() );
</ins><span class="cx">                         break;
</span><span class="cx">         }
</span><span class="cx"> }
</span></span></pre>
</div>
</div>
</body>
</html>