From 333d2f205ab50b9556661e1507f5977c2a6ed22f Mon Sep 17 00:00:00 2001 From: "Dominik Schilling (ocean90)" Date: Mon, 7 Dec 2015 19:15:16 +0000 Subject: [PATCH] List Tables: Revert [34728] and [35482]. Part of [34728] was already reverted in [35682], but the default values still made it impossible to set a default ordering for custom post types. See #25493. See #34825. git-svn-id: https://develop.svn.wordpress.org/trunk@35818 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/class-wp-list-table.php | 45 +++++-------------- src/wp-admin/includes/post.php | 6 +-- 2 files changed, 12 insertions(+), 39 deletions(-) diff --git a/src/wp-admin/includes/class-wp-list-table.php b/src/wp-admin/includes/class-wp-list-table.php index e98d4b6344..32d0883947 100644 --- a/src/wp-admin/includes/class-wp-list-table.php +++ b/src/wp-admin/includes/class-wp-list-table.php @@ -1036,38 +1036,6 @@ class WP_List_Table { return count( $columns ) - count( $hidden ); } - /** - * If 'orderby' is set, return it. - * - * @access protected - * @since 4.4.0 - * - * @return string The value of 'orderby' or empty string. - */ - protected function get_orderby() { - if ( isset( $_GET['orderby'] ) ) { - return $_GET['orderby']; - } - - return ''; - } - - /** - * If 'order' is 'desc', return it. Else return 'asc'. - * - * @access protected - * @since 4.4.0 - * - * @return string 'desc' or 'asc'. - */ - protected function get_order() { - if ( isset( $_GET['order'] ) && 'desc' === $_GET['order'] ) { - return 'desc'; - } - - return 'asc'; - } - /** * Print column headers, accounting for hidden and sortable columns. * @@ -1084,8 +1052,17 @@ class WP_List_Table { $current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ); $current_url = remove_query_arg( 'paged', $current_url ); - $current_orderby = $this->get_orderby(); - $current_order = $this->get_order(); + if ( isset( $_GET['orderby'] ) ) { + $current_orderby = $_GET['orderby']; + } else { + $current_orderby = ''; + } + + if ( isset( $_GET['order'] ) && 'desc' === $_GET['order'] ) { + $current_order = 'desc'; + } else { + $current_order = 'asc'; + } if ( ! empty( $columns['cb'] ) ) { static $cb_counter = 1; diff --git a/src/wp-admin/includes/post.php b/src/wp-admin/includes/post.php index 7fde35483e..3df8af8f3a 100644 --- a/src/wp-admin/includes/post.php +++ b/src/wp-admin/includes/post.php @@ -1008,16 +1008,12 @@ function wp_edit_posts_query( $q = false ) { $orderby = $q['orderby']; } elseif ( isset( $q['post_status'] ) && in_array( $q['post_status'], array( 'pending', 'draft' ) ) ) { $orderby = 'modified'; - } elseif ( ! is_post_type_hierarchical( $post_type ) ) { - $orderby = 'date'; } if ( isset( $q['order'] ) ) { $order = $q['order']; } elseif ( isset( $q['post_status'] ) && 'pending' == $q['post_status'] ) { $order = 'ASC'; - } else { - $order = 'desc'; } $per_page = "edit_{$post_type}_per_page"; @@ -1844,4 +1840,4 @@ function redirect_post($post_id = '') { */ wp_redirect( apply_filters( 'redirect_post_location', $location, $post_id ) ); exit; -} \ No newline at end of file +}