<!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'] ) &amp;&amp; in_array( $_REQUEST['plugin_status'], array( 'active', 'inactive', 'recently_activated', 'upgrade', 'network', 'mustuse', 'dropins', 'search' ) ) )
</del><ins>+                if ( isset( $_REQUEST['plugin_status'] ) &amp;&amp; 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-&gt;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 =&gt; $time )
-                        if ( $time + $one_week &lt; time() )
-                                unset( $recently_activated[$key] );
-                update_option( 'recently_activated', $recently_activated );
</del><ins>+                        $one_week = 7*24*60*60;
+                        foreach ( $recently_activated as $key =&gt; $time )
+                                if ( $time + $one_week &lt; 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 =&gt; $plugin_data ) {
</span><span class="cx">                         // Filter into individual sections
</span><del>-                        if ( is_multisite() &amp;&amp; is_network_only_plugin( $plugin_file ) &amp;&amp; !$screen-&gt;is_network ) {
-                                unset( $plugins['all'][ $plugin_file] );
-                        } elseif ( is_plugin_active_for_network($plugin_file) &amp;&amp; !$screen-&gt;is_network ) {
</del><ins>+                        if ( ! $screen-&gt;is_network &amp;&amp; is_plugin_active_for_network( $plugin_file ) ) {
</ins><span class="cx">                                 unset( $plugins['all'][ $plugin_file ] );
</span><del>-                        } elseif ( is_multisite() &amp;&amp; is_network_only_plugin( $plugin_file ) &amp;&amp; !current_user_can( 'manage_network_plugins' ) ) {
-                                $plugins['network'][ $plugin_file ] = $plugin_data;
-                        } elseif ( ( !$screen-&gt;is_network &amp;&amp; is_plugin_active( $plugin_file ) )
</del><ins>+                        } elseif ( ( ! $screen-&gt;is_network &amp;&amp; is_plugin_active( $plugin_file ) )
</ins><span class="cx">                                 || ( $screen-&gt;is_network &amp;&amp; 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 &lt;span class=&quot;count&quot;&gt;(%s)&lt;/span&gt;', 'Inactive &lt;span class=&quot;count&quot;&gt;(%s)&lt;/span&gt;', $count );
</span><span class="cx">                                         break;
</span><del>-                                case 'network':
-                                        $text = _n( 'Network &lt;span class=&quot;count&quot;&gt;(%s)&lt;/span&gt;', 'Network &lt;span class=&quot;count&quot;&gt;(%s)&lt;/span&gt;', $count );
-                                        break;
</del><span class="cx">                                 case 'mustuse':
</span><span class="cx">                                         $text = _n( 'Must-Use &lt;span class=&quot;count&quot;&gt;(%s)&lt;/span&gt;', 'Must-Use &lt;span class=&quot;count&quot;&gt;(%s)&lt;/span&gt;', $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-&gt;is_network ? 'network-activate-selected' : 'activate-selected';
-                        $actions[ $action ] = $screen-&gt;is_network ? __( 'Network Activate' ) : __( 'Activate' );
-                }
</del><ins>+                if ( 'active' != $status )
+                        $actions['activate-selected'] = $screen-&gt;is_network ? __( 'Network Activate' ) : __( 'Activate' );
</ins><span class="cx"> 
</span><span class="cx">                 if ( 'inactive' != $status &amp;&amp; 'recent' != $status )
</span><span class="cx">                         $actions['deactivate-selected'] = $screen-&gt;is_network ? __( 'Network Deactivate' ) : __( 'Deactivate' );
</span><span class="lines">@@ -283,7 +276,9 @@
</span><span class="cx"> 
</span><span class="cx">                 echo '&lt;div class=&quot;alignleft actions&quot;&gt;';
</span><span class="cx"> 
</span><del>-                if ( 'recently_activated' == $status )
</del><ins>+                $screen = get_current_screen();
+
+                if ( ! $screen-&gt;is_network &amp;&amp; 'recently_activated' == $status )
</ins><span class="cx">                         submit_button( __( 'Clear List' ), 'secondary', 'clear-recent-list', false );
</span><span class="cx">                 elseif ( 'top' == $which &amp;&amp; 'mustuse' == $status )
</span><span class="cx">                         echo '&lt;p&gt;' . sprintf( __( 'Files in the &lt;code&gt;%s&lt;/code&gt; directory are executed automatically.' ), str_replace( ABSPATH, '/', WPMU_PLUGIN_DIR ) ) . '&lt;/p&gt;';
</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' =&gt; '', 'deactivate' =&gt; '',
-                        'network_only' =&gt; '', 'activate' =&gt; '',
-                        'network_activate' =&gt; '',
</del><ins>+                        'deactivate' =&gt; '',
+                        'activate' =&gt; '',
</ins><span class="cx">                         'edit' =&gt; '',
</span><span class="cx">                         'delete' =&gt; '',
</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 .= '&lt;p&gt;' . $plugin_data['Description'] . '&lt;/p&gt;';
</span><span class="cx">                 } else {
</span><del>-                        $is_active_for_network = is_plugin_active_for_network($plugin_file);
</del><span class="cx">                         if ( $screen-&gt;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 &amp;&amp; !is_super_admin() &amp;&amp; !$screen-&gt;is_network )
-                                return;
-
</del><span class="cx">                         if ( $screen-&gt;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'] = '&lt;a href=&quot;' . wp_nonce_url('plugins.php?action=deactivate&amp;amp;networkwide=1&amp;amp;plugin=' . $plugin_file . '&amp;amp;plugin_status=' . $context . '&amp;amp;paged=' . $page . '&amp;amp;s=' . $s, 'deactivate-plugin_' . $plugin_file) . '&quot; title=&quot;' . esc_attr__('Deactivate this plugin') . '&quot;&gt;' . __('Network Deactivate') . '&lt;/a&gt;';
</del><ins>+                                                $actions['deactivate'] = '&lt;a href=&quot;' . wp_nonce_url('plugins.php?action=deactivate&amp;amp;plugin=' . $plugin_file . '&amp;amp;plugin_status=' . $context . '&amp;amp;paged=' . $page . '&amp;amp;s=' . $s, 'deactivate-plugin_' . $plugin_file) . '&quot; title=&quot;' . esc_attr__('Deactivate this plugin') . '&quot;&gt;' . __('Network Deactivate') . '&lt;/a&gt;';
</ins><span class="cx">                                 } else {
</span><span class="cx">                                         if ( current_user_can( 'manage_network_plugins' ) )
</span><del>-                                                $actions['network_activate'] = '&lt;a href=&quot;' . wp_nonce_url('plugins.php?action=activate&amp;amp;networkwide=1&amp;amp;plugin=' . $plugin_file . '&amp;amp;plugin_status=' . $context . '&amp;amp;paged=' . $page . '&amp;amp;s=' . $s, 'activate-plugin_' . $plugin_file) . '&quot; title=&quot;' . esc_attr__('Activate this plugin for all sites in this network') . '&quot; class=&quot;edit&quot;&gt;' . __('Network Activate') . '&lt;/a&gt;';
</del><ins>+                                                $actions['activate'] = '&lt;a href=&quot;' . wp_nonce_url('plugins.php?action=activate&amp;amp;plugin=' . $plugin_file . '&amp;amp;plugin_status=' . $context . '&amp;amp;paged=' . $page . '&amp;amp;s=' . $s, 'activate-plugin_' . $plugin_file) . '&quot; title=&quot;' . esc_attr__('Activate this plugin for all sites in this network') . '&quot; class=&quot;edit&quot;&gt;' . __('Network Activate') . '&lt;/a&gt;';
</ins><span class="cx">                                         if ( current_user_can( 'delete_plugins' ) &amp;&amp; ! is_plugin_active( $plugin_file ) )
</span><span class="cx">                                                 $actions['delete'] = '&lt;a href=&quot;' . wp_nonce_url('plugins.php?action=delete-selected&amp;amp;checked[]=' . $plugin_file . '&amp;amp;plugin_status=' . $context . '&amp;amp;paged=' . $page . '&amp;amp;s=' . $s, 'bulk-plugins') . '&quot; title=&quot;' . esc_attr__('Delete this plugin') . '&quot; class=&quot;delete&quot;&gt;' . __('Delete') . '&lt;/a&gt;';
</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 &amp;&amp; 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 =&gt; time()) + (array)get_option('recently_activated'));
</del><ins>+                        if ( ! is_network_admin() )
+                                update_option( 'recently_activated', array( $file =&gt; 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), &quot;plugin-editor.php?file=$file&amp;liveupdate=1&amp;scrollto=$scrollto&amp;networkwide=&quot; . $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'] ) &amp;&amp; ! is_super_admin() )
</del><ins>+        if ( empty( $menu_perms['plugins'] ) &amp;&amp; ! current_user_can( 'manage_network_plugins' ) )
</ins><span class="cx">                 wp_die( __( 'Cheatin&amp;#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 ) &amp;&amp; is_multisite() &amp;&amp; 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&amp;plugin=' . $plugin), $network_wide);
</del><ins>+                        $result = activate_plugin($plugin, self_admin_url('plugins.php?error=true&amp;plugin=' . $plugin), is_network_admin() );
</ins><span class="cx">                         if ( is_wp_error( $result ) ) {
</span><span class="cx">                                 if ( 'unexpected_output' == $result-&gt;get_error_code() ) {
</span><span class="cx">                                         $redirect = self_admin_url('plugins.php?error=true&amp;charsout=' . strlen($result-&gt;get_error_data()) . '&amp;plugin=' . $plugin . &quot;&amp;plugin_status=$status&amp;paged=$page&amp;s=$s&quot;);
</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']) &amp;&amp; 'import' == $_GET['from'] ) {
</span><span class="cx">                                 wp_redirect( self_admin_url(&quot;import.php?import=&quot; . 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 =&gt; $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 =&gt; $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(&quot;plugins.php?activate-multi=true&amp;plugin_status=$status&amp;paged=$page&amp;s=$s&quot;) );
</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 =&gt; time()) + (array)get_option('recently_activated'));
</del><ins>+
+                        if ( ! is_network_admin() &amp;&amp; is_plugin_active_for_network() ) {
+                                wp_redirect( self_admin_url(&quot;plugins.php?plugin_status=$status&amp;paged=$page&amp;s=$s&quot;) );
+                                exit;
+                        }
+
+                        deactivate_plugins( $plugin, false, is_network_admin() );
+                        if ( ! is_network_admin() )
+                                update_option( 'recently_activated', array( $plugin =&gt; time() ) + (array) get_option( 'recently_activated' ) );
</ins><span class="cx">                         if ( headers_sent() )
</span><span class="cx">                                 echo &quot;&lt;meta http-equiv='refresh' content='&quot; . esc_attr( &quot;0;url=plugins.php?deactivate=true&amp;plugin_status=$status&amp;paged=$page&amp;s=$s&quot; ) . &quot;' /&gt;&quot;;
</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(&quot;plugins.php?plugin_status=$status&amp;paged=$page&amp;s=$s&quot;) );
</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(&quot;plugins.php?deactivate-multi=true&amp;plugin_status=$status&amp;paged=$page&amp;s=$s&quot;) );
</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>