Make WordPress Core

Changeset 11371


Ignore:
Timestamp:
05/17/2009 09:39:32 AM (16 years ago)
Author:
westi
Message:

Add an action link to allow for plugins to be deleted individually. Also switch to storing the deletion information and redirecting before displaying. Fixes #9835 props DD32.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/plugins.php

    r11368 r11371  
    1212if ( isset($_POST['clear-recent-list']) )
    1313    $action = 'clear-recent-list';
    14 elseif ( isset($_GET['action']) )
    15     $action = $_GET['action'];
    16 elseif ( isset($_POST['action']) )
    17     $action = $_POST['action'];
     14elseif ( isset($_REQUEST['action']) )
     15    $action = $_REQUEST['action'];
    1816else
    1917    $action = false;
     
    3129
    3230$page = isset($_REQUEST['paged']) ? $_REQUEST['paged'] : 1;
     31
     32//Clean up request URI from temporary args for screen options/paging uri's to work as expected.
     33$_SERVER['REQUEST_URI'] = remove_query_arg(array('error', 'deleted', 'activate', 'activate-multi', 'deactivate', 'deactivate-multi', '_error_nonce'), $_SERVER['REQUEST_URI']);
    3334
    3435if ( !empty($action) ) {
     
    164165            $delete_result = delete_plugins($plugins);
    165166
    166             wp_cache_delete('plugins', 'plugins');
     167            set_transient('plugins_delete_result_'.$user_ID, $delete_result); //Store the result in a cache rather than a URL param due to object type & length
     168            wp_redirect("plugins.php?deleted=true&plugin_status=$status&paged=$page");
     169            exit;
    167170            break;
    168171        case 'clear-recent-list':
     
    199202    ?>
    200203    </div>
    201 <?php elseif ( 'delete-selected' == $action ) :
     204<?php elseif ( isset($_GET['deleted']) ) :
     205        $delete_result = get_transient('plugins_delete_result_'.$user_ID);
     206        delete_transient('plugins_delete_result'); //Delete it once we're done.
     207
    202208        if ( is_wp_error($delete_result) ) : ?>
    203209        <div id="message" class="updated fade"><p><?php printf( __('Plugin could not be deleted due to an error: %s'), $delete_result->get_error_message() ); ?></p></div>
     
    286292
    287293$plugin_array_name = "${status}_plugins";
     294if ( empty($$plugin_array_name) && $status != 'all' ) {
     295    $status = 'all';
     296    $plugin_array_name = "${status}_plugins";
     297}
     298
    288299$plugins = &$$plugin_array_name;
    289300
     
    362373            $actions[] = '<a href="' . $plugin_data['PluginURI'] . '" title="' . __( 'Visit plugin homepage' ) . '">' . __('View Site') . '</a>';
    363374        }
     375
     376        if ( ! $is_active && current_user_can('delete_plugins') )
     377            $actions[] = '<a href="' . wp_nonce_url('plugins.php?action=delete-selected&amp;checked[]=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page, 'bulk-manage-plugins') . '" title="' . __('Delete this plugin') . '" class="delete">' . __('Delete') . '</a>';
    364378
    365379        $actions = apply_filters( 'plugin_action_links', $actions, $plugin_file, $plugin_data, $context );
Note: See TracChangeset for help on using the changeset viewer.