forked from roryee/artificial-intelligence
/
comments.php
179 lines (141 loc) · 4.05 KB
/
comments.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<?php
class AI_Walker_Comment extends Walker_Comment
{
public $tree_type = 'comment';
public $db_fields = array( 'parent' => 'comment_parent', 'id' => 'comment_ID' );
// opens the comments section
function __construct()
{ ?>
<section class="comments-old w">
<h3>Comments</h3>
<ul class="comments-old c">
<?php }
// opens a comment thread
public function start_lvl( &$output, $depth = 0, $args = array() )
{
$GLOBALS['comment_depth'] = $depth + 1; ?>
<ul class="comment-replies">
<?php }
// closes a comment thread
public function end_lvl( &$output, $depth = 0, $args = array() )
{
$GLOBALS['comment_depth'] = $depth + 1; ?>
</ul>
<?php }
// opens a single comment
public function start_el( &$output, $comment, $depth = 0, $args = array(), $id = 0 )
{
$depth++;
$GLOBALS['comment_depth'] = $depth;
$GLOBALS['comment'] = $comment;
$parent_class = ( empty( $args['has_children'] ) ? '' : 'parent' ); ?>
<li id="comment-<?php comment_ID(); ?>" <?php comment_class( $parent_class ); ?>>
<div class="comment-header">
<div class="left">
<ul class="c">
<li class="author">
<a href="<?php comment_author_url(); ?>">
<?php comment_author(); ?>
</a>
</li>
<li class="date">
<?php comment_time( get_option( 'n/j/Y g:i A' ) ); ?>
</li>
</ul>
</div>
<div class="right">
<ul class="c">
<li class="reply">
<?php
$reply_args = array(
'depth' => $depth,
'max_depth' => $args['max_depth'],
'reply_text' => '<span data-icon="reply"></span>'
);
comment_reply_link( array_merge( $args, $reply_args ) );
?>
</li>
<li class="edit">
<?php edit_comment_link( '<span data-icon="edit"></span>' ); ?>
</li>
</ul>
</div>
</div>
<section class="comment-body">
<?php comment_text(); ?>
</section>
<?php }
// closes a single comment
public function end_el( &$output, $comment, $depth = 0, $args = array(), $id = 0 )
{ ?>
</li>
<?php }
// closes the comments section
function __destruct()
{ ?>
</ul>
</section>
<?php }
}
function ai_comments_fields( $fields )
{
$req = '';
if ( get_option( 'require_name_email' ) )
{
$req = ' req';
}
$commenter = wp_get_current_commenter();
$fields['author'] =
'<div class="form-group' . $req . '">' .
'<input type="text" name="author" placeholder="' . __( 'Name' ) .
'" value="' . esc_attr( $commenter['comment_author'] ) . '" />' .
'</div>';
$fields['email'] =
'<div class="form-group' . $req . '">' .
'<input type="text" name="author" placeholder="' . __( 'Email' ) .
'"value="' . esc_attr( $commenter['comment_author_email'] ) . '" />' .
'</div>';
$fields['url'] =
'<div class="form-group">' .
'<input type="text" name="author" placeholder="' . __( 'Website' ) .
'"value="' . esc_attr( $commenter['comment_author_url'] ) . '" />' .
'</div>';
return $fields;
}
add_filter( 'comment_form_default_fields', 'ai_comments_fields' );
function ai_comments_field()
{
return
'<div class="form-group req">' .
'<textarea name="comment" placeholder="Comment" style="min-height:10em;"></textarea>' .
'</div>';
}
add_filter( 'comment_form_field_comment', 'ai_comments_field' );
?>
<?php if ( comments_open() || get_comments_number() ): ?>
<aside id="comments">
<div class="cc">
<?php if ( get_comments_number() ): ?>
<?php
wp_list_comments( array(
'walker' => new AI_Walker_Comment,
));
?>
<?php endif; if ( comments_open() ): ?>
<section class="comments-new w">
<?php
comment_form( array(
'id_form' => '',
'comment_notes_before' => '',
'comment_notes_after' => '',
'title_reply' => __( 'Reply' ),
'title_reply_to' => __( 'Reply to %s' ),
'cancel_reply_link' => __( 'Cancel' ),
'label_submit' => __( 'Submit' ),
));
?>
</section>
<?php endif; ?>
</div>
</aside>
<?php endif; ?>