Add the ability to use HTML5 input types in the comment form.
props jorbin, georgestephanis, obenland. fixes #15080 git-svn-id: http://core.svn.wordpress.org/trunk@23689 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
0eaa363b8e
commit
a1e32d3217
|
@ -1518,15 +1518,16 @@ function comment_form( $args = array(), $post_id = null ) {
|
||||||
$user = wp_get_current_user();
|
$user = wp_get_current_user();
|
||||||
$user_identity = $user->exists() ? $user->display_name : '';
|
$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'" : '' );
|
$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> ' .
|
'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>',
|
'<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> ' .
|
'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>' .
|
'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>' );
|
$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' ),
|
'title_reply_to' => __( 'Leave a Reply to %s' ),
|
||||||
'cancel_reply_link' => __( 'Cancel reply' ),
|
'cancel_reply_link' => __( 'Cancel reply' ),
|
||||||
'label_submit' => __( 'Post Comment' ),
|
'label_submit' => __( 'Post Comment' ),
|
||||||
|
'format' => 'xhtml',
|
||||||
);
|
);
|
||||||
|
|
||||||
$args = wp_parse_args( $args, apply_filters( 'comment_form_defaults', $defaults ) );
|
$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 echo $args['must_log_in']; ?>
|
||||||
<?php do_action( 'comment_form_must_log_in_after' ); ?>
|
<?php do_action( 'comment_form_must_log_in_after' ); ?>
|
||||||
<?php else : ?>
|
<?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 do_action( 'comment_form_top' ); ?>
|
||||||
<?php if ( is_user_logged_in() ) : ?>
|
<?php if ( is_user_logged_in() ) : ?>
|
||||||
<?php echo apply_filters( 'comment_form_logged_in', $args['logged_in_as'], $commenter, $user_identity ); ?>
|
<?php echo apply_filters( 'comment_form_logged_in', $args['logged_in_as'], $commenter, $user_identity ); ?>
|
||||||
|
|
Loading…
Reference in New Issue