WordPress.org

Make WordPress Core

Changeset 35357


Ignore:
Timestamp:
10/22/2015 07:24:10 PM (6 years ago)
Author:
helen
Message:

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.

Location:
trunk/src/wp-admin
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/edit.php

    r34891 r35357  
    196196            '<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>' .
    197197            '<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>' .
    198             '<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>' .
     198            '<li>' . __('You can view posts in a simple title list or with an excerpt using the Screen Options tab.') . '</li>' .
    199199            '<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>' .
    200200        '</ul>'
  • trunk/src/wp-admin/includes/class-wp-posts-list-table.php

    r35263 r35357  
    516516
    517517        parent::pagination( $which );
    518 
    519         if ( 'top' === $which && ! is_post_type_hierarchical( $this->screen->post_type ) )
    520             $this->view_switcher( $mode );
    521518    }
    522519
  • trunk/src/wp-admin/includes/class-wp-screen.php

    r35161 r35357  
    992992        $this->render_screen_layout();
    993993        $this->render_per_page_options();
     994        $this->render_view_mode();
    994995        echo $this->_screen_settings;
    995996
     
    11891190
    11901191    /**
     1192     * Render the list table view mode preferences.
     1193     *
     1194     * @since 4.4.0
     1195     */
     1196    public function render_view_mode() {
     1197        /**
     1198         * Filter the post types that have different view mode options.
     1199         *
     1200         * @since 4.4.0
     1201         *
     1202         * @param array $view_mode_post_types Array of post types that can change view modes.
     1203         *                                    Default hierarchical post types with show_ui on.
     1204         */
     1205        $view_mode_post_types = get_post_types( array( 'hierarchical' => false, 'show_ui' => true ) );
     1206        $view_mode_post_types = apply_filters( 'view_mode_post_types', $view_mode_post_types );
     1207
     1208        if ( ! in_array( $this->post_type, $view_mode_post_types ) ) {
     1209            return;
     1210        }
     1211
     1212        global $mode;
     1213
     1214        // This needs a submit button
     1215        add_filter( 'screen_options_show_submit', '__return_true' );
     1216?>
     1217        <fieldset class="metabox-prefs view-mode">
     1218        <legend><?php _e( 'View Mode' ); ?></legend>
     1219                <label for="list-view-mode">
     1220                    <input id="list-view-mode" type="radio" name="mode" value="list" <?php checked( 'list', $mode ); ?> />
     1221                    <?php _e( 'List View' ); ?>
     1222                </label>
     1223                <label for="excerpt-view-mode">
     1224                    <input id="excerpt-view-mode" type="radio" name="mode" value="excerpt" <?php checked( 'excerpt', $mode ); ?> />
     1225                    <?php _e( 'Excerpt View' ); ?>
     1226                </label>
     1227        </fieldset>
     1228<?php
     1229    }
     1230
     1231    /**
    11911232     * Render screen reader text.
    11921233     *
  • trunk/src/wp-admin/includes/misc.php

    r35314 r35357  
    462462
    463463        update_user_meta($user->ID, $option, $value);
    464         wp_safe_redirect( remove_query_arg( array('pagenum', 'apage', 'paged'), wp_get_referer() ) );
     464
     465        $url = remove_query_arg( array( 'pagenum', 'apage', 'paged' ), wp_get_referer() );
     466        if ( isset( $_POST['mode'] ) ) {
     467            $url = add_query_arg( array( 'mode' => $_POST['mode'] ), $url );
     468        }
     469
     470        wp_safe_redirect( $url );
    465471        exit;
    466472    }
Note: See TracChangeset for help on using the changeset viewer.