Make WordPress Core

Ticket #54673: 54673-2.diff

File 54673-2.diff, 55.4 KB (added by johnregan3, 3 years ago)

Removed errant personal .gitignore changes.

  • src/wp-admin/user-edit.php

    diff --git src/wp-admin/user-edit.php src/wp-admin/user-edit.php
    index 45fe5ecea3..ad0da5c8f0 100644
    switch ( $action ) { 
    197197                require_once ABSPATH . 'wp-admin/admin-header.php';
    198198                ?>
    199199
    200                 <?php if ( ! IS_PROFILE_PAGE && is_super_admin( $profile_user->ID ) && current_user_can( 'manage_network_options' ) ) { ?>
    201         <div class="notice notice-info"><p><strong><?php _e( 'Important:' ); ?></strong> <?php _e( 'This user has super admin privileges.' ); ?></p></div>
    202 <?php } ?>
    203                 <?php if ( isset( $_GET['updated'] ) ) : ?>
    204 <div id="message" class="updated notice is-dismissible">
    205                         <?php if ( IS_PROFILE_PAGE ) : ?>
    206         <p><strong><?php _e( 'Profile updated.' ); ?></strong></p>
    207         <?php else : ?>
    208         <p><strong><?php _e( 'User updated.' ); ?></strong></p>
    209         <?php endif; ?>
    210                         <?php if ( $wp_http_referer && false === strpos( $wp_http_referer, 'user-new.php' ) && ! IS_PROFILE_PAGE ) : ?>
    211         <p><a href="<?php echo esc_url( wp_validate_redirect( esc_url_raw( $wp_http_referer ), self_admin_url( 'users.php' ) ) ); ?>"><?php _e( '&larr; Go to Users' ); ?></a></p>
    212         <?php endif; ?>
    213 </div>
    214                 <?php endif; ?>
    215                 <?php if ( isset( $_GET['error'] ) ) : ?>
    216 <div class="notice notice-error">
    217                         <?php if ( 'new-email' === $_GET['error'] ) : ?>
    218         <p><?php _e( 'Error while saving the new email address. Please try again.' ); ?></p>
    219         <?php endif; ?>
    220 </div>
    221                 <?php endif; ?>
    222                 <?php if ( isset( $errors ) && is_wp_error( $errors ) ) : ?>
    223 <div class="error"><p><?php echo implode( "</p>\n<p>", $errors->get_error_messages() ); ?></p></div>
     200                <?php if ( ! IS_PROFILE_PAGE && is_super_admin( $profile_user->ID ) && current_user_can( 'manage_network_options' ) ) : ?>
     201                        <div class="notice notice-info"><p><strong><?php _e( 'Important:' ); ?></strong> <?php _e( 'This user has super admin privileges.' ); ?></p></div>
    224202                <?php endif; ?>
    225203
    226 <div class="wrap" id="profile-page">
    227 <h1 class="wp-heading-inline">
    228                 <?php
    229                 echo esc_html( $title );
    230                 ?>
    231 </h1>
    232 
    233                 <?php
    234                 if ( ! IS_PROFILE_PAGE ) {
    235                         if ( current_user_can( 'create_users' ) ) {
    236                                 ?>
    237                 <a href="user-new.php" class="page-title-action"><?php echo esc_html_x( 'Add New', 'user' ); ?></a>
    238         <?php } elseif ( is_multisite() && current_user_can( 'promote_users' ) ) { ?>
    239                 <a href="user-new.php" class="page-title-action"><?php echo esc_html_x( 'Add Existing', 'user' ); ?></a>
    240                                 <?php
    241         }
    242                 }
    243                 ?>
    244 
    245 <hr class="wp-header-end">
    246 
    247 <form id="your-profile" action="<?php echo esc_url( self_admin_url( IS_PROFILE_PAGE ? 'profile.php' : 'user-edit.php' ) ); ?>" method="post" novalidate="novalidate"
    248                 <?php
    249                 /**
    250                  * Fires inside the your-profile form tag on the user editing screen.
    251                  *
    252                  * @since 3.0.0
    253                  */
    254                 do_action( 'user_edit_form_tag' );
    255                 ?>
    256         >
    257                 <?php wp_nonce_field( 'update-user_' . $user_id ); ?>
    258                 <?php if ( $wp_http_referer ) : ?>
    259         <input type="hidden" name="wp_http_referer" value="<?php echo esc_url( $wp_http_referer ); ?>" />
    260                 <?php endif; ?>
    261 <p>
    262 <input type="hidden" name="from" value="profile" />
    263 <input type="hidden" name="checkuser_id" value="<?php echo get_current_user_id(); ?>" />
    264 </p>
    265 
    266 <h2><?php _e( 'Personal Options' ); ?></h2>
    267 
    268 <table class="form-table" role="presentation">
    269                 <?php if ( ! ( IS_PROFILE_PAGE && ! $user_can_edit ) ) : ?>
    270         <tr class="user-rich-editing-wrap">
    271                 <th scope="row"><?php _e( 'Visual Editor' ); ?></th>
    272                 <td>
    273                         <label for="rich_editing"><input name="rich_editing" type="checkbox" id="rich_editing" value="false" <?php checked( 'false', $profile_user->rich_editing ); ?> />
    274                                 <?php _e( 'Disable the visual editor when writing' ); ?>
    275                         </label>
    276                 </td>
    277         </tr>
    278                 <?php endif; ?>
    279                 <?php
    280                 $show_syntax_highlighting_preference = (
    281                 // For Custom HTML widget and Additional CSS in Customizer.
    282                 user_can( $profile_user, 'edit_theme_options' )
    283                 ||
    284                 // Edit plugins.
    285                 user_can( $profile_user, 'edit_plugins' )
    286                 ||
    287                 // Edit themes.
    288                 user_can( $profile_user, 'edit_themes' )
    289                 );
    290                 ?>
    291 
    292                 <?php if ( $show_syntax_highlighting_preference ) : ?>
    293         <tr class="user-syntax-highlighting-wrap">
    294                 <th scope="row"><?php _e( 'Syntax Highlighting' ); ?></th>
    295                 <td>
    296                         <label for="syntax_highlighting"><input name="syntax_highlighting" type="checkbox" id="syntax_highlighting" value="false" <?php checked( 'false', $profile_user->syntax_highlighting ); ?> />
    297                                 <?php _e( 'Disable syntax highlighting when editing code' ); ?>
    298                         </label>
    299                 </td>
    300         </tr>
     204                <?php if ( isset( $_GET['updated'] ) ) : ?>
     205                        <div id="message" class="updated notice is-dismissible">
     206                                <?php if ( IS_PROFILE_PAGE ) : ?>
     207                                        <p><strong><?php _e( 'Profile updated.' ); ?></strong></p>
     208                                <?php else : ?>
     209                                        <p><strong><?php _e( 'User updated.' ); ?></strong></p>
     210                                <?php endif; ?>
     211                                <?php if ( $wp_http_referer && false === strpos( $wp_http_referer, 'user-new.php' ) && ! IS_PROFILE_PAGE ) : ?>
     212                                        <p><a href="<?php echo esc_url( wp_validate_redirect( esc_url_raw( $wp_http_referer ), self_admin_url( 'users.php' ) ) ); ?>"><?php _e( '&larr; Go to Users' ); ?></a></p>
     213                                <?php endif; ?>
     214                        </div>
    301215                <?php endif; ?>
    302216
    303                 <?php if ( count( $_wp_admin_css_colors ) > 1 && has_action( 'admin_color_scheme_picker' ) ) : ?>
    304         <tr class="user-admin-color-wrap">
    305                 <th scope="row"><?php _e( 'Admin Color Scheme' ); ?></th>
    306                 <td>
    307                         <?php
    308                         /**
    309                          * Fires in the 'Admin Color Scheme' section of the user editing screen.
    310                          *
    311                          * The section is only enabled if a callback is hooked to the action,
    312                          * and if there is more than one defined color scheme for the admin.
    313                          *
    314                          * @since 3.0.0
    315                          * @since 3.8.1 Added `$user_id` parameter.
    316                          *
    317                          * @param int $user_id The user ID.
    318                          */
    319                         do_action( 'admin_color_scheme_picker', $user_id );
    320                         ?>
    321                 </td>
    322         </tr>
    323                 <?php endif; // End if count ( $_wp_admin_css_colors ) > 1 ?>
    324 
    325                 <?php if ( ! ( IS_PROFILE_PAGE && ! $user_can_edit ) ) : ?>
    326         <tr class="user-comment-shortcuts-wrap">
    327                 <th scope="row"><?php _e( 'Keyboard Shortcuts' ); ?></th>
    328                 <td>
    329                         <label for="comment_shortcuts">
    330                                 <input type="checkbox" name="comment_shortcuts" id="comment_shortcuts" value="true" <?php checked( 'true', $profile_user->comment_shortcuts ); ?> />
    331                                 <?php _e( 'Enable keyboard shortcuts for comment moderation.' ); ?>
    332                         </label>
    333                         <?php _e( '<a href="https://wordpress.org/support/article/keyboard-shortcuts/" target="_blank">More information</a>' ); ?>
    334                 </td>
    335         </tr>
     217                <?php if ( isset( $_GET['error'] ) ) : ?>
     218                        <div class="notice notice-error">
     219                        <?php if ( 'new-email' === $_GET['error'] ) : ?>
     220                                <p><?php _e( 'Error while saving the new email address. Please try again.' ); ?></p>
     221                        <?php endif; ?>
     222                        </div>
    336223                <?php endif; ?>
    337224
    338         <tr class="show-admin-bar user-admin-bar-front-wrap">
    339                 <th scope="row"><?php _e( 'Toolbar' ); ?></th>
    340                 <td>
    341                         <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', $profile_user->ID ) ); ?> />
    343                                 <?php _e( 'Show Toolbar when viewing site' ); ?>
    344                         </label><br />
    345                 </td>
    346         </tr>
    347 
    348                 <?php
    349                 $languages = get_available_languages();
    350                 if ( $languages ) :
    351                         ?>
    352         <tr class="user-language-wrap">
    353                 <th scope="row">
    354                         <?php /* translators: The user language selection field label. */ ?>
    355                         <label for="locale"><?php _e( 'Language' ); ?><span class="dashicons dashicons-translation" aria-hidden="true"></span></label>
    356                 </th>
    357                 <td>
    358                         <?php
    359                                 $user_locale = $profile_user->locale;
    360 
    361                         if ( 'en_US' === $user_locale ) {
    362                                 $user_locale = '';
    363                         } elseif ( '' === $user_locale || ! in_array( $user_locale, $languages, true ) ) {
    364                                 $user_locale = 'site-default';
    365                         }
    366 
    367                         wp_dropdown_languages(
    368                                 array(
    369                                         'name'                        => 'locale',
    370                                         'id'                          => 'locale',
    371                                         'selected'                    => $user_locale,
    372                                         'languages'                   => $languages,
    373                                         'show_available_translations' => false,
    374                                         'show_option_site_default'    => true,
    375                                 )
    376                         );
    377                         ?>
    378                 </td>
    379         </tr>
    380                         <?php
    381 endif;
    382                 ?>
    383 
    384                 <?php
    385                 /**
    386                  * Fires at the end of the 'Personal Options' settings table on the user editing screen.
    387                  *
    388                  * @since 2.7.0
    389                  *
    390                  * @param WP_User $profile_user The current WP_User object.
    391                  */
    392                 do_action( 'personal_options', $profile_user );
    393                 ?>
    394 
    395 </table>
    396                 <?php
    397                 if ( IS_PROFILE_PAGE ) {
    398                         /**
    399                          * Fires after the 'Personal Options' settings table on the 'Profile' editing screen.
    400                          *
    401                          * The action only fires if the current user is editing their own profile.
    402                          *
    403                          * @since 2.0.0
    404                          *
    405                          * @param WP_User $profile_user The current WP_User object.
    406                          */
    407                         do_action( 'profile_personal_options', $profile_user );
    408                 }
    409                 ?>
    410 
    411 <h2><?php _e( 'Name' ); ?></h2>
    412 
    413 <table class="form-table" role="presentation">
    414         <tr class="user-user-login-wrap">
    415                 <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( $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 ) ) : ?>
    420 <tr class="user-role-wrap"><th><label for="role"><?php _e( 'Role' ); ?></label></th>
    421 <td><select name="role" id="role">
    422                         <?php
    423                         // Compare user role against currently editable roles.
    424                         $user_roles = array_intersect( array_values( $profile_user->roles ), array_keys( get_editable_roles() ) );
    425                         $user_role  = reset( $user_roles );
    426 
    427                         // Print the full list of roles with the primary one selected.
    428                         wp_dropdown_roles( $user_role );
    429 
    430                         // Print the 'no role' option. Make it selected if the user has no role yet.
    431                         if ( $user_role ) {
    432                                 echo '<option value="">' . __( '&mdash; No role for this site &mdash;' ) . '</option>';
    433                         } else {
    434                                 echo '<option value="" selected="selected">' . __( '&mdash; No role for this site &mdash;' ) . '</option>';
    435                         }
    436                         ?>
    437 </select></td></tr>
    438                         <?php
    439                 endif; // End if ! IS_PROFILE_PAGE.
    440 
    441                 if ( is_multisite() && is_network_admin() && ! IS_PROFILE_PAGE && current_user_can( 'manage_network_options' ) && ! isset( $super_admins ) ) {
    442                         ?>
    443 <tr class="user-super-admin-wrap"><th><?php _e( 'Super Admin' ); ?></th>
    444 <td>
    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>
    447 <?php else : ?>
    448 <p><?php _e( 'Super admin privileges cannot be removed because this user has the network admin email.' ); ?></p>
    449 <?php endif; ?>
    450 </td></tr>
    451                 <?php } ?>
    452 
    453 <tr class="user-first-name-wrap">
    454         <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( $profile_user->first_name ); ?>" class="regular-text" /></td>
    456 </tr>
    457 
    458 <tr class="user-last-name-wrap">
    459         <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( $profile_user->last_name ); ?>" class="regular-text" /></td>
    461 </tr>
    462 
    463 <tr class="user-nickname-wrap">
    464         <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( $profile_user->nickname ); ?>" class="regular-text" /></td>
    466 </tr>
    467 
    468 <tr class="user-display-name-wrap">
    469         <th><label for="display_name"><?php _e( 'Display name publicly as' ); ?></label></th>
    470         <td>
    471                 <select name="display_name" id="display_name">
    472                 <?php
    473                         $public_display                     = array();
    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;
    492                 }
    493 
    494                         $public_display = array_map( 'trim', $public_display );
    495                         $public_display = array_unique( $public_display );
    496 
    497                 foreach ( $public_display as $id => $item ) {
    498                         ?>
    499                 <option <?php selected( $profile_user->display_name, $item ); ?>><?php echo $item; ?></option>
    500                         <?php
    501                 }
    502                 ?>
    503                 </select>
    504                 </td>
    505         </tr>
    506         </table>
    507 
    508         <h2><?php _e( 'Contact Info' ); ?></h2>
    509 
    510         <table class="form-table" role="presentation">
    511         <tr class="user-email-wrap">
    512                 <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( $profile_user->user_email ); ?>" class="regular-text ltr" />
    514                 <?php
    515                 if ( $profile_user->ID === $current_user->ID ) :
    516                         ?>
    517                 <p class="description" id="email-description">
    518                         <?php _e( 'If you change this, we will send you an email at your new address to confirm it. <strong>The new address will not become active until confirmed.</strong>' ); ?>
    519                 </p>
    520                         <?php
    521                 endif;
    522 
    523                 $new_email = get_user_meta( $current_user->ID, '_new_email', true );
    524                 if ( $new_email && $new_email['newemail'] !== $current_user->user_email && $profile_user->ID === $current_user->ID ) :
    525                         ?>
    526                 <div class="updated inline">
    527                 <p>
    528                         <?php
    529                         printf(
    530                                 /* translators: %s: New email. */
    531                                 __( 'There is a pending change of your email to %s.' ),
    532                                 '<code>' . esc_html( $new_email['newemail'] ) . '</code>'
    533                         );
    534                         printf(
    535                                 ' <a href="%1$s">%2$s</a>',
    536                                 esc_url( wp_nonce_url( self_admin_url( 'profile.php?dismiss=' . $current_user->ID . '_new_email' ), 'dismiss-' . $current_user->ID . '_new_email' ) ),
    537                                 __( 'Cancel' )
    538                         );
    539                         ?>
    540                 </p>
    541                 </div>
     225                <?php if ( isset( $errors ) && is_wp_error( $errors ) ) : ?>
     226                        <div class="error">
     227                                <p><?php echo implode( "</p>\n<p>", $errors->get_error_messages() ); ?></p>
     228                        </div>
    542229                <?php endif; ?>
    543         </td>
    544         </tr>
    545 
    546         <tr class="user-url-wrap">
    547         <th><label for="url"><?php _e( 'Website' ); ?></label></th>
    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 ) {
    553                         ?>
    554         <tr class="user-<?php echo $name; ?>-wrap">
    555 <th><label for="<?php echo $name; ?>">
    556                         <?php
    557                         /**
    558                          * Filters a user contactmethod label.
    559                          *
    560                          * The dynamic portion of the hook name, `$name`, refers to
    561                          * each of the keys in the contact methods array.
    562                          *
    563                          * @since 2.9.0
    564                          *
    565                          * @param string $desc The translatable label for the contact method.
    566                          */
    567                         echo apply_filters( "user_{$name}_label", $desc );
    568                         ?>
    569         </label></th>
    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>
    571         </tr>
    572                         <?php
    573                 }
    574                 ?>
    575         </table>
    576 
    577         <h2><?php IS_PROFILE_PAGE ? _e( 'About Yourself' ) : _e( 'About the user' ); ?></h2>
    578 
    579 <table class="form-table" role="presentation">
    580 <tr class="user-description-wrap">
    581         <th><label for="description"><?php _e( 'Biographical Info' ); ?></label></th>
    582         <td><textarea name="description" id="description" rows="5" cols="30"><?php echo $profile_user->description; // textarea_escaped ?></textarea>
    583         <p class="description"><?php _e( 'Share a little biographical information to fill out your profile. This may be shown publicly.' ); ?></p></td>
    584 </tr>
    585 
    586                 <?php if ( get_option( 'show_avatars' ) ) : ?>
    587 <tr class="user-profile-picture">
    588         <th><?php _e( 'Profile Picture' ); ?></th>
    589         <td>
    590                         <?php echo get_avatar( $user_id ); ?>
    591                 <p class="description">
    592                         <?php
    593                         if ( IS_PROFILE_PAGE ) {
    594                                 $description = sprintf(
    595                                         /* translators: %s: Gravatar URL. */
    596                                         __( '<a href="%s">You can change your profile picture on Gravatar</a>.' ),
    597                                         __( 'https://en.gravatar.com/' )
    598                                 );
    599                         } else {
    600                                 $description = '';
    601                         }
    602230
    603                         /**
    604                          * Filters the user profile picture description displayed under the Gravatar.
    605                          *
    606                          * @since 4.4.0
    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.
    611                          */
    612                         echo apply_filters( 'user_profile_picture_description', $description, $profile_user );
    613                         ?>
    614                 </p>
    615         </td>
    616 </tr>
    617 <?php endif; ?>
    618                 <?php
    619                 /**
    620                  * Filters the display of the password fields.
    621                  *
    622                  * @since 1.5.1
    623                  * @since 2.8.0 Added the `$profile_user` parameter.
    624                  * @since 4.4.0 Now evaluated only in user-edit.php.
    625                  *
    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.
    628                  */
    629                 $show_password_fields = apply_filters( 'show_password_fields', true, $profile_user );
    630                 if ( $show_password_fields ) :
    631                         ?>
    632         </table>
    633 
    634         <h2><?php _e( 'Account Management' ); ?></h2>
    635 <table class="form-table" role="presentation">
    636 <tr id="password" class="user-pass1-wrap">
    637         <th><label for="pass1"><?php _e( 'New Password' ); ?></label></th>
    638         <td>
    639                 <input class="hidden" value=" " /><!-- #24364 workaround -->
    640                 <button type="button" class="button wp-generate-pw hide-if-no-js" aria-expanded="false"><?php _e( 'Set New Password' ); ?></button>
    641                 <div class="wp-pwd hide-if-js">
    642                         <span class="password-input-wrapper">
    643                                 <input type="password" name="pass1" id="pass1" class="regular-text" value="" autocomplete="off" data-pw="<?php echo esc_attr( wp_generate_password( 24 ) ); ?>" aria-describedby="pass-strength-result" />
    644                         </span>
    645                         <button type="button" class="button wp-hide-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e( 'Hide password' ); ?>">
    646                                 <span class="dashicons dashicons-hidden" aria-hidden="true"></span>
    647                                 <span class="text"><?php _e( 'Hide' ); ?></span>
    648                         </button>
    649                         <button type="button" class="button wp-cancel-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e( 'Cancel password change' ); ?>">
    650                                 <span class="dashicons dashicons-no" aria-hidden="true"></span>
    651                                 <span class="text"><?php _e( 'Cancel' ); ?></span>
    652                         </button>
    653                         <div style="display:none" id="pass-strength-result" aria-live="polite"></div>
    654                 </div>
    655         </td>
    656 </tr>
    657 <tr class="user-pass2-wrap hide-if-js">
    658         <th scope="row"><label for="pass2"><?php _e( 'Repeat New Password' ); ?></label></th>
    659         <td>
    660         <input name="pass2" type="password" id="pass2" class="regular-text" value="" autocomplete="off" aria-describedby="pass2-desc" />
    661                         <?php if ( IS_PROFILE_PAGE ) : ?>
    662                                 <p class="description" id="pass2-desc"><?php _e( 'Type your new password again.' ); ?></p>
    663                         <?php else : ?>
    664                                 <p class="description" id="pass2-desc"><?php _e( 'Type the new password again.' ); ?></p>
     231                <div class="wrap" id="profile-page">
     232                        <h1 class="wp-heading-inline">
     233                                        <?php echo esc_html( $title ); ?>
     234                        </h1>
     235
     236                        <?php if ( ! IS_PROFILE_PAGE ) : ?>
     237                                <?php if ( current_user_can( 'create_users' ) ) : ?>
     238                                        <a href="user-new.php" class="page-title-action"><?php echo esc_html_x( 'Add New', 'user' ); ?></a>
     239                                <?php elseif ( is_multisite() && current_user_can( 'promote_users' ) ) : ?>
     240                                        <a href="user-new.php" class="page-title-action"><?php echo esc_html_x( 'Add Existing', 'user' ); ?></a>
     241                                <?php endif; ?>
    665242                        <?php endif; ?>
    666         </td>
    667 </tr>
    668 <tr class="pw-weak">
    669         <th><?php _e( 'Confirm Password' ); ?></th>
    670         <td>
    671                 <label>
    672                         <input type="checkbox" name="pw_weak" class="pw-checkbox" />
    673                         <span id="pw-weak-text-label"><?php _e( 'Confirm use of weak password' ); ?></span>
    674                 </label>
    675         </td>
    676 </tr>
    677         <?php endif; ?>
    678243
    679                 <?php
    680                 // Allow admins to send reset password link.
    681                 if ( ! IS_PROFILE_PAGE ) :
    682                         ?>
    683         <tr class="user-generate-reset-link-wrap hide-if-no-js">
    684                 <th><?php _e( 'Password Reset' ); ?></th>
    685                 <td>
    686                         <div class="generate-reset-link">
    687                                 <button type="button" class="button button-secondary" id="generate-reset-link">
    688                                         <?php _e( 'Send Reset Link' ); ?>
    689                                 </button>
    690                         </div>
    691                         <p class="description">
    692                                 <?php
    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                                 );
    698                                 ?>
    699                         </p>
    700                 </td>
    701         </tr>
    702                 <?php endif; ?>
     244                        <hr class="wp-header-end">
    703245
    704                 <?php
    705                 if ( IS_PROFILE_PAGE && count( $sessions->get_all() ) === 1 ) :
    706                         ?>
    707         <tr class="user-sessions-wrap hide-if-no-js">
    708                 <th><?php _e( 'Sessions' ); ?></th>
    709                 <td aria-live="assertive">
    710                         <div class="destroy-sessions"><button type="button" disabled class="button"><?php _e( 'Log Out Everywhere Else' ); ?></button></div>
    711                         <p class="description">
    712                                 <?php _e( 'You are only logged in at this location.' ); ?>
    713                         </p>
    714                 </td>
    715         </tr>
    716 <?php elseif ( IS_PROFILE_PAGE && count( $sessions->get_all() ) > 1 ) : ?>
    717         <tr class="user-sessions-wrap hide-if-no-js">
    718                 <th><?php _e( 'Sessions' ); ?></th>
    719                 <td aria-live="assertive">
    720                         <div class="destroy-sessions"><button type="button" class="button" id="destroy-sessions"><?php _e( 'Log Out Everywhere Else' ); ?></button></div>
    721                         <p class="description">
    722                                 <?php _e( 'Did you lose your phone or leave your account logged in at a public computer? You can log out everywhere else, and stay logged in here.' ); ?>
    723                         </p>
    724                 </td>
    725         </tr>
    726 <?php elseif ( ! IS_PROFILE_PAGE && $sessions->get_all() ) : ?>
    727         <tr class="user-sessions-wrap hide-if-no-js">
    728                 <th><?php _e( 'Sessions' ); ?></th>
    729                 <td>
    730                         <p><button type="button" class="button" id="destroy-sessions"><?php _e( 'Log Out Everywhere' ); ?></button></p>
    731                         <p class="description">
     246                        <form id="your-profile" action="<?php echo esc_url( self_admin_url( IS_PROFILE_PAGE ? 'profile.php' : 'user-edit.php' ) ); ?>" method="post" novalidate="novalidate"
    732247                                <?php
    733                                 /* translators: %s: User's display name. */
    734                                 printf( __( 'Log %s out of all locations.' ), $profile_user->display_name );
     248                                /**
     249                                 * Fires inside the your-profile form tag on the user editing screen.
     250                                 *
     251                                 * @since 3.0.0
     252                                 */
     253                                do_action( 'user_edit_form_tag' );
    735254                                ?>
    736                         </p>
    737                 </td>
    738         </tr>
    739 <?php endif; ?>
     255                                >
     256                                <?php wp_nonce_field( 'update-user_' . $user_id ); ?>
     257                                <?php if ( $wp_http_referer ) : ?>
     258                                        <input type="hidden" name="wp_http_referer" value="<?php echo esc_url( $wp_http_referer ); ?>" />
     259                                <?php endif; ?>
     260                                <p>
     261                                        <input type="hidden" name="from" value="profile" />
     262                                        <input type="hidden" name="checkuser_id" value="<?php echo get_current_user_id(); ?>" />
     263                                </p>
     264
     265                                <h2><?php _e( 'Personal Options' ); ?></h2>
     266
     267                                <table class="form-table" role="presentation">
     268                                        <?php if ( ! ( IS_PROFILE_PAGE && ! $user_can_edit ) ) : ?>
     269                                                <tr class="user-rich-editing-wrap">
     270                                                        <th scope="row"><?php _e( 'Visual Editor' ); ?></th>
     271                                                        <td>
     272                                                                <label for="rich_editing"><input name="rich_editing" type="checkbox" id="rich_editing" value="false" <?php checked( 'false', $profile_user->rich_editing ); ?> />
     273                                                                        <?php _e( 'Disable the visual editor when writing' ); ?>
     274                                                                </label>
     275                                                        </td>
     276                                                </tr>
     277                                        <?php endif; ?>
    740278
    741         </table>
    742 
    743 <?php if ( wp_is_application_passwords_available_for_user( $user_id ) || ! wp_is_application_passwords_supported() ) : // phpcs:disable Generic.WhiteSpace.ScopeIndent ?>
    744         <div class="application-passwords hide-if-no-js" id="application-passwords-section">
    745                 <h2><?php _e( 'Application Passwords' ); ?></h2>
    746                 <p><?php _e( 'Application passwords allow authentication via non-interactive systems, such as XML-RPC or the REST API, without providing your actual password. Application passwords can be easily revoked. They cannot be used for traditional logins to your website.' ); ?></p>
    747                 <?php if ( wp_is_application_passwords_available_for_user( $user_id ) ) : ?>
    748                         <?php
    749                         if ( is_multisite() ) {
    750                                 $blogs       = get_blogs_of_user( $user_id, true );
    751                                 $blogs_count = count( $blogs );
    752                                 if ( $blogs_count > 1 ) {
    753                                         ?>
    754                                         <p>
    755                                                 <?php
    756                                                 printf(
    757                                                         /* translators: 1: URL to my-sites.php, 2: Number of sites the user has. */
    758                                                         _n(
    759                                                                 'Application passwords grant access to <a href="%1$s">the %2$s site in this installation that you have permissions on</a>.',
    760                                                                 'Application passwords grant access to <a href="%1$s">all %2$s sites in this installation that you have permissions on</a>.',
    761                                                                 $blogs_count
    762                                                         ),
    763                                                         admin_url( 'my-sites.php' ),
    764                                                         number_format_i18n( $blogs_count )
    765                                                 );
    766                                                 ?>
    767                                         </p>
    768279                                        <?php
    769                                 }
    770                         }
     280                                        $show_syntax_highlighting_preference = (
     281                                        // For Custom HTML widget and Additional CSS in Customizer.
     282                                        user_can( $profile_user, 'edit_theme_options' )
     283                                        ||
     284                                        // Edit plugins.
     285                                        user_can( $profile_user, 'edit_plugins' )
     286                                        ||
     287                                        // Edit themes.
     288                                        user_can( $profile_user, 'edit_themes' )
     289                                        );
     290                                        ?>
    771291
    772                         if ( ! wp_is_site_protected_by_basic_auth( 'front' ) ) {
    773                                 ?>
    774                         <div class="create-application-password form-wrap">
    775                                 <div class="form-field">
    776                                         <label for="new_application_password_name"><?php _e( 'New Application Password Name' ); ?></label>
    777                                         <input type="text" size="30" id="new_application_password_name" name="new_application_password_name" class="input" aria-required="true" aria-describedby="new_application_password_name_desc" />
    778                                         <p class="description" id="new_application_password_name_desc"><?php _e( 'Required to create an Application Password, but not to update the user.' ); ?></p>
    779                                 </div>
     292                                        <?php if ( $show_syntax_highlighting_preference ) : ?>
     293                                        <tr class="user-syntax-highlighting-wrap">
     294                                                <th scope="row"><?php _e( 'Syntax Highlighting' ); ?></th>
     295                                                <td>
     296                                                        <label for="syntax_highlighting"><input name="syntax_highlighting" type="checkbox" id="syntax_highlighting" value="false" <?php checked( 'false', $profile_user->syntax_highlighting ); ?> />
     297                                                                <?php _e( 'Disable syntax highlighting when editing code' ); ?>
     298                                                        </label>
     299                                                </td>
     300                                        </tr>
     301                                        <?php endif; ?>
     302
     303                                        <?php if ( count( $_wp_admin_css_colors ) > 1 && has_action( 'admin_color_scheme_picker' ) ) : ?>
     304                                        <tr class="user-admin-color-wrap">
     305                                                <th scope="row"><?php _e( 'Admin Color Scheme' ); ?></th>
     306                                                <td>
     307                                                        <?php
     308                                                        /**
     309                                                         * Fires in the 'Admin Color Scheme' section of the user editing screen.
     310                                                         *
     311                                                         * The section is only enabled if a callback is hooked to the action,
     312                                                         * and if there is more than one defined color scheme for the admin.
     313                                                         *
     314                                                         * @since 3.0.0
     315                                                         * @since 3.8.1 Added `$user_id` parameter.
     316                                                         *
     317                                                         * @param int $user_id The user ID.
     318                                                         */
     319                                                        do_action( 'admin_color_scheme_picker', $user_id );
     320                                                        ?>
     321                                                </td>
     322                                        </tr>
     323                                        <?php endif; // End if count ( $_wp_admin_css_colors ) > 1 ?>
     324
     325                                        <?php if ( ! ( IS_PROFILE_PAGE && ! $user_can_edit ) ) : ?>
     326                                        <tr class="user-comment-shortcuts-wrap">
     327                                                <th scope="row"><?php _e( 'Keyboard Shortcuts' ); ?></th>
     328                                                <td>
     329                                                        <label for="comment_shortcuts">
     330                                                                <input type="checkbox" name="comment_shortcuts" id="comment_shortcuts" value="true" <?php checked( 'true', $profile_user->comment_shortcuts ); ?> />
     331                                                                <?php _e( 'Enable keyboard shortcuts for comment moderation.' ); ?>
     332                                                        </label>
     333                                                        <?php _e( '<a href="https://wordpress.org/support/article/keyboard-shortcuts/" target="_blank">More information</a>' ); ?>
     334                                                </td>
     335                                        </tr>
     336                                        <?php endif; ?>
     337
     338                                        <tr class="show-admin-bar user-admin-bar-front-wrap">
     339                                                <th scope="row"><?php _e( 'Toolbar' ); ?></th>
     340                                                <td>
     341                                                        <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', $profile_user->ID ) ); ?> />
     343                                                                <?php _e( 'Show Toolbar when viewing site' ); ?>
     344                                                        </label><br />
     345                                                </td>
     346                                        </tr>
     347
     348                                        <?php $languages = get_available_languages(); ?>
     349                                        <?php if ( $languages ) : ?>
     350                                        <tr class="user-language-wrap">
     351                                                <th scope="row">
     352                                                        <?php /* translators: The user language selection field label. */ ?>
     353                                                        <label for="locale"><?php _e( 'Language' ); ?><span class="dashicons dashicons-translation" aria-hidden="true"></span></label>
     354                                                </th>
     355                                                <td>
     356                                                        <?php
     357                                                                $user_locale = $profile_user->locale;
     358
     359                                                        if ( 'en_US' === $user_locale ) {
     360                                                                $user_locale = '';
     361                                                        } elseif ( '' === $user_locale || ! in_array( $user_locale, $languages, true ) ) {
     362                                                                $user_locale = 'site-default';
     363                                                        }
     364
     365                                                        wp_dropdown_languages(
     366                                                                array(
     367                                                                        'name'      => 'locale',
     368                                                                        'id'        => 'locale',
     369                                                                        'selected'  => $user_locale,
     370                                                                        'languages' => $languages,
     371                                                                        'show_available_translations' => false,
     372                                                                        'show_option_site_default' => true,
     373                                                                )
     374                                                        );
     375                                                        ?>
     376                                                </td>
     377                                        </tr>
     378                                        <?php endif; ?>
    780379
    781                                 <?php
    782                                 /**
    783                                  * Fires in the create Application Passwords form.
    784                                 *
    785                                  * @since 5.6.0
    786                                 *
    787                                 * @param WP_User $profile_user The current WP_User object.
    788                                 */
    789                                 do_action( 'wp_create_application_password_form', $profile_user );
    790                                 ?>
     380                                        <?php
     381                                        /**
     382                                         * Fires at the end of the 'Personal Options' settings table on the user editing screen.
     383                                        *
     384                                         * @since 2.7.0
     385                                        *
     386                                        * @param WP_User $profile_user The current WP_User object.
     387                                        */
     388                                        do_action( 'personal_options', $profile_user );
     389                                        ?>
    791390
    792                                 <button type="button" name="do_new_application_password" id="do_new_application_password" class="button button-secondary"><?php _e( 'Add New Application Password' ); ?></button>
    793                         </div>
    794                 <?php } else { ?>
    795                         <div class="notice notice-error inline">
    796                                 <p><?php _e( 'Your website appears to use Basic Authentication, which is not currently compatible with Application Passwords.' ); ?></p>
    797                         </div>
    798                 <?php } ?>
    799 
    800                 <div class="application-passwords-list-table-wrapper">
    801                         <?php
    802                         $application_passwords_list_table = _get_list_table( 'WP_Application_Passwords_List_Table', array( 'screen' => 'application-passwords-user' ) );
    803                         $application_passwords_list_table->prepare_items();
    804                         $application_passwords_list_table->display();
    805                         ?>
    806                 </div>
    807                 <?php elseif ( ! wp_is_application_passwords_supported() ) : ?>
    808                         <p><?php _e( 'The application password feature requires HTTPS, which is not enabled on this site.' ); ?></p>
    809                         <p>
     391                                </table>
    810392                                <?php
    811                                 printf(
    812                                         /* translators: %s: Documentation URL. */
    813                                         __( 'If this is a development website you can <a href="%s" target="_blank">set the environment type accordingly</a> to enable application passwords.' ),
    814                                         __( 'https://wordpress.org/support/article/editing-wp-config-php/#wp_environment_type' )
    815                                 );
     393                                if ( IS_PROFILE_PAGE ) {
     394                                        /**
     395                                         * Fires after the 'Personal Options' settings table on the 'Profile' editing screen.
     396                                         *
     397                                         * The action only fires if the current user is editing their own profile.
     398                                         *
     399                                         * @since 2.0.0
     400                                         *
     401                                         * @param WP_User $profile_user The current WP_User object.
     402                                         */
     403                                        do_action( 'profile_personal_options', $profile_user );
     404                                }
    816405                                ?>
    817                         </p>
    818                 <?php endif; ?>
    819         </div>
    820 <?php endif; // phpcs:enable Generic.WhiteSpace.ScopeIndent ?>
    821 
    822                 <?php
    823                 if ( IS_PROFILE_PAGE ) {
    824                         /**
    825                          * Fires after the 'About Yourself' settings table on the 'Profile' editing screen.
    826                          *
    827                          * The action only fires if the current user is editing their own profile.
    828                          *
    829                          * @since 2.0.0
    830                          *
    831                          * @param WP_User $profile_user The current WP_User object.
    832                          */
    833                         do_action( 'show_user_profile', $profile_user );
    834                 } else {
    835                         /**
    836                          * Fires after the 'About the User' settings table on the 'Edit User' screen.
    837                          *
    838                          * @since 2.0.0
    839                          *
    840                          * @param WP_User $profile_user The current WP_User object.
    841                          */
    842                         do_action( 'edit_user_profile', $profile_user );
    843                 }
    844                 ?>
    845406
    846                 <?php
    847                 /**
    848                  * Filters whether to display additional capabilities for the user.
    849                  *
    850                  * The 'Additional Capabilities' section will only be enabled if
    851                  * the number of the user's capabilities exceeds their number of
    852                  * roles.
    853                  *
    854                  * @since 2.8.0
    855                  *
    856                  * @param bool    $enable       Whether to display the capabilities. Default true.
    857                  * @param WP_User $profile_user The current WP_User object.
    858                  */
    859                 if ( count( $profile_user->caps ) > count( $profile_user->roles )
    860                         && apply_filters( 'additional_capabilities_display', true, $profile_user )
    861                 ) :
    862                         ?>
    863         <h2><?php _e( 'Additional Capabilities' ); ?></h2>
    864 <table class="form-table" role="presentation">
    865 <tr class="user-capabilities-wrap">
    866         <th scope="row"><?php _e( 'Capabilities' ); ?></th>
    867         <td>
    868                         <?php
    869                         $output = '';
    870                         foreach ( $profile_user->caps as $cap => $value ) {
    871                                 if ( ! $wp_roles->is_role( $cap ) ) {
    872                                         if ( '' !== $output ) {
    873                                                 $output .= ', ';
    874                                         }
     407                                <h2><?php _e( 'Name' ); ?></h2>
     408
     409                                <table class="form-table" role="presentation">
     410                                        <tr class="user-user-login-wrap">
     411                                                <th><label for="user_login"><?php _e( 'Username' ); ?></label></th>
     412                                                <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>
     413                                        </tr>
     414
     415                                        <?php if ( ! IS_PROFILE_PAGE && ! is_network_admin() && current_user_can( 'promote_user', $profile_user->ID ) ) : ?>
     416                                                <tr class="user-role-wrap">
     417                                                        <th><label for="role"><?php _e( 'Role' ); ?></label></th>
     418                                                        <td>
     419                                                                <select name="role" id="role">
     420                                                                        <?php
     421                                                                        // Compare user role against currently editable roles.
     422                                                                        $user_roles = array_intersect( array_values( $profile_user->roles ), array_keys( get_editable_roles() ) );
     423                                                                        $user_role  = reset( $user_roles );
     424
     425                                                                        // Print the full list of roles with the primary one selected.
     426                                                                        wp_dropdown_roles( $user_role );
     427
     428                                                                        // Print the 'no role' option. Make it selected if the user has no role yet.
     429                                                                        if ( $user_role ) {
     430                                                                                echo '<option value="">' . __( '&mdash; No role for this site &mdash;' ) . '</option>';
     431                                                                        } else {
     432                                                                                echo '<option value="" selected="selected">' . __( '&mdash; No role for this site &mdash;' ) . '</option>';
     433                                                                        }
     434                                                                        ?>
     435                                                        </select>
     436                                                        </td>
     437                                                </tr>
     438                                        <?php endif; // End if ! IS_PROFILE_PAGE. ?>
     439
     440                                        <?php if ( is_multisite() && is_network_admin() && ! IS_PROFILE_PAGE && current_user_can( 'manage_network_options' ) && ! isset( $super_admins ) ) : ?>
     441                                                <tr class="user-super-admin-wrap">
     442                                                        <th><?php _e( 'Super Admin' ); ?></th>
     443                                                        <td>
     444                                                                <?php if ( 0 !== strcasecmp( $profile_user->user_email, get_site_option( 'admin_email' ) ) || ! is_super_admin( $profile_user->ID ) ) : ?>
     445                                                                        <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>
     446                                                                <?php else : ?>
     447                                                                        <p><?php _e( 'Super admin privileges cannot be removed because this user has the network admin email.' ); ?></p>
     448                                                                <?php endif; ?>
     449                                                        </td>
     450                                                </tr>
     451                                        <?php endif; ?>
     452
     453                                        <tr class="user-first-name-wrap">
     454                                                <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( $profile_user->first_name ); ?>" class="regular-text" /></td>
     456                                        </tr>
     457
     458                                        <tr class="user-last-name-wrap">
     459                                                <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( $profile_user->last_name ); ?>" class="regular-text" /></td>
     461                                        </tr>
     462
     463                                        <tr class="user-nickname-wrap">
     464                                                <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( $profile_user->nickname ); ?>" class="regular-text" /></td>
     466                                        </tr>
     467
     468                                        <tr class="user-display-name-wrap">
     469                                                <th>
     470                                                        <label for="display_name"><?php _e( 'Display name publicly as' ); ?></label>
     471                                                </th>
     472                                                <td>
     473                                                        <select name="display_name" id="display_name">
     474                                                                <?php
     475                                                                        $public_display                     = array();
     476                                                                        $public_display['display_nickname'] = $profile_user->nickname;
     477                                                                        $public_display['display_username'] = $profile_user->user_login;
     478
     479                                                                if ( ! empty( $profile_user->first_name ) ) {
     480                                                                        $public_display['display_firstname'] = $profile_user->first_name;
     481                                                                }
     482
     483                                                                if ( ! empty( $profile_user->last_name ) ) {
     484                                                                        $public_display['display_lastname'] = $profile_user->last_name;
     485                                                                }
     486
     487                                                                if ( ! empty( $profile_user->first_name ) && ! empty( $profile_user->last_name ) ) {
     488                                                                        $public_display['display_firstlast'] = $profile_user->first_name . ' ' . $profile_user->last_name;
     489                                                                        $public_display['display_lastfirst'] = $profile_user->last_name . ' ' . $profile_user->first_name;
     490                                                                }
     491
     492                                                                if ( ! in_array( $profile_user->display_name, $public_display, true ) ) { // Only add this if it isn't duplicated elsewhere.
     493                                                                        $public_display = array( 'display_displayname' => $profile_user->display_name ) + $public_display;
     494                                                                }
     495
     496                                                                $public_display = array_map( 'trim', $public_display );
     497                                                                $public_display = array_unique( $public_display );
     498
     499                                                                ?>
     500                                                                <?php foreach ( $public_display as $id => $item ) : ?>
     501                                                                        <option <?php selected( $profile_user->display_name, $item ); ?>><?php echo $item; ?></option>
     502                                                                <?php endforeach; ?>
     503                                                        </select>
     504                                                </td>
     505                                        </tr>
     506                                </table>
     507
     508                                <h2><?php _e( 'Contact Info' ); ?></h2>
     509
     510                                <table class="form-table" role="presentation">
     511                                        <tr class="user-email-wrap">
     512                                                <th><label for="email"><?php _e( 'Email' ); ?> <span class="description"><?php _e( '(required)' ); ?></span></label></th>
     513                                                <td>
     514                                                        <input type="email" name="email" id="email" aria-describedby="email-description" value="<?php echo esc_attr( $profile_user->user_email ); ?>" class="regular-text ltr" />
     515                                                        <?php if ( $profile_user->ID === $current_user->ID ) : ?>
     516                                                                <p class="description" id="email-description">
     517                                                                        <?php _e( 'If you change this, we will send you an email at your new address to confirm it. <strong>The new address will not become active until confirmed.</strong>' ); ?>
     518                                                                </p>
     519                                                        <?php endif; ?>
     520
     521                                                        <?php $new_email = get_user_meta( $current_user->ID, '_new_email', true ); ?>
     522                                                        <?php if ( $new_email && $new_email['newemail'] !== $current_user->user_email && $profile_user->ID === $current_user->ID ) : ?>
     523                                                        <div class="updated inline">
     524                                                                <p>
     525                                                                        <?php
     526                                                                        printf(
     527                                                                                /* translators: %s: New email. */
     528                                                                                __( 'There is a pending change of your email to %s.' ),
     529                                                                                '<code>' . esc_html( $new_email['newemail'] ) . '</code>'
     530                                                                        );
     531                                                                        printf(
     532                                                                                ' <a href="%1$s">%2$s</a>',
     533                                                                                esc_url( wp_nonce_url( self_admin_url( 'profile.php?dismiss=' . $current_user->ID . '_new_email' ), 'dismiss-' . $current_user->ID . '_new_email' ) ),
     534                                                                                __( 'Cancel' )
     535                                                                        );
     536                                                                        ?>
     537                                                                </p>
     538                                                        </div>
     539                                                        <?php endif; ?>
     540                                                </td>
     541                                        </tr>
     542
     543                                        <tr class="user-url-wrap">
     544                                                <th><label for="url"><?php _e( 'Website' ); ?></label></th>
     545                                                <td><input type="url" name="url" id="url" value="<?php echo esc_attr( $profile_user->user_url ); ?>" class="regular-text code" /></td>
     546                                        </tr>
     547
     548                                        <?php foreach ( wp_get_user_contact_methods( $profile_user ) as $name => $desc ) : ?>
     549                                        <tr class="user-<?php echo $name; ?>-wrap">
     550                                                <th>
     551                                                        <label for="<?php echo $name; ?>">
     552                                                        <?php
     553                                                        /**
     554                                                         * Filters a user contactmethod label.
     555                                                         *
     556                                                         * The dynamic portion of the hook name, `$name`, refers to
     557                                                         * each of the keys in the contact methods array.
     558                                                         *
     559                                                         * @since 2.9.0
     560                                                         *
     561                                                         * @param string $desc The translatable label for the contact method.
     562                                                         */
     563                                                        echo apply_filters( "user_{$name}_label", $desc );
     564                                                        ?>
     565                                                        </label>
     566                                                </th>
     567                                                <td>
     568                                                        <input type="text" name="<?php echo $name; ?>" id="<?php echo $name; ?>" value="<?php echo esc_attr( $profile_user->$name ); ?>" class="regular-text" />
     569                                                </td>
     570                                        </tr>
     571                                        <?php endforeach; ?>
     572                                </table>
     573
     574                                <h2><?php IS_PROFILE_PAGE ? _e( 'About Yourself' ) : _e( 'About the user' ); ?></h2>
     575
     576                                <table class="form-table" role="presentation">
     577                                        <tr class="user-description-wrap">
     578                                                <th><label for="description"><?php _e( 'Biographical Info' ); ?></label></th>
     579                                                <td><textarea name="description" id="description" rows="5" cols="30"><?php echo $profile_user->description; // textarea_escaped ?></textarea>
     580                                                <p class="description"><?php _e( 'Share a little biographical information to fill out your profile. This may be shown publicly.' ); ?></p></td>
     581                                        </tr>
     582
     583                                        <?php if ( get_option( 'show_avatars' ) ) : ?>
     584                                                <tr class="user-profile-picture">
     585                                                        <th><?php _e( 'Profile Picture' ); ?></th>
     586                                                        <td>
     587                                                                <?php echo get_avatar( $user_id ); ?>
     588                                                                <p class="description">
     589                                                                        <?php
     590                                                                        if ( IS_PROFILE_PAGE ) {
     591                                                                                $description = sprintf(
     592                                                                                        /* translators: %s: Gravatar URL. */
     593                                                                                        __( '<a href="%s">You can change your profile picture on Gravatar</a>.' ),
     594                                                                                        __( 'https://en.gravatar.com/' )
     595                                                                                );
     596                                                                        } else {
     597                                                                                $description = '';
     598                                                                        }
     599
     600                                                                        /**
     601                                                                         * Filters the user profile picture description displayed under the Gravatar.
     602                                                                         *
     603                                                                         * @since 4.4.0
     604                                                                         * @since 4.7.0 Added the `$profile_user` parameter.
     605                                                                         *
     606                                                                         * @param string  $description  The description that will be printed.
     607                                                                         * @param WP_User $profile_user The current WP_User object.
     608                                                                         */
     609                                                                        echo apply_filters( 'user_profile_picture_description', $description, $profile_user );
     610                                                                        ?>
     611                                                                </p>
     612                                                        </td>
     613                                                </tr>
     614                                        <?php endif; ?>
     615                                        <?php
     616                                        /**
     617                                         * Filters the display of the password fields.
     618                                         *
     619                                         * @since 1.5.1
     620                                         * @since 2.8.0 Added the `$profile_user` parameter.
     621                                         * @since 4.4.0 Now evaluated only in user-edit.php.
     622                                         *
     623                                         * @param bool    $show         Whether to show the password fields. Default true.
     624                                         * @param WP_User $profile_user User object for the current user to edit.
     625                                         */
     626                                        $show_password_fields = apply_filters( 'show_password_fields', true, $profile_user );
     627                                        ?>
     628                                        <?php if ( $show_password_fields ) : ?>
     629                                                </table>
     630
     631                                                <h2><?php _e( 'Account Management' ); ?></h2>
     632
     633                                                <table class="form-table" role="presentation">
     634                                                        <tr id="password" class="user-pass1-wrap">
     635                                                                <th><label for="pass1"><?php _e( 'New Password' ); ?></label></th>
     636                                                                <td>
     637                                                                        <input class="hidden" value=" " /><!-- #24364 workaround -->
     638                                                                        <button type="button" class="button wp-generate-pw hide-if-no-js" aria-expanded="false"><?php _e( 'Set New Password' ); ?></button>
     639                                                                        <div class="wp-pwd hide-if-js">
     640                                                                                <span class="password-input-wrapper">
     641                                                                                        <input type="password" name="pass1" id="pass1" class="regular-text" value="" autocomplete="off" data-pw="<?php echo esc_attr( wp_generate_password( 24 ) ); ?>" aria-describedby="pass-strength-result" />
     642                                                                                </span>
     643                                                                                <button type="button" class="button wp-hide-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e( 'Hide password' ); ?>">
     644                                                                                        <span class="dashicons dashicons-hidden" aria-hidden="true"></span>
     645                                                                                        <span class="text"><?php _e( 'Hide' ); ?></span>
     646                                                                                </button>
     647                                                                                <button type="button" class="button wp-cancel-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e( 'Cancel password change' ); ?>">
     648                                                                                        <span class="dashicons dashicons-no" aria-hidden="true"></span>
     649                                                                                        <span class="text"><?php _e( 'Cancel' ); ?></span>
     650                                                                                </button>
     651                                                                                <div style="display:none" id="pass-strength-result" aria-live="polite"></div>
     652                                                                        </div>
     653                                                                </td>
     654                                                        </tr>
     655                                                        <tr class="user-pass2-wrap hide-if-js">
     656                                                                <th scope="row"><label for="pass2"><?php _e( 'Repeat New Password' ); ?></label></th>
     657                                                                <td>
     658                                                                <input name="pass2" type="password" id="pass2" class="regular-text" value="" autocomplete="off" aria-describedby="pass2-desc" />
     659                                                                        <?php if ( IS_PROFILE_PAGE ) : ?>
     660                                                                                <p class="description" id="pass2-desc"><?php _e( 'Type your new password again.' ); ?></p>
     661                                                                        <?php else : ?>
     662                                                                                <p class="description" id="pass2-desc"><?php _e( 'Type the new password again.' ); ?></p>
     663                                                                        <?php endif; ?>
     664                                                                </td>
     665                                                        </tr>
     666                                                        <tr class="pw-weak">
     667                                                                <th><?php _e( 'Confirm Password' ); ?></th>
     668                                                                <td>
     669                                                                        <label>
     670                                                                                <input type="checkbox" name="pw_weak" class="pw-checkbox" />
     671                                                                                <span id="pw-weak-text-label"><?php _e( 'Confirm use of weak password' ); ?></span>
     672                                                                        </label>
     673                                                                </td>
     674                                                        </tr>
     675                                                        <?php endif; // End Show Password Fields. ?>
     676
     677                                                        <?php // Allow admins to send reset password link. ?>
     678                                                        <?php if ( ! IS_PROFILE_PAGE ) : ?>
     679                                                                <tr class="user-generate-reset-link-wrap hide-if-no-js">
     680                                                                        <th><?php _e( 'Password Reset' ); ?></th>
     681                                                                        <td>
     682                                                                                <div class="generate-reset-link">
     683                                                                                        <button type="button" class="button button-secondary" id="generate-reset-link">
     684                                                                                                <?php _e( 'Send Reset Link' ); ?>
     685                                                                                        </button>
     686                                                                                </div>
     687                                                                                <p class="description">
     688                                                                                        <?php
     689                                                                                        printf(
     690                                                                                                /* translators: %s: User's display name. */
     691                                                                                                __( 'Send %s a link to reset their password. This will not change their password, nor will it force a change.' ),
     692                                                                                                esc_html( $profile_user->display_name )
     693                                                                                        );
     694                                                                                        ?>
     695                                                                                </p>
     696                                                                        </td>
     697                                                                </tr>
     698                                                        <?php endif; ?>
     699
     700                                                        <?php if ( IS_PROFILE_PAGE && count( $sessions->get_all() ) === 1 ) : ?>
     701                                                                <tr class="user-sessions-wrap hide-if-no-js">
     702                                                                        <th><?php _e( 'Sessions' ); ?></th>
     703                                                                        <td aria-live="assertive">
     704                                                                                <div class="destroy-sessions"><button type="button" disabled class="button"><?php _e( 'Log Out Everywhere Else' ); ?></button></div>
     705                                                                                <p class="description">
     706                                                                                        <?php _e( 'You are only logged in at this location.' ); ?>
     707                                                                                </p>
     708                                                                        </td>
     709                                                                </tr>
     710                                                        <?php elseif ( IS_PROFILE_PAGE && count( $sessions->get_all() ) > 1 ) : ?>
     711                                                                <tr class="user-sessions-wrap hide-if-no-js">
     712                                                                        <th><?php _e( 'Sessions' ); ?></th>
     713                                                                        <td aria-live="assertive">
     714                                                                                <div class="destroy-sessions"><button type="button" class="button" id="destroy-sessions"><?php _e( 'Log Out Everywhere Else' ); ?></button></div>
     715                                                                                <p class="description">
     716                                                                                        <?php _e( 'Did you lose your phone or leave your account logged in at a public computer? You can log out everywhere else, and stay logged in here.' ); ?>
     717                                                                                </p>
     718                                                                        </td>
     719                                                                </tr>
     720                                                        <?php elseif ( ! IS_PROFILE_PAGE && $sessions->get_all() ) : ?>
     721                                                                <tr class="user-sessions-wrap hide-if-no-js">
     722                                                                        <th><?php _e( 'Sessions' ); ?></th>
     723                                                                        <td>
     724                                                                                <p><button type="button" class="button" id="destroy-sessions"><?php _e( 'Log Out Everywhere' ); ?></button></p>
     725                                                                                <p class="description">
     726                                                                                        <?php
     727                                                                                        /* translators: %s: User's display name. */
     728                                                                                        printf( __( 'Log %s out of all locations.' ), $profile_user->display_name );
     729                                                                                        ?>
     730                                                                                </p>
     731                                                                        </td>
     732                                                                </tr>
     733                                                        <?php endif; ?>
     734                                                </table>
     735
     736                                        <?php if ( wp_is_application_passwords_available_for_user( $user_id ) || ! wp_is_application_passwords_supported() ) : ?>
     737                                                <div class="application-passwords hide-if-no-js" id="application-passwords-section">
     738                                                        <h2><?php _e( 'Application Passwords' ); ?></h2>
     739                                                        <p><?php _e( 'Application passwords allow authentication via non-interactive systems, such as XML-RPC or the REST API, without providing your actual password. Application passwords can be easily revoked. They cannot be used for traditional logins to your website.' ); ?></p>
     740                                                        <?php if ( wp_is_application_passwords_available_for_user( $user_id ) ) : ?>
     741                                                                <?php
     742                                                                if ( is_multisite() ) :
     743                                                                        $blogs       = get_blogs_of_user( $user_id, true );
     744                                                                        $blogs_count = count( $blogs );
     745                                                                        if ( $blogs_count > 1 ) :
     746                                                                                ?>
     747                                                                                <p>
     748                                                                                        <?php
     749                                                                                        printf(
     750                                                                                                /* translators: 1: URL to my-sites.php, 2: Number of sites the user has. */
     751                                                                                                _n(
     752                                                                                                        'Application passwords grant access to <a href="%1$s">the %2$s site in this installation that you have permissions on</a>.',
     753                                                                                                        'Application passwords grant access to <a href="%1$s">all %2$s sites in this installation that you have permissions on</a>.',
     754                                                                                                        $blogs_count
     755                                                                                                ),
     756                                                                                                admin_url( 'my-sites.php' ),
     757                                                                                                number_format_i18n( $blogs_count )
     758                                                                                        );
     759                                                                                        ?>
     760                                                                                </p>
     761                                                                                <?php
     762                                                                        endif;
     763                                                                endif;
     764                                                                ?>
     765
     766                                                                <?php if ( ! wp_is_site_protected_by_basic_auth( 'front' ) ) : ?>
     767                                                                        <div class="create-application-password form-wrap">
     768                                                                                <div class="form-field">
     769                                                                                        <label for="new_application_password_name"><?php _e( 'New Application Password Name' ); ?></label>
     770                                                                                        <input type="text" size="30" id="new_application_password_name" name="new_application_password_name" class="input" aria-required="true" aria-describedby="new_application_password_name_desc" />
     771                                                                                        <p class="description" id="new_application_password_name_desc"><?php _e( 'Required to create an Application Password, but not to update the user.' ); ?></p>
     772                                                                                </div>
     773
     774                                                                                <?php
     775                                                                                /**
     776                                                                                 * Fires in the create Application Passwords form.
     777                                                                                 *
     778                                                                                 * @since 5.6.0
     779                                                                                 *
     780                                                                                 * @param WP_User $profile_user The current WP_User object.
     781                                                                                 */
     782                                                                                do_action( 'wp_create_application_password_form', $profile_user );
     783                                                                                ?>
     784
     785                                                                                <button type="button" name="do_new_application_password" id="do_new_application_password" class="button button-secondary"><?php _e( 'Add New Application Password' ); ?></button>
     786                                                                        </div>
     787                                                                <?php else : ?>
     788                                                                        <div class="notice notice-error inline">
     789                                                                                <p><?php _e( 'Your website appears to use Basic Authentication, which is not currently compatible with Application Passwords.' ); ?></p>
     790                                                                        </div>
     791                                                                <?php endif; ?>
     792
     793                                                                <div class="application-passwords-list-table-wrapper">
     794                                                                        <?php
     795                                                                        $application_passwords_list_table = _get_list_table( 'WP_Application_Passwords_List_Table', array( 'screen' => 'application-passwords-user' ) );
     796                                                                        $application_passwords_list_table->prepare_items();
     797                                                                        $application_passwords_list_table->display();
     798                                                                        ?>
     799                                                                </div>
     800                                                        <?php elseif ( ! wp_is_application_passwords_supported() ) : ?>
     801                                                                <p><?php _e( 'The application password feature requires HTTPS, which is not enabled on this site.' ); ?></p>
     802                                                                <p>
     803                                                                        <?php
     804                                                                        printf(
     805                                                                                /* translators: %s: Documentation URL. */
     806                                                                                __( 'If this is a development website you can <a href="%s" target="_blank">set the environment type accordingly</a> to enable application passwords.' ),
     807                                                                                __( 'https://wordpress.org/support/article/editing-wp-config-php/#wp_environment_type' )
     808                                                                        );
     809                                                                        ?>
     810                                                                </p>
     811                                                        <?php endif; ?>
     812                                                </div>
     813                                        <?php endif; // End Application Passwords. ?>
    875814
    876                                         if ( $value ) {
    877                                                 $output .= $cap;
     815                                        <?php
     816                                        if ( IS_PROFILE_PAGE ) {
     817                                                /**
     818                                                 * Fires after the 'About Yourself' settings table on the 'Profile' editing screen.
     819                                                 *
     820                                                 * The action only fires if the current user is editing their own profile.
     821                                                 *
     822                                                 * @since 2.0.0
     823                                                 *
     824                                                 * @param WP_User $profile_user The current WP_User object.
     825                                                 */
     826                                                do_action( 'show_user_profile', $profile_user );
    878827                                        } else {
    879                                                 /* translators: %s: Capability name. */
    880                                                 $output .= sprintf( __( 'Denied: %s' ), $cap );
     828                                                /**
     829                                                 * Fires after the 'About the User' settings table on the 'Edit User' screen.
     830                                                 *
     831                                                 * @since 2.0.0
     832                                                 *
     833                                                 * @param WP_User $profile_user The current WP_User object.
     834                                                 */
     835                                                do_action( 'edit_user_profile', $profile_user );
    881836                                        }
    882                                 }
    883                         }
    884                         echo $output;
    885                         ?>
    886         </td>
    887 </tr>
    888 </table>
    889         <?php endif; ?>
    890 
    891 <input type="hidden" name="action" value="update" />
    892 <input type="hidden" name="user_id" id="user_id" value="<?php echo esc_attr( $user_id ); ?>" />
     837                                        ?>
    893838
    894                 <?php submit_button( IS_PROFILE_PAGE ? __( 'Update Profile' ) : __( 'Update User' ) ); ?>
     839                                        <?php
     840                                        /**
     841                                         * Filters whether to display additional capabilities for the user.
     842                                         *
     843                                         * The 'Additional Capabilities' section will only be enabled if
     844                                         * the number of the user's capabilities exceeds their number of
     845                                         * roles.
     846                                         *
     847                                         * @since 2.8.0
     848                                         *
     849                                         * @param bool    $enable      Whether to display the capabilities. Default true.
     850                                         * @param WP_User $profile_user The current WP_User object.
     851                                         */
     852                                        $display_additional_caps = apply_filters( 'additional_capabilities_display', true, $profile_user );
     853                                        ?>
    895854
    896 </form>
    897 </div>
     855                                <?php if ( count( $profile_user->caps ) > count( $profile_user->roles ) && ( true === $display_additional_caps ) ) : ?>
     856                                        <h2><?php _e( 'Additional Capabilities' ); ?></h2>
     857
     858                                        <table class="form-table" role="presentation">
     859                                                <tr class="user-capabilities-wrap">
     860                                                        <th scope="row"><?php _e( 'Capabilities' ); ?></th>
     861                                                        <td>
     862                                                                <?php
     863                                                                $output = '';
     864                                                                foreach ( $profile_user->caps as $cap => $value ) {
     865                                                                        if ( ! $wp_roles->is_role( $cap ) ) {
     866                                                                                if ( '' !== $output ) {
     867                                                                                        $output .= ', ';
     868                                                                                }
     869
     870                                                                                if ( $value ) {
     871                                                                                        $output .= $cap;
     872                                                                                } else {
     873                                                                                        /* translators: %s: Capability name. */
     874                                                                                        $output .= sprintf( __( 'Denied: %s' ), $cap );
     875                                                                                }
     876                                                                        }
     877                                                                }
     878                                                                echo $output;
     879                                                                ?>
     880                                                        </td>
     881                                                </tr>
     882                                        </table>
     883                                <?php endif; // End Display Additional Capabilities. ?>
     884
     885                                <input type="hidden" name="action" value="update" />
     886                                <input type="hidden" name="user_id" id="user_id" value="<?php echo esc_attr( $user_id ); ?>" />
     887
     888                                <?php submit_button( IS_PROFILE_PAGE ? __( 'Update Profile' ) : __( 'Update User' ) ); ?>
     889
     890                        </form>
     891                </div>
    898892                <?php
    899893                break;
    900894}