WordPress.org

Make WordPress Core

Ticket #16166: garyc40.16166.diff

File garyc40.16166.diff, 5.6 KB (added by garyc40, 4 years ago)

don't reset order and orderby when after bulk edit

  • wp-admin/edit-comments.php

    diff --git wp-admin/edit-comments.php wp-admin/edit-comments.php
    index 29e5f03..779c311 100644
    if ( !current_user_can('edit_posts') ) 
    1313 
    1414$wp_list_table = get_list_table('WP_Comments_List_Table'); 
    1515$pagenum = $wp_list_table->get_pagenum(); 
    16  
     16list( $current_orderby, $current_order ) = $wp_list_table->get_order_info(); 
    1717$doaction = $wp_list_table->current_action(); 
    1818 
    1919if ( $doaction ) { 
    if ( $doaction ) { 
    3838 
    3939        $redirect_to = remove_query_arg( array( 'trashed', 'untrashed', 'deleted', 'spammed', 'unspammed', 'approved', 'unapproved', 'ids' ), wp_get_referer() ); 
    4040        $redirect_to = add_query_arg( 'paged', $pagenum, $redirect_to ); 
     41        if ( $current_orderby ) 
     42                $redirect_to = add_query_arg( array( 'order' => $current_order, 'orderby' => $current_orderby ), $redirect_to ); 
    4143 
    4244        foreach ( $comment_ids as $comment_id ) { // Check the permissions on each 
    4345                if ( !current_user_can( 'edit_comment', $comment_id ) ) 
  • wp-admin/edit-tags.php

    diff --git wp-admin/edit-tags.php wp-admin/edit-tags.php
    index cfaba6c..4ca5981 100644
    case 'bulk-delete': 
    9494        foreach ( $tags as $tag_ID ) { 
    9595                wp_delete_term( $tag_ID, $taxonomy ); 
    9696        } 
    97  
     97        $pagenum = $wp_list_table->get_pagenum(); 
     98        list( $current_orderby, $current_order ) = $wp_list_table->get_order_info(); 
    9899        $location = 'edit-tags.php?taxonomy=' . $taxonomy; 
    99100        if ( 'post' != $post_type ) 
    100101                $location .= '&post_type=' . $post_type; 
    case 'bulk-delete': 
    103104                        $location = $referer; 
    104105        } 
    105106 
    106         $location = add_query_arg( 'message', 6, $location ); 
     107        $location = add_query_arg( array( 'message' => 6, 'paged' => $pagenum ), $location ); 
     108        if ( $current_orderby ) 
     109                $location = add_query_arg( array( 'order' => $current_order, 'orderby' => $current_orderby ), $location ); 
     110 
    107111        wp_redirect( $location ); 
    108112        exit; 
    109113 
  • wp-admin/edit.php

    diff --git wp-admin/edit.php wp-admin/edit.php
    index 5e0154f..2cb3491 100644
    if ( !current_user_can($post_type_object->cap->edit_posts) ) 
    2525 
    2626$wp_list_table = get_list_table('WP_Posts_List_Table'); 
    2727$pagenum = $wp_list_table->get_pagenum(); 
     28list( $current_orderby, $current_order ) = $wp_list_table->get_order_info(); 
    2829 
    2930// Back-compat for viewing comments of an entry 
    3031foreach ( array( 'p', 'attachment_id', 'page_id' ) as $_redirect ) { 
    if ( $doaction ) { 
    4243 
    4344        $sendback = remove_query_arg( array('trashed', 'untrashed', 'deleted', 'ids'), wp_get_referer() ); 
    4445        $sendback = add_query_arg( 'paged', $pagenum, $sendback ); 
     46        if ( $current_orderby ) 
     47                $sendback = add_query_arg( array( 'order' => $current_order, 'orderby' => $current_orderby ), $sendback ); 
    4548        if ( strpos($sendback, 'post.php') !== false ) 
    4649                $sendback = admin_url($post_new_file); 
    4750 
  • wp-admin/includes/class-wp-list-table.php

    diff --git wp-admin/includes/class-wp-list-table.php wp-admin/includes/class-wp-list-table.php
    index fa2001d..d15b80b 100644
    class WP_List_Table { 
    611611                $hidden = array_intersect( array_keys( $columns ), array_filter( $hidden ) ); 
    612612                return count( $columns ) - count( $hidden ); 
    613613        } 
     614         
     615        function get_order_info() { 
     616                if ( isset( $_GET['orderby'] ) ) 
     617                        $current_orderby = $_GET['orderby']; 
     618                else 
     619                        $current_orderby = ''; 
     620 
     621                if ( ! $current_orderby ) 
     622                        $current_order = ''; 
     623                elseif ( isset( $_GET['order'] ) && 'desc' == $_GET['order'] ) 
     624                        $current_order = 'desc'; 
     625                else 
     626                        $current_order = 'asc'; 
     627                         
     628                return array($current_orderby, $current_order); 
     629        } 
    614630 
    615631        /** 
    616632         * Print column headers, accounting for hidden and sortable columns. 
    class WP_List_Table { 
    627643 
    628644                $current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; 
    629645 
    630                 if ( isset( $_GET['orderby'] ) ) 
    631                         $current_orderby = $_GET['orderby']; 
    632                 else 
    633                         $current_orderby = ''; 
    634  
    635                 if ( isset( $_GET['order'] ) && 'desc' == $_GET['order'] ) 
    636                         $current_order = 'desc'; 
    637                 else 
    638                         $current_order = 'asc'; 
     646                list( $current_orderby, $current_order ) = $this->get_order_info(); 
    639647 
    640648                foreach ( $columns as $column_key => $column_display_name ) { 
    641649                        $class = array( 'manage-column', "column-$column_key" ); 
    class WP_List_Table { 
    728736         * @access protected 
    729737         */ 
    730738        function display_tablenav( $which ) { 
    731                 if ( 'top' == $which ) 
     739                if ( 'top' == $which ) { 
    732740                        wp_nonce_field( 'bulk-' . $this->_args['plural'] ); 
     741                        list( $current_orderby, $current_order ) = $this->get_order_info(); 
     742                        echo '<input type="hidden" name="orderby" value="' . $current_orderby . '" /><input type="hidden" name="order" value="' . $current_order . '" />'; 
     743                } 
    733744?> 
    734745        <div class="tablenav <?php echo esc_attr( $which ); ?>"> 
    735746 
  • wp-admin/js/list-table.dev.js

    diff --git wp-admin/js/list-table.dev.js wp-admin/js/list-table.dev.js
    index 51b52d1..2176da2 100644
    window.listTable = { 
    103103                if ( 'object' != typeof response ) { 
    104104                        this.handle_error(); 
    105105                } else { 
    106                         var tablenav = $('.tablenav-pages'); 
     106                        var tablenav = $('.tablenav-pages'), 
     107                                order = $.query.GET('order'), 
     108                                orderby = (order) ? $.query.GET('orderby') : ''; 
    107109 
    108110                        this.stop_loading(); 
    109111 
    window.listTable = { 
    124126                        // Disable buttons that should noop. 
    125127                        tablenav.find('.first-page, .prev-page').toggleClass('disabled', 1 == $.query.GET('paged')); 
    126128                        tablenav.find('.next-page, .last-page').toggleClass('disabled', response.total_pages == $.query.GET('paged')); 
    127  
     129                         
     130                        $('input[name=order]').val(order); 
     131                        $('input[name=orderby]').val(orderby); 
     132                         
    128133                        $('th.column-cb :input').attr('checked', false); 
    129134 
    130135                        if ( history.replaceState ) {