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