<!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->__construct($args);
</span><span class="lines">@@ -997,7 +998,8 @@
</span><span class="cx">
</span><span class="cx">                 $this->plugin = $args['plugin'];
</span><span class="cx">
</span><del>-                $this->plugin_active = is_plugin_active($this->plugin);
</del><ins>+                $this->plugin_active = is_plugin_active( $this->plugin );
+                $this->plugin_network_active = is_plugin_active_for_network( $this->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->plugin = $this->upgrader->plugin_info();
</span><span class="cx">                 if ( !empty($this->plugin) && !is_wp_error($this->result) && $this->plugin_active ){
</span><span class="cx">                         show_message(__('Reactivating the plugin&#8230;'));
</span><del>-                        echo '<iframe style="border:0;overflow:hidden" width="100%" height="170px" src="' . wp_nonce_url('update.php?action=activate-plugin&plugin=' . $this->plugin, 'activate-plugin_' . $this->plugin) .'"></iframe>';
</del><ins>+                        echo '<iframe style="border:0;overflow:hidden" width="100%" height="170px" src="' . wp_nonce_url('update.php?action=activate-plugin&networkwide=' . $this->plugin_network_active . '&plugin=' . $this->plugin, 'activate-plugin_' . $this->plugin) .'"></iframe>';
</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->package = $uploads['basedir'] . '/' . $this->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 => 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), "plugin-editor.php?file=$file&liveupdate=1&scrollto=$scrollto"));
</del><ins>+                        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));
</ins><span class="cx">                         exit;
</span><span class="cx">                 }
</span><span class="cx">                 wp_redirect("plugin-editor.php?file=$file&a=te&scrollto=$scrollto");
</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, "plugin-editor.php?file=$file&phperror=1"); // we'll override this later if the plugin can be included without fatal error
</del><ins>+                        activate_plugin($file, "plugin-editor.php?file=$file&phperror=1", ! 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("plugin-editor.php?file=$file&a=te&scrollto=$scrollto");
</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']) && ! isset($_GET['success']) ) {
</span><span class="cx">                         wp_redirect( 'update.php?action=activate-plugin&failure=true&plugin=' . $plugin . '&_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&success=true&plugin=' . $plugin . '&_wpnonce=' . $_GET['_wpnonce'] );
</span><span class="cx">                         die();
</span><span class="cx">                 }
</span></span></pre>
</div>
</div>
</body>
</html>