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