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