-
Notifications
You must be signed in to change notification settings - Fork 8
/
wp-bootstrap-comment-walker.php
79 lines (68 loc) · 2.45 KB
/
wp-bootstrap-comment-walker.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
/*
* Plugin Name: WP Bootstrap Comment Walker
* Plugin URI: https://github.com/wp-bootstrap/wp-bootstrap-comment-walker
* Version: 2.0.5
* Description: A WordPress class to format WordPress Comments to Twitter Bootstrap.
* Author: WP-Bootstrap
* Author URI: https://github.com/wp-bootstrap
* GitHub Plugin URI: https://github.com/wp-bootstrap/wp-bootstrap-comment-walker
* GitHub Branch: master
* License: GPL-3.0+
* License URI: http://www.gnu.org/licenses/gpl-3.0.txt
*/
class Bootstrap_Comment_Walker extends Walker_Comment {
/**
* Output a comment in the HTML5 format.
*
* @access protected
* @since 1.0.0
*
* @see wp_list_comments()
*
* @param object $comment Comment to display.
* @param int $depth Depth of comment.
* @param array $args An array of arguments.
*/
protected function html5_comment( $comment, $depth, $args ) {
$tag = ( 'div' === $args['style'] ) ? 'div' : 'li';
?>
<<?php echo $tag; ?> id="comment-<?php comment_ID(); ?>" <?php comment_class( $this->has_children ? 'parent media' : 'media' ); ?>>
<?php if ( 0 != $args['avatar_size'] ): ?>
<div class="media-left">
<a href="<?php echo get_comment_author_url(); ?>" class="media-object">
<?php echo get_avatar( $comment, $args['avatar_size'] ); ?>
</a>
</div>
<?php endif; ?>
<div class="media-body">
<?php printf( '<h4 class="media-heading">%s</h4>', get_comment_author_link() ); ?>
<div class="comment-metadata">
<a href="<?php echo esc_url( get_comment_link( $comment->comment_ID, $args ) ); ?>">
<time datetime="<?php comment_time( 'c' ); ?>">
<?php printf( _x( '%1$s at %2$s', '1: date, 2: time' ), get_comment_date(), get_comment_time() ); ?>
</time>
</a>
</div><!-- .comment-metadata -->
<?php if ( '0' == $comment->comment_approved ) : ?>
<p class="comment-awaiting-moderation label label-info"><?php _e( 'Your comment is awaiting moderation.' ); ?></p>
<?php endif; ?>
<div class="comment-content">
<?php comment_text(); ?>
</div><!-- .comment-content -->
<ul class="list-inline">
<?php edit_comment_link( __( 'Edit' ), '<li class="edit-link">', '</li>' ); ?>
<?php
comment_reply_link( array_merge( $args, array(
'add_below' => 'div-comment',
'depth' => $depth,
'max_depth' => $args['max_depth'],
'before' => '<li class="reply-link">',
'after' => '</li>'
) ) );
?>
</ul>
</div>
<?php
}
}