WordPress.org

Make WordPress Core

Changeset 11029


Ignore:
Timestamp:
04/21/09 19:17:44 (6 years ago)
Author:
ryan
Message:

Remember status and page when redirecting. see #9527

File:
1 edited

Legend:

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

    r11027 r11029  
    2121$plugin = isset($_REQUEST['plugin']) ? $_REQUEST['plugin'] : ''; 
    2222 
    23 if( !empty($action) ) { 
    24     switch( $action ) { 
     23$status = isset($_REQUEST['plugin_status']) ? $_REQUEST['plugin_status'] : 'all'; 
     24if ( !in_array($status, array('all', 'active', 'inactive', 'recent', 'upgrade', 'search')) ) 
     25    $status = 'all'; 
     26 
     27$page = isset($_REQUEST['paged']) ? $_REQUEST['paged'] : 1; 
     28 
     29if ( !empty($action) ) { 
     30    switch ( $action ) { 
    2531        case 'activate': 
    2632            check_admin_referer('activate-plugin_' . $plugin); 
     
    3339                update_option('recently_activated', $recent); 
    3440            } 
    35             wp_redirect('plugins.php?activate=true'); // overrides the ?error=true one above 
     41            wp_redirect("plugins.php?activate=true&plugin_status=$status&paged=$page"); // overrides the ?error=true one above 
    3642            exit; 
    3743            break; 
     
    4854                update_option('recently_activated', $recent); 
    4955 
    50             wp_redirect('plugins.php?activate-multi=true'); 
     56            wp_redirect("plugins.php?activate-multi=true&plugin_status=$status&paged=$page"); 
    5157            exit; 
    5258            break; 
     
    6672            deactivate_plugins($plugin); 
    6773            update_option('recently_activated', array($plugin => time()) + (array)get_option('recently_activated')); 
    68             wp_redirect('plugins.php?deactivate=true'); 
     74            wp_redirect("plugins.php?deactivate=true&plugin_status=$status&paged=$page"); 
    6975            exit; 
    7076            break; 
     
    7682                $deactivated[ $plugin ] = time(); 
    7783            update_option('recently_activated', $deactivated + (array)get_option('recently_activated')); 
    78             wp_redirect('plugins.php?deactivate-multi=true'); 
     84            wp_redirect("plugins.php?deactivate-multi=true&plugin_status=$status&paged=$page"); 
    7985            exit; 
    8086            break; 
     
    272278            return false; 
    273279    } 
    274     $_GET['plugin_status'] = 'search'; 
     280    $status = 'search'; 
    275281    $search_plugins = array_filter($all_plugins, '_search_plugins_filter_callback'); 
    276282    $total_search_plugins = count($search_plugins); 
    277283} 
    278284 
    279 $status = isset($_GET['plugin_status']) ? $_GET['plugin_status'] : 'all'; 
    280 if ( !in_array($status, array('all', 'active', 'inactive', 'recent', 'upgrade', 'search')) ) 
    281     $status = 'all'; 
    282285$plugin_array_name = "${status}_plugins"; 
    283286$plugins = &$$plugin_array_name; 
    284287 
    285288//Paging. 
    286 $page = isset($_GET['paged']) ? $_GET['paged'] : 1; 
    287289$total_this_page = "total_{$status}_plugins"; 
    288290$total_this_page = $$total_this_page; 
     
    316318 */ 
    317319function print_plugins_table($plugins, $context = '') { 
     320    global $page; 
    318321?> 
    319322<table class="widefat" cellspacing="0" id="<?php echo $context ?>-plugins-table"> 
     
    349352 
    350353        if ( $is_active ) 
    351             $actions[] = '<a href="' . wp_nonce_url('plugins.php?action=deactivate&amp;plugin=' . $plugin_file, 'deactivate-plugin_' . $plugin_file) . '" title="' . __('Deactivate this plugin') . '">' . __('Deactivate') . '</a>'; 
     354            $actions[] = '<a href="' . wp_nonce_url('plugins.php?action=deactivate&amp;plugin=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page, 'deactivate-plugin_' . $plugin_file) . '" title="' . __('Deactivate this plugin') . '">' . __('Deactivate') . '</a>'; 
    352355        else //Inactive or Recently deactivated 
    353             $actions[] = '<a href="' . wp_nonce_url('plugins.php?action=activate&amp;plugin=' . $plugin_file, 'activate-plugin_' . $plugin_file) . '" title="' . __('Activate this plugin') . '" class="edit">' . __('Activate') . '</a>'; 
     356            $actions[] = '<a href="' . wp_nonce_url('plugins.php?action=activate&amp;plugin=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page, 'activate-plugin_' . $plugin_file) . '" title="' . __('Activate this plugin') . '" class="edit">' . __('Activate') . '</a>'; 
    354357 
    355358        if ( current_user_can('edit_plugins') && is_writable(WP_PLUGIN_DIR . '/' . $plugin_file) ) 
     
    425428<form method="post" action="<?php echo admin_url('plugins.php') ?>"> 
    426429<?php wp_nonce_field('bulk-manage-plugins') ?> 
     430<input type="hidden" name="plugin_status" value="<?php echo attribute_escape($status) ?>" /> 
     431<input type="hidden" name="paged" value="<?php echo attribute_escape($page) ?>" /> 
    427432 
    428433<ul class="subsubsub"> 
Note: See TracChangeset for help on using the changeset viewer.