From 8ec123bd342de0404556f6cdbf62c515fa7416c4 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Fri, 17 Dec 2010 21:53:47 +0000 Subject: [PATCH] Remove the delete action link from the network admin if the plugin is active on the main site. Remove the plugin(s) from the deletion list for the bulk actions and shows an error if no other plugin was selected for bulk-deletion. Props PeteMall. see #15709 git-svn-id: https://develop.svn.wordpress.org/trunk@17033 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/includes/class-wp-plugins-list-table.php | 2 +- wp-admin/plugins.php | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/wp-admin/includes/class-wp-plugins-list-table.php b/wp-admin/includes/class-wp-plugins-list-table.php index 3a122569d7..f7abecb83c 100644 --- a/wp-admin/includes/class-wp-plugins-list-table.php +++ b/wp-admin/includes/class-wp-plugins-list-table.php @@ -362,7 +362,7 @@ class WP_Plugins_List_Table extends WP_List_Table { } else { if ( current_user_can( 'manage_network_plugins' ) ) $actions['network_activate'] = '' . __('Network Activate') . ''; - if ( current_user_can('delete_plugins') ) + if ( current_user_can( 'delete_plugins' ) && ! is_plugin_active( $plugin_file ) ) $actions['delete'] = '' . __('Delete') . ''; } } else { diff --git a/wp-admin/plugins.php b/wp-admin/plugins.php index 8b366c6cb9..3ee1cff2eb 100644 --- a/wp-admin/plugins.php +++ b/wp-admin/plugins.php @@ -195,12 +195,17 @@ if ( $action ) { //$_POST = from the plugin form; $_GET = from the FTP details screen. $plugins = isset( $_REQUEST['checked'] ) ? (array) $_REQUEST['checked'] : array(); - $plugins = array_filter($plugins, 'is_plugin_inactive'); // Do not allow to delete Activated plugins. - if ( empty($plugins) ) { + if ( empty( $plugins ) ) { wp_redirect( self_admin_url("plugins.php?plugin_status=$status&paged=$page&s=$s") ); exit; } + $plugins = array_filter($plugins, 'is_plugin_inactive'); // Do not allow to delete Activated plugins. + if ( empty( $plugins ) ) { + wp_redirect( self_admin_url( "plugins.php?error=true&main=true&plugin_status=$status&paged=$page&s=$s" ) ); + exit; + } + include(ABSPATH . 'wp-admin/update.php'); $parent_file = 'plugins.php'; @@ -330,14 +335,16 @@ if ( !empty($invalid) ) unexpected output during activation. If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin.'), $_GET['charsout']); else $errmsg = __('Plugin could not be activated because it triggered a fatal error.'); ?>

+ if ( !isset( $_GET['main'] ) && !isset($_GET['charsout']) && wp_verify_nonce($_GET['_error_nonce'], 'plugin-activation-error_' . $plugin) ) { ?>