<!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" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { 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 #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#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>
<title>[14348] trunk/wp-admin:
  Support network-wide plugin re-activation in upgrades and edits.</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/14348">14348</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2010-05-02 22:57:44 +0000 (Sun, 02 May 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>Support network-wide plugin re-activation in upgrades and edits. props PeteMall, fixes <a href="http://trac.wordpress.org/ticket/13216">#13216</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminincludesclasswpupgraderphp">trunk/wp-admin/includes/class-wp-upgrader.php</a></li>
<li><a href="#trunkwpadminplugineditorphp">trunk/wp-admin/plugin-editor.php</a></li>
<li><a href="#trunkwpadminupdatephp">trunk/wp-admin/update.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminincludesclasswpupgraderphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/class-wp-upgrader.php (14347 => 14348)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/class-wp-upgrader.php        2010-05-02 22:53:59 UTC (rev 14347)
+++ trunk/wp-admin/includes/class-wp-upgrader.php        2010-05-02 22:57:44 UTC (rev 14348)
</span><span class="lines">@@ -986,6 +986,7 @@
</span><span class="cx"> class Plugin_Upgrader_Skin extends WP_Upgrader_Skin {
</span><span class="cx">         var $plugin = '';
</span><span class="cx">         var $plugin_active = false;
</span><ins>+        var $plugin_network_active = false;
</ins><span class="cx"> 
</span><span class="cx">         function Plugin_Upgrader_Skin($args = array()) {
</span><span class="cx">                 return $this-&gt;__construct($args);
</span><span class="lines">@@ -997,7 +998,8 @@
</span><span class="cx"> 
</span><span class="cx">                 $this-&gt;plugin = $args['plugin'];
</span><span class="cx"> 
</span><del>-                $this-&gt;plugin_active = is_plugin_active($this-&gt;plugin);
</del><ins>+                $this-&gt;plugin_active = is_plugin_active( $this-&gt;plugin );
+                $this-&gt;plugin_network_active = is_plugin_active_for_network( $this-&gt;plugin );
</ins><span class="cx"> 
</span><span class="cx">                 parent::__construct($args);
</span><span class="cx">         }
</span><span class="lines">@@ -1006,7 +1008,7 @@
</span><span class="cx">                 $this-&gt;plugin = $this-&gt;upgrader-&gt;plugin_info();
</span><span class="cx">                 if ( !empty($this-&gt;plugin) &amp;&amp; !is_wp_error($this-&gt;result) &amp;&amp; $this-&gt;plugin_active ){
</span><span class="cx">                         show_message(__('Reactivating the plugin&amp;#8230;'));
</span><del>-                        echo '&lt;iframe style=&quot;border:0;overflow:hidden&quot; width=&quot;100%&quot; height=&quot;170px&quot; src=&quot;' . wp_nonce_url('update.php?action=activate-plugin&amp;plugin=' . $this-&gt;plugin, 'activate-plugin_' . $this-&gt;plugin) .'&quot;&gt;&lt;/iframe&gt;';
</del><ins>+                        echo '&lt;iframe style=&quot;border:0;overflow:hidden&quot; width=&quot;100%&quot; height=&quot;170px&quot; src=&quot;' . wp_nonce_url('update.php?action=activate-plugin&amp;networkwide=' . $this-&gt;plugin_network_active . '&amp;plugin=' . $this-&gt;plugin, 'activate-plugin_' . $this-&gt;plugin) .'&quot;&gt;&lt;/iframe&gt;';
</ins><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 $update_actions =  array(
</span><span class="lines">@@ -1390,4 +1392,4 @@
</span><span class="cx">                         $this-&gt;package = $uploads['basedir'] . '/' . $this-&gt;filename;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-}
</del><span class="cx">\ No newline at end of file
</span><ins>+}
</ins></span></pre></div>
<a id="trunkwpadminplugineditorphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/plugin-editor.php (14347 => 14348)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/plugin-editor.php        2010-05-02 22:53:59 UTC (rev 14347)
+++ trunk/wp-admin/plugin-editor.php        2010-05-02 22:57:44 UTC (rev 14348)
</span><span class="lines">@@ -55,6 +55,8 @@
</span><span class="cx">                 fwrite($f, $newcontent);
</span><span class="cx">                 fclose($f);
</span><span class="cx"> 
</span><ins>+                $network_wide = is_plugin_active_for_network( $file );
+
</ins><span class="cx">                 // Deactivate so we can test it.
</span><span class="cx">                 if ( is_plugin_active($file) || isset($_POST['phperror']) ) {
</span><span class="cx">                         if ( is_plugin_active($file) )
</span><span class="lines">@@ -62,7 +64,7 @@
</span><span class="cx"> 
</span><span class="cx">                         update_option('recently_activated', array($file =&gt; time()) + (array)get_option('recently_activated'));
</span><span class="cx"> 
</span><del>-                        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&quot;));
</del><ins>+                        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));
</ins><span class="cx">                         exit;
</span><span class="cx">                 }
</span><span class="cx">                 wp_redirect(&quot;plugin-editor.php?file=$file&amp;a=te&amp;scrollto=$scrollto&quot;);
</span><span class="lines">@@ -83,7 +85,7 @@
</span><span class="cx">                         wp_die( $error );
</span><span class="cx"> 
</span><span class="cx">                 if ( ! is_plugin_active($file) )
</span><del>-                        activate_plugin($file, &quot;plugin-editor.php?file=$file&amp;phperror=1&quot;); // we'll override this later if the plugin can be included without fatal error
</del><ins>+                        activate_plugin($file, &quot;plugin-editor.php?file=$file&amp;phperror=1&quot;, ! empty( $_GET['networkwide'] ) ); // we'll override this later if the plugin can be included without fatal error
</ins><span class="cx"> 
</span><span class="cx">                 wp_redirect(&quot;plugin-editor.php?file=$file&amp;a=te&amp;scrollto=$scrollto&quot;);
</span><span class="cx">                 exit;
</span></span></pre></div>
<a id="trunkwpadminupdatephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/update.php (14347 => 14348)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/update.php        2010-05-02 22:53:59 UTC (rev 14347)
+++ trunk/wp-admin/update.php        2010-05-02 22:57:44 UTC (rev 14348)
</span><span class="lines">@@ -69,7 +69,7 @@
</span><span class="cx">                 check_admin_referer('activate-plugin_' . $plugin);
</span><span class="cx">                 if ( ! isset($_GET['failure']) &amp;&amp; ! isset($_GET['success']) ) {
</span><span class="cx">                         wp_redirect( 'update.php?action=activate-plugin&amp;failure=true&amp;plugin=' . $plugin . '&amp;_wpnonce=' . $_GET['_wpnonce'] );
</span><del>-                        activate_plugin($plugin);
</del><ins>+                        activate_plugin( $plugin, '', ! empty( $_GET['networkwide'] ) );
</ins><span class="cx">                         wp_redirect( 'update.php?action=activate-plugin&amp;success=true&amp;plugin=' . $plugin . '&amp;_wpnonce=' . $_GET['_wpnonce'] );
</span><span class="cx">                         die();
</span><span class="cx">                 }
</span></span></pre>
</div>
</div>

</body>
</html>