Skip to content

Commit a3d9130

Browse files
committed
Users: A11y: Use autocomplete attributes for user name and email.
Support autocomplete attributes on user's own profile to improve accessibility. Helps user profile management meet accessibility criteria regarding user input purpose and aids users with mobility impairments. Props greatislander, umeshsinghin, jorbin, lukasfritzedev, joedolson. Fixes #63286. git-svn-id: https://develop.svn.wordpress.org/trunk@60283 602fd350-edb4-49c9-b593-d223f7449a82
1 parent ee53cb4 commit a3d9130

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

src/wp-admin/user-edit.php

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -486,17 +486,35 @@
486486

487487
<tr class="user-first-name-wrap">
488488
<th><label for="first_name"><?php _e( 'First Name' ); ?></label></th>
489-
<td><input type="text" name="first_name" id="first_name" value="<?php echo esc_attr( $profile_user->first_name ); ?>" class="regular-text" /></td>
489+
<td>
490+
<?php if ( IS_PROFILE_PAGE ) : ?>
491+
<input type="text" name="first_name" id="first_name" value="<?php echo esc_attr( $profile_user->first_name ); ?>" autocomplete="given-name" class="regular-text" />
492+
<?php else : ?>
493+
<input type="text" name="first_name" id="first_name" value="<?php echo esc_attr( $profile_user->first_name ); ?>" class="regular-text" />
494+
<?php endif; ?>
495+
</td>
490496
</tr>
491497

492498
<tr class="user-last-name-wrap">
493499
<th><label for="last_name"><?php _e( 'Last Name' ); ?></label></th>
494-
<td><input type="text" name="last_name" id="last_name" value="<?php echo esc_attr( $profile_user->last_name ); ?>" class="regular-text" /></td>
500+
<td>
501+
<?php if ( IS_PROFILE_PAGE ) : ?>
502+
<input type="text" name="last_name" id="last_name" value="<?php echo esc_attr( $profile_user->last_name ); ?>" autocomplete="family-name" class="regular-text" />
503+
<?php else : ?>
504+
<input type="text" name="last_name" id="last_name" value="<?php echo esc_attr( $profile_user->last_name ); ?>" class="regular-text" />
505+
<?php endif; ?>
506+
</td>
495507
</tr>
496508

497509
<tr class="user-nickname-wrap">
498510
<th><label for="nickname"><?php _e( 'Nickname' ); ?> <span class="description"><?php _e( '(required)' ); ?></span></label></th>
499-
<td><input type="text" name="nickname" id="nickname" value="<?php echo esc_attr( $profile_user->nickname ); ?>" class="regular-text" /></td>
511+
<td>
512+
<?php if ( IS_PROFILE_PAGE ) : ?>
513+
<input type="text" name="nickname" id="nickname" value="<?php echo esc_attr( $profile_user->nickname ); ?>" autocomplete="nickname" class="regular-text" />
514+
<?php else : ?>
515+
<input type="text" name="nickname" id="nickname" value="<?php echo esc_attr( $profile_user->nickname ); ?>" class="regular-text" />
516+
<?php endif; ?>
517+
</td>
500518
</tr>
501519

502520
<tr class="user-display-name-wrap">
@@ -546,7 +564,7 @@
546564
<th><label for="email"><?php _e( 'Email' ); ?> <span class="description"><?php _e( '(required)' ); ?></span></label></th>
547565
<td>
548566
<?php if ( $profile_user->ID === $current_user->ID ) : ?>
549-
<input type="email" name="email" id="email" aria-describedby="email-description" value="<?php echo esc_attr( $profile_user->user_email ); ?>" class="regular-text ltr" />
567+
<input type="email" name="email" id="email" aria-describedby="email-description" value="<?php echo esc_attr( $profile_user->user_email ); ?>" autocomplete="email" class="regular-text ltr" />
550568
<p class="description" id="email-description">
551569
<?php _e( 'If you change this, an email will be sent at your new address to confirm it. <strong>The new address will not become active until confirmed.</strong>' ); ?>
552570
</p>

0 commit comments

Comments
 (0)