WordPress.org

Make WordPress Core

Ticket #9835: 9835.2.diff

File 9835.2.diff, 3.0 KB (added by dd32, 5 years ago)
  • wp-admin/plugins.php

     
    1111 
    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; 
    2018 
     
    3129 
    3230$page = isset($_REQUEST['paged']) ? $_REQUEST['paged'] : 1; 
    3331 
     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']); 
     34 
    3435if ( !empty($action) ) { 
    3536        switch ( $action ) { 
    3637                case 'activate': 
     
    163164                        } //Endif verify-delete 
    164165                        $delete_result = delete_plugins($plugins); 
    165166 
    166                         wp_cache_delete('plugins', 'plugins'); 
     167                        set_transient('plugins_delete_result', $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': 
    169172                        update_option('recently_activated', array()); 
     
    198201                } 
    199202        ?> 
    200203        </div> 
    201 <?php elseif ( 'delete-selected' == $action ) : 
     204<?php elseif ( isset($_GET['deleted']) ) : 
     205                $delete_result = get_transient('plugins_delete_result'); 
     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> 
    204210                <?php else : ?> 
     
    288294} 
    289295 
    290296$plugin_array_name = "${status}_plugins"; 
     297if ( empty($$plugin_array_name) && $status != 'all' ) { 
     298        $status = 'all'; 
     299        $plugin_array_name = "${status}_plugins"; 
     300} 
     301 
    291302$plugins = &$$plugin_array_name; 
    292303 
    293304//Paging. 
     
    363374                if ( current_user_can('edit_plugins') && is_writable(WP_PLUGIN_DIR . '/' . $plugin_file) ) 
    364375                        $actions[] = '<a href="plugin-editor.php?file=' . $plugin_file . '" title="' . __('Open this file in the Plugin Editor') . '" class="edit">' . __('Edit') . '</a>'; 
    365376 
     377                if ( ! $is_active && current_user_can('delete_plugins') ) 
     378                        $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>'; 
     379 
    366380                $actions = apply_filters( 'plugin_action_links', $actions, $plugin_file, $plugin_data, $context ); 
    367381                $actions = apply_filters( "plugin_action_links_$plugin_file", $actions, $plugin_file, $plugin_data, $context ); 
    368382                $action_count = count($actions);