WordPress.org

Make WordPress Core


Ignore:
Timestamp:
07/07/2020 07:10:46 PM (15 months 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-posts-list-table.php

    r48352 r48398  
    179179
    180180        if ( ! empty( $_REQUEST['mode'] ) ) {
    181             $mode = 'excerpt' === $_REQUEST['mode'] ? 'excerpt' : 'list';
     181            $mode = 'extended' === $_REQUEST['mode'] ? 'extended' : 'list';
    182182            set_user_setting( 'posts_list_mode', $mode );
    183183        } else {
     
    599599     */
    600600    protected function get_table_classes() {
    601         return array( 'widefat', 'fixed', 'striped', is_post_type_hierarchical( $this->screen->post_type ) ? 'pages' : 'posts' );
     601        $mode       = get_user_setting( 'posts_list_mode', 'list' );
     602        $mode_class = 'extended' === $mode ? 'table-view-extended' : 'table-view-list';
     603        $mode = get_user_setting( 'posts_list_mode', 'list' );
     604        /**
     605         * Filters the current view mode.
     606         *
     607         * @since 5.5.0
     608         *
     609         * @param string $mode The current selected mode. Default value of
     610         *                     posts_list_mode user setting.
     611         */
     612        $mode = apply_filters( 'table_view_mode', $mode );
     613
     614        $mode_class = 'extended' === $mode ? 'table-view-extended' : 'table-view-' . $mode;
     615
     616        return array( 'widefat', 'fixed', 'striped', $mode_class, is_post_type_hierarchical( $this->screen->post_type ) ? 'pages' : 'posts' );
    602617    }
    603618
     
    10431058        echo "</strong>\n";
    10441059
    1045         if ( ! is_post_type_hierarchical( $this->screen->post_type ) && 'excerpt' === $mode && current_user_can( 'read_post', $post->ID ) ) {
     1060        if ( ! is_post_type_hierarchical( $this->screen->post_type ) && 'extended' === $mode && current_user_can( 'read_post', $post->ID ) ) {
    10461061            if ( post_password_required( $post ) ) {
    10471062                echo '<span class="protected-post-excerpt">' . esc_html( get_the_excerpt() ) . '</span>';
     
    11031118         * @param WP_Post $post        Post object.
    11041119         * @param string  $column_name The column name.
    1105          * @param string  $mode        The list display mode ('excerpt' or 'list').
     1120         * @param string  $mode        The list display mode ('extended' or 'list').
    11061121         */
    11071122        $status = apply_filters( 'post_date_column_status', $status, $post, 'date', $mode );
     
    11221137         * @param WP_Post $post        Post object.
    11231138         * @param string  $column_name The column name.
    1124          * @param string  $mode        The list display mode ('excerpt' or 'list').
     1139         * @param string  $mode        The list display mode ('extended' or 'list').
    11251140         */
    11261141        echo apply_filters( 'post_date_column_time', $t_time, $post, 'date', $mode );
     
    14921507        }
    14931508
    1494         $m            = ( isset( $mode ) && 'excerpt' === $mode ) ? 'excerpt' : 'list';
     1509        $m            = ( isset( $mode ) && 'extended' === $mode ) ? 'extended' : 'list';
    14951510        $can_publish  = current_user_can( $post_type_object->cap->publish_posts );
    14961511        $core_columns = array(
Note: See TracChangeset for help on using the changeset viewer.