From b0641c55c9b7e2ab7b8b8d738da1718fa46d952c Mon Sep 17 00:00:00 2001 From: scribu Date: Fri, 29 Oct 2010 19:09:04 +0000 Subject: [PATCH] Fix bulk actions for Network Admin -> plugins. See #14435 git-svn-id: http://svn.automattic.com/wordpress/trunk@16089 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/list-table-plugins.php | 27 ++++++++++++------------ wp-admin/plugins.php | 8 ++++++- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/wp-admin/includes/list-table-plugins.php b/wp-admin/includes/list-table-plugins.php index e83f907e3d..8086dae665 100644 --- a/wp-admin/includes/list-table-plugins.php +++ b/wp-admin/includes/list-table-plugins.php @@ -253,21 +253,20 @@ class WP_Plugins_Table extends WP_List_Table { global $status; $actions = array(); - if ( 'active' != $status ) - $actions['activate-selected'] = __( 'Activate' ); - if ( is_multisite() && 'network' != $status ) - $actions['network-activate-selected'] = __( 'Network Activate' ); + + if ( 'active' != $status ) { + $action = is_network_admin() ? 'network-activate-selected' : 'activate-selected'; + $actions[ $action ] = __( 'Activate' ); + } + if ( 'inactive' != $status && 'recent' != $status ) $actions['deactivate-selected'] = __( 'Deactivate' ); - if ( current_user_can( 'update_plugins' ) ) - $actions['update-selected'] = __( 'Update' ); - if ( current_user_can( 'delete_plugins' ) && ( 'active' != $status ) ) - $actions['delete-selected'] = __( 'Delete' ); - - if ( is_multisite() && !is_network_admin() ) { - unset( $actions['network-activate-selected'] ); - unset( $actions['update-selected'] ); - unset( $actions['delete-selected'] ); + + if ( !is_multisite() || is_network_admin() ) { + if ( current_user_can( 'update_plugins' ) ) + $actions['update-selected'] = __( 'Update' ); + if ( current_user_can( 'delete_plugins' ) && ( 'active' != $status ) ) + $actions['delete-selected'] = __( 'Delete' ); } return $actions; @@ -424,4 +423,4 @@ class WP_Plugins_Table extends WP_List_Table { } } -?> \ No newline at end of file +?> diff --git a/wp-admin/plugins.php b/wp-admin/plugins.php index 313602a29a..9ab244cb79 100644 --- a/wp-admin/plugins.php +++ b/wp-admin/plugins.php @@ -63,7 +63,13 @@ if ( $action ) { check_admin_referer('bulk-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. + + // Only activate plugins which are not already active. + $check = $network_wide ? 'is_plugin_active_for_network' : 'is_plugin_active'; + foreach ( $plugins as $i => $plugin ) + if ( $check( $plugin ) ) + unset( $plugins[ $i ] ); + if ( empty($plugins) ) { wp_redirect( self_admin_url("plugins.php?plugin_status=$status&paged=$page&s=$s") ); exit;