|
1 <?php |
|
2 /** |
|
3 * Comments and Post Comments List Table classes. |
|
4 * |
|
5 * @package WordPress |
|
6 * @subpackage List_Table |
|
7 * @since 3.1.0 |
|
8 */ |
|
9 |
|
10 /** |
|
11 * Comments List Table class. |
|
12 * |
|
13 * @package WordPress |
|
14 * @subpackage List_Table |
|
15 * @since 3.1.0 |
|
16 * @access private |
|
17 */ |
|
18 class WP_Comments_List_Table extends WP_List_Table { |
|
19 |
|
20 var $checkbox = true; |
|
21 |
|
22 var $pending_count = array(); |
|
23 |
|
24 function __construct( $args = array() ) { |
|
25 global $post_id; |
|
26 |
|
27 $post_id = isset( $_REQUEST['p'] ) ? absint( $_REQUEST['p'] ) : 0; |
|
28 |
|
29 if ( get_option('show_avatars') ) |
|
30 add_filter( 'comment_author', 'floated_admin_avatar' ); |
|
31 |
|
32 parent::__construct( array( |
|
33 'plural' => 'comments', |
|
34 'singular' => 'comment', |
|
35 'ajax' => true, |
|
36 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, |
|
37 ) ); |
|
38 } |
|
39 |
|
40 function ajax_user_can() { |
|
41 return current_user_can('edit_posts'); |
|
42 } |
|
43 |
|
44 function prepare_items() { |
|
45 global $post_id, $comment_status, $search, $comment_type; |
|
46 |
|
47 $comment_status = isset( $_REQUEST['comment_status'] ) ? $_REQUEST['comment_status'] : 'all'; |
|
48 if ( !in_array( $comment_status, array( 'all', 'moderated', 'approved', 'spam', 'trash' ) ) ) |
|
49 $comment_status = 'all'; |
|
50 |
|
51 $comment_type = !empty( $_REQUEST['comment_type'] ) ? $_REQUEST['comment_type'] : ''; |
|
52 |
|
53 $search = ( isset( $_REQUEST['s'] ) ) ? $_REQUEST['s'] : ''; |
|
54 |
|
55 $post_type = ( isset( $_REQUEST['post_type'] ) ) ? sanitize_key( $_REQUEST['post_type'] ) : ''; |
|
56 |
|
57 $user_id = ( isset( $_REQUEST['user_id'] ) ) ? $_REQUEST['user_id'] : ''; |
|
58 |
|
59 $orderby = ( isset( $_REQUEST['orderby'] ) ) ? $_REQUEST['orderby'] : ''; |
|
60 $order = ( isset( $_REQUEST['order'] ) ) ? $_REQUEST['order'] : ''; |
|
61 |
|
62 $comments_per_page = $this->get_per_page( $comment_status ); |
|
63 |
|
64 $doing_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX; |
|
65 |
|
66 if ( isset( $_REQUEST['number'] ) ) { |
|
67 $number = (int) $_REQUEST['number']; |
|
68 } |
|
69 else { |
|
70 $number = $comments_per_page + min( 8, $comments_per_page ); // Grab a few extra |
|
71 } |
|
72 |
|
73 $page = $this->get_pagenum(); |
|
74 |
|
75 if ( isset( $_REQUEST['start'] ) ) { |
|
76 $start = $_REQUEST['start']; |
|
77 } else { |
|
78 $start = ( $page - 1 ) * $comments_per_page; |
|
79 } |
|
80 |
|
81 if ( $doing_ajax && isset( $_REQUEST['offset'] ) ) { |
|
82 $start += $_REQUEST['offset']; |
|
83 } |
|
84 |
|
85 $status_map = array( |
|
86 'moderated' => 'hold', |
|
87 'approved' => 'approve', |
|
88 'all' => '', |
|
89 ); |
|
90 |
|
91 $args = array( |
|
92 'status' => isset( $status_map[$comment_status] ) ? $status_map[$comment_status] : $comment_status, |
|
93 'search' => $search, |
|
94 'user_id' => $user_id, |
|
95 'offset' => $start, |
|
96 'number' => $number, |
|
97 'post_id' => $post_id, |
|
98 'type' => $comment_type, |
|
99 'orderby' => $orderby, |
|
100 'order' => $order, |
|
101 'post_type' => $post_type, |
|
102 ); |
|
103 |
|
104 $_comments = get_comments( $args ); |
|
105 |
|
106 update_comment_cache( $_comments ); |
|
107 |
|
108 $this->items = array_slice( $_comments, 0, $comments_per_page ); |
|
109 $this->extra_items = array_slice( $_comments, $comments_per_page ); |
|
110 |
|
111 $total_comments = get_comments( array_merge( $args, array('count' => true, 'offset' => 0, 'number' => 0) ) ); |
|
112 |
|
113 $_comment_post_ids = array(); |
|
114 foreach ( $_comments as $_c ) { |
|
115 $_comment_post_ids[] = $_c->comment_post_ID; |
|
116 } |
|
117 |
|
118 $_comment_post_ids = array_unique( $_comment_post_ids ); |
|
119 |
|
120 $this->pending_count = get_pending_comments_num( $_comment_post_ids ); |
|
121 |
|
122 $this->set_pagination_args( array( |
|
123 'total_items' => $total_comments, |
|
124 'per_page' => $comments_per_page, |
|
125 ) ); |
|
126 } |
|
127 |
|
128 function get_per_page( $comment_status = 'all' ) { |
|
129 $comments_per_page = $this->get_items_per_page( 'edit_comments_per_page' ); |
|
130 $comments_per_page = apply_filters( 'comments_per_page', $comments_per_page, $comment_status ); |
|
131 return $comments_per_page; |
|
132 } |
|
133 |
|
134 function no_items() { |
|
135 global $comment_status; |
|
136 |
|
137 if ( 'moderated' == $comment_status ) |
|
138 _e( 'No comments awaiting moderation.' ); |
|
139 else |
|
140 _e( 'No comments found.' ); |
|
141 } |
|
142 |
|
143 function get_views() { |
|
144 global $post_id, $comment_status, $comment_type; |
|
145 |
|
146 $status_links = array(); |
|
147 $num_comments = ( $post_id ) ? wp_count_comments( $post_id ) : wp_count_comments(); |
|
148 //, number_format_i18n($num_comments->moderated) ), "<span class='comment-count'>" . number_format_i18n($num_comments->moderated) . "</span>"), |
|
149 //, number_format_i18n($num_comments->spam) ), "<span class='spam-comment-count'>" . number_format_i18n($num_comments->spam) . "</span>") |
|
150 $stati = array( |
|
151 'all' => _nx_noop('All', 'All', 'comments'), // singular not used |
|
152 'moderated' => _n_noop('Pending <span class="count">(<span class="pending-count">%s</span>)</span>', 'Pending <span class="count">(<span class="pending-count">%s</span>)</span>'), |
|
153 'approved' => _n_noop('Approved', 'Approved'), // singular not used |
|
154 'spam' => _n_noop('Spam <span class="count">(<span class="spam-count">%s</span>)</span>', 'Spam <span class="count">(<span class="spam-count">%s</span>)</span>'), |
|
155 'trash' => _n_noop('Trash <span class="count">(<span class="trash-count">%s</span>)</span>', 'Trash <span class="count">(<span class="trash-count">%s</span>)</span>') |
|
156 ); |
|
157 |
|
158 if ( !EMPTY_TRASH_DAYS ) |
|
159 unset($stati['trash']); |
|
160 |
|
161 $link = 'edit-comments.php'; |
|
162 if ( !empty($comment_type) && 'all' != $comment_type ) |
|
163 $link = add_query_arg( 'comment_type', $comment_type, $link ); |
|
164 |
|
165 foreach ( $stati as $status => $label ) { |
|
166 $class = ( $status == $comment_status ) ? ' class="current"' : ''; |
|
167 |
|
168 if ( !isset( $num_comments->$status ) ) |
|
169 $num_comments->$status = 10; |
|
170 $link = add_query_arg( 'comment_status', $status, $link ); |
|
171 if ( $post_id ) |
|
172 $link = add_query_arg( 'p', absint( $post_id ), $link ); |
|
173 /* |
|
174 // I toyed with this, but decided against it. Leaving it in here in case anyone thinks it is a good idea. ~ Mark |
|
175 if ( !empty( $_REQUEST['s'] ) ) |
|
176 $link = add_query_arg( 's', esc_attr( wp_unslash( $_REQUEST['s'] ) ), $link ); |
|
177 */ |
|
178 $status_links[$status] = "<a href='$link'$class>" . sprintf( |
|
179 translate_nooped_plural( $label, $num_comments->$status ), |
|
180 number_format_i18n( $num_comments->$status ) |
|
181 ) . '</a>'; |
|
182 } |
|
183 |
|
184 $status_links = apply_filters( 'comment_status_links', $status_links ); |
|
185 return $status_links; |
|
186 } |
|
187 |
|
188 function get_bulk_actions() { |
|
189 global $comment_status; |
|
190 |
|
191 $actions = array(); |
|
192 if ( in_array( $comment_status, array( 'all', 'approved' ) ) ) |
|
193 $actions['unapprove'] = __( 'Unapprove' ); |
|
194 if ( in_array( $comment_status, array( 'all', 'moderated' ) ) ) |
|
195 $actions['approve'] = __( 'Approve' ); |
|
196 if ( in_array( $comment_status, array( 'all', 'moderated', 'approved' ) ) ) |
|
197 $actions['spam'] = _x( 'Mark as Spam', 'comment' ); |
|
198 |
|
199 if ( 'trash' == $comment_status ) |
|
200 $actions['untrash'] = __( 'Restore' ); |
|
201 elseif ( 'spam' == $comment_status ) |
|
202 $actions['unspam'] = _x( 'Not Spam', 'comment' ); |
|
203 |
|
204 if ( in_array( $comment_status, array( 'trash', 'spam' ) ) || !EMPTY_TRASH_DAYS ) |
|
205 $actions['delete'] = __( 'Delete Permanently' ); |
|
206 else |
|
207 $actions['trash'] = __( 'Move to Trash' ); |
|
208 |
|
209 return $actions; |
|
210 } |
|
211 |
|
212 function extra_tablenav( $which ) { |
|
213 global $comment_status, $comment_type; |
|
214 ?> |
|
215 <div class="alignleft actions"> |
|
216 <?php |
|
217 if ( 'top' == $which ) { |
|
218 ?> |
|
219 <select name="comment_type"> |
|
220 <option value=""><?php _e( 'Show all comment types' ); ?></option> |
|
221 <?php |
|
222 $comment_types = apply_filters( 'admin_comment_types_dropdown', array( |
|
223 'comment' => __( 'Comments' ), |
|
224 'pings' => __( 'Pings' ), |
|
225 ) ); |
|
226 |
|
227 foreach ( $comment_types as $type => $label ) |
|
228 echo "\t<option value='" . esc_attr( $type ) . "'" . selected( $comment_type, $type, false ) . ">$label</option>\n"; |
|
229 ?> |
|
230 </select> |
|
231 <?php |
|
232 do_action( 'restrict_manage_comments' ); |
|
233 submit_button( __( 'Filter' ), 'button', false, false, array( 'id' => 'post-query-submit' ) ); |
|
234 } |
|
235 |
|
236 if ( ( 'spam' == $comment_status || 'trash' == $comment_status ) && current_user_can( 'moderate_comments' ) ) { |
|
237 wp_nonce_field( 'bulk-destroy', '_destroy_nonce' ); |
|
238 $title = ( 'spam' == $comment_status ) ? esc_attr__( 'Empty Spam' ) : esc_attr__( 'Empty Trash' ); |
|
239 submit_button( $title, 'apply', 'delete_all', false ); |
|
240 } |
|
241 do_action( 'manage_comments_nav', $comment_status ); |
|
242 echo '</div>'; |
|
243 } |
|
244 |
|
245 function current_action() { |
|
246 if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) ) |
|
247 return 'delete_all'; |
|
248 |
|
249 return parent::current_action(); |
|
250 } |
|
251 |
|
252 function get_columns() { |
|
253 global $post_id; |
|
254 |
|
255 $columns = array(); |
|
256 |
|
257 if ( $this->checkbox ) |
|
258 $columns['cb'] = '<input type="checkbox" />'; |
|
259 |
|
260 $columns['author'] = __( 'Author' ); |
|
261 $columns['comment'] = _x( 'Comment', 'column name' ); |
|
262 |
|
263 if ( !$post_id ) |
|
264 $columns['response'] = _x( 'In Response To', 'column name' ); |
|
265 |
|
266 return $columns; |
|
267 } |
|
268 |
|
269 function get_sortable_columns() { |
|
270 return array( |
|
271 'author' => 'comment_author', |
|
272 'response' => 'comment_post_ID' |
|
273 ); |
|
274 } |
|
275 |
|
276 function display() { |
|
277 extract( $this->_args ); |
|
278 |
|
279 wp_nonce_field( "fetch-list-" . get_class( $this ), '_ajax_fetch_list_nonce' ); |
|
280 |
|
281 $this->display_tablenav( 'top' ); |
|
282 |
|
283 ?> |
|
284 <table class="<?php echo implode( ' ', $this->get_table_classes() ); ?>" cellspacing="0"> |
|
285 <thead> |
|
286 <tr> |
|
287 <?php $this->print_column_headers(); ?> |
|
288 </tr> |
|
289 </thead> |
|
290 |
|
291 <tfoot> |
|
292 <tr> |
|
293 <?php $this->print_column_headers( false ); ?> |
|
294 </tr> |
|
295 </tfoot> |
|
296 |
|
297 <tbody id="the-comment-list" data-wp-lists="list:comment"> |
|
298 <?php $this->display_rows_or_placeholder(); ?> |
|
299 </tbody> |
|
300 |
|
301 <tbody id="the-extra-comment-list" data-wp-lists="list:comment" style="display: none;"> |
|
302 <?php $this->items = $this->extra_items; $this->display_rows(); ?> |
|
303 </tbody> |
|
304 </table> |
|
305 <?php |
|
306 |
|
307 $this->display_tablenav( 'bottom' ); |
|
308 } |
|
309 |
|
310 function single_row( $a_comment ) { |
|
311 global $post, $comment; |
|
312 |
|
313 $comment = $a_comment; |
|
314 $the_comment_class = join( ' ', get_comment_class( wp_get_comment_status( $comment->comment_ID ) ) ); |
|
315 |
|
316 $post = get_post( $comment->comment_post_ID ); |
|
317 |
|
318 $this->user_can = current_user_can( 'edit_comment', $comment->comment_ID ); |
|
319 |
|
320 echo "<tr id='comment-$comment->comment_ID' class='$the_comment_class'>"; |
|
321 $this->single_row_columns( $comment ); |
|
322 echo "</tr>\n"; |
|
323 } |
|
324 |
|
325 function column_cb( $comment ) { |
|
326 if ( $this->user_can ) { ?> |
|
327 <label class="screen-reader-text" for="cb-select-<?php echo $comment->comment_ID; ?>"><?php _e( 'Select comment' ); ?></label> |
|
328 <input id="cb-select-<?php echo $comment->comment_ID; ?>" type="checkbox" name="delete_comments[]" value="<?php echo $comment->comment_ID; ?>" /> |
|
329 <?php |
|
330 } |
|
331 } |
|
332 |
|
333 function column_comment( $comment ) { |
|
334 global $comment_status; |
|
335 $post = get_post(); |
|
336 |
|
337 $user_can = $this->user_can; |
|
338 |
|
339 $comment_url = esc_url( get_comment_link( $comment->comment_ID ) ); |
|
340 $the_comment_status = wp_get_comment_status( $comment->comment_ID ); |
|
341 |
|
342 if ( $user_can ) { |
|
343 $del_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "delete-comment_$comment->comment_ID" ) ); |
|
344 $approve_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "approve-comment_$comment->comment_ID" ) ); |
|
345 |
|
346 $url = "comment.php?c=$comment->comment_ID"; |
|
347 |
|
348 $approve_url = esc_url( $url . "&action=approvecomment&$approve_nonce" ); |
|
349 $unapprove_url = esc_url( $url . "&action=unapprovecomment&$approve_nonce" ); |
|
350 $spam_url = esc_url( $url . "&action=spamcomment&$del_nonce" ); |
|
351 $unspam_url = esc_url( $url . "&action=unspamcomment&$del_nonce" ); |
|
352 $trash_url = esc_url( $url . "&action=trashcomment&$del_nonce" ); |
|
353 $untrash_url = esc_url( $url . "&action=untrashcomment&$del_nonce" ); |
|
354 $delete_url = esc_url( $url . "&action=deletecomment&$del_nonce" ); |
|
355 } |
|
356 |
|
357 echo '<div class="submitted-on">'; |
|
358 /* translators: 2: comment date, 3: comment time */ |
|
359 printf( __( 'Submitted on <a href="%1$s">%2$s at %3$s</a>' ), $comment_url, |
|
360 /* translators: comment date format. See http://php.net/date */ |
|
361 get_comment_date( __( 'Y/m/d' ) ), |
|
362 get_comment_date( get_option( 'time_format' ) ) |
|
363 ); |
|
364 |
|
365 if ( $comment->comment_parent ) { |
|
366 $parent = get_comment( $comment->comment_parent ); |
|
367 $parent_link = esc_url( get_comment_link( $comment->comment_parent ) ); |
|
368 $name = get_comment_author( $parent->comment_ID ); |
|
369 printf( ' | '.__( 'In reply to <a href="%1$s">%2$s</a>.' ), $parent_link, $name ); |
|
370 } |
|
371 |
|
372 echo '</div>'; |
|
373 comment_text(); |
|
374 if ( $user_can ) { ?> |
|
375 <div id="inline-<?php echo $comment->comment_ID; ?>" class="hidden"> |
|
376 <textarea class="comment" rows="1" cols="1"><?php echo esc_textarea( apply_filters( 'comment_edit_pre', $comment->comment_content ) ); ?></textarea> |
|
377 <div class="author-email"><?php echo esc_attr( $comment->comment_author_email ); ?></div> |
|
378 <div class="author"><?php echo esc_attr( $comment->comment_author ); ?></div> |
|
379 <div class="author-url"><?php echo esc_attr( $comment->comment_author_url ); ?></div> |
|
380 <div class="comment_status"><?php echo $comment->comment_approved; ?></div> |
|
381 </div> |
|
382 <?php |
|
383 } |
|
384 |
|
385 if ( $user_can ) { |
|
386 // preorder it: Approve | Reply | Quick Edit | Edit | Spam | Trash |
|
387 $actions = array( |
|
388 'approve' => '', 'unapprove' => '', |
|
389 'reply' => '', |
|
390 'quickedit' => '', |
|
391 'edit' => '', |
|
392 'spam' => '', 'unspam' => '', |
|
393 'trash' => '', 'untrash' => '', 'delete' => '' |
|
394 ); |
|
395 |
|
396 if ( $comment_status && 'all' != $comment_status ) { // not looking at all comments |
|
397 if ( 'approved' == $the_comment_status ) |
|
398 $actions['unapprove'] = "<a href='$unapprove_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&new=unapproved' class='vim-u vim-destructive' title='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>'; |
|
399 else if ( 'unapproved' == $the_comment_status ) |
|
400 $actions['approve'] = "<a href='$approve_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&new=approved' class='vim-a vim-destructive' title='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>'; |
|
401 } else { |
|
402 $actions['approve'] = "<a href='$approve_url' data-wp-lists='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=approved' class='vim-a' title='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>'; |
|
403 $actions['unapprove'] = "<a href='$unapprove_url' data-wp-lists='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=unapproved' class='vim-u' title='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>'; |
|
404 } |
|
405 |
|
406 if ( 'spam' != $the_comment_status && 'trash' != $the_comment_status ) { |
|
407 $actions['spam'] = "<a href='$spam_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::spam=1' class='vim-s vim-destructive' title='" . esc_attr__( 'Mark this comment as spam' ) . "'>" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . '</a>'; |
|
408 } elseif ( 'spam' == $the_comment_status ) { |
|
409 $actions['unspam'] = "<a href='$unspam_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID:66cc66:unspam=1' class='vim-z vim-destructive'>" . _x( 'Not Spam', 'comment' ) . '</a>'; |
|
410 } elseif ( 'trash' == $the_comment_status ) { |
|
411 $actions['untrash'] = "<a href='$untrash_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID:66cc66:untrash=1' class='vim-z vim-destructive'>" . __( 'Restore' ) . '</a>'; |
|
412 } |
|
413 |
|
414 if ( 'spam' == $the_comment_status || 'trash' == $the_comment_status || !EMPTY_TRASH_DAYS ) { |
|
415 $actions['delete'] = "<a href='$delete_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::delete=1' class='delete vim-d vim-destructive'>" . __( 'Delete Permanently' ) . '</a>'; |
|
416 } else { |
|
417 $actions['trash'] = "<a href='$trash_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::trash=1' class='delete vim-d vim-destructive' title='" . esc_attr__( 'Move this comment to the trash' ) . "'>" . _x( 'Trash', 'verb' ) . '</a>'; |
|
418 } |
|
419 |
|
420 if ( 'spam' != $the_comment_status && 'trash' != $the_comment_status ) { |
|
421 $actions['edit'] = "<a href='comment.php?action=editcomment&c={$comment->comment_ID}' title='" . esc_attr__( 'Edit comment' ) . "'>". __( 'Edit' ) . '</a>'; |
|
422 $actions['quickedit'] = '<a onclick="commentReply.open( \''.$comment->comment_ID.'\',\''.$post->ID.'\',\'edit\' );return false;" class="vim-q" title="'.esc_attr__( 'Quick Edit' ).'" href="#">' . __( 'Quick Edit' ) . '</a>'; |
|
423 $actions['reply'] = '<a onclick="commentReply.open( \''.$comment->comment_ID.'\',\''.$post->ID.'\' );return false;" class="vim-r" title="'.esc_attr__( 'Reply to this comment' ).'" href="#">' . __( 'Reply' ) . '</a>'; |
|
424 } |
|
425 |
|
426 $actions = apply_filters( 'comment_row_actions', array_filter( $actions ), $comment ); |
|
427 |
|
428 $i = 0; |
|
429 echo '<div class="row-actions">'; |
|
430 foreach ( $actions as $action => $link ) { |
|
431 ++$i; |
|
432 ( ( ( 'approve' == $action || 'unapprove' == $action ) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | '; |
|
433 |
|
434 // Reply and quickedit need a hide-if-no-js span when not added with ajax |
|
435 if ( ( 'reply' == $action || 'quickedit' == $action ) && ! defined('DOING_AJAX') ) |
|
436 $action .= ' hide-if-no-js'; |
|
437 elseif ( ( $action == 'untrash' && $the_comment_status == 'trash' ) || ( $action == 'unspam' && $the_comment_status == 'spam' ) ) { |
|
438 if ( '1' == get_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', true ) ) |
|
439 $action .= ' approve'; |
|
440 else |
|
441 $action .= ' unapprove'; |
|
442 } |
|
443 |
|
444 echo "<span class='$action'>$sep$link</span>"; |
|
445 } |
|
446 echo '</div>'; |
|
447 } |
|
448 } |
|
449 |
|
450 function column_author( $comment ) { |
|
451 global $comment_status; |
|
452 |
|
453 $author_url = get_comment_author_url(); |
|
454 if ( 'http://' == $author_url ) |
|
455 $author_url = ''; |
|
456 $author_url_display = preg_replace( '|http://(www\.)?|i', '', $author_url ); |
|
457 if ( strlen( $author_url_display ) > 50 ) |
|
458 $author_url_display = substr( $author_url_display, 0, 49 ) . '…'; |
|
459 |
|
460 echo "<strong>"; comment_author(); echo '</strong><br />'; |
|
461 if ( !empty( $author_url ) ) |
|
462 echo "<a title='$author_url' href='$author_url'>$author_url_display</a><br />"; |
|
463 |
|
464 if ( $this->user_can ) { |
|
465 if ( !empty( $comment->comment_author_email ) ) { |
|
466 comment_author_email_link(); |
|
467 echo '<br />'; |
|
468 } |
|
469 echo '<a href="edit-comments.php?s='; |
|
470 comment_author_IP(); |
|
471 echo '&mode=detail'; |
|
472 if ( 'spam' == $comment_status ) |
|
473 echo '&comment_status=spam'; |
|
474 echo '">'; |
|
475 comment_author_IP(); |
|
476 echo '</a>'; |
|
477 } |
|
478 } |
|
479 |
|
480 function column_date( $comment ) { |
|
481 return get_comment_date( __( 'Y/m/d \a\t g:ia' ) ); |
|
482 } |
|
483 |
|
484 function column_response( $comment ) { |
|
485 $post = get_post(); |
|
486 |
|
487 if ( isset( $this->pending_count[$post->ID] ) ) { |
|
488 $pending_comments = $this->pending_count[$post->ID]; |
|
489 } else { |
|
490 $_pending_count_temp = get_pending_comments_num( array( $post->ID ) ); |
|
491 $pending_comments = $this->pending_count[$post->ID] = $_pending_count_temp[$post->ID]; |
|
492 } |
|
493 |
|
494 if ( current_user_can( 'edit_post', $post->ID ) ) { |
|
495 $post_link = "<a href='" . get_edit_post_link( $post->ID ) . "'>"; |
|
496 $post_link .= get_the_title( $post->ID ) . '</a>'; |
|
497 } else { |
|
498 $post_link = get_the_title( $post->ID ); |
|
499 } |
|
500 |
|
501 echo '<div class="response-links"><span class="post-com-count-wrapper">'; |
|
502 echo $post_link . '<br />'; |
|
503 $this->comments_bubble( $post->ID, $pending_comments ); |
|
504 echo '</span> '; |
|
505 $post_type_object = get_post_type_object( $post->post_type ); |
|
506 echo "<a href='" . get_permalink( $post->ID ) . "'>" . $post_type_object->labels->view_item . '</a>'; |
|
507 echo '</div>'; |
|
508 if ( 'attachment' == $post->post_type && ( $thumb = wp_get_attachment_image( $post->ID, array( 80, 60 ), true ) ) ) |
|
509 echo $thumb; |
|
510 } |
|
511 |
|
512 function column_default( $comment, $column_name ) { |
|
513 do_action( 'manage_comments_custom_column', $column_name, $comment->comment_ID ); |
|
514 } |
|
515 } |
|
516 |
|
517 /** |
|
518 * Post Comments List Table class. |
|
519 * |
|
520 * @package WordPress |
|
521 * @subpackage List_Table |
|
522 * @since 3.1.0 |
|
523 * @access private |
|
524 * |
|
525 * @see WP_Comments_Table |
|
526 */ |
|
527 class WP_Post_Comments_List_Table extends WP_Comments_List_Table { |
|
528 |
|
529 function get_column_info() { |
|
530 $this->_column_headers = array( |
|
531 array( |
|
532 'author' => __( 'Author' ), |
|
533 'comment' => _x( 'Comment', 'column name' ), |
|
534 ), |
|
535 array(), |
|
536 array(), |
|
537 ); |
|
538 |
|
539 return $this->_column_headers; |
|
540 } |
|
541 |
|
542 function get_table_classes() { |
|
543 $classes = parent::get_table_classes(); |
|
544 $classes[] = 'comments-box'; |
|
545 return $classes; |
|
546 } |
|
547 |
|
548 function display( $output_empty = false ) { |
|
549 extract( $this->_args ); |
|
550 |
|
551 wp_nonce_field( "fetch-list-" . get_class( $this ), '_ajax_fetch_list_nonce' ); |
|
552 ?> |
|
553 <table class="<?php echo implode( ' ', $this->get_table_classes() ); ?>" cellspacing="0" style="display:none;"> |
|
554 <tbody id="the-comment-list"<?php if ( $singular ) echo " data-wp-lists='list:$singular'"; ?>> |
|
555 <?php if ( ! $output_empty ) $this->display_rows_or_placeholder(); ?> |
|
556 </tbody> |
|
557 </table> |
|
558 <?php |
|
559 } |
|
560 |
|
561 function get_per_page( $comment_status = false ) { |
|
562 return 10; |
|
563 } |
|
564 } |