From 6ca92efe23bbc80fa1fd7639972adafc67b6020d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Helen=20Hou-Sand=C3=AD?= Date: Thu, 22 Oct 2015 19:25:25 +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. Built from https://develop.svn.wordpress.org/trunk@35357 git-svn-id: http://core.svn.wordpress.org/trunk@35323 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/edit.php | 2 +- .../includes/class-wp-posts-list-table.php | 3 -- wp-admin/includes/class-wp-screen.php | 41 +++++++++++++++++++ wp-admin/includes/misc.php | 8 +++- wp-includes/version.php | 2 +- 5 files changed, 50 insertions(+), 6 deletions(-) diff --git a/wp-admin/edit.php b/wp-admin/edit.php index fa4a7b6179..192b36aeca 100644 --- a/wp-admin/edit.php +++ b/wp-admin/edit.php @@ -195,7 +195,7 @@ if ( 'post' == $post_type ) { '' ) ); diff --git a/wp-admin/includes/class-wp-posts-list-table.php b/wp-admin/includes/class-wp-posts-list-table.php index fb5a790d6c..3300621c2b 100644 --- a/wp-admin/includes/class-wp-posts-list-table.php +++ b/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/wp-admin/includes/class-wp-screen.php b/wp-admin/includes/class-wp-screen.php index 100fa132ed..13d59dc981 100644 --- a/wp-admin/includes/class-wp-screen.php +++ b/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; } } diff --git a/wp-includes/version.php b/wp-includes/version.php index fe028adfa7..e7572a7cda 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.4-alpha-35356'; +$wp_version = '4.4-alpha-35357'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.