WordPress.org

Make WordPress Core

Changeset 23689


Ignore:
Timestamp:
03/13/2013 08:31:43 PM (7 years ago)
Author:
markjaquith
Message:

Add the ability to use HTML5 input types in the comment form.

props jorbin, georgestephanis, obenland. fixes #15080

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/comment-template.php

    r23624 r23689  
    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
     
    15441545        'cancel_reply_link'    => __( 'Cancel reply' ),
    15451546        'label_submit'         => __( 'Post Comment' ),
     1547        'format'               => 'xhtml',
    15461548    );
    15471549
     
    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() ) : ?>
Note: See TracChangeset for help on using the changeset viewer.