run:R W Run
7.85 KB
2026-03-11 16:18:51
R W Run
3.54 KB
2026-03-11 16:18:51
R W Run
148.33 KB
2026-03-11 16:18:51
R W Run
11.45 KB
2026-03-11 16:18:51
R W Run
3.58 KB
2026-03-11 16:18:51
R W Run
2.53 KB
2026-03-11 16:18:51
R W Run
2.6 KB
2026-03-11 16:18:51
R W Run
6.59 KB
2026-03-11 16:18:51
R W Run
14.83 KB
2026-03-11 16:18:51
R W Run
21.18 KB
2026-03-11 16:18:51
R W Run
48.13 KB
2026-03-11 16:18:51
R W Run
4.07 KB
2026-03-11 16:18:51
R W Run
5.3 KB
2026-03-11 16:18:51
R W Run
8.28 KB
2026-03-11 16:18:51
R W Run
26.73 KB
2026-03-11 16:18:51
R W Run
2.8 KB
2026-03-11 16:18:51
R W Run
15.2 KB
2026-03-11 16:18:51
R W Run
192.08 KB
2026-03-11 16:18:51
R W Run
11.77 KB
2026-03-11 16:18:51
R W Run
3.2 KB
2026-03-11 16:18:51
R W Run
22.89 KB
2026-03-11 16:18:51
R W Run
12.77 KB
2026-03-11 16:18:51
R W Run
4.08 KB
2026-03-11 16:18:51
R W Run
26.27 KB
2026-03-11 16:18:51
R W Run
4.97 KB
2026-03-11 16:18:51
R W Run
5.57 KB
2026-03-11 16:18:51
R W Run
13.93 KB
2026-03-11 16:18:51
R W Run
4.09 KB
2026-03-11 16:18:51
R W Run
6.79 KB
2026-03-11 16:18:51
R W Run
60.45 KB
2026-03-11 16:18:51
R W Run
32.4 KB
2026-03-11 16:18:51
R W Run
18.24 KB
2026-03-11 16:18:51
R W Run
66.01 KB
2026-03-11 16:18:51
R W Run
23.84 KB
2026-03-11 16:18:51
R W Run
17.72 KB
2026-03-11 16:18:51
R W Run
22.71 KB
2026-03-11 16:18:51
R W Run
18.05 KB
2026-03-11 16:18:51
R W Run
22.76 KB
2026-03-11 16:18:51
R W Run
7.34 KB
2026-03-11 16:18:51
R W Run
4.51 KB
2026-03-11 16:18:51
R W Run
9.02 KB
2026-03-11 16:18:51
R W Run
1.46 KB
2026-03-11 16:18:51
R W Run
51.76 KB
2026-03-11 16:18:51
R W Run
25.29 KB
2026-03-11 16:18:51
R W Run
21.61 KB
2026-03-11 16:18:51
R W Run
27.77 KB
2026-03-11 16:18:51
R W Run
15.35 KB
2026-03-11 16:18:51
R W Run
24.54 KB
2026-03-11 16:18:51
R W Run
56.44 KB
2026-03-11 16:18:51
R W Run
1.42 KB
2026-03-11 16:18:51
R W Run
63.66 KB
2026-03-11 16:18:51
R W Run
31.9 KB
2026-03-11 16:18:51
R W Run
14.44 KB
2026-03-11 16:18:51
R W Run
36.47 KB
2026-03-11 16:18:51
R W Run
14 KB
2026-03-11 16:18:51
R W Run
121.89 KB
2026-03-11 16:18:51
R W Run
6.26 KB
2026-03-11 16:18:51
R W Run
20.73 KB
2026-03-11 16:18:51
R W Run
15.23 KB
2026-03-11 16:18:51
R W Run
10.14 KB
2026-03-11 16:18:51
R W Run
6.94 KB
2026-03-11 16:18:51
R W Run
1.44 KB
2026-03-11 16:18:51
R W Run
46.85 KB
2026-03-11 16:18:51
R W Run
18.61 KB
2026-03-11 16:18:51
R W Run
6.08 KB
2026-03-11 16:18:51
R W Run
20.06 KB
2026-03-11 16:18:51
R W Run
5.73 KB
2026-03-11 16:18:51
R W Run
68.18 KB
2026-03-11 16:18:51
R W Run
40.8 KB
2026-03-11 16:18:51
R W Run
1.44 KB
2026-03-11 16:18:51
R W Run
25.26 KB
2026-03-11 16:18:51
R W Run
95.94 KB
2026-03-11 16:18:51
R W Run
43.12 KB
2026-03-11 16:18:51
R W Run
41.73 KB
2026-03-11 16:18:51
R W Run
6.46 KB
2026-03-11 16:18:51
R W Run
3.71 KB
2026-03-11 16:18:51
R W Run
116.31 KB
2026-03-11 16:18:51
R W Run
9.39 KB
2026-03-11 16:18:51
R W Run
64.34 KB
2026-03-11 16:18:51
R W Run
44.73 KB
2026-03-11 16:18:51
R W Run
1.27 KB
2026-03-11 16:18:51
R W Run
3.68 KB
2026-03-11 16:18:51
R W Run
33.53 KB
2026-03-11 16:18:51
R W Run
48.84 KB
2026-03-11 16:18:51
R W Run
26.35 KB
2026-03-11 16:18:51
R W Run
1.12 KB
2026-03-11 16:18:51
R W Run
4.19 KB
2026-03-11 16:18:51
R W Run
38.19 KB
2026-03-11 16:18:51
R W Run
91.33 KB
2026-03-11 16:18:51
R W Run
80.39 KB
2026-03-11 16:18:51
R W Run
32.67 KB
2026-03-11 16:18:51
R W Run
16.18 KB
2026-03-11 16:18:51
R W Run
44.46 KB
2026-03-11 16:18:51
R W Run
6.23 KB
2026-03-11 16:18:51
R W Run
8.23 KB
2026-03-11 16:18:51
R W Run
96.96 KB
2026-03-11 16:18:51
R W Run
6.83 KB
2026-03-11 16:18:51
R W Run
46.62 KB
2026-03-11 16:18:51
R W Run
10.82 KB
2026-03-11 16:18:51
R W Run
68.86 KB
2026-03-11 16:18:51
R W Run
33.63 KB
2026-03-11 16:18:51
R W Run
113.3 KB
2026-03-11 16:18:51
R W Run
22.98 KB
2026-03-11 16:18:51
R W Run
10.66 KB
2026-03-11 16:18:51
R W Run
error_log
📄class-wp-comments-list-table.php
1<?php
2/**
3 * List Table API: WP_Comments_List_Table class
4 *
5 * @package WordPress
6 * @subpackage Administration
7 * @since 3.1.0
8 */
9
10/**
11 * Core class used to implement displaying comments in a list table.
12 *
13 * @since 3.1.0
14 *
15 * @see WP_List_Table
16 */
17class WP_Comments_List_Table extends WP_List_Table {
18
19 public $checkbox = true;
20
21 public $pending_count = array();
22
23 public $extra_items;
24
25 private $user_can;
26
27 /**
28 * Constructor.
29 *
30 * @since 3.1.0
31 *
32 * @see WP_List_Table::__construct() for more information on default arguments.
33 *
34 * @global int $post_id
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', array( $this, 'floated_admin_avatar' ), 10, 2 );
45 }
46
47 parent::__construct(
48 array(
49 'plural' => 'comments',
50 'singular' => 'comment',
51 'ajax' => true,
52 'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
53 )
54 );
55 }
56
57 /**
58 * Adds avatars to comment author names.
59 *
60 * @since 3.1.0
61 *
62 * @param string $name Comment author name.
63 * @param int $comment_id Comment ID.
64 * @return string Avatar with the user name.
65 */
66 public function floated_admin_avatar( $name, $comment_id ) {
67 $comment = get_comment( $comment_id );
68 $avatar = get_avatar( $comment, 32, 'mystery' );
69 return "$avatar $name";
70 }
71
72 /**
73 * @return bool
74 */
75 public function ajax_user_can() {
76 return current_user_can( 'edit_posts' );
77 }
78
79 /**
80 * @global string $mode List table view mode.
81 * @global int $post_id
82 * @global string $comment_status
83 * @global string $comment_type
84 * @global string $search
85 */
86 public function prepare_items() {
87 global $mode, $post_id, $comment_status, $comment_type, $search;
88
89 if ( ! empty( $_REQUEST['mode'] ) ) {
90 $mode = 'excerpt' === $_REQUEST['mode'] ? 'excerpt' : 'list';
91 set_user_setting( 'posts_list_mode', $mode );
92 } else {
93 $mode = get_user_setting( 'posts_list_mode', 'list' );
94 }
95
96 $comment_status = isset( $_REQUEST['comment_status'] ) ? $_REQUEST['comment_status'] : 'all';
97
98 if ( ! in_array( $comment_status, array( 'all', 'mine', 'moderated', 'approved', 'spam', 'trash' ), true ) ) {
99 $comment_status = 'all';
100 }
101
102 $comment_type = '';
103
104 if ( ! empty( $_REQUEST['comment_type'] ) && 'note' !== $_REQUEST['comment_type'] ) {
105 $comment_type = $_REQUEST['comment_type'];
106 }
107
108 $search = ( isset( $_REQUEST['s'] ) ) ? $_REQUEST['s'] : '';
109
110 $post_type = ( isset( $_REQUEST['post_type'] ) ) ? sanitize_key( $_REQUEST['post_type'] ) : '';
111
112 $user_id = ( isset( $_REQUEST['user_id'] ) ) ? $_REQUEST['user_id'] : '';
113
114 $orderby = ( isset( $_REQUEST['orderby'] ) ) ? $_REQUEST['orderby'] : '';
115 $order = ( isset( $_REQUEST['order'] ) ) ? $_REQUEST['order'] : '';
116
117 $comments_per_page = $this->get_per_page( $comment_status );
118
119 $doing_ajax = wp_doing_ajax();
120
121 if ( isset( $_REQUEST['number'] ) ) {
122 $number = (int) $_REQUEST['number'];
123 } else {
124 $number = $comments_per_page + min( 8, $comments_per_page ); // Grab a few extra.
125 }
126
127 $page = $this->get_pagenum();
128
129 if ( isset( $_REQUEST['start'] ) ) {
130 $start = $_REQUEST['start'];
131 } else {
132 $start = ( $page - 1 ) * $comments_per_page;
133 }
134
135 if ( $doing_ajax && isset( $_REQUEST['offset'] ) ) {
136 $start += $_REQUEST['offset'];
137 }
138
139 $status_map = array(
140 'mine' => '',
141 'moderated' => 'hold',
142 'approved' => 'approve',
143 'all' => '',
144 );
145
146 $args = array(
147 'status' => isset( $status_map[ $comment_status ] ) ? $status_map[ $comment_status ] : $comment_status,
148 'search' => $search,
149 'user_id' => $user_id,
150 'offset' => $start,
151 'number' => $number,
152 'post_id' => $post_id,
153 'type' => $comment_type,
154 'type__not_in' => array( 'note' ),
155 'orderby' => $orderby,
156 'order' => $order,
157 'post_type' => $post_type,
158 'update_comment_post_cache' => true,
159 );
160
161 /**
162 * Filters the arguments for the comment query in the comments list table.
163 *
164 * @since 5.1.0
165 *
166 * @param array $args An array of get_comments() arguments.
167 */
168 $args = apply_filters( 'comments_list_table_query_args', $args );
169
170 $_comments = get_comments( $args );
171
172 if ( is_array( $_comments ) ) {
173 $this->items = array_slice( $_comments, 0, $comments_per_page );
174 $this->extra_items = array_slice( $_comments, $comments_per_page );
175
176 $_comment_post_ids = array_unique( wp_list_pluck( $_comments, 'comment_post_ID' ) );
177
178 $this->pending_count = get_pending_comments_num( $_comment_post_ids );
179 }
180
181 $total_comments = get_comments(
182 array_merge(
183 $args,
184 array(
185 'count' => true,
186 'offset' => 0,
187 'number' => 0,
188 'orderby' => 'none',
189 )
190 )
191 );
192
193 $this->set_pagination_args(
194 array(
195 'total_items' => $total_comments,
196 'per_page' => $comments_per_page,
197 )
198 );
199 }
200
201 /**
202 * @param string $comment_status
203 * @return int
204 */
205 public function get_per_page( $comment_status = 'all' ) {
206 $comments_per_page = $this->get_items_per_page( 'edit_comments_per_page' );
207
208 /**
209 * Filters the number of comments listed per page in the comments list table.
210 *
211 * @since 2.6.0
212 *
213 * @param int $comments_per_page The number of comments to list per page.
214 * @param string $comment_status The comment status name. Default 'All'.
215 */
216 return apply_filters( 'comments_per_page', $comments_per_page, $comment_status );
217 }
218
219 /**
220 * @global string $comment_status
221 */
222 public function no_items() {
223 global $comment_status;
224
225 if ( 'moderated' === $comment_status ) {
226 _e( 'No comments awaiting moderation.' );
227 } elseif ( 'trash' === $comment_status ) {
228 _e( 'No comments found in Trash.' );
229 } else {
230 _e( 'No comments found.' );
231 }
232 }
233
234 /**
235 * @global int $post_id
236 * @global string $comment_status
237 * @global string $comment_type
238 */
239 protected function get_views() {
240 global $post_id, $comment_status, $comment_type;
241
242 $status_links = array();
243 $num_comments = ( $post_id ) ? wp_count_comments( $post_id ) : wp_count_comments();
244
245 $statuses = array(
246 /* translators: %s: Number of comments. */
247 'all' => _nx_noop(
248 'All <span class="count">(%s)</span>',
249 'All <span class="count">(%s)</span>',
250 'comments'
251 ), // Singular not used.
252
253 /* translators: %s: Number of comments. */
254 'mine' => _nx_noop(
255 'Mine <span class="count">(%s)</span>',
256 'Mine <span class="count">(%s)</span>',
257 'comments'
258 ),
259
260 /* translators: %s: Number of comments. */
261 'moderated' => _nx_noop(
262 'Pending <span class="count">(%s)</span>',
263 'Pending <span class="count">(%s)</span>',
264 'comments'
265 ),
266
267 /* translators: %s: Number of comments. */
268 'approved' => _nx_noop(
269 'Approved <span class="count">(%s)</span>',
270 'Approved <span class="count">(%s)</span>',
271 'comments'
272 ),
273
274 /* translators: %s: Number of comments. */
275 'spam' => _nx_noop(
276 'Spam <span class="count">(%s)</span>',
277 'Spam <span class="count">(%s)</span>',
278 'comments'
279 ),
280
281 /* translators: %s: Number of comments. */
282 'trash' => _nx_noop(
283 'Trash <span class="count">(%s)</span>',
284 'Trash <span class="count">(%s)</span>',
285 'comments'
286 ),
287 );
288
289 if ( ! EMPTY_TRASH_DAYS ) {
290 unset( $statuses['trash'] );
291 }
292
293 $link = admin_url( 'edit-comments.php' );
294
295 if ( ! empty( $comment_type ) && 'all' !== $comment_type ) {
296 $link = add_query_arg( 'comment_type', $comment_type, $link );
297 }
298
299 foreach ( $statuses as $status => $label ) {
300 if ( 'mine' === $status ) {
301 $current_user_id = get_current_user_id();
302 $num_comments->mine = get_comments(
303 array(
304 'post_id' => $post_id ? $post_id : 0,
305 'user_id' => $current_user_id,
306 'count' => true,
307 'orderby' => 'none',
308 )
309 );
310 $link = add_query_arg( 'user_id', $current_user_id, $link );
311 } else {
312 $link = remove_query_arg( 'user_id', $link );
313 }
314
315 if ( ! isset( $num_comments->$status ) ) {
316 $num_comments->$status = 10;
317 }
318
319 $link = add_query_arg( 'comment_status', $status, $link );
320
321 if ( $post_id ) {
322 $link = add_query_arg( 'p', absint( $post_id ), $link );
323 }
324
325 /*
326 // I toyed with this, but decided against it. Leaving it in here in case anyone thinks it is a good idea. ~ Mark
327 if ( !empty( $_REQUEST['s'] ) )
328 $link = add_query_arg( 's', esc_attr( wp_unslash( $_REQUEST['s'] ) ), $link );
329 */
330
331 $status_links[ $status ] = array(
332 'url' => esc_url( $link ),
333 'label' => sprintf(
334 translate_nooped_plural( $label, $num_comments->$status ),
335 sprintf(
336 '<span class="%s-count">%s</span>',
337 ( 'moderated' === $status ) ? 'pending' : $status,
338 number_format_i18n( $num_comments->$status )
339 )
340 ),
341 'current' => $status === $comment_status,
342 );
343 }
344
345 /**
346 * Filters the comment status links.
347 *
348 * @since 2.5.0
349 * @since 5.1.0 The 'Mine' link was added.
350 *
351 * @param string[] $status_links An associative array of fully-formed comment status links. Includes 'All', 'Mine',
352 * 'Pending', 'Approved', 'Spam', and 'Trash'.
353 */
354 return apply_filters( 'comment_status_links', $this->get_views_links( $status_links ) );
355 }
356
357 /**
358 * @global string $comment_status
359 *
360 * @return array
361 */
362 protected function get_bulk_actions() {
363 global $comment_status;
364
365 if ( ! current_user_can( 'moderate_comments' ) ) {
366 return array(); // Return an empty array if the user doesn't have permission
367 }
368
369 $actions = array();
370
371 if ( in_array( $comment_status, array( 'all', 'approved' ), true ) ) {
372 $actions['unapprove'] = __( 'Unapprove' );
373 }
374
375 if ( in_array( $comment_status, array( 'all', 'moderated' ), true ) ) {
376 $actions['approve'] = __( 'Approve' );
377 }
378
379 if ( in_array( $comment_status, array( 'all', 'moderated', 'approved', 'trash' ), true ) ) {
380 $actions['spam'] = _x( 'Mark as spam', 'comment' );
381 }
382
383 if ( 'trash' === $comment_status ) {
384 $actions['untrash'] = __( 'Restore' );
385 } elseif ( 'spam' === $comment_status ) {
386 $actions['unspam'] = _x( 'Not spam', 'comment' );
387 }
388
389 if ( in_array( $comment_status, array( 'trash', 'spam' ), true ) || ! EMPTY_TRASH_DAYS ) {
390 $actions['delete'] = __( 'Delete permanently' );
391 } else {
392 $actions['trash'] = __( 'Move to Trash' );
393 }
394
395 return $actions;
396 }
397
398 /**
399 * @global string $comment_status
400 * @global string $comment_type
401 *
402 * @param string $which
403 */
404 protected function extra_tablenav( $which ) {
405 global $comment_status, $comment_type;
406 static $has_items;
407
408 if ( ! isset( $has_items ) ) {
409 $has_items = $this->has_items();
410 }
411
412 echo '<div class="alignleft actions">';
413
414 if ( 'top' === $which ) {
415 ob_start();
416
417 $this->comment_type_dropdown( $comment_type );
418
419 /**
420 * Fires just before the Filter submit button for comment types.
421 *
422 * @since 3.5.0
423 */
424 do_action( 'restrict_manage_comments' );
425
426 $output = ob_get_clean();
427
428 if ( ! empty( $output ) && $this->has_items() ) {
429 echo $output;
430 submit_button( __( 'Filter' ), '', 'filter_action', false, array( 'id' => 'post-query-submit' ) );
431 }
432 }
433
434 if ( ( 'spam' === $comment_status || 'trash' === $comment_status ) && $has_items
435 && current_user_can( 'moderate_comments' )
436 ) {
437 wp_nonce_field( 'bulk-destroy', '_destroy_nonce' );
438 $title = ( 'spam' === $comment_status ) ? esc_attr__( 'Empty Spam' ) : esc_attr__( 'Empty Trash' );
439 submit_button( $title, 'apply', 'delete_all', false );
440 }
441
442 /**
443 * Fires after the Filter submit button for comment types.
444 *
445 * @since 2.5.0
446 * @since 5.6.0 The `$which` parameter was added.
447 *
448 * @param string $comment_status The comment status name. Default 'All'.
449 * @param string $which The location of the extra table nav markup: Either 'top' or 'bottom'.
450 */
451 do_action( 'manage_comments_nav', $comment_status, $which );
452
453 echo '</div>';
454 }
455
456 /**
457 * @return string|false
458 */
459 public function current_action() {
460 if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) ) {
461 return 'delete_all';
462 }
463
464 return parent::current_action();
465 }
466
467 /**
468 * @global int $post_id
469 *
470 * @return string[] Array of column titles keyed by their column name.
471 */
472 public function get_columns() {
473 global $post_id;
474
475 $columns = array();
476
477 if ( $this->checkbox ) {
478 $columns['cb'] = '<input type="checkbox" />';
479 }
480
481 $columns['author'] = __( 'Author' );
482 $columns['comment'] = _x( 'Comment', 'column name' );
483
484 if ( ! $post_id ) {
485 /* translators: Column name or table row header. */
486 $columns['response'] = __( 'In response to' );
487 }
488
489 $columns['date'] = _x( 'Submitted on', 'column name' );
490
491 return $columns;
492 }
493
494 /**
495 * Displays a comment type drop-down for filtering on the Comments list table.
496 *
497 * @since 5.5.0
498 * @since 5.6.0 Renamed from `comment_status_dropdown()` to `comment_type_dropdown()`.
499 *
500 * @param string $comment_type The current comment type slug.
501 */
502 protected function comment_type_dropdown( $comment_type ) {
503 /**
504 * Filters the comment types shown in the drop-down menu on the Comments list table.
505 *
506 * @since 2.7.0
507 *
508 * @param string[] $comment_types Array of comment type labels keyed by their name.
509 */
510 $comment_types = apply_filters(
511 'admin_comment_types_dropdown',
512 array(
513 'comment' => __( 'Comments' ),
514 'pings' => __( 'Pings' ),
515 )
516 );
517
518 if ( $comment_types && is_array( $comment_types ) ) {
519 printf(
520 '<label class="screen-reader-text" for="filter-by-comment-type">%s</label>',
521 /* translators: Hidden accessibility text. */
522 __( 'Filter by comment type' )
523 );
524
525 echo '<select id="filter-by-comment-type" name="comment_type">';
526
527 printf( "\t<option value=''>%s</option>", __( 'All comment types' ) );
528
529 foreach ( $comment_types as $type => $label ) {
530 if ( get_comments(
531 array(
532 'count' => true,
533 'orderby' => 'none',
534 'type' => $type,
535 )
536 ) ) {
537 printf(
538 "\t<option value='%s'%s>%s</option>\n",
539 esc_attr( $type ),
540 selected( $comment_type, $type, false ),
541 esc_html( $label )
542 );
543 }
544 }
545
546 echo '</select>';
547 }
548 }
549
550 /**
551 * @return array
552 */
553 protected function get_sortable_columns() {
554 return array(
555 'author' => array( 'comment_author', false, __( 'Author' ), __( 'Table ordered by Comment Author.' ) ),
556 'response' => array( 'comment_post_ID', false, _x( 'In Response To', 'column name' ), __( 'Table ordered by Post Replied To.' ) ),
557 'date' => 'comment_date',
558 );
559 }
560
561 /**
562 * Gets the name of the default primary column.
563 *
564 * @since 4.3.0
565 *
566 * @return string Name of the default primary column, in this case, 'comment'.
567 */
568 protected function get_default_primary_column_name() {
569 return 'comment';
570 }
571
572 /**
573 * Displays the comments table.
574 *
575 * Overrides the parent display() method to render extra comments.
576 *
577 * @since 3.1.0
578 */
579 public function display() {
580 wp_nonce_field( 'fetch-list-' . get_class( $this ), '_ajax_fetch_list_nonce' );
581 static $has_items;
582
583 if ( ! isset( $has_items ) ) {
584 $has_items = $this->has_items();
585
586 if ( $has_items ) {
587 $this->display_tablenav( 'top' );
588 }
589 }
590
591 $this->screen->render_screen_reader_content( 'heading_list' );
592
593 ?>
594<table class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>">
595 <?php
596 if ( ! isset( $_GET['orderby'] ) ) {
597 // In the initial view, Comments are ordered by comment's date but there's no column for that.
598 echo '<caption class="screen-reader-text">' .
599 /* translators: Hidden accessibility text. */
600 __( 'Ordered by Comment Date, descending.' ) .
601 '</caption>';
602 } else {
603 $this->print_table_description();
604 }
605 ?>
606 <thead>
607 <tr>
608 <?php $this->print_column_headers(); ?>
609 </tr>
610 </thead>
611
612 <tbody id="the-comment-list" data-wp-lists="list:comment">
613 <?php $this->display_rows_or_placeholder(); ?>
614 </tbody>
615
616 <tbody id="the-extra-comment-list" data-wp-lists="list:comment" style="display: none;">
617 <?php
618 /*
619 * Back up the items to restore after printing the extra items markup.
620 * The extra items may be empty, which will prevent the table nav from displaying later.
621 */
622 $items = $this->items;
623 $this->items = $this->extra_items;
624 $this->display_rows_or_placeholder();
625 $this->items = $items;
626 ?>
627 </tbody>
628
629 <tfoot>
630 <tr>
631 <?php $this->print_column_headers( false ); ?>
632 </tr>
633 </tfoot>
634
635</table>
636 <?php
637
638 $this->display_tablenav( 'bottom' );
639 }
640
641 /**
642 * @global WP_Post $post Global post object.
643 * @global WP_Comment $comment Global comment object.
644 *
645 * @param WP_Comment $item
646 */
647 public function single_row( $item ) {
648 global $post, $comment;
649
650 // Restores the more descriptive, specific name for use within this method.
651 $comment = $item;
652
653 if ( $comment->comment_post_ID > 0 ) {
654 $post = get_post( $comment->comment_post_ID );
655 }
656
657 $edit_post_cap = $post ? 'edit_post' : 'edit_posts';
658
659 if ( ! current_user_can( $edit_post_cap, $comment->comment_post_ID )
660 && ( post_password_required( $comment->comment_post_ID )
661 || ! current_user_can( 'read_post', $comment->comment_post_ID ) )
662 ) {
663 // The user has no access to the post and thus cannot see the comments.
664 return false;
665 }
666
667 $the_comment_class = wp_get_comment_status( $comment );
668
669 if ( ! $the_comment_class ) {
670 $the_comment_class = '';
671 }
672
673 $the_comment_class = implode( ' ', get_comment_class( $the_comment_class, $comment, $comment->comment_post_ID ) );
674
675 $this->user_can = current_user_can( 'edit_comment', $comment->comment_ID );
676
677 echo "<tr id='comment-$comment->comment_ID' class='$the_comment_class'>";
678 $this->single_row_columns( $comment );
679 echo "</tr>\n";
680
681 unset( $GLOBALS['post'], $GLOBALS['comment'] );
682 }
683
684 /**
685 * Generates and displays row actions links.
686 *
687 * @since 4.3.0
688 * @since 5.9.0 Renamed `$comment` to `$item` to match parent class for PHP 8 named parameter support.
689 *
690 * @global string $comment_status Status for the current listed comments.
691 *
692 * @param WP_Comment $item The comment object.
693 * @param string $column_name Current column name.
694 * @param string $primary Primary column name.
695 * @return string Row actions output for comments. An empty string
696 * if the current column is not the primary column,
697 * or if the current user cannot edit the comment.
698 */
699 protected function handle_row_actions( $item, $column_name, $primary ) {
700 global $comment_status;
701
702 if ( $primary !== $column_name ) {
703 return '';
704 }
705
706 if ( ! $this->user_can ) {
707 return '';
708 }
709
710 // Restores the more descriptive, specific name for use within this method.
711 $comment = $item;
712
713 $the_comment_status = wp_get_comment_status( $comment );
714
715 $output = '';
716
717 $approve_nonce = esc_html( '_wpnonce=' . wp_create_nonce( 'approve-comment_' . $comment->comment_ID ) );
718 $del_nonce = esc_html( '_wpnonce=' . wp_create_nonce( 'delete-comment_' . $comment->comment_ID ) );
719
720 $action_string = 'comment.php?action=%s&c=' . $comment->comment_ID . '&%s';
721
722 $approve_url = sprintf( $action_string, 'approvecomment', $approve_nonce );
723 $unapprove_url = sprintf( $action_string, 'unapprovecomment', $approve_nonce );
724 $spam_url = sprintf( $action_string, 'spamcomment', $del_nonce );
725 $unspam_url = sprintf( $action_string, 'unspamcomment', $del_nonce );
726 $trash_url = sprintf( $action_string, 'trashcomment', $del_nonce );
727 $untrash_url = sprintf( $action_string, 'untrashcomment', $del_nonce );
728 $delete_url = sprintf( $action_string, 'deletecomment', $del_nonce );
729
730 // Preorder it: Approve | Reply | Quick Edit | Edit | Spam | Trash.
731 $actions = array(
732 'approve' => '',
733 'unapprove' => '',
734 'reply' => '',
735 'quickedit' => '',
736 'edit' => '',
737 'spam' => '',
738 'unspam' => '',
739 'trash' => '',
740 'untrash' => '',
741 'delete' => '',
742 );
743
744 // Not looking at all comments.
745 if ( $comment_status && 'all' !== $comment_status ) {
746 if ( 'approved' === $the_comment_status ) {
747 $actions['unapprove'] = sprintf(
748 '<a href="%s" data-wp-lists="%s" class="vim-u vim-destructive aria-button-if-js" aria-label="%s">%s</a>',
749 esc_url( $unapprove_url ),
750 "delete:the-comment-list:comment-{$comment->comment_ID}:e7e7d3:action=dim-comment&amp;new=unapproved",
751 esc_attr__( 'Unapprove this comment' ),
752 __( 'Unapprove' )
753 );
754 } elseif ( 'unapproved' === $the_comment_status ) {
755 $actions['approve'] = sprintf(
756 '<a href="%s" data-wp-lists="%s" class="vim-a vim-destructive aria-button-if-js" aria-label="%s">%s</a>',
757 esc_url( $approve_url ),
758 "delete:the-comment-list:comment-{$comment->comment_ID}:e7e7d3:action=dim-comment&amp;new=approved",
759 esc_attr__( 'Approve this comment' ),
760 __( 'Approve' )
761 );
762 }
763 } else {
764 $actions['approve'] = sprintf(
765 '<a href="%s" data-wp-lists="%s" class="vim-a aria-button-if-js" aria-label="%s">%s</a>',
766 esc_url( $approve_url ),
767 "dim:the-comment-list:comment-{$comment->comment_ID}:unapproved:e7e7d3:e7e7d3:new=approved",
768 esc_attr__( 'Approve this comment' ),
769 __( 'Approve' )
770 );
771
772 $actions['unapprove'] = sprintf(
773 '<a href="%s" data-wp-lists="%s" class="vim-u aria-button-if-js" aria-label="%s">%s</a>',
774 esc_url( $unapprove_url ),
775 "dim:the-comment-list:comment-{$comment->comment_ID}:unapproved:e7e7d3:e7e7d3:new=unapproved",
776 esc_attr__( 'Unapprove this comment' ),
777 __( 'Unapprove' )
778 );
779 }
780
781 if ( 'spam' !== $the_comment_status ) {
782 $actions['spam'] = sprintf(
783 '<a href="%s" data-wp-lists="%s" class="vim-s vim-destructive aria-button-if-js" aria-label="%s">%s</a>',
784 esc_url( $spam_url ),
785 "delete:the-comment-list:comment-{$comment->comment_ID}::spam=1",
786 esc_attr__( 'Mark this comment as spam' ),
787 /* translators: "Mark as spam" link. */
788 _x( 'Spam', 'verb' )
789 );
790 } elseif ( 'spam' === $the_comment_status ) {
791 $actions['unspam'] = sprintf(
792 '<a href="%s" data-wp-lists="%s" class="vim-z vim-destructive aria-button-if-js" aria-label="%s">%s</a>',
793 esc_url( $unspam_url ),
794 "delete:the-comment-list:comment-{$comment->comment_ID}:66cc66:unspam=1",
795 esc_attr__( 'Restore this comment from the spam' ),
796 _x( 'Not Spam', 'comment' )
797 );
798 }
799
800 if ( 'trash' === $the_comment_status ) {
801 $actions['untrash'] = sprintf(
802 '<a href="%s" data-wp-lists="%s" class="vim-z vim-destructive aria-button-if-js" aria-label="%s">%s</a>',
803 esc_url( $untrash_url ),
804 "delete:the-comment-list:comment-{$comment->comment_ID}:66cc66:untrash=1",
805 esc_attr__( 'Restore this comment from the Trash' ),
806 __( 'Restore' )
807 );
808 }
809
810 if ( 'spam' === $the_comment_status || 'trash' === $the_comment_status || ! EMPTY_TRASH_DAYS ) {
811 $actions['delete'] = sprintf(
812 '<a href="%s" data-wp-lists="%s" class="delete vim-d vim-destructive aria-button-if-js" aria-label="%s">%s</a>',
813 esc_url( $delete_url ),
814 "delete:the-comment-list:comment-{$comment->comment_ID}::delete=1",
815 esc_attr__( 'Delete this comment permanently' ),
816 __( 'Delete Permanently' )
817 );
818 } else {
819 $actions['trash'] = sprintf(
820 '<a href="%s" data-wp-lists="%s" class="delete vim-d vim-destructive aria-button-if-js" aria-label="%s">%s</a>',
821 esc_url( $trash_url ),
822 "delete:the-comment-list:comment-{$comment->comment_ID}::trash=1",
823 esc_attr__( 'Move this comment to the Trash' ),
824 _x( 'Trash', 'verb' )
825 );
826 }
827
828 if ( 'spam' !== $the_comment_status && 'trash' !== $the_comment_status ) {
829 $actions['edit'] = sprintf(
830 '<a href="%s" aria-label="%s">%s</a>',
831 "comment.php?action=editcomment&amp;c={$comment->comment_ID}",
832 esc_attr__( 'Edit this comment' ),
833 __( 'Edit' )
834 );
835
836 $format = '<button type="button" data-comment-id="%d" data-post-id="%d" data-action="%s" class="%s button-link" aria-expanded="false" aria-label="%s">%s</button>';
837
838 $actions['quickedit'] = sprintf(
839 $format,
840 $comment->comment_ID,
841 $comment->comment_post_ID,
842 'edit',
843 'vim-q comment-inline',
844 esc_attr__( 'Quick edit this comment inline' ),
845 __( 'Quick&nbsp;Edit' )
846 );
847
848 $actions['reply'] = sprintf(
849 $format,
850 $comment->comment_ID,
851 $comment->comment_post_ID,
852 'replyto',
853 'vim-r comment-inline',
854 esc_attr__( 'Reply to this comment' ),
855 __( 'Reply' )
856 );
857 }
858
859 /**
860 * Filters the action links displayed for each comment in the Comments list table.
861 *
862 * @since 2.6.0
863 *
864 * @param string[] $actions An array of comment actions. Default actions include:
865 * 'Approve', 'Unapprove', 'Edit', 'Reply', 'Spam',
866 * 'Delete', and 'Trash'.
867 * @param WP_Comment $comment The comment object.
868 */
869 $actions = apply_filters( 'comment_row_actions', array_filter( $actions ), $comment );
870
871 $always_visible = false;
872
873 $mode = get_user_setting( 'posts_list_mode', 'list' );
874
875 if ( 'excerpt' === $mode ) {
876 $always_visible = true;
877 }
878
879 $output .= '<div class="' . ( $always_visible ? 'row-actions visible' : 'row-actions' ) . '">';
880
881 $i = 0;
882
883 foreach ( $actions as $action => $link ) {
884 ++$i;
885
886 if ( ( ( 'approve' === $action || 'unapprove' === $action ) && 2 === $i )
887 || 1 === $i
888 ) {
889 $separator = '';
890 } else {
891 $separator = ' | ';
892 }
893
894 // Reply and quickedit need a hide-if-no-js span when not added with Ajax.
895 if ( ( 'reply' === $action || 'quickedit' === $action ) && ! wp_doing_ajax() ) {
896 $action .= ' hide-if-no-js';
897 } elseif ( ( 'untrash' === $action && 'trash' === $the_comment_status )
898 || ( 'unspam' === $action && 'spam' === $the_comment_status )
899 ) {
900 if ( '1' === get_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', true ) ) {
901 $action .= ' approve';
902 } else {
903 $action .= ' unapprove';
904 }
905 }
906
907 $output .= "<span class='$action'>{$separator}{$link}</span>";
908 }
909
910 $output .= '</div>';
911
912 $output .= '<button type="button" class="toggle-row"><span class="screen-reader-text">' .
913 /* translators: Hidden accessibility text. */
914 __( 'Show more details' ) .
915 '</span></button>';
916
917 return $output;
918 }
919
920 /**
921 * @since 5.9.0 Renamed `$comment` to `$item` to match parent class for PHP 8 named parameter support.
922 *
923 * @param WP_Comment $item The comment object.
924 */
925 public function column_cb( $item ) {
926 // Restores the more descriptive, specific name for use within this method.
927 $comment = $item;
928
929 if ( $this->user_can ) {
930 ?>
931 <input id="cb-select-<?php echo $comment->comment_ID; ?>" type="checkbox" name="delete_comments[]" value="<?php echo $comment->comment_ID; ?>" />
932 <label for="cb-select-<?php echo $comment->comment_ID; ?>">
933 <span class="screen-reader-text">
934 <?php
935 /* translators: Hidden accessibility text. */
936 _e( 'Select comment' );
937 ?>
938 </span>
939 </label>
940 <?php
941 }
942 }
943
944 /**
945 * @param WP_Comment $comment The comment object.
946 */
947 public function column_comment( $comment ) {
948 echo '<div class="comment-author">';
949 $this->column_author( $comment );
950 echo '</div>';
951
952 if ( $comment->comment_parent ) {
953 $parent = get_comment( $comment->comment_parent );
954
955 if ( $parent ) {
956 $parent_link = esc_url( get_comment_link( $parent ) );
957 $name = get_comment_author( $parent );
958 printf(
959 /* translators: %s: Comment link. */
960 __( 'In reply to %s.' ),
961 '<a href="' . $parent_link . '">' . $name . '</a>'
962 );
963 }
964 }
965
966 comment_text( $comment );
967
968 if ( $this->user_can ) {
969 /** This filter is documented in wp-admin/includes/comment.php */
970 $comment_content = apply_filters( 'comment_edit_pre', $comment->comment_content );
971 ?>
972 <div id="inline-<?php echo $comment->comment_ID; ?>" class="hidden">
973 <textarea class="comment" rows="1" cols="1"><?php echo esc_textarea( $comment_content ); ?></textarea>
974 <div class="author-email"><?php echo esc_html( $comment->comment_author_email ); ?></div>
975 <div class="author"><?php echo esc_html( $comment->comment_author ); ?></div>
976 <div class="author-url"><?php echo esc_url( $comment->comment_author_url ); ?></div>
977 <div class="comment_status"><?php echo $comment->comment_approved; ?></div>
978 </div>
979 <?php
980 }
981 }
982
983 /**
984 * @global string $comment_status
985 *
986 * @param WP_Comment $comment The comment object.
987 */
988 public function column_author( $comment ) {
989 global $comment_status;
990
991 $author_url = get_comment_author_url( $comment );
992
993 $author_url_display = untrailingslashit( preg_replace( '|^http(s)?://(www\.)?|i', '', $author_url ) );
994
995 if ( strlen( $author_url_display ) > 50 ) {
996 $author_url_display = wp_html_excerpt( $author_url_display, 49, '&hellip;' );
997 }
998
999 echo '<strong>';
1000 comment_author( $comment );
1001 echo '</strong><br />';
1002
1003 if ( ! empty( $author_url_display ) ) {
1004 // Print link to author URL, and disallow referrer information (without using target="_blank").
1005 printf(
1006 '<a href="%s" rel="noopener noreferrer">%s</a><br />',
1007 esc_url( $author_url ),
1008 esc_html( $author_url_display )
1009 );
1010 }
1011
1012 if ( $this->user_can ) {
1013 if ( ! empty( $comment->comment_author_email ) ) {
1014 /** This filter is documented in wp-includes/comment-template.php */
1015 $email = apply_filters( 'comment_email', $comment->comment_author_email, $comment );
1016
1017 if ( ! empty( $email ) && '@' !== $email ) {
1018 printf( '<a href="%1$s">%2$s</a><br />', esc_url( 'mailto:' . $email ), esc_html( $email ) );
1019 }
1020 }
1021
1022 $author_ip = get_comment_author_IP( $comment );
1023
1024 if ( $author_ip ) {
1025 $author_ip_url = add_query_arg(
1026 array(
1027 's' => $author_ip,
1028 'mode' => 'detail',
1029 ),
1030 admin_url( 'edit-comments.php' )
1031 );
1032
1033 if ( 'spam' === $comment_status ) {
1034 $author_ip_url = add_query_arg( 'comment_status', 'spam', $author_ip_url );
1035 }
1036
1037 printf( '<a href="%1$s">%2$s</a>', esc_url( $author_ip_url ), esc_html( $author_ip ) );
1038 }
1039 }
1040 }
1041
1042 /**
1043 * @param WP_Comment $comment The comment object.
1044 */
1045 public function column_date( $comment ) {
1046 $submitted = sprintf(
1047 /* translators: 1: Comment date, 2: Comment time. */
1048 __( '%1$s at %2$s' ),
1049 /* translators: Comment date format. See https://www.php.net/manual/datetime.format.php */
1050 get_comment_date( __( 'Y/m/d' ), $comment ),
1051 /* translators: Comment time format. See https://www.php.net/manual/datetime.format.php */
1052 get_comment_date( __( 'g:i a' ), $comment )
1053 );
1054
1055 echo '<div class="submitted-on">';
1056
1057 if ( 'approved' === wp_get_comment_status( $comment ) && ! empty( $comment->comment_post_ID ) ) {
1058 printf(
1059 '<a href="%s">%s</a>',
1060 esc_url( get_comment_link( $comment ) ),
1061 $submitted
1062 );
1063 } else {
1064 echo $submitted;
1065 }
1066
1067 echo '</div>';
1068 }
1069
1070 /**
1071 * @param WP_Comment $comment The comment object.
1072 */
1073 public function column_response( $comment ) {
1074 $post = get_post();
1075
1076 if ( ! $post ) {
1077 return;
1078 }
1079
1080 if ( isset( $this->pending_count[ $post->ID ] ) ) {
1081 $pending_comments = $this->pending_count[ $post->ID ];
1082 } else {
1083 $_pending_count_temp = get_pending_comments_num( array( $post->ID ) );
1084 $pending_comments = $_pending_count_temp[ $post->ID ];
1085 $this->pending_count[ $post->ID ] = $pending_comments;
1086 }
1087
1088 if ( current_user_can( 'edit_post', $post->ID ) ) {
1089 $post_link = "<a href='" . get_edit_post_link( $post->ID ) . "' class='comments-edit-item-link'>";
1090 $post_link .= esc_html( get_the_title( $post->ID ) ) . '</a>';
1091 } else {
1092 $post_link = esc_html( get_the_title( $post->ID ) );
1093 }
1094
1095 echo '<div class="response-links">';
1096
1097 if ( 'attachment' === $post->post_type ) {
1098 $thumb = wp_get_attachment_image( $post->ID, array( 80, 60 ), true );
1099 if ( $thumb ) {
1100 echo $thumb;
1101 }
1102 }
1103
1104 echo $post_link;
1105
1106 $post_type_object = get_post_type_object( $post->post_type );
1107 echo "<a href='" . get_permalink( $post->ID ) . "' class='comments-view-item-link'>" . $post_type_object->labels->view_item . '</a>';
1108
1109 echo '<span class="post-com-count-wrapper post-com-count-', $post->ID, '">';
1110 $this->comments_bubble( $post->ID, $pending_comments );
1111 echo '</span> ';
1112
1113 echo '</div>';
1114 }
1115
1116 /**
1117 * @since 5.9.0 Renamed `$comment` to `$item` to match parent class for PHP 8 named parameter support.
1118 *
1119 * @param WP_Comment $item The comment object.
1120 * @param string $column_name The custom column's name.
1121 */
1122 public function column_default( $item, $column_name ) {
1123 // Restores the more descriptive, specific name for use within this method.
1124 $comment = $item;
1125
1126 /**
1127 * Fires when the default column output is displayed for a single row.
1128 *
1129 * @since 2.8.0
1130 *
1131 * @param string $column_name The custom column's name.
1132 * @param string $comment_id The comment ID as a numeric string.
1133 */
1134 do_action( 'manage_comments_custom_column', $column_name, $comment->comment_ID );
1135 }
1136}
1137
Ui Ux Design – Teachers Night Out

Get in Touch

© 2024 Teachers Night Out. All Rights Reserved.