Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save prajwal-stha/d1ff67f3b146d33b2dde3abe85050188 to your computer and use it in GitHub Desktop.
Save prajwal-stha/d1ff67f3b146d33b2dde3abe85050188 to your computer and use it in GitHub Desktop.
Remove "novalidate" attribute in default WordPress Comment Form
ob_start();
$commenter = wp_get_current_commenter();
$req = get_option( 'require_name_email' );
$aria_req = ( $req ? " aria-required='true'" : '' );
$html_req = ( $req ? " required='required'" : '' );
$span_req = ( $req ? ' <span class="required">*</span>' : '' );
comment_form( array(
'title_reply' => __( 'Leave your thoughts', 'issimple' ),
'comment_notes_after' => '',
'fields' => apply_filters( 'comment_form_default_fields', array(
'author' => '<div class="comment-form-author form-group">' . '<label for="author">' . __( 'Name', 'issimple' ) . $span_req . '</label> ' .
'<input id="author" class="form-control" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="40"' . $aria_req . $html_req . ' /></div>',
'email' => '<div class="comment-form-email form-group"><label for="email">' . __( 'Email', 'issimple' ) . $span_req . '</label> ' .
'<input id="email" class="form-control" name="email" type="email" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="40" aria-describedby="email-notes"' . $aria_req . $html_req . ' /></div>',
'url' => '<div class="comment-form-url form-group"><label for="url">' . __( 'Website', 'issimple' ) . '</label> ' .
'<input id="url" class="form-control" name="url" ' . ( $html5 ? 'type="url"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="40" /></div>',
) ),
'comment_field' => '<div class="comment-form-comment form-group"><label for="comment">' . __( 'Comment', 'issimple' ) . ' <span class="required">*</span></label> ' .
'<textarea id="comment" class="form-control" name="comment" cols="45" rows="8" aria-describedby="form-allowed-tags" aria-required="true" required="required"></textarea></div>',
'class_submit' => 'submit btn btn-default',
) );
$comment_form = ob_get_contents();
ob_end_clean();
echo str_replace( 'novalidate', '', $comment_form );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment