Make WordPress Core

Changeset 52689


Ignore:
Timestamp:
02/07/2022 03:24:27 PM (2 years ago)
Author:
SergeyBiryukov
Message:

Coding Standards: Rename the $profileuser variable to $profile_user in wp-admin/user-edit.php.

This brings the naming more in line with other variables like $current_user.

Follow-up to [2872].

See #54728.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/user-edit.php

    r52687 r52689  
    186186        // Intentional fall-through to display $errors.
    187187    default:
    188         $profileuser = get_user_to_edit( $user_id );
     188        $profile_user = get_user_to_edit( $user_id );
    189189
    190190        if ( ! current_user_can( 'edit_user', $user_id ) ) {
     
    192192        }
    193193
    194         $title    = sprintf( $title, $profileuser->display_name );
    195         $sessions = WP_Session_Tokens::get_instance( $profileuser->ID );
     194        $title    = sprintf( $title, $profile_user->display_name );
     195        $sessions = WP_Session_Tokens::get_instance( $profile_user->ID );
    196196
    197197        require_once ABSPATH . 'wp-admin/admin-header.php';
    198198        ?>
    199199
    200         <?php if ( ! IS_PROFILE_PAGE && is_super_admin( $profileuser->ID ) && current_user_can( 'manage_network_options' ) ) { ?>
     200        <?php if ( ! IS_PROFILE_PAGE && is_super_admin( $profile_user->ID ) && current_user_can( 'manage_network_options' ) ) { ?>
    201201    <div class="notice notice-info"><p><strong><?php _e( 'Important:' ); ?></strong> <?php _e( 'This user has super admin privileges.' ); ?></p></div>
    202202<?php } ?>
     
    271271        <th scope="row"><?php _e( 'Visual Editor' ); ?></th>
    272272        <td>
    273             <label for="rich_editing"><input name="rich_editing" type="checkbox" id="rich_editing" value="false" <?php checked( 'false', $profileuser->rich_editing ); ?> />
     273            <label for="rich_editing"><input name="rich_editing" type="checkbox" id="rich_editing" value="false" <?php checked( 'false', $profile_user->rich_editing ); ?> />
    274274                <?php _e( 'Disable the visual editor when writing' ); ?>
    275275            </label>
     
    280280        $show_syntax_highlighting_preference = (
    281281        // For Custom HTML widget and Additional CSS in Customizer.
    282         user_can( $profileuser, 'edit_theme_options' )
     282        user_can( $profile_user, 'edit_theme_options' )
    283283        ||
    284284        // Edit plugins.
    285         user_can( $profileuser, 'edit_plugins' )
     285        user_can( $profile_user, 'edit_plugins' )
    286286        ||
    287287        // Edit themes.
    288         user_can( $profileuser, 'edit_themes' )
     288        user_can( $profile_user, 'edit_themes' )
    289289        );
    290290        ?>
     
    294294        <th scope="row"><?php _e( 'Syntax Highlighting' ); ?></th>
    295295        <td>
    296             <label for="syntax_highlighting"><input name="syntax_highlighting" type="checkbox" id="syntax_highlighting" value="false" <?php checked( 'false', $profileuser->syntax_highlighting ); ?> />
     296            <label for="syntax_highlighting"><input name="syntax_highlighting" type="checkbox" id="syntax_highlighting" value="false" <?php checked( 'false', $profile_user->syntax_highlighting ); ?> />
    297297                <?php _e( 'Disable syntax highlighting when editing code' ); ?>
    298298            </label>
     
    328328        <td>
    329329            <label for="comment_shortcuts">
    330                 <input type="checkbox" name="comment_shortcuts" id="comment_shortcuts" value="true" <?php checked( 'true', $profileuser->comment_shortcuts ); ?> />
     330                <input type="checkbox" name="comment_shortcuts" id="comment_shortcuts" value="true" <?php checked( 'true', $profile_user->comment_shortcuts ); ?> />
    331331                <?php _e( 'Enable keyboard shortcuts for comment moderation.' ); ?>
    332332            </label>
     
    340340        <td>
    341341            <label for="admin_bar_front">
    342                 <input name="admin_bar_front" type="checkbox" id="admin_bar_front" value="1"<?php checked( _get_admin_bar_pref( 'front', $profileuser->ID ) ); ?> />
     342                <input name="admin_bar_front" type="checkbox" id="admin_bar_front" value="1"<?php checked( _get_admin_bar_pref( 'front', $profile_user->ID ) ); ?> />
    343343                <?php _e( 'Show Toolbar when viewing site' ); ?>
    344344            </label><br />
     
    357357        <td>
    358358            <?php
    359                 $user_locale = $profileuser->locale;
     359                $user_locale = $profile_user->locale;
    360360
    361361            if ( 'en_US' === $user_locale ) {
     
    388388         * @since 2.7.0
    389389         *
    390          * @param WP_User $profileuser The current WP_User object.
     390         * @param WP_User $profile_user The current WP_User object.
    391391         */
    392         do_action( 'personal_options', $profileuser );
     392        do_action( 'personal_options', $profile_user );
    393393        ?>
    394394
     
    403403             * @since 2.0.0
    404404             *
    405              * @param WP_User $profileuser The current WP_User object.
     405             * @param WP_User $profile_user The current WP_User object.
    406406             */
    407             do_action( 'profile_personal_options', $profileuser );
     407            do_action( 'profile_personal_options', $profile_user );
    408408        }
    409409        ?>
     
    414414    <tr class="user-user-login-wrap">
    415415        <th><label for="user_login"><?php _e( 'Username' ); ?></label></th>
    416         <td><input type="text" name="user_login" id="user_login" value="<?php echo esc_attr( $profileuser->user_login ); ?>" disabled="disabled" class="regular-text" /> <span class="description"><?php _e( 'Usernames cannot be changed.' ); ?></span></td>
    417     </tr>
    418 
    419         <?php if ( ! IS_PROFILE_PAGE && ! is_network_admin() && current_user_can( 'promote_user', $profileuser->ID ) ) : ?>
     416        <td><input type="text" name="user_login" id="user_login" value="<?php echo esc_attr( $profile_user->user_login ); ?>" disabled="disabled" class="regular-text" /> <span class="description"><?php _e( 'Usernames cannot be changed.' ); ?></span></td>
     417    </tr>
     418
     419        <?php if ( ! IS_PROFILE_PAGE && ! is_network_admin() && current_user_can( 'promote_user', $profile_user->ID ) ) : ?>
    420420<tr class="user-role-wrap"><th><label for="role"><?php _e( 'Role' ); ?></label></th>
    421421<td><select name="role" id="role">
    422422            <?php
    423423            // Compare user role against currently editable roles.
    424             $user_roles = array_intersect( array_values( $profileuser->roles ), array_keys( get_editable_roles() ) );
     424            $user_roles = array_intersect( array_values( $profile_user->roles ), array_keys( get_editable_roles() ) );
    425425            $user_role  = reset( $user_roles );
    426426
     
    443443<tr class="user-super-admin-wrap"><th><?php _e( 'Super Admin' ); ?></th>
    444444<td>
    445             <?php if ( 0 !== strcasecmp( $profileuser->user_email, get_site_option( 'admin_email' ) ) || ! is_super_admin( $profileuser->ID ) ) : ?>
    446 <p><label><input type="checkbox" id="super_admin" name="super_admin"<?php checked( is_super_admin( $profileuser->ID ) ); ?> /> <?php _e( 'Grant this user super admin privileges for the Network.' ); ?></label></p>
     445            <?php if ( 0 !== strcasecmp( $profile_user->user_email, get_site_option( 'admin_email' ) ) || ! is_super_admin( $profile_user->ID ) ) : ?>
     446<p><label><input type="checkbox" id="super_admin" name="super_admin"<?php checked( is_super_admin( $profile_user->ID ) ); ?> /> <?php _e( 'Grant this user super admin privileges for the Network.' ); ?></label></p>
    447447<?php else : ?>
    448448<p><?php _e( 'Super admin privileges cannot be removed because this user has the network admin email.' ); ?></p>
     
    453453<tr class="user-first-name-wrap">
    454454    <th><label for="first_name"><?php _e( 'First Name' ); ?></label></th>
    455     <td><input type="text" name="first_name" id="first_name" value="<?php echo esc_attr( $profileuser->first_name ); ?>" class="regular-text" /></td>
     455    <td><input type="text" name="first_name" id="first_name" value="<?php echo esc_attr( $profile_user->first_name ); ?>" class="regular-text" /></td>
    456456</tr>
    457457
    458458<tr class="user-last-name-wrap">
    459459    <th><label for="last_name"><?php _e( 'Last Name' ); ?></label></th>
    460     <td><input type="text" name="last_name" id="last_name" value="<?php echo esc_attr( $profileuser->last_name ); ?>" class="regular-text" /></td>
     460    <td><input type="text" name="last_name" id="last_name" value="<?php echo esc_attr( $profile_user->last_name ); ?>" class="regular-text" /></td>
    461461</tr>
    462462
    463463<tr class="user-nickname-wrap">
    464464    <th><label for="nickname"><?php _e( 'Nickname' ); ?> <span class="description"><?php _e( '(required)' ); ?></span></label></th>
    465     <td><input type="text" name="nickname" id="nickname" value="<?php echo esc_attr( $profileuser->nickname ); ?>" class="regular-text" /></td>
     465    <td><input type="text" name="nickname" id="nickname" value="<?php echo esc_attr( $profile_user->nickname ); ?>" class="regular-text" /></td>
    466466</tr>
    467467
     
    472472        <?php
    473473            $public_display                     = array();
    474             $public_display['display_nickname'] = $profileuser->nickname;
    475             $public_display['display_username'] = $profileuser->user_login;
    476 
    477         if ( ! empty( $profileuser->first_name ) ) {
    478             $public_display['display_firstname'] = $profileuser->first_name;
    479         }
    480 
    481         if ( ! empty( $profileuser->last_name ) ) {
    482             $public_display['display_lastname'] = $profileuser->last_name;
    483         }
    484 
    485         if ( ! empty( $profileuser->first_name ) && ! empty( $profileuser->last_name ) ) {
    486             $public_display['display_firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name;
    487             $public_display['display_lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name;
    488         }
    489 
    490         if ( ! in_array( $profileuser->display_name, $public_display, true ) ) { // Only add this if it isn't duplicated elsewhere.
    491             $public_display = array( 'display_displayname' => $profileuser->display_name ) + $public_display;
     474            $public_display['display_nickname'] = $profile_user->nickname;
     475            $public_display['display_username'] = $profile_user->user_login;
     476
     477        if ( ! empty( $profile_user->first_name ) ) {
     478            $public_display['display_firstname'] = $profile_user->first_name;
     479        }
     480
     481        if ( ! empty( $profile_user->last_name ) ) {
     482            $public_display['display_lastname'] = $profile_user->last_name;
     483        }
     484
     485        if ( ! empty( $profile_user->first_name ) && ! empty( $profile_user->last_name ) ) {
     486            $public_display['display_firstlast'] = $profile_user->first_name . ' ' . $profile_user->last_name;
     487            $public_display['display_lastfirst'] = $profile_user->last_name . ' ' . $profile_user->first_name;
     488        }
     489
     490        if ( ! in_array( $profile_user->display_name, $public_display, true ) ) { // Only add this if it isn't duplicated elsewhere.
     491            $public_display = array( 'display_displayname' => $profile_user->display_name ) + $public_display;
    492492        }
    493493
     
    497497        foreach ( $public_display as $id => $item ) {
    498498            ?>
    499         <option <?php selected( $profileuser->display_name, $item ); ?>><?php echo $item; ?></option>
     499        <option <?php selected( $profile_user->display_name, $item ); ?>><?php echo $item; ?></option>
    500500            <?php
    501501        }
     
    511511    <tr class="user-email-wrap">
    512512        <th><label for="email"><?php _e( 'Email' ); ?> <span class="description"><?php _e( '(required)' ); ?></span></label></th>
    513         <td><input type="email" name="email" id="email" aria-describedby="email-description" value="<?php echo esc_attr( $profileuser->user_email ); ?>" class="regular-text ltr" />
    514         <?php
    515         if ( $profileuser->ID === $current_user->ID ) :
     513        <td><input type="email" name="email" id="email" aria-describedby="email-description" value="<?php echo esc_attr( $profile_user->user_email ); ?>" class="regular-text ltr" />
     514        <?php
     515        if ( $profile_user->ID === $current_user->ID ) :
    516516            ?>
    517517        <p class="description" id="email-description">
     
    522522
    523523        $new_email = get_user_meta( $current_user->ID, '_new_email', true );
    524         if ( $new_email && $new_email['newemail'] !== $current_user->user_email && $profileuser->ID === $current_user->ID ) :
     524        if ( $new_email && $new_email['newemail'] !== $current_user->user_email && $profile_user->ID === $current_user->ID ) :
    525525            ?>
    526526        <div class="updated inline">
     
    546546    <tr class="user-url-wrap">
    547547    <th><label for="url"><?php _e( 'Website' ); ?></label></th>
    548     <td><input type="url" name="url" id="url" value="<?php echo esc_attr( $profileuser->user_url ); ?>" class="regular-text code" /></td>
    549     </tr>
    550 
    551         <?php
    552         foreach ( wp_get_user_contact_methods( $profileuser ) as $name => $desc ) {
     548    <td><input type="url" name="url" id="url" value="<?php echo esc_attr( $profile_user->user_url ); ?>" class="regular-text code" /></td>
     549    </tr>
     550
     551        <?php
     552        foreach ( wp_get_user_contact_methods( $profile_user ) as $name => $desc ) {
    553553            ?>
    554554    <tr class="user-<?php echo $name; ?>-wrap">
     
    568568            ?>
    569569    </label></th>
    570     <td><input type="text" name="<?php echo $name; ?>" id="<?php echo $name; ?>" value="<?php echo esc_attr( $profileuser->$name ); ?>" class="regular-text" /></td>
     570    <td><input type="text" name="<?php echo $name; ?>" id="<?php echo $name; ?>" value="<?php echo esc_attr( $profile_user->$name ); ?>" class="regular-text" /></td>
    571571    </tr>
    572572            <?php
     
    580580<tr class="user-description-wrap">
    581581    <th><label for="description"><?php _e( 'Biographical Info' ); ?></label></th>
    582     <td><textarea name="description" id="description" rows="5" cols="30"><?php echo $profileuser->description; // textarea_escaped ?></textarea>
     582    <td><textarea name="description" id="description" rows="5" cols="30"><?php echo $profile_user->description; // textarea_escaped ?></textarea>
    583583    <p class="description"><?php _e( 'Share a little biographical information to fill out your profile. This may be shown publicly.' ); ?></p></td>
    584584</tr>
     
    605605             *
    606606             * @since 4.4.0
    607              * @since 4.7.0 Added the `$profileuser` parameter.
    608              *
    609              * @param string  $description The description that will be printed.
    610              * @param WP_User $profileuser The current WP_User object.
     607             * @since 4.7.0 Added the `$profile_user` parameter.
     608             *
     609             * @param string  $description  The description that will be printed.
     610             * @param WP_User $profile_user The current WP_User object.
    611611             */
    612             echo apply_filters( 'user_profile_picture_description', $description, $profileuser );
     612            echo apply_filters( 'user_profile_picture_description', $description, $profile_user );
    613613            ?>
    614614        </p>
     
    621621         *
    622622         * @since 1.5.1
    623          * @since 2.8.0 Added the `$profileuser` parameter.
     623         * @since 2.8.0 Added the `$profile_user` parameter.
    624624         * @since 4.4.0 Now evaluated only in user-edit.php.
    625625         *
    626          * @param bool    $show        Whether to show the password fields. Default true.
    627          * @param WP_User $profileuser User object for the current user to edit.
     626         * @param bool    $show         Whether to show the password fields. Default true.
     627         * @param WP_User $profile_user User object for the current user to edit.
    628628         */
    629         $show_password_fields = apply_filters( 'show_password_fields', true, $profileuser );
     629        $show_password_fields = apply_filters( 'show_password_fields', true, $profile_user );
    630630        if ( $show_password_fields ) :
    631631            ?>
     
    691691            <p class="description">
    692692                <?php
    693                 /* translators: %s: User's display name. */
    694                 printf( __( 'Send %s a link to reset their password. This will not change their password, nor will it force a change.' ), esc_html( $profileuser->display_name ) );
     693                printf(
     694                    /* translators: %s: User's display name. */
     695                    __( 'Send %s a link to reset their password. This will not change their password, nor will it force a change.' ),
     696                    esc_html( $profile_user->display_name )
     697                );
    695698                ?>
    696699            </p>
     
    729732                <?php
    730733                /* translators: %s: User's display name. */
    731                 printf( __( 'Log %s out of all locations.' ), $profileuser->display_name );
     734                printf( __( 'Log %s out of all locations.' ), $profile_user->display_name );
    732735                ?>
    733736            </p>
     
    782785                 * @since 5.6.0
    783786                 *
    784                  * @param WP_User $profileuser The current WP_User object.
     787                 * @param WP_User $profile_user The current WP_User object.
    785788                 */
    786                 do_action( 'wp_create_application_password_form', $profileuser );
     789                do_action( 'wp_create_application_password_form', $profile_user );
    787790                ?>
    788791
     
    826829             * @since 2.0.0
    827830             *
    828              * @param WP_User $profileuser The current WP_User object.
     831             * @param WP_User $profile_user The current WP_User object.
    829832             */
    830             do_action( 'show_user_profile', $profileuser );
     833            do_action( 'show_user_profile', $profile_user );
    831834        } else {
    832835            /**
     
    835838             * @since 2.0.0
    836839             *
    837              * @param WP_User $profileuser The current WP_User object.
     840             * @param WP_User $profile_user The current WP_User object.
    838841             */
    839             do_action( 'edit_user_profile', $profileuser );
     842            do_action( 'edit_user_profile', $profile_user );
    840843        }
    841844        ?>
     
    851854         * @since 2.8.0
    852855         *
    853          * @param bool    $enable      Whether to display the capabilities. Default true.
    854          * @param WP_User $profileuser The current WP_User object.
     856         * @param bool    $enable       Whether to display the capabilities. Default true.
     857         * @param WP_User $profile_user The current WP_User object.
    855858         */
    856         if ( count( $profileuser->caps ) > count( $profileuser->roles )
    857         && apply_filters( 'additional_capabilities_display', true, $profileuser )
     859        if ( count( $profile_user->caps ) > count( $profile_user->roles )
     860            && apply_filters( 'additional_capabilities_display', true, $profile_user )
    858861        ) :
    859862            ?>
     
    865868            <?php
    866869            $output = '';
    867             foreach ( $profileuser->caps as $cap => $value ) {
     870            foreach ( $profile_user->caps as $cap => $value ) {
    868871                if ( ! $wp_roles->is_role( $cap ) ) {
    869872                    if ( '' !== $output ) {
Note: See TracChangeset for help on using the changeset viewer.