Skip to content

Commit 16baa38

Browse files
committed
Login and Registration: Add autocomplete attributes.
Set valid autocomplete attributes for registration and login fields for username, email, and current password. Autocomplete values are required in WCAG 2.1 at level AA for login forms. Props johnjamesjacoby, dhanendran, rianrietveld, joedolson, peterwilsoncc. Fixes #41136. git-svn-id: https://develop.svn.wordpress.org/trunk@53041 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 143df6e commit 16baa38

3 files changed

Lines changed: 12 additions & 12 deletions

File tree

src/wp-includes/general-template.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ function wp_login_form( $args = array() ) {
586586
sprintf(
587587
'<p class="login-username">
588588
<label for="%1$s">%2$s</label>
589-
<input type="text" name="log" id="%1$s" class="input" value="%3$s" size="20" />
589+
<input type="text" name="log" id="%1$s" autocomplete="username" class="input" value="%3$s" size="20" />
590590
</p>',
591591
esc_attr( $args['id_username'] ),
592592
esc_html( $args['label_username'] ),
@@ -595,7 +595,7 @@ function wp_login_form( $args = array() ) {
595595
sprintf(
596596
'<p class="login-password">
597597
<label for="%1$s">%2$s</label>
598-
<input type="password" name="pwd" id="%1$s" class="input" value="" size="20" />
598+
<input type="password" name="pwd" id="%1$s" autocomplete="current-password" class="input" value="" size="20" />
599599
</p>',
600600
esc_attr( $args['id_password'] ),
601601
esc_html( $args['label_password'] )

src/wp-login.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ function wp_login_viewport_meta() {
827827
<form name="lostpasswordform" id="lostpasswordform" action="<?php echo esc_url( network_site_url( 'wp-login.php?action=lostpassword', 'login_post' ) ); ?>" method="post">
828828
<p>
829829
<label for="user_login"><?php _e( 'Username or Email Address' ); ?></label>
830-
<input type="text" name="user_login" id="user_login" class="input" value="<?php echo esc_attr( $user_login ); ?>" size="20" autocapitalize="off" />
830+
<input type="text" name="user_login" id="user_login" class="input" value="<?php echo esc_attr( $user_login ); ?>" size="20" autocapitalize="off" autocomplete="username" />
831831
</p>
832832
<?php
833833

@@ -1060,11 +1060,11 @@ function wp_login_viewport_meta() {
10601060
<form name="registerform" id="registerform" action="<?php echo esc_url( site_url( 'wp-login.php?action=register', 'login_post' ) ); ?>" method="post" novalidate="novalidate">
10611061
<p>
10621062
<label for="user_login"><?php _e( 'Username' ); ?></label>
1063-
<input type="text" name="user_login" id="user_login" class="input" value="<?php echo esc_attr( wp_unslash( $user_login ) ); ?>" size="20" autocapitalize="off" />
1063+
<input type="text" name="user_login" id="user_login" class="input" value="<?php echo esc_attr( wp_unslash( $user_login ) ); ?>" size="20" autocapitalize="off" autocomplete="username" />
10641064
</p>
10651065
<p>
10661066
<label for="user_email"><?php _e( 'Email' ); ?></label>
1067-
<input type="email" name="user_email" id="user_email" class="input" value="<?php echo esc_attr( wp_unslash( $user_email ) ); ?>" size="25" />
1067+
<input type="email" name="user_email" id="user_email" class="input" value="<?php echo esc_attr( wp_unslash( $user_email ) ); ?>" size="25" autocomplete="email" />
10681068
</p>
10691069
<?php
10701070

@@ -1387,13 +1387,13 @@ function wp_login_viewport_meta() {
13871387
<form name="loginform" id="loginform" action="<?php echo esc_url( site_url( 'wp-login.php', 'login_post' ) ); ?>" method="post">
13881388
<p>
13891389
<label for="user_login"><?php _e( 'Username or Email Address' ); ?></label>
1390-
<input type="text" name="log" id="user_login"<?php echo $aria_describedby_error; ?> class="input" value="<?php echo esc_attr( $user_login ); ?>" size="20" autocapitalize="off" />
1390+
<input type="text" name="log" id="user_login"<?php echo $aria_describedby_error; ?> class="input" value="<?php echo esc_attr( $user_login ); ?>" size="20" autocapitalize="off" autocomplete="username" />
13911391
</p>
13921392

13931393
<div class="user-pass-wrap">
13941394
<label for="user_pass"><?php _e( 'Password' ); ?></label>
13951395
<div class="wp-pwd">
1396-
<input type="password" name="pwd" id="user_pass"<?php echo $aria_describedby_error; ?> class="input password-input" value="" size="20" />
1396+
<input type="password" name="pwd" id="user_pass"<?php echo $aria_describedby_error; ?> class="input password-input" value="" size="20" autocomplete="current-password" />
13971397
<button type="button" class="button button-secondary wp-hide-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e( 'Show password' ); ?>">
13981398
<span class="dashicons dashicons-visibility" aria-hidden="true"></span>
13991399
</button>

src/wp-signup.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,10 @@ function show_blog_form( $blogname = '', $blog_title = '', $errors = '' ) {
118118
}
119119

120120
if ( ! is_subdomain_install() ) {
121-
echo '<span class="prefix_address">' . $current_network->domain . $current_network->path . '</span><input name="blogname" type="text" id="blogname" value="' . esc_attr( $blogname ) . '" maxlength="60" /><br />';
121+
echo '<span class="prefix_address">' . $current_network->domain . $current_network->path . '</span><input name="blogname" type="text" id="blogname" value="' . esc_attr( $blogname ) . '" maxlength="60" autocomplete="off" /><br />';
122122
} else {
123123
$site_domain = preg_replace( '|^www\.|', '', $current_network->domain );
124-
echo '<input name="blogname" type="text" id="blogname" value="' . esc_attr( $blogname ) . '" maxlength="60" /><span class="suffix_address">.' . esc_html( $site_domain ) . '</span><br />';
124+
echo '<input name="blogname" type="text" id="blogname" value="' . esc_attr( $blogname ) . '" maxlength="60" autocomplete="off" /><span class="suffix_address">.' . esc_html( $site_domain ) . '</span><br />';
125125
}
126126

127127
if ( ! is_user_logged_in() ) {
@@ -149,7 +149,7 @@ function show_blog_form( $blogname = '', $blog_title = '', $errors = '' ) {
149149
<p class="error"><?php echo $errmsg; ?></p>
150150
<?php
151151
}
152-
echo '<input name="blog_title" type="text" id="blog_title" value="' . esc_attr( $blog_title ) . '" />';
152+
echo '<input name="blog_title" type="text" id="blog_title" value="' . esc_attr( $blog_title ) . '" autocomplete="off" />';
153153
?>
154154

155155
<?php
@@ -260,7 +260,7 @@ function show_user_form( $user_name = '', $user_email = '', $errors = '' ) {
260260
if ( $errmsg ) {
261261
echo '<p class="error">' . $errmsg . '</p>';
262262
}
263-
echo '<input name="user_name" type="text" id="user_name" value="' . esc_attr( $user_name ) . '" autocapitalize="none" autocorrect="off" maxlength="60" /><br />';
263+
echo '<input name="user_name" type="text" id="user_name" value="' . esc_attr( $user_name ) . '" autocapitalize="none" autocorrect="off" maxlength="60" autocomplete="username" /><br />';
264264
_e( '(Must be at least 4 characters, letters and numbers only.)' );
265265
?>
266266

@@ -271,7 +271,7 @@ function show_user_form( $user_name = '', $user_email = '', $errors = '' ) {
271271
?>
272272
<p class="error"><?php echo $errmsg; ?></p>
273273
<?php } ?>
274-
<input name="user_email" type="email" id="user_email" value="<?php echo esc_attr( $user_email ); ?>" maxlength="200" /><br /><?php _e( 'We send your registration email to this address. (Double-check your email address before continuing.)' ); ?>
274+
<input name="user_email" type="email" id="user_email" value="<?php echo esc_attr( $user_email ); ?>" maxlength="200" autocomplete="email" /><br /><?php _e( 'We send your registration email to this address. (Double-check your email address before continuing.)' ); ?>
275275
<?php
276276
$errmsg = $errors->get_error_message( 'generic' );
277277
if ( $errmsg ) {

0 commit comments

Comments
 (0)