From 7adf6e9125a0d0be8842f11abdfa59d34ba5796f Mon Sep 17 00:00:00 2001 From: Helen Hou-Sandi Date: Thu, 22 Oct 2015 19:24:10 +0000 Subject: [PATCH] List tables: Move the view mode switcher into screen options for posts. Having a view mode switcher nestled within table navigation makes no sense, especially now that it's a sticky user option. While less convenient for frequent switching, there is no evidence as of yet that there is a large userbase of frequent view mode switchers. Introduces a filter for `view_mode_post_types`, which by default is all hierarchical post types with edit UI on. props Oxymoron. fixes #22222. git-svn-id: https://develop.svn.wordpress.org/trunk@35357 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/edit.php | 2 +- .../includes/class-wp-posts-list-table.php | 3 -- src/wp-admin/includes/class-wp-screen.php | 41 +++++++++++++++++++ src/wp-admin/includes/misc.php | 8 +++- 4 files changed, 49 insertions(+), 5 deletions(-) diff --git a/src/wp-admin/edit.php b/src/wp-admin/edit.php index fa4a7b6179..192b36aeca 100644 --- a/src/wp-admin/edit.php +++ b/src/wp-admin/edit.php @@ -195,7 +195,7 @@ if ( 'post' == $post_type ) { '' ) ); diff --git a/src/wp-admin/includes/class-wp-posts-list-table.php b/src/wp-admin/includes/class-wp-posts-list-table.php index fb5a790d6c..3300621c2b 100644 --- a/src/wp-admin/includes/class-wp-posts-list-table.php +++ b/src/wp-admin/includes/class-wp-posts-list-table.php @@ -515,9 +515,6 @@ class WP_Posts_List_Table extends WP_List_Table { global $mode; parent::pagination( $which ); - - if ( 'top' === $which && ! is_post_type_hierarchical( $this->screen->post_type ) ) - $this->view_switcher( $mode ); } /** diff --git a/src/wp-admin/includes/class-wp-screen.php b/src/wp-admin/includes/class-wp-screen.php index 100fa132ed..13d59dc981 100644 --- a/src/wp-admin/includes/class-wp-screen.php +++ b/src/wp-admin/includes/class-wp-screen.php @@ -991,6 +991,7 @@ final class WP_Screen { $this->render_list_table_columns_preferences(); $this->render_screen_layout(); $this->render_per_page_options(); + $this->render_view_mode(); echo $this->_screen_settings; /** @@ -1187,6 +1188,46 @@ final class WP_Screen { false, 'show_ui' => true ) ); + $view_mode_post_types = apply_filters( 'view_mode_post_types', $view_mode_post_types ); + + if ( ! in_array( $this->post_type, $view_mode_post_types ) ) { + return; + } + + global $mode; + + // This needs a submit button + add_filter( 'screen_options_show_submit', '__return_true' ); +?> +
+ + + +
+ID, $option, $value); - wp_safe_redirect( remove_query_arg( array('pagenum', 'apage', 'paged'), wp_get_referer() ) ); + + $url = remove_query_arg( array( 'pagenum', 'apage', 'paged' ), wp_get_referer() ); + if ( isset( $_POST['mode'] ) ) { + $url = add_query_arg( array( 'mode' => $_POST['mode'] ), $url ); + } + + wp_safe_redirect( $url ); exit; } }