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
This commit is contained in:
parent
a37f75eb87
commit
7adf6e9125
@ -195,7 +195,7 @@ if ( 'post' == $post_type ) {
|
||||
'<ul>' .
|
||||
'<li>' . __('You can hide/display columns based on your needs and decide how many posts to list per screen using the Screen Options tab.') . '</li>' .
|
||||
'<li>' . __('You can filter the list of posts by post status using the text links in the upper left to show All, Published, Draft, or Trashed posts. The default view is to show all posts.') . '</li>' .
|
||||
'<li>' . __('You can view posts in a simple title list or with an excerpt. Choose the view you prefer by clicking on the icons at the top of the list on the right.') . '</li>' .
|
||||
'<li>' . __('You can view posts in a simple title list or with an excerpt using the Screen Options tab.') . '</li>' .
|
||||
'<li>' . __('You can refine the list to show only posts in a specific category or from a specific month by using the dropdown menus above the posts list. Click the Filter button after making your selection. You also can refine the list by clicking on the post author, category or tag in the posts list.') . '</li>' .
|
||||
'</ul>'
|
||||
) );
|
||||
|
@ -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 );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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 {
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the list table view mode preferences.
|
||||
*
|
||||
* @since 4.4.0
|
||||
*/
|
||||
public function render_view_mode() {
|
||||
/**
|
||||
* Filter the post types that have different view mode options.
|
||||
*
|
||||
* @since 4.4.0
|
||||
*
|
||||
* @param array $view_mode_post_types Array of post types that can change view modes.
|
||||
* Default hierarchical post types with show_ui on.
|
||||
*/
|
||||
$view_mode_post_types = get_post_types( array( 'hierarchical' => 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' );
|
||||
?>
|
||||
<fieldset class="metabox-prefs view-mode">
|
||||
<legend><?php _e( 'View Mode' ); ?></legend>
|
||||
<label for="list-view-mode">
|
||||
<input id="list-view-mode" type="radio" name="mode" value="list" <?php checked( 'list', $mode ); ?> />
|
||||
<?php _e( 'List View' ); ?>
|
||||
</label>
|
||||
<label for="excerpt-view-mode">
|
||||
<input id="excerpt-view-mode" type="radio" name="mode" value="excerpt" <?php checked( 'excerpt', $mode ); ?> />
|
||||
<?php _e( 'Excerpt View' ); ?>
|
||||
</label>
|
||||
</fieldset>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Render screen reader text.
|
||||
*
|
||||
|
@ -461,7 +461,13 @@ function set_screen_options() {
|
||||
}
|
||||
|
||||
update_user_meta($user->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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user