Make WordPress Core


Ignore:
Timestamp:
07/07/2020 07:10:46 PM (6 years ago)
Author:
whyisjake
Message:

Administration: Introduce extensibility to posts and comments list table views, for accessibility purposes.

At default, expands the excerpt view to become an extended view. Includes a new table_view_mode filter to allow further configuration.

Fixes #49715.
Props joedolson, audrasjb, afercia, whyisjake.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-screen.php

    r47802 r48398  
    12891289                $screen = get_current_screen();
    12901290
    1291                 // Currently only enabled for posts lists.
    1292                 if ( 'edit' !== $screen->base ) {
     1291                // Currently only enabled for posts and comments lists.
     1292                if ( 'edit' !== $screen->base && 'edit-comments' !== $screen->base ) {
    12931293                        return;
    12941294                }
    12951295
    1296                 $view_mode_post_types = get_post_types(
    1297                         array(
    1298                                 'hierarchical' => false,
    1299                                 'show_ui'      => true,
    1300                         )
    1301                 );
     1296                $view_mode_post_types = get_post_types( array( 'show_ui' => true ) );
    13021297
    13031298                /**
    … …  
    13071302                 *
    13081303                 * @param string[] $view_mode_post_types Array of post types that can change view modes.
    1309                  *                                       Default non-hierarchical post types with show_ui on.
     1304                 *                                       Default post types with show_ui on.
    13101305                 */
    13111306                $view_mode_post_types = apply_filters( 'view_mode_post_types', $view_mode_post_types );
    13121307
    1313                 if ( ! in_array( $this->post_type, $view_mode_post_types, true ) ) {
     1308                if ( 'edit' === $screen->base && ! in_array( $this->post_type, $view_mode_post_types, true ) ) {
    13141309                        return;
    13151310                }
    13161311
    1317                 global $mode;
     1312                $mode = get_user_setting( 'posts_list_mode', 'list' );
     1313
     1314                // Set 'list' as default value if $mode is not set.
     1315                $mode = ( isset( $mode ) && 'extended' === $mode ) ? 'extended' : 'list';
     1316
     1317                /**
     1318                 * Filters the current view mode.
     1319                 *
     1320                 * @since 5.5.0
     1321                 *
     1322                 * @param string $mode The current selected mode. Default value of
     1323                 *                     posts_list_mode user setting.
     1324                 */
     1325                $mode = apply_filters( 'table_view_mode', $mode );
    13181326
    13191327                // This needs a submit button.
    … …  
    13241332                                <label for="list-view-mode">
    13251333                                        <input id="list-view-mode" type="radio" name="mode" value="list" <?php checked( 'list', $mode ); ?> />
    1326                                         <?php _e( 'List View' ); ?>
     1334                                        <?php _e( 'Compact view' ); ?>
    13271335                                </label>
    13281336                                <label for="excerpt-view-mode">
    1329                                         <input id="excerpt-view-mode" type="radio" name="mode" value="excerpt" <?php checked( 'excerpt', $mode ); ?> />
    1330                                         <?php _e( 'Excerpt View' ); ?>
     1337                                        <input id="excerpt-view-mode" type="radio" name="mode" value="extended" <?php checked( 'extended', $mode ); ?> />
     1338                                        <?php _e( 'Extended View' ); ?>
    13311339                                </label>
     1340                                <?php
     1341                                /**
     1342                                 * Fires at the end of the table view modes screen option.
     1343                                 *
     1344                                 * @since 5.5.0
     1345                                 *
     1346                                 * @param string $mode The currently selected mode.
     1347                                 */
     1348                                do_action( 'wp_table_view_modes', $mode );
     1349                                ?>
    13321350                </fieldset>
    13331351                <?php
Note: See TracChangeset for help on using the changeset viewer.