Make WordPress Core


Ignore:
Timestamp:
07/10/2020 04:02:00 PM (6 years ago)
Author:
SergeyBiryukov
Message:

Administration: Bring some consistency to handling list table view modes.

  • Remove duplicate variables and DocBlocks.
  • Add missing description for the $mode global.
  • Use sentence case for "Compact view" and "Extended view" labels.

Follow-up to [48398], [48423].

Props afercia, Offereins, SergeyBiryukov.
See #49715.

File:
1 edited

Legend:

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

    r47557 r48424  
    2525
    2626        /**
     27         * @global string $mode       List table view mode.
    2728         * @global string $usersearch
    2829         * @global string $role
    29          * @global string $mode
    3030         */
    3131        public function prepare_items() {
    32                 global $usersearch, $role, $mode;
     32                global $mode, $usersearch, $role;
     33
     34                if ( ! empty( $_REQUEST['mode'] ) ) {
     35                        $mode = 'excerpt' === $_REQUEST['mode'] ? 'excerpt' : 'list';
     36                        set_user_setting( 'network_users_list_mode', $mode );
     37                } else {
     38                        $mode = get_user_setting( 'network_users_list_mode', 'list' );
     39                }
    3340
    3441                $usersearch = isset( $_REQUEST['s'] ) ? wp_unslash( trim( $_REQUEST['s'] ) ) : '';
    … …  
    8289                if ( isset( $_REQUEST['order'] ) ) {
    8390                        $args['order'] = $_REQUEST['order'];
    84                 }
    85 
    86                 if ( ! empty( $_REQUEST['mode'] ) ) {
    87                         $mode = 'excerpt' === $_REQUEST['mode'] ? 'excerpt' : 'list';
    88                         set_user_setting( 'network_users_list_mode', $mode );
    89                 } else {
    90                         $mode = get_user_setting( 'network_users_list_mode', 'list' );
    9191                }
    9292
    … …  
    423423                        $actions = apply_filters( 'ms_user_list_site_actions', $actions, $val->userblog_id );
    424424
    425                         $i            = 0;
    426425                        $action_count = count( $actions );
     426
     427                        $i = 0;
     428
    427429                        foreach ( $actions as $action => $link ) {
    428430                                ++$i;
    429                                 $sep = ( $i == $action_count ) ? '' : ' | ';
     431
     432                                $sep = ( $i < $action_count ) ? ' | ' : '';
     433
    430434                                echo "<span class='$action'>$link$sep</span>";
    431435                        }
     436
    432437                        echo '</small></span><br/>';
    433438                }
Note: See TracChangeset for help on using the changeset viewer.