Add "Network Activate" option to Bulk Actions menu on plugins.php. See #11644, #12139

git-svn-id: http://svn.automattic.com/wordpress/trunk@13155 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
nacin 2010-02-14 14:46:38 +00:00
parent 17828647fe
commit f8ca7dfd10
4 changed files with 10 additions and 6 deletions

File diff suppressed because one or more lines are too long

View File

@ -851,7 +851,6 @@ div.comment-item:hover .row-actions {
.row-actions-visible {
padding: 2px 0 0;
cursor: pointer;
}
/* Admin Header */

View File

@ -437,9 +437,10 @@ function deactivate_plugins( $plugins, $silent = false ) {
*
* @param string|array $plugins
* @param string $redirect Redirect to page after successful activation.
* @param bool $network_wide Whether to enable the plugin for all sites in the network.
* @return bool|WP_Error True when finished or WP_Error if there were errors during a plugin activation.
*/
function activate_plugins($plugins, $redirect = '') {
function activate_plugins($plugins, $redirect = '', $network_wide) {
if ( !is_array($plugins) )
$plugins = array($plugins);
@ -447,7 +448,7 @@ function activate_plugins($plugins, $redirect = '') {
foreach ( (array) $plugins as $plugin ) {
if ( !empty($redirect) )
$redirect = add_query_arg('plugin', $plugin, $redirect);
$result = activate_plugin($plugin, $redirect);
$result = activate_plugin($plugin, $redirect, $network_wide);
if ( is_wp_error($result) )
$errors[$plugin] = $result;
}

View File

@ -39,7 +39,7 @@ $_SERVER['REQUEST_URI'] = remove_query_arg(array('error', 'deleted', 'activate',
if ( !empty($action) ) {
$network_wide = false;
if ( isset($_GET['networkwide']) && is_multisite() && is_super_admin() )
if ( ( isset( $_GET['networkwide'] ) || 'network-activate-selected' == $action ) && is_multisite() && is_super_admin() )
$network_wide = true;
switch ( $action ) {
@ -63,13 +63,14 @@ if ( !empty($action) ) {
exit;
break;
case 'activate-selected':
case 'network-activate-selected':
if ( ! current_user_can('activate_plugins') )
wp_die(__('You do not have sufficient permissions to activate plugins for this blog.'));
check_admin_referer('bulk-manage-plugins');
$plugins = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array();
$plugins = array_filter($plugins, create_function('$plugin', 'return !is_plugin_active($plugin);') ); //Only activate plugins which are not already active.
$plugins = array_filter($plugins, create_function('$plugin', 'return !is_plugin_active($plugin);') ); // Only activate plugins which are not already active.
if ( empty($plugins) ) {
wp_redirect("plugins.php?plugin_status=$status&paged=$page");
exit;
@ -564,6 +565,9 @@ function print_plugin_actions($context, $field_name = 'action' ) {
<?php if ( 'active' != $context ) : ?>
<option value="activate-selected"><?php _e('Activate'); ?></option>
<?php endif; ?>
<?php if ( is_multisite() && 'network' != $context ) : ?>
<option value="network-activate-selected"><?php _e('Network Activate'); ?></option>
<?php endif; ?>
<?php if ( 'inactive' != $context && 'recent' != $context ) : ?>
<option value="deactivate-selected"><?php _e('Deactivate'); ?></option>
<?php endif; ?>