Make WordPress Core

Changeset 54070


Ignore:
Timestamp:
09/05/2022 04:00:16 PM (4 years ago)
Author:
SergeyBiryukov
Message:

Coding Standards: Use more meaningful variable names in WP_Users_List_Table.

This renames some variables for clarity, per the Naming Conventions:

Don’t abbreviate variable names unnecessarily; let the code be unambiguous and self-documenting.

  • $c is renamed to $columns in ::get_columns() and ::get_sortable_columns().
  • $r is renamed to $row in ::single_row().

Follow-up to [3677], [5542], [6852], [8936], [15491], [16573].

Props burhandodhy, costdev, mukesh27, Presskopp.
See #56448, #55647.

File:
1 edited

Legend:

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

    r53501 r54070  
    366366         */
    367367        public function get_columns() {
    368                 $c = array(
     368                $columns = array(
    369369                        'cb'       => '<input type="checkbox" />',
    370370                        'username' => __( 'Username' ),
     
    376376
    377377                if ( $this->is_site_users ) {
    378                         unset( $c['posts'] );
    379                 }
    380 
    381                 return $c;
     378                        unset( $columns['posts'] );
     379                }
     380
     381                return $columns;
    382382        }
    383383
     
    390390         */
    391391        protected function get_sortable_columns() {
    392                 $c = array(
     392                $columns = array(
    393393                        'username' => 'login',
    394394                        'email'    => 'email',
    395395                );
    396396
    397                 return $c;
     397                return $columns;
    398398        }
    399399
     
    538538                $roles_list = implode( ', ', $user_roles );
    539539
    540                 $r = "<tr id='user-$user_object->ID'>";
     540                $row = "<tr id='user-$user_object->ID'>";
    541541
    542542                list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info();
     
    560560
    561561                        if ( 'cb' === $column_name ) {
    562                                 $r .= "<th scope='row' class='check-column'>$checkbox</th>";
     562                                $row .= "<th scope='row' class='check-column'>$checkbox</th>";
    563563                        } else {
    564                                 $r .= "<td $attributes>";
     564                                $row .= "<td $attributes>";
    565565                                switch ( $column_name ) {
    566566                                        case 'username':
    567                                                 $r .= "$avatar $edit";
     567                                                $row .= "$avatar $edit";
    568568                                                break;
    569569                                        case 'name':
    570570                                                if ( $user_object->first_name && $user_object->last_name ) {
    571                                                         $r .= sprintf(
     571                                                        $row .= sprintf(
    572572                                                                /* translators: 1: User's first name, 2: Last name. */
    573573                                                                _x( '%1$s %2$s', 'Display name based on first name and last name' ),
     
    576576                                                        );
    577577                                                } elseif ( $user_object->first_name ) {
    578                                                         $r .= $user_object->first_name;
     578                                                        $row .= $user_object->first_name;
    579579                                                } elseif ( $user_object->last_name ) {
    580                                                         $r .= $user_object->last_name;
     580                                                        $row .= $user_object->last_name;
    581581                                                } else {
    582                                                         $r .= sprintf(
     582                                                        $row .= sprintf(
    583583                                                                '<span aria-hidden="true">&#8212;</span><span class="screen-reader-text">%s</span>',
    584584                                                                _x( 'Unknown', 'name' )
     
    587587                                                break;
    588588                                        case 'email':
    589                                                 $r .= "<a href='" . esc_url( "mailto:$email" ) . "'>$email</a>";
     589                                                $row .= "<a href='" . esc_url( "mailto:$email" ) . "'>$email</a>";
    590590                                                break;
    591591                                        case 'role':
    592                                                 $r .= esc_html( $roles_list );
     592                                                $row .= esc_html( $roles_list );
    593593                                                break;
    594594                                        case 'posts':
    595595                                                if ( $numposts > 0 ) {
    596                                                         $r .= sprintf(
     596                                                        $row .= sprintf(
    597597                                                                '<a href="%s" class="edit"><span aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></a>',
    598598                                                                "edit.php?author={$user_object->ID}",
     
    605605                                                        );
    606606                                                } else {
    607                                                         $r .= 0;
     607                                                        $row .= 0;
    608608                                                }
    609609                                                break;
     
    618618                                                 * @param int    $user_id     ID of the currently-listed user.
    619619                                                 */
    620                                                 $r .= apply_filters( 'manage_users_custom_column', '', $column_name, $user_object->ID );
     620                                                $row .= apply_filters( 'manage_users_custom_column', '', $column_name, $user_object->ID );
    621621                                }
    622622
    623623                                if ( $primary === $column_name ) {
    624                                         $r .= $this->row_actions( $actions );
     624                                        $row .= $this->row_actions( $actions );
    625625                                }
    626                                 $r .= '</td>';
    627                         }
    628                 }
    629                 $r .= '</tr>';
    630 
    631                 return $r;
     626                                $row .= '</td>';
     627                        }
     628                }
     629                $row .= '</tr>';
     630
     631                return $row;
    632632        }
    633633
Note: See TracChangeset for help on using the changeset viewer.