Make WordPress Core

Changeset 34728


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.

Location:
trunk/src/wp-admin/includes
Files:
3 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'] ) ) {
  • trunk/src/wp-admin/includes/class-wp-posts-list-table.php

    r34667 r34728  
    122122
    123123    /**
     124     * Get the value of the 'orderby' query var.
     125     *
     126     * @access protected
     127     * @since 4.4.0
     128     *
     129     * @return string The value of 'orderby'.
     130     */
     131    protected function get_orderby() {
     132        return strtolower( get_query_var( 'orderby' ) );
     133    }
     134
     135    /**
     136     * Get the value of the 'order' query var.
     137     *
     138     * @access protected
     139     * @since 4.4.0
     140     *
     141     * @return string The value of 'order'.
     142     */
     143    protected function get_order() {
     144        return strtolower( get_query_var( 'order' ) );
     145    }
     146
     147    /**
    124148     *
    125149     * @global array    $avail_post_stati
     
    131155        global $avail_post_stati, $wp_query, $per_page, $mode;
    132156
     157        // is going to call wp()
    133158        $avail_post_stati = wp_edit_posts_query();
    134159
  • trunk/src/wp-admin/includes/post.php

    r34690 r34728  
    10051005    }
    10061006
    1007     if ( isset($q['orderby']) )
     1007    if ( isset( $q['orderby'] ) ) {
    10081008        $orderby = $q['orderby'];
    1009     elseif ( isset($q['post_status']) && in_array($q['post_status'], array('pending', 'draft')) )
     1009    } elseif ( isset( $q['post_status'] ) && in_array( $q['post_status'], array( 'pending', 'draft' ) ) ) {
    10101010        $orderby = 'modified';
    1011 
    1012     if ( isset($q['order']) )
     1011    } else {
     1012        $orderby = 'date';
     1013    }
     1014
     1015    if ( isset( $q['order'] ) ) {
    10131016        $order = $q['order'];
    1014     elseif ( isset($q['post_status']) && 'pending' == $q['post_status'] )
     1017    } elseif ( isset( $q['post_status'] ) && 'pending' == $q['post_status'] ) {
    10151018        $order = 'ASC';
     1019    } else {
     1020        $order = 'desc';
     1021    }
    10161022
    10171023    $per_page = "edit_{$post_type}_per_page";
Note: See TracChangeset for help on using the changeset viewer.