Add the ability to use HTML5 input types in the comment form.
props jorbin, georgestephanis, obenland. fixes #15080 git-svn-id: https://develop.svn.wordpress.org/trunk@23689 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
5aed50bd3c
commit
b95b9917f1
|
@ -1518,15 +1518,16 @@ function comment_form( $args = array(), $post_id = null ) {
|
|||
$user = wp_get_current_user();
|
||||
$user_identity = $user->exists() ? $user->display_name : '';
|
||||
|
||||
$req = get_option( 'require_name_email' );
|
||||
$req = get_option( 'require_name_email' );
|
||||
$aria_req = ( $req ? " aria-required='true'" : '' );
|
||||
$fields = array(
|
||||
$html5 = isset( $args['format'] ) && 'html5' === $args['format'];
|
||||
$fields = array(
|
||||
'author' => '<p class="comment-form-author">' . '<label for="author">' . __( 'Name' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' .
|
||||
'<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . ' /></p>',
|
||||
'email' => '<p class="comment-form-email"><label for="email">' . __( 'Email' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' .
|
||||
'<input id="email" name="email" type="text" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . ' /></p>',
|
||||
'<input id="email" name="email" ' . ( $html5 ? 'type="email" pattern=""' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . ' /></p>',
|
||||
'url' => '<p class="comment-form-url"><label for="url">' . __( 'Website' ) . '</label>' .
|
||||
'<input id="url" name="url" type="text" value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" /></p>',
|
||||
'<input id="url" name="url" ' . ( $html5 ? 'type="url" pattern=""' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" /></p>',
|
||||
);
|
||||
|
||||
$required_text = sprintf( ' ' . __('Required fields are marked %s'), '<span class="required">*</span>' );
|
||||
|
@ -1543,6 +1544,7 @@ function comment_form( $args = array(), $post_id = null ) {
|
|||
'title_reply_to' => __( 'Leave a Reply to %s' ),
|
||||
'cancel_reply_link' => __( 'Cancel reply' ),
|
||||
'label_submit' => __( 'Post Comment' ),
|
||||
'format' => 'xhtml',
|
||||
);
|
||||
|
||||
$args = wp_parse_args( $args, apply_filters( 'comment_form_defaults', $defaults ) );
|
||||
|
@ -1556,7 +1558,7 @@ function comment_form( $args = array(), $post_id = null ) {
|
|||
<?php echo $args['must_log_in']; ?>
|
||||
<?php do_action( 'comment_form_must_log_in_after' ); ?>
|
||||
<?php else : ?>
|
||||
<form action="<?php echo site_url( '/wp-comments-post.php' ); ?>" method="post" id="<?php echo esc_attr( $args['id_form'] ); ?>">
|
||||
<form action="<?php echo site_url( '/wp-comments-post.php' ); ?>" method="post" id="<?php echo esc_attr( $args['id_form'] ); ?>"<?php echo $html5 ? ' novalidate' : ''; ?>>
|
||||
<?php do_action( 'comment_form_top' ); ?>
|
||||
<?php if ( is_user_logged_in() ) : ?>
|
||||
<?php echo apply_filters( 'comment_form_logged_in', $args['logged_in_as'], $commenter, $user_identity ); ?>
|
||||
|
|
Loading…
Reference in New Issue