WordPress.org

Make WordPress Core


Ignore:
Timestamp:
03/19/2015 02:25:05 AM (5 years ago)
Author:
wonderboymusic
Message:

Add WP_Posts_List_Table::is_base_request() to determine if the current "view" is the "All" (default) view.

Fixes #24869.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-posts-list-table.php

    r31730 r31828  
    149149    }
    150150
     151    /**
     152     * Determine if the current view is the "All" view
     153     *
     154     * @since 4.2.0
     155     *
     156     * @return boolean
     157     */
     158    protected function is_base_request() {
     159        if ( empty( $_GET ) ) {
     160            return true;
     161        } elseif ( 1 === count( $_GET ) && ! empty( $_GET['post_type'] ) ) {
     162            return $this->screen->post_type === $_GET['post_type'];
     163        }
     164    }
     165
    151166    protected function get_views() {
    152167        global $locked_post_status, $avail_post_stati;
     
    177192            $total_posts -= $num_posts->$state;
    178193
    179         $class = empty( $class ) && empty( $_REQUEST['post_status'] ) && empty( $_REQUEST['show_sticky'] ) ? ' class="current"' : '';
    180         $status_links['all'] = "<a href='edit.php?post_type=$post_type{$allposts}'$class>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_posts, 'posts' ), number_format_i18n( $total_posts ) ) . '</a>';
     194        if ( empty( $class ) && $this->is_base_request() ) {
     195            $class =  ' class="current"';
     196        }
     197
     198        $all_inner_html = sprintf(
     199            _nx(
     200                'All <span class="count">(%s)</span>',
     201                'All <span class="count">(%s)</span>',
     202                $total_posts,
     203                'posts'
     204            ),
     205            number_format_i18n( $total_posts )
     206        );
     207
     208        $status_links['all'] = "<a href='edit.php?post_type=$post_type{$allposts}'$class>" . $all_inner_html . '</a>';
    181209
    182210        foreach ( get_post_stati(array('show_in_admin_status_list' => true), 'objects') as $status ) {
Note: See TracChangeset for help on using the changeset viewer.