Support network-wide plugin re-activation in upgrades and edits. props PeteMall, fixes #13216
git-svn-id: http://svn.automattic.com/wordpress/trunk@14348 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
91354eefee
commit
ec38ce48e9
|
@ -986,6 +986,7 @@ class WP_Upgrader_Skin {
|
|||
class Plugin_Upgrader_Skin extends WP_Upgrader_Skin {
|
||||
var $plugin = '';
|
||||
var $plugin_active = false;
|
||||
var $plugin_network_active = false;
|
||||
|
||||
function Plugin_Upgrader_Skin($args = array()) {
|
||||
return $this->__construct($args);
|
||||
|
@ -997,7 +998,8 @@ class Plugin_Upgrader_Skin extends WP_Upgrader_Skin {
|
|||
|
||||
$this->plugin = $args['plugin'];
|
||||
|
||||
$this->plugin_active = is_plugin_active($this->plugin);
|
||||
$this->plugin_active = is_plugin_active( $this->plugin );
|
||||
$this->plugin_network_active = is_plugin_active_for_network( $this->plugin );
|
||||
|
||||
parent::__construct($args);
|
||||
}
|
||||
|
@ -1006,7 +1008,7 @@ class Plugin_Upgrader_Skin extends WP_Upgrader_Skin {
|
|||
$this->plugin = $this->upgrader->plugin_info();
|
||||
if ( !empty($this->plugin) && !is_wp_error($this->result) && $this->plugin_active ){
|
||||
show_message(__('Reactivating the plugin…'));
|
||||
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>';
|
||||
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>';
|
||||
}
|
||||
|
||||
$update_actions = array(
|
||||
|
@ -1390,4 +1392,4 @@ class File_Upload_Upgrader {
|
|||
$this->package = $uploads['basedir'] . '/' . $this->filename;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,6 +55,8 @@ case 'update':
|
|||
fwrite($f, $newcontent);
|
||||
fclose($f);
|
||||
|
||||
$network_wide = is_plugin_active_for_network( $file );
|
||||
|
||||
// Deactivate so we can test it.
|
||||
if ( is_plugin_active($file) || isset($_POST['phperror']) ) {
|
||||
if ( is_plugin_active($file) )
|
||||
|
@ -62,7 +64,7 @@ case 'update':
|
|||
|
||||
update_option('recently_activated', array($file => time()) + (array)get_option('recently_activated'));
|
||||
|
||||
wp_redirect(add_query_arg('_wpnonce', wp_create_nonce('edit-plugin-test_' . $file), "plugin-editor.php?file=$file&liveupdate=1&scrollto=$scrollto"));
|
||||
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));
|
||||
exit;
|
||||
}
|
||||
wp_redirect("plugin-editor.php?file=$file&a=te&scrollto=$scrollto");
|
||||
|
@ -83,7 +85,7 @@ default:
|
|||
wp_die( $error );
|
||||
|
||||
if ( ! is_plugin_active($file) )
|
||||
activate_plugin($file, "plugin-editor.php?file=$file&phperror=1"); // we'll override this later if the plugin can be included without fatal error
|
||||
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
|
||||
|
||||
wp_redirect("plugin-editor.php?file=$file&a=te&scrollto=$scrollto");
|
||||
exit;
|
||||
|
|
|
@ -69,7 +69,7 @@ if ( isset($_GET['action']) ) {
|
|||
check_admin_referer('activate-plugin_' . $plugin);
|
||||
if ( ! isset($_GET['failure']) && ! isset($_GET['success']) ) {
|
||||
wp_redirect( 'update.php?action=activate-plugin&failure=true&plugin=' . $plugin . '&_wpnonce=' . $_GET['_wpnonce'] );
|
||||
activate_plugin($plugin);
|
||||
activate_plugin( $plugin, '', ! empty( $_GET['networkwide'] ) );
|
||||
wp_redirect( 'update.php?action=activate-plugin&success=true&plugin=' . $plugin . '&_wpnonce=' . $_GET['_wpnonce'] );
|
||||
die();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue