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: http://svn.automattic.com/wordpress/trunk@17033 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2010-12-17 21:53:47 +00:00
parent 58e65d1855
commit 1d304b55c6
2 changed files with 12 additions and 5 deletions

View File

@ -362,7 +362,7 @@ class WP_Plugins_List_Table extends WP_List_Table {
} else {
if ( current_user_can( 'manage_network_plugins' ) )
$actions['network_activate'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&amp;networkwide=1&amp;plugin=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'activate-plugin_' . $plugin_file) . '" title="' . __('Activate this plugin for all sites in this network') . '" class="edit">' . __('Network Activate') . '</a>';
if ( current_user_can('delete_plugins') )
if ( current_user_can( 'delete_plugins' ) && ! is_plugin_active( $plugin_file ) )
$actions['delete'] = '<a href="' . wp_nonce_url('plugins.php?action=delete-selected&amp;checked[]=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'bulk-plugins') . '" title="' . __('Delete this plugin') . '" class="delete">' . __('Delete') . '</a>';
}
} else {

View File

@ -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) )
<?php if ( isset($_GET['error']) ) :
if ( isset($_GET['charsout']) )
if ( isset( $_GET['main'] ) )
$errmsg = __( 'You cannot delete a plugin while it is active on the main site.' );
elseif ( isset($_GET['charsout']) )
$errmsg = sprintf(__('The plugin generated %d characters of <strong>unexpected output</strong> during activation. If you notice &#8220;headers already sent&#8221; 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 <strong>fatal error</strong>.');
?>
<div id="message" class="updated"><p><?php echo $errmsg; ?></p>
<?php
if ( !isset($_GET['charsout']) && wp_verify_nonce($_GET['_error_nonce'], 'plugin-activation-error_' . $plugin) ) { ?>
if ( !isset( $_GET['main'] ) && !isset($_GET['charsout']) && wp_verify_nonce($_GET['_error_nonce'], 'plugin-activation-error_' . $plugin) ) { ?>
<iframe style="border:0" width="100%" height="70px" src="<?php echo 'plugins.php?action=error_scrape&amp;plugin=' . esc_attr($plugin) . '&amp;_wpnonce=' . esc_attr($_GET['_error_nonce']); ?>"></iframe>
<?php
}