Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (8 years ago)
Author:
pento
Message:

Code is Poetry.
WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.

File:
1 edited

Legend:

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

    r42257 r42343  
    1818class WP_MS_Users_List_Table extends WP_List_Table {
    1919    /**
    20      *
    2120     * @return bool
    2221     */
     
    2625
    2726    /**
    28      *
    2927     * @global string $usersearch
    3028     * @global string $role
     
    4442
    4543        $args = array(
    46             'number' => $users_per_page,
    47             'offset' => ( $paged-1 ) * $users_per_page,
    48             'search' => $usersearch,
     44            'number'  => $users_per_page,
     45            'offset'  => ( $paged - 1 ) * $users_per_page,
     46            'search'  => $usersearch,
    4947            'blog_id' => 0,
    50             'fields' => 'all_with_meta'
     48            'fields'  => 'all_with_meta',
    5149        );
    5250
    5351        if ( wp_is_large_network( 'users' ) ) {
    5452            $args['search'] = ltrim( $args['search'], '*' );
    55         } else if ( '' !== $args['search'] ) {
     53        } elseif ( '' !== $args['search'] ) {
    5654            $args['search'] = trim( $args['search'], '*' );
    5755            $args['search'] = '*' . $args['search'] . '*';
     
    5957
    6058        if ( $role === 'super' ) {
    61             $logins = implode( "', '", get_super_admins() );
     59            $logins          = implode( "', '", get_super_admins() );
    6260            $args['include'] = $wpdb->get_col( "SELECT ID FROM $wpdb->users WHERE user_login IN ('$logins')" );
    6361        }
     
    6866         * expensive count queries.
    6967         */
    70         if ( !$usersearch && wp_is_large_network( 'users' ) ) {
    71             if ( !isset($_REQUEST['orderby']) )
     68        if ( ! $usersearch && wp_is_large_network( 'users' ) ) {
     69            if ( ! isset( $_REQUEST['orderby'] ) ) {
    7270                $_GET['orderby'] = $_REQUEST['orderby'] = 'id';
    73             if ( !isset($_REQUEST['order']) )
     71            }
     72            if ( ! isset( $_REQUEST['order'] ) ) {
    7473                $_GET['order'] = $_REQUEST['order'] = 'DESC';
     74            }
    7575            $args['count_total'] = false;
    7676        }
    7777
    78         if ( isset( $_REQUEST['orderby'] ) )
     78        if ( isset( $_REQUEST['orderby'] ) ) {
    7979            $args['orderby'] = $_REQUEST['orderby'];
    80 
    81         if ( isset( $_REQUEST['order'] ) )
     80        }
     81
     82        if ( isset( $_REQUEST['order'] ) ) {
    8283            $args['order'] = $_REQUEST['order'];
     84        }
    8385
    8486        if ( ! empty( $_REQUEST['mode'] ) ) {
     
    9799        $this->items = $wp_user_search->get_results();
    98100
    99         $this->set_pagination_args( array(
    100             'total_items' => $wp_user_search->get_total(),
    101             'per_page' => $users_per_page,
    102         ) );
    103     }
    104 
    105     /**
    106      *
     101        $this->set_pagination_args(
     102            array(
     103                'total_items' => $wp_user_search->get_total(),
     104                'per_page'    => $users_per_page,
     105            )
     106        );
     107    }
     108
     109    /**
    107110     * @return array
    108111     */
    109112    protected function get_bulk_actions() {
    110113        $actions = array();
    111         if ( current_user_can( 'delete_users' ) )
     114        if ( current_user_can( 'delete_users' ) ) {
    112115            $actions['delete'] = __( 'Delete' );
    113         $actions['spam'] = _x( 'Mark as Spam', 'user' );
     116        }
     117        $actions['spam']    = _x( 'Mark as Spam', 'user' );
    114118        $actions['notspam'] = _x( 'Not Spam', 'user' );
    115119
     
    124128
    125129    /**
    126      *
    127130     * @global string $role
    128131     * @return array
     
    131134        global $role;
    132135
    133         $total_users = get_user_count();
     136        $total_users  = get_user_count();
    134137        $super_admins = get_super_admins();
    135138        $total_admins = count( $super_admins );
    136139
    137140        $current_link_attributes = $role !== 'super' ? ' class="current" aria-current="page"' : '';
    138         $role_links = array();
    139         $role_links['all'] = "<a href='" . network_admin_url( 'users.php' ) . "'$current_link_attributes>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_users, 'users' ), number_format_i18n( $total_users ) ) . '</a>';
     141        $role_links              = array();
     142        $role_links['all']       = "<a href='" . network_admin_url( 'users.php' ) . "'$current_link_attributes>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_users, 'users' ), number_format_i18n( $total_users ) ) . '</a>';
    140143        $current_link_attributes = $role === 'super' ? ' class="current" aria-current="page"' : '';
    141         $role_links['super'] = "<a href='" . network_admin_url( 'users.php?role=super' ) . "'$current_link_attributes>" . sprintf( _n( 'Super Admin <span class="count">(%s)</span>', 'Super Admins <span class="count">(%s)</span>', $total_admins ), number_format_i18n( $total_admins ) ) . '</a>';
     144        $role_links['super']     = "<a href='" . network_admin_url( 'users.php?role=super' ) . "'$current_link_attributes>" . sprintf( _n( 'Super Admin <span class="count">(%s)</span>', 'Super Admins <span class="count">(%s)</span>', $total_admins ), number_format_i18n( $total_admins ) ) . '</a>';
    142145
    143146        return $role_links;
     
    152155        global $mode;
    153156
    154         parent::pagination ( $which );
     157        parent::pagination( $which );
    155158
    156159        if ( 'top' === $which ) {
     
    160163
    161164    /**
    162      *
    163165     * @return array
    164166     */
     
    170172            'email'      => __( 'Email' ),
    171173            'registered' => _x( 'Registered', 'user' ),
    172             'blogs'      => __( 'Sites' )
     174            'blogs'      => __( 'Sites' ),
    173175        );
    174176        /**
     
    184186
    185187    /**
    186      *
    187188     * @return array
    188189     */
     
    209210        ?>
    210211        <label class="screen-reader-text" for="blog_<?php echo $user->ID; ?>"><?php echo sprintf( __( 'Select %s' ), $user->user_login ); ?></label>
    211         <input type="checkbox" id="blog_<?php echo $user->ID ?>" name="allusers[]" value="<?php echo esc_attr( $user->ID ) ?>" />
     212        <input type="checkbox" id="blog_<?php echo $user->ID; ?>" name="allusers[]" value="<?php echo esc_attr( $user->ID ); ?>" />
    212213        <?php
    213214    }
     
    233234    public function column_username( $user ) {
    234235        $super_admins = get_super_admins();
    235         $avatar = get_avatar( $user->user_email, 32 );
     236        $avatar       = get_avatar( $user->user_email, 32 );
    236237
    237238        echo $avatar;
     
    239240        if ( current_user_can( 'edit_user', $user->ID ) ) {
    240241            $edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), get_edit_user_link( $user->ID ) ) );
    241             $edit = "<a href=\"{$edit_link}\">{$user->user_login}</a>";
     242            $edit      = "<a href=\"{$edit_link}\">{$user->user_login}</a>";
    242243        } else {
    243244            $edit = $user->user_login;
     
    339340            }
    340341
    341             $path   = ( $val->path === '/' ) ? '' : $val->path;
     342            $path = ( $val->path === '/' ) ? '' : $val->path;
    342343            echo '<span class="site-' . $val->site_id . '" >';
    343             echo '<a href="'. esc_url( network_admin_url( 'site-info.php?id=' . $val->userblog_id ) ) .'">' . str_replace( '.' . get_network()->domain, '', $val->domain . $path ) . '</a>';
     344            echo '<a href="' . esc_url( network_admin_url( 'site-info.php?id=' . $val->userblog_id ) ) . '">' . str_replace( '.' . get_network()->domain, '', $val->domain . $path ) . '</a>';
    344345            echo ' <small class="row-actions">';
    345             $actions = array();
    346             $actions['edit'] = '<a href="'. esc_url( network_admin_url( 'site-info.php?id=' . $val->userblog_id ) ) .'">' . __( 'Edit' ) . '</a>';
     346            $actions         = array();
     347            $actions['edit'] = '<a href="' . esc_url( network_admin_url( 'site-info.php?id=' . $val->userblog_id ) ) . '">' . __( 'Edit' ) . '</a>';
    347348
    348349            $class = '';
     
    374375            $actions = apply_filters( 'ms_user_list_site_actions', $actions, $val->userblog_id );
    375376
    376             $i=0;
     377            $i            = 0;
    377378            $action_count = count( $actions );
    378379            foreach ( $actions as $action => $link ) {
     
    402403            $class = '';
    403404
    404             $status_list = array( 'spam' => 'site-spammed', 'deleted' => 'site-deleted' );
     405            $status_list = array(
     406                'spam'    => 'site-spammed',
     407                'deleted' => 'site-deleted',
     408            );
    405409
    406410            foreach ( $status_list as $status => $col ) {
     
    449453
    450454        if ( current_user_can( 'edit_user', $user->ID ) ) {
    451             $edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), get_edit_user_link( $user->ID ) ) );
     455            $edit_link       = esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), get_edit_user_link( $user->ID ) ) );
    452456            $actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';
    453457        }
Note: See TracChangeset for help on using the changeset viewer.