Make WordPress Core


Ignore:
Timestamp:
10/01/2015 02:09:41 AM (9 years ago)
Author:
wonderboymusic
Message:

Post List Table: Ensure that edit.php with no query string produces the proper markup and links in the date column header.

Add 2 methods to WP_List_Table, ->get_orderby() and ->get_order(). Override the methods in WP_Posts_List_Table.

WP_Posts_List_Table calls wp_edit_posts_query() in ->prepare_items() which is a wrapper for wp(). As such, we can obtain orderby and order via get_query_var(), instead of the URL.

Fixes #25493.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-list-table.php

    r34707 r34728  
    10081008
    10091009    /**
     1010     * If 'orderby' is set, return it.
     1011     *
     1012     * @access protected
     1013     * @since 4.4.0
     1014     *
     1015     * @return string The value of 'orderby' or empty string.
     1016     */
     1017    protected function get_orderby() {
     1018        if ( isset( $_GET['orderby'] ) ) {
     1019            return $_GET['orderby'];
     1020        }
     1021
     1022        return '';
     1023    }
     1024
     1025    /**
     1026     * If 'order' is 'desc', return it. Else return 'asc'.
     1027     *
     1028     * @access protected
     1029     * @since 4.4.0
     1030     *
     1031     * @return string 'desc' or 'asc'.
     1032     */
     1033    protected function get_order() {
     1034        if ( isset( $_GET['order'] ) && 'desc' === $_GET['order'] ) {
     1035            return 'desc';
     1036        }
     1037
     1038        return 'asc';
     1039    }
     1040
     1041    /**
    10101042     * Print column headers, accounting for hidden and sortable columns.
    10111043     *
     
    10231055        $current_url = remove_query_arg( 'paged', $current_url );
    10241056
    1025         if ( isset( $_GET['orderby'] ) )
    1026             $current_orderby = $_GET['orderby'];
    1027         else
    1028             $current_orderby = '';
    1029 
    1030         if ( isset( $_GET['order'] ) && 'desc' === $_GET['order'] )
    1031             $current_order = 'desc';
    1032         else
    1033             $current_order = 'asc';
     1057        $current_orderby = $this->get_orderby();
     1058        $current_order = $this->get_order();
    10341059
    10351060        if ( ! empty( $columns['cb'] ) ) {
Note: See TracChangeset for help on using the changeset viewer.