我使用html5支持输入格式和自定义注释表单字段,代码如下:
<?php
$commenter = wp_get_current_commenter();
$args = wp_parse_args( $args );
if ( ! isset( $args[\'format\'] ) )
$args[\'format\'] = current_theme_supports( \'html5\', \'comment-form\' ) ? \'html5\' : \'xhtml\';
$req = get_option( \'require_name_email\' );
$aria_req = ( $req ? " aria-required=\'true\'" : \'\' );
$html_req = ( $req ? " required=\'required\'" : \'\' );
$html5 = \'html5\' === $args[\'format\'];
comment_form(
array(
\'comment_notes_after\' => \'\',
\'comment_field\' => \'<div class="comment-form-comment form-group"><label class="control-label" for="comment">\' . __( \'Comment\', \'odin\' ) . \'</label><div class="controls"><textarea id="comment" name="comment" cols="45" rows="8" class="form-control" aria-required="true" ></textarea></div></div>\',
\'fields\' => apply_filters( \'comment_form_default_fields\', array(
\'author\' => \'<div class="comment-form-author form-group">\' . \'<label class="control-label" for="author">\' . __( \'Name\', \'odin\' ) . ( $req ? \'<span class="required"> *</span>\' : \'\' ) . \'</label><input class="form-control" id="author" name="author" type="text" value="\' . esc_attr( $commenter[\'comment_author\'] ) . \'" size="30"\' . $aria_req . $html_req . \' /></div>\',
\'email\' => \'<div class="comment-form-email form-group"><label class="control-label" for="email">\' . __( \'E-mail\', \'odin\' ) . ( $req ? \'<span class="required"> *</span>\' : \'\' ) . \'</label><input class="form-control" id="email" name="email" \' . ( $html5 ? \'type="email"\' : \'type="text"\' ) . \' value="\' . esc_attr( $commenter[\'comment_author_email\'] ) . \'" size="30"\' . $aria_req . $html_req . \' /></div>\',
\'url\' => \'<div class="comment-form-url form-group"><label class="control-label" for="url">\' . __( \'Website\', \'odin\' ) . \'</label>\' . \'<input class="form-control" id="url" name="url" \' . ( $html5 ? \'type="url"\' : \'type="text"\' ) . \' value="\' . esc_attr( $commenter[\'comment_author_url\'] ) . \'" size="30" /></div>\' ) )
)
); ?>
为验证html5做好了一切准备,除了标记的novalidade属性。我目前正在删除jQuery,但我想知道是否有办法通过WP/PHP