Make WordPress Core

Ticket #15080: 15080.7.diff

File 15080.7.diff, 5.2 KB (added by sscovil, 12 years ago)

Wrapped comment form help text in label tags for accessibility.

  • wp-includes/comment-template.php

     
    15181518        $user = wp_get_current_user();
    15191519        $user_identity = $user->exists() ? $user->display_name : '';
    15201520
    1521         $req = get_option( 'require_name_email' );
     1521        $req      = get_option( 'require_name_email' );
    15221522        $aria_req = ( $req ? " aria-required='true'" : '' );
    1523         $fields =  array(
     1523        $html5    = isset( $args['format'] ) && 'html5' === $args['format'];
     1524        $fields   =  array(
    15241525                'author' => '<p class="comment-form-author">' . '<label for="author">' . __( 'Name' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' .
    15251526                            '<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . ' /></p>',
    15261527                'email'  => '<p class="comment-form-email"><label for="email">' . __( 'Email' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' .
    1527                             '<input id="email" name="email" type="text" value="' . esc_attr(  $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . ' /></p>',
     1528                            '<input id="email" name="email" ' . ( $html5 ? 'type="email" pattern=""' : 'type="text"' ) . ' value="' . esc_attr(  $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . ' /></p>',
    15281529                'url'    => '<p class="comment-form-url"><label for="url">' . __( 'Website' ) . '</label>' .
    1529                             '<input id="url" name="url" type="text" value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" /></p>',
     1530                            '<input id="url" name="url" ' . ( $html5 ? 'type="url" pattern=""' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" /></p>',
    15301531        );
    15311532
    15321533        $required_text = sprintf( ' ' . __('Required fields are marked %s'), '<span class="required">*</span>' );
    15331534        $defaults = array(
    15341535                'fields'               => apply_filters( 'comment_form_default_fields', $fields ),
    15351536                'comment_field'        => '<p class="comment-form-comment"><label for="comment">' . _x( 'Comment', 'noun' ) . '</label><textarea id="comment" name="comment" cols="45" rows="8" aria-required="true"></textarea></p>',
    1536                 'must_log_in'          => '<p class="must-log-in">' . sprintf( __( 'You must be <a href="%s">logged in</a> to post a comment.' ), wp_login_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '</p>',
    1537                 'logged_in_as'         => '<p class="logged-in-as">' . sprintf( __( 'Logged in as <a href="%1$s">%2$s</a>. <a href="%3$s" title="Log out of this account">Log out?</a>' ), get_edit_user_link(), $user_identity, wp_logout_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '</p>',
    1538                 'comment_notes_before' => '<p class="comment-notes">' . __( 'Your email address will not be published.' ) . ( $req ? $required_text : '' ) . '</p>',
    1539                 'comment_notes_after'  => '<p class="form-allowed-tags">' . sprintf( __( 'You may use these <abbr title="HyperText Markup Language">HTML</abbr> tags and attributes: %s' ), ' <code>' . allowed_tags() . '</code>' ) . '</p>',
     1537                'must_log_in'          => '<p class="must-log-in"><label for="author">' . sprintf( __( 'You must be <a href="%s">logged in</a> to post a comment.' ), wp_login_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '</label></p>',
     1538                'logged_in_as'         => '<p class="logged-in-as"><label for="author">' . sprintf( __( 'Logged in as <a href="%1$s">%2$s</a>. <a href="%3$s" title="Log out of this account">Log out?</a>' ), get_edit_user_link(), $user_identity, wp_logout_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '</label></p>',
     1539                'comment_notes_before' => '<p class="comment-notes"><label for="name">' . __( 'Your email address will not be published.' ) . ( $req ? $required_text : '' ) . '</label></p>',
     1540                'comment_notes_after'  => '<p class="form-allowed-tags"><label for="name">' . sprintf( __( 'You may use these <abbr title="HyperText Markup Language">HTML</abbr> tags and attributes: %s' ), ' <code>' . allowed_tags() . '</code>' ) . '</label></p>',
    15401541                'id_form'              => 'commentform',
    15411542                'id_submit'            => 'submit',
    15421543                'title_reply'          => __( 'Leave a Reply' ),
    15431544                'title_reply_to'       => __( 'Leave a Reply to %s' ),
    15441545                'cancel_reply_link'    => __( 'Cancel reply' ),
    15451546                'label_submit'         => __( 'Post Comment' ),
     1547                'format'               => 'xhtml',
    15461548        );
    15471549
    15481550        $args = wp_parse_args( $args, apply_filters( 'comment_form_defaults', $defaults ) );
     
    15561558                                        <?php echo $args['must_log_in']; ?>
    15571559                                        <?php do_action( 'comment_form_must_log_in_after' ); ?>
    15581560                                <?php else : ?>
    1559                                         <form action="<?php echo site_url( '/wp-comments-post.php' ); ?>" method="post" id="<?php echo esc_attr( $args['id_form'] ); ?>">
     1561                                        <form action="<?php echo site_url( '/wp-comments-post.php' ); ?>" method="post" id="<?php echo esc_attr( $args['id_form'] ); ?>"<?php echo $html5 ? ' novalidate' : ''; ?>>
    15601562                                                <?php do_action( 'comment_form_top' ); ?>
    15611563                                                <?php if ( is_user_logged_in() ) : ?>
    15621564                                                        <?php echo apply_filters( 'comment_form_logged_in', $args['logged_in_as'], $commenter, $user_identity ); ?>