diff --git a/wp-includes/comment-template.php b/wp-includes/comment-template.php index e45088729f..1415dd1e2f 100644 --- a/wp-includes/comment-template.php +++ b/wp-includes/comment-template.php @@ -2350,9 +2350,15 @@ function comment_form( $args = array(), $post_id = null ) { $args['format'] = current_theme_supports( 'html5', 'comment-form' ) ? 'html5' : 'xhtml'; } - $req = get_option( 'require_name_email' ); - $html_req = ( $req ? " required='required'" : '' ); - $html5 = 'html5' === $args['format']; + $req = get_option( 'require_name_email' ); + $html5 = 'html5' === $args['format']; + + // Define attributes in HTML5 or XHTML syntax. + $required_attribute = ( $html5 ? ' required' : ' required="required"' ); + $checked_attribute = ( $html5 ? ' checked' : ' checked="checked"' ); + + // Identify required fields visually. + $required_indicator = ' '; $fields = array( 'author' => sprintf( @@ -2360,12 +2366,12 @@ function comment_form( $args = array(), $post_id = null ) { sprintf( '', __( 'Name' ), - ( $req ? ' *' : '' ) + ( $req ? $required_indicator : '' ) ), sprintf( '', esc_attr( $commenter['comment_author'] ), - $html_req + ( $req ? $required_attribute : '' ) ) ), 'email' => sprintf( @@ -2373,13 +2379,13 @@ function comment_form( $args = array(), $post_id = null ) { sprintf( '', __( 'Email' ), - ( $req ? ' *' : '' ) + ( $req ? $required_indicator : '' ) ), sprintf( '', ( $html5 ? 'type="email"' : 'type="text"' ), esc_attr( $commenter['comment_author_email'] ), - $html_req + ( $req ? $required_attribute : '' ) ) ), 'url' => sprintf( @@ -2397,7 +2403,7 @@ function comment_form( $args = array(), $post_id = null ) { ); if ( has_action( 'set_comment_cookies', 'wp_set_comment_cookies' ) && get_option( 'show_comments_cookies_opt_in' ) ) { - $consent = empty( $commenter['comment_author_email'] ) ? '' : ' checked="checked"'; + $consent = empty( $commenter['comment_author_email'] ) ? '' : $checked_attribute; $fields['cookies'] = sprintf( '', @@ -2419,8 +2425,8 @@ function comment_form( $args = array(), $post_id = null ) { $required_text = sprintf( /* translators: %s: Asterisk symbol (*). */ - ' ' . __( 'Required fields are marked %s' ), - '*' + ' ', + trim( $required_indicator ) ); /** @@ -2437,10 +2443,11 @@ function comment_form( $args = array(), $post_id = null ) { 'comment_field' => sprintf( '

%s %s

', sprintf( - '', - _x( 'Comment', 'noun' ) + '', + _x( 'Comment', 'noun' ), + $required_indicator ), - '' + '' ), 'must_log_in' => sprintf( '

%s

', @@ -2452,7 +2459,7 @@ function comment_form( $args = array(), $post_id = null ) { ) ), 'logged_in_as' => sprintf( - '

%s

', + '

%s%s

', sprintf( /* translators: 1: Edit user link, 2: Accessibility text, 3: User name, 4: Logout URL. */ __( 'Logged in as %3$s. Log out?' ), @@ -2462,7 +2469,8 @@ function comment_form( $args = array(), $post_id = null ) { $user_identity, /** This filter is documented in wp-includes/link-template.php */ wp_logout_url( apply_filters( 'the_permalink', get_permalink( $post_id ), $post_id ) ) - ) + ), + $required_text ), 'comment_notes_before' => sprintf( '

%s%s

', @@ -2470,7 +2478,7 @@ function comment_form( $args = array(), $post_id = null ) { '%s', __( 'Your email address will not be published.' ) ), - ( $req ? $required_text : '' ) + $required_text ), 'comment_notes_after' => '', 'action' => site_url( '/wp-comments-post.php' ), diff --git a/wp-includes/comment.php b/wp-includes/comment.php index 113bb2e719..c2892f16b1 100644 --- a/wp-includes/comment.php +++ b/wp-includes/comment.php @@ -3549,7 +3549,7 @@ function wp_handle_comment_submission( $comment_data ) { if ( get_option( 'require_name_email' ) && ! $user->exists() ) { if ( '' == $comment_author_email || '' == $comment_author ) { - return new WP_Error( 'require_name_email', __( 'Error: Please fill the required fields (name, email).' ), 200 ); + return new WP_Error( 'require_name_email', __( 'Error: Please fill the required fields.' ), 200 ); } elseif ( ! is_email( $comment_author_email ) ) { return new WP_Error( 'require_valid_email', __( 'Error: Please enter a valid email address.' ), 200 ); } diff --git a/wp-includes/version.php b/wp-includes/version.php index a2a5857dd3..d64fdab1d1 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '5.9-alpha-52028'; +$wp_version = '5.9-alpha-52029'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.