Last active
August 29, 2015 14:23
-
-
Save vajrasar/f0a309a3174c52571daa to your computer and use it in GitHub Desktop.
Modifying Comment Form & Comment List along with its Markup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| //Disabling URL field | |
| function vg_disable_comment_url( $fields ) { | |
| unset( $fields['url'] ); | |
| return $fields; | |
| } | |
| add_filter('comment_form_default_fields','vg_disable_comment_url'); | |
| //To edit defaults in comment field | |
| function vg_modify_comment_defaults( $defaults ) { | |
| $defaults['comment_notes_after'] = ''; | |
| $defaults['comment_notes_before'] = ''; | |
| $defaults['title_reply'] = 'Leave A Comment'; | |
| $defaults['comment_field'] = ''; | |
| return $defaults; | |
| } | |
| add_filter( 'comment_form_defaults', 'vg_modify_comment_defaults' ); | |
| //To modify structure of input fields and the wrapping html markup | |
| function vg_modify_comment_form_fields( $fields ){ | |
| $fields['author'] = '<div class="col-xs-12 col-sm-4 col-md-4 form-group">' | |
| . '<input class="form-control height-in" placeholder="Enter Name" id="author" name="author" type="text" value="' | |
| . esc_attr( $commenter['comment_author'] ) | |
| . '" size="30"' | |
| . $aria_req | |
| . ' /></div>'; | |
| $fields['email'] = '<div class="col-xs-12 col-sm-4 col-md-4 form-group">' | |
| . '<input class="form-control height-in" placeholder="Enter Email" id="email" name="email" ' | |
| . ( $html5 ? 'type="email"' : 'type="text"' ) | |
| . ' value="' | |
| . esc_attr( $commenter['comment_author_email'] ) | |
| . '" size="30"' | |
| . $aria_req | |
| . ' /></div>'; | |
| $fields['comment_field'] = '<div class="col-xs-12 col-sm-12 col-md-12 form-group top-equal"> | |
| <textarea class="form-control" placeholder="Comment" id="comment" name="comment" cols="45" rows="7" aria-required="true"></textarea> | |
| </div>'; | |
| $fields['comment_notes_after'] = '<input type="submit" class="btn btn-1 btn-1a ct-us-send" id="submit-new" value="' . __( 'Submit' ) . '" />'; | |
| return $fields; | |
| } | |
| add_filter('comment_form_default_fields','vg_modify_comment_form_fields'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // To add custom class in comment form | |
| ob_start(); | |
| comment_form(); | |
| echo str_replace('class="comment-form"','class="form-inline"',ob_get_clean()); //class added is form-inline |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| //This will go in place of default comment list call | |
| function vg_list_comments() { | |
| wp_list_comments( 'type=comment&callback=vg_format_comment' ); //vg_format_comment is the function being called | |
| } | |
| remove_action( 'genesis_list_comments', 'genesis_default_list_comments' ); | |
| add_action( 'genesis_list_comments', 'vg_list_comments' ); | |
| //To modify comment list and its wrapping markup using vg_format_comment function defined in callback | |
| function vg_format_comment( $comment, $args, $depth ) { | |
| $GLOBALS['comment'] = $comment; | |
| $ca = get_comment_author(); | |
| ?> | |
| <div class="comment-details"> | |
| <div class="comment-pic"> | |
| <?php echo get_avatar( $comment, 32 ); ?> | |
| </div> | |
| <div class="comment-inner"> | |
| <div class="comment-info"> | |
| <div class="clearfix"> | |
| <h4><?php printf(__('%s'), get_comment_author_link()) ?></h4> | |
| <div id="reply-cover"> | |
| <i class="fa fa-reply"></i> <?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?> | |
| </div> | |
| </div> | |
| <div class="comment-on"> | |
| <h6><?php printf(__('%1$s'), get_comment_date(), get_comment_time()) ?></h6> | |
| </div> | |
| <div class="comment-text"> | |
| <?php comment_text(); ?> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="clearfix"></div> | |
| <?php | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!-- Comment Form HTML --> | |
| <div class="sub-figure"> | |
| <div class="sub-post-title"> | |
| <h4 class="recent-title">Comments</h4> | |
| </div> | |
| </div> | |
| <!-- Leave a comment --> | |
| <div class="sub-figure"> | |
| <div class="sub-post-title"> | |
| <h4 class="recent-title">Leave A Comment</h4> | |
| </div> | |
| <form class="form-inline"> | |
| <div class="col-xs-12 col-sm-4 col-md-4 form-group"> | |
| <input type="text" class="form-control height-in" id="reply-name" placeholder="Enter Name"> | |
| </div> | |
| <div class="col-xs-12 col-sm-4 col-md-4 form-group"> | |
| <input type="email" class="form-control height-in" id="replay-email" placeholder="Enter Email"> | |
| </div> | |
| <div class="col-xs-12 col-sm-12 col-md-12 form-group top-equal"> | |
| <textarea class="form-control" rows="7" placeholder="Comment"></textarea> | |
| </div> | |
| <div class="col-xs-12 col-sm-12 col-md-12 form-group top-equal"> | |
| <input type="submit" class="btn btn-1 btn-1a ct-us-send"> | |
| </div> | |
| </form> | |
| </div> | |
| <!-- Comments List HTML --> | |
| <div class="comment-details"> | |
| <div class="comment-pic"> | |
| <img src="img/comment.jpg"> | |
| </div> | |
| <div class="comment-inner"> | |
| <div class="comment-info"> | |
| <div class="clearfix"> | |
| <h4>Vajrasar</h4> | |
| <a href="#"><i class="fa fa-reply"></i> Reply</a> | |
| </div> | |
| <div class="comment-on"> | |
| <h6>September 9, 2014</h6> | |
| </div> | |
| <div class="comment-text"> | |
| <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p> | |
| </div> | |
| </div> | |
| </div> | |
| </div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment