Comments: Add contextual `autocomplete` attributes to comment form fields.

For accessibility, input fields should identify their "purpose".  The HTML5 attribute `autocomplete` allows for various user data to be quickly autofilled while adding context for some assistive technologies.

This commit adds the appropriate autofill purposes for an author's name, email, and website URL in the comment form template.

Props juliemoynat, bhrugesh96, sabernhardt.
Fixes #55779.
Built from https://develop.svn.wordpress.org/trunk@53576


git-svn-id: http://core.svn.wordpress.org/trunk@53165 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
davidbaumwald 2022-06-24 21:26:12 +00:00
parent e7a9fe918c
commit c2fbb4950d
2 changed files with 4 additions and 4 deletions

View File

@ -2371,7 +2371,7 @@ function comment_form( $args = array(), $post_id = null ) {
( $req ? $required_indicator : '' )
),
sprintf(
'<input id="author" name="author" type="text" value="%s" size="30" maxlength="245"%s />',
'<input id="author" name="author" type="text" value="%s" size="30" maxlength="245" autocomplete="name"%s />',
esc_attr( $commenter['comment_author'] ),
( $req ? $required_attribute : '' )
)
@ -2384,7 +2384,7 @@ function comment_form( $args = array(), $post_id = null ) {
( $req ? $required_indicator : '' )
),
sprintf(
'<input id="email" name="email" %s value="%s" size="30" maxlength="100" aria-describedby="email-notes"%s />',
'<input id="email" name="email" %s value="%s" size="30" maxlength="100" aria-describedby="email-notes" autocomplete="email"%s />',
( $html5 ? 'type="email"' : 'type="text"' ),
esc_attr( $commenter['comment_author_email'] ),
( $req ? $required_attribute : '' )
@ -2397,7 +2397,7 @@ function comment_form( $args = array(), $post_id = null ) {
__( 'Website' )
),
sprintf(
'<input id="url" name="url" %s value="%s" size="30" maxlength="200" />',
'<input id="url" name="url" %s value="%s" size="30" maxlength="200" autocomplete="url" />',
( $html5 ? 'type="url"' : 'type="text"' ),
esc_attr( $commenter['comment_author_url'] )
)

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.1-alpha-53575';
$wp_version = '6.1-alpha-53576';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.