custom comment form

adding bootstrap markup via filter to comment form
This commit is contained in:
Holger 2015-03-31 16:17:52 +02:00
parent 14f72166b3
commit 1a8a5960df
2 changed files with 34 additions and 3 deletions

View File

@ -43,6 +43,11 @@ require get_template_directory() . '/inc/extras.php';
*/ */
require get_template_directory() . '/inc/customizer.php'; require get_template_directory() . '/inc/customizer.php';
/**
* Customizer additions.
*/
require get_template_directory() . '/inc/custom-comments.php';
/** /**
* Load Jetpack compatibility file. * Load Jetpack compatibility file.
*/ */
@ -52,6 +57,3 @@ require get_template_directory() . '/inc/jetpack.php';
* Load custom WordPress nav walker. * Load custom WordPress nav walker.
*/ */
require get_template_directory() . '/inc/bootstrap-wp-navwalker.php'; require get_template_directory() . '/inc/bootstrap-wp-navwalker.php';
require_once('inc/wp-updates-theme.php');
new WPUpdatesThemeUpdater_1114( 'http://wp-updates.com/api/2/theme', basename( get_template_directory() ) );

29
inc/custom-comments.php Normal file
View File

@ -0,0 +1,29 @@
<?php
/************* COMMENT LAYOUT *********************/
// Comment Form
add_filter( 'comment_form_default_fields', 'bootstrap3_comment_form_fields' );
function bootstrap3_comment_form_fields( $fields ) {
$commenter = wp_get_current_commenter();
$req = get_option( 'require_name_email' );
$aria_req = ( $req ? " aria-required='true'" : '' );
$html5 = current_theme_supports( 'html5', 'comment-form' ) ? 1 : 0;
$fields = array(
'author' => '<div class="form-group comment-form-author">' . '<label for="author">' . __( 'Name' ) . ( $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 . ' /></div>',
'email' => '<div class="form-group comment-form-email"><label for="email">' . __( 'Email' ) . ( $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 . ' /></div>',
'url' => '<div class="form-group comment-form-url"><label for="url">' . __( 'Website' ) . '</label> ' .
'<input class="form-control" id="url" name="url" ' . ( $html5 ? 'type="url"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" /></div>',
);
return $fields;
}
add_filter( 'comment_form_defaults', 'bootstrap3_comment_form' );
function bootstrap3_comment_form( $args ) {
$args['comment_field'] = '<div class="form-group comment-form-comment">
<label for="comment">' . _x( 'Comment', 'noun' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label>
<textarea class="form-control" id="comment" name="comment" cols="45" rows="8" aria-required="true"></textarea>
</div>';
return $args;
}