author | ymh <ymh.work@gmail.com> |
Mon, 14 Oct 2019 18:28:13 +0200 | |
changeset 9 | 177826044cd9 |
parent 7 | cf61fcea0001 |
child 16 | a86126ab1dd4 |
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 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
58 |
public function floated_admin_avatar( $name, $comment_ID ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
59 |
$comment = get_comment( $comment_ID ); |
9 | 60 |
$avatar = get_avatar( $comment, 32, 'mystery' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
61 |
return "$avatar $name"; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
62 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
63 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
64 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
65 |
* @return bool |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
66 |
*/ |
5 | 67 |
public function ajax_user_can() { |
9 | 68 |
return current_user_can( 'edit_posts' ); |
0 | 69 |
} |
70 |
||
7
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 |
* @global int $post_id |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
73 |
* @global string $comment_status |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
74 |
* @global string $search |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
75 |
* @global string $comment_type |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
76 |
*/ |
5 | 77 |
public function prepare_items() { |
0 | 78 |
global $post_id, $comment_status, $search, $comment_type; |
79 |
||
80 |
$comment_status = isset( $_REQUEST['comment_status'] ) ? $_REQUEST['comment_status'] : 'all'; |
|
9 | 81 |
if ( ! in_array( $comment_status, array( 'all', 'mine', 'moderated', 'approved', 'spam', 'trash' ) ) ) { |
0 | 82 |
$comment_status = 'all'; |
9 | 83 |
} |
0 | 84 |
|
9 | 85 |
$comment_type = ! empty( $_REQUEST['comment_type'] ) ? $_REQUEST['comment_type'] : ''; |
0 | 86 |
|
87 |
$search = ( isset( $_REQUEST['s'] ) ) ? $_REQUEST['s'] : ''; |
|
88 |
||
89 |
$post_type = ( isset( $_REQUEST['post_type'] ) ) ? sanitize_key( $_REQUEST['post_type'] ) : ''; |
|
90 |
||
91 |
$user_id = ( isset( $_REQUEST['user_id'] ) ) ? $_REQUEST['user_id'] : ''; |
|
92 |
||
93 |
$orderby = ( isset( $_REQUEST['orderby'] ) ) ? $_REQUEST['orderby'] : ''; |
|
9 | 94 |
$order = ( isset( $_REQUEST['order'] ) ) ? $_REQUEST['order'] : ''; |
0 | 95 |
|
96 |
$comments_per_page = $this->get_per_page( $comment_status ); |
|
97 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
98 |
$doing_ajax = wp_doing_ajax(); |
0 | 99 |
|
100 |
if ( isset( $_REQUEST['number'] ) ) { |
|
101 |
$number = (int) $_REQUEST['number']; |
|
9 | 102 |
} else { |
0 | 103 |
$number = $comments_per_page + min( 8, $comments_per_page ); // Grab a few extra |
104 |
} |
|
105 |
||
106 |
$page = $this->get_pagenum(); |
|
107 |
||
108 |
if ( isset( $_REQUEST['start'] ) ) { |
|
109 |
$start = $_REQUEST['start']; |
|
110 |
} else { |
|
111 |
$start = ( $page - 1 ) * $comments_per_page; |
|
112 |
} |
|
113 |
||
114 |
if ( $doing_ajax && isset( $_REQUEST['offset'] ) ) { |
|
115 |
$start += $_REQUEST['offset']; |
|
116 |
} |
|
117 |
||
118 |
$status_map = array( |
|
9 | 119 |
'mine' => '', |
0 | 120 |
'moderated' => 'hold', |
9 | 121 |
'approved' => 'approve', |
122 |
'all' => '', |
|
0 | 123 |
); |
124 |
||
125 |
$args = array( |
|
9 | 126 |
'status' => isset( $status_map[ $comment_status ] ) ? $status_map[ $comment_status ] : $comment_status, |
127 |
'search' => $search, |
|
128 |
'user_id' => $user_id, |
|
129 |
'offset' => $start, |
|
130 |
'number' => $number, |
|
131 |
'post_id' => $post_id, |
|
132 |
'type' => $comment_type, |
|
133 |
'orderby' => $orderby, |
|
134 |
'order' => $order, |
|
0 | 135 |
'post_type' => $post_type, |
136 |
); |
|
137 |
||
9 | 138 |
/** |
139 |
* Filters the arguments for the comment query in the comments list table. |
|
140 |
* |
|
141 |
* @since 5.1.0 |
|
142 |
* |
|
143 |
* @param array $args An array of get_comments() arguments. |
|
144 |
*/ |
|
145 |
$args = apply_filters( 'comments_list_table_query_args', $args ); |
|
146 |
||
0 | 147 |
$_comments = get_comments( $args ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
148 |
if ( is_array( $_comments ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
149 |
update_comment_cache( $_comments ); |
0 | 150 |
|
9 | 151 |
$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
|
152 |
$this->extra_items = array_slice( $_comments, $comments_per_page ); |
0 | 153 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
154 |
$_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
|
155 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
156 |
$this->pending_count = get_pending_comments_num( $_comment_post_ids ); |
0 | 157 |
} |
158 |
||
9 | 159 |
$total_comments = get_comments( |
160 |
array_merge( |
|
161 |
$args, |
|
162 |
array( |
|
163 |
'count' => true, |
|
164 |
'offset' => 0, |
|
165 |
'number' => 0, |
|
166 |
) |
|
167 |
) |
|
168 |
); |
|
0 | 169 |
|
9 | 170 |
$this->set_pagination_args( |
171 |
array( |
|
172 |
'total_items' => $total_comments, |
|
173 |
'per_page' => $comments_per_page, |
|
174 |
) |
|
175 |
); |
|
0 | 176 |
} |
177 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
178 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
179 |
* @param string $comment_status |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
180 |
* @return int |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
181 |
*/ |
5 | 182 |
public function get_per_page( $comment_status = 'all' ) { |
0 | 183 |
$comments_per_page = $this->get_items_per_page( 'edit_comments_per_page' ); |
5 | 184 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
185 |
* Filters the number of comments listed per page in the comments list table. |
5 | 186 |
* |
187 |
* @since 2.6.0 |
|
188 |
* |
|
189 |
* @param int $comments_per_page The number of comments to list per page. |
|
190 |
* @param string $comment_status The comment status name. Default 'All'. |
|
191 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
192 |
return apply_filters( 'comments_per_page', $comments_per_page, $comment_status ); |
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 |
* @global string $comment_status |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
197 |
*/ |
5 | 198 |
public function no_items() { |
0 | 199 |
global $comment_status; |
200 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
201 |
if ( 'moderated' === $comment_status ) { |
0 | 202 |
_e( 'No comments awaiting moderation.' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
203 |
} else { |
0 | 204 |
_e( 'No comments found.' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
205 |
} |
0 | 206 |
} |
207 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
208 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
209 |
* @global int $post_id |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
210 |
* @global string $comment_status |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
211 |
* @global string $comment_type |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
212 |
*/ |
5 | 213 |
protected function get_views() { |
0 | 214 |
global $post_id, $comment_status, $comment_type; |
215 |
||
216 |
$status_links = array(); |
|
217 |
$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
|
218 |
|
0 | 219 |
$stati = array( |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
220 |
/* translators: %s: all comments count */ |
9 | 221 |
'all' => _nx_noop( |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
222 |
'All <span class="count">(%s)</span>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
223 |
'All <span class="count">(%s)</span>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
224 |
'comments' |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
225 |
), // singular not used |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
226 |
|
9 | 227 |
/* translators: %s: current user's comments count */ |
228 |
'mine' => _nx_noop( |
|
229 |
'Mine <span class="count">(%s)</span>', |
|
230 |
'Mine <span class="count">(%s)</span>', |
|
231 |
'comments' |
|
232 |
), |
|
233 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
234 |
/* translators: %s: pending comments count */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
235 |
'moderated' => _nx_noop( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
236 |
'Pending <span class="count">(%s)</span>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
237 |
'Pending <span class="count">(%s)</span>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
238 |
'comments' |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
239 |
), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
240 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
241 |
/* translators: %s: approved comments count */ |
9 | 242 |
'approved' => _nx_noop( |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
243 |
'Approved <span class="count">(%s)</span>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
244 |
'Approved <span class="count">(%s)</span>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
245 |
'comments' |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
246 |
), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
247 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
248 |
/* translators: %s: spam comments count */ |
9 | 249 |
'spam' => _nx_noop( |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
250 |
'Spam <span class="count">(%s)</span>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
251 |
'Spam <span class="count">(%s)</span>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
252 |
'comments' |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
253 |
), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
254 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
255 |
/* translators: %s: trashed comments count */ |
9 | 256 |
'trash' => _nx_noop( |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
257 |
'Trash <span class="count">(%s)</span>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
258 |
'Trash <span class="count">(%s)</span>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
259 |
'comments' |
9 | 260 |
), |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
261 |
); |
0 | 262 |
|
9 | 263 |
if ( ! EMPTY_TRASH_DAYS ) { |
264 |
unset( $stati['trash'] ); |
|
265 |
} |
|
0 | 266 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
267 |
$link = admin_url( 'edit-comments.php' ); |
9 | 268 |
if ( ! empty( $comment_type ) && 'all' != $comment_type ) { |
0 | 269 |
$link = add_query_arg( 'comment_type', $comment_type, $link ); |
9 | 270 |
} |
0 | 271 |
|
272 |
foreach ( $stati as $status => $label ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
273 |
$current_link_attributes = ''; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
274 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
275 |
if ( $status === $comment_status ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
276 |
$current_link_attributes = ' class="current" aria-current="page"'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
277 |
} |
0 | 278 |
|
9 | 279 |
if ( 'mine' === $status ) { |
280 |
$current_user_id = get_current_user_id(); |
|
281 |
$num_comments->mine = get_comments( |
|
282 |
array( |
|
283 |
'post_id' => $post_id ? $post_id : 0, |
|
284 |
'user_id' => $current_user_id, |
|
285 |
'count' => true, |
|
286 |
) |
|
287 |
); |
|
288 |
$link = add_query_arg( 'user_id', $current_user_id, $link ); |
|
289 |
} else { |
|
290 |
$link = remove_query_arg( 'user_id', $link ); |
|
291 |
} |
|
292 |
||
293 |
if ( ! isset( $num_comments->$status ) ) { |
|
0 | 294 |
$num_comments->$status = 10; |
9 | 295 |
} |
0 | 296 |
$link = add_query_arg( 'comment_status', $status, $link ); |
9 | 297 |
if ( $post_id ) { |
0 | 298 |
$link = add_query_arg( 'p', absint( $post_id ), $link ); |
9 | 299 |
} |
0 | 300 |
/* |
301 |
// I toyed with this, but decided against it. Leaving it in here in case anyone thinks it is a good idea. ~ Mark |
|
302 |
if ( !empty( $_REQUEST['s'] ) ) |
|
303 |
$link = add_query_arg( 's', esc_attr( wp_unslash( $_REQUEST['s'] ) ), $link ); |
|
304 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
305 |
$status_links[ $status ] = "<a href='$link'$current_link_attributes>" . sprintf( |
0 | 306 |
translate_nooped_plural( $label, $num_comments->$status ), |
9 | 307 |
sprintf( |
308 |
'<span class="%s-count">%s</span>', |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
309 |
( 'moderated' === $status ) ? 'pending' : $status, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
310 |
number_format_i18n( $num_comments->$status ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
311 |
) |
0 | 312 |
) . '</a>'; |
313 |
} |
|
314 |
||
5 | 315 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
316 |
* Filters the comment status links. |
5 | 317 |
* |
318 |
* @since 2.5.0 |
|
9 | 319 |
* @since 5.1.0 The 'Mine' link was added. |
5 | 320 |
* |
9 | 321 |
* @param string[] $status_links An associative array of fully-formed comment status links. Includes 'All', 'Mine', |
322 |
* 'Pending', 'Approved', 'Spam', and 'Trash'. |
|
5 | 323 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
324 |
return apply_filters( 'comment_status_links', $status_links ); |
0 | 325 |
} |
326 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
327 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
328 |
* @global string $comment_status |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
329 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
330 |
* @return array |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
331 |
*/ |
5 | 332 |
protected function get_bulk_actions() { |
0 | 333 |
global $comment_status; |
334 |
||
335 |
$actions = array(); |
|
9 | 336 |
if ( in_array( $comment_status, array( 'all', 'approved' ) ) ) { |
0 | 337 |
$actions['unapprove'] = __( 'Unapprove' ); |
9 | 338 |
} |
339 |
if ( in_array( $comment_status, array( 'all', 'moderated' ) ) ) { |
|
0 | 340 |
$actions['approve'] = __( 'Approve' ); |
9 | 341 |
} |
342 |
if ( in_array( $comment_status, array( 'all', 'moderated', 'approved', 'trash' ) ) ) { |
|
0 | 343 |
$actions['spam'] = _x( 'Mark as Spam', 'comment' ); |
9 | 344 |
} |
0 | 345 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
346 |
if ( 'trash' === $comment_status ) { |
0 | 347 |
$actions['untrash'] = __( 'Restore' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
348 |
} elseif ( 'spam' === $comment_status ) { |
0 | 349 |
$actions['unspam'] = _x( 'Not Spam', 'comment' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
350 |
} |
0 | 351 |
|
9 | 352 |
if ( in_array( $comment_status, array( 'trash', 'spam' ) ) || ! EMPTY_TRASH_DAYS ) { |
0 | 353 |
$actions['delete'] = __( 'Delete Permanently' ); |
9 | 354 |
} else { |
0 | 355 |
$actions['trash'] = __( 'Move to Trash' ); |
9 | 356 |
} |
0 | 357 |
|
358 |
return $actions; |
|
359 |
} |
|
360 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
361 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
362 |
* @global string $comment_status |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
363 |
* @global string $comment_type |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
364 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
365 |
* @param string $which |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
366 |
*/ |
5 | 367 |
protected function extra_tablenav( $which ) { |
0 | 368 |
global $comment_status, $comment_type; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
369 |
static $has_items; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
370 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
371 |
if ( ! isset( $has_items ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
372 |
$has_items = $this->has_items(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
373 |
} |
9 | 374 |
?> |
0 | 375 |
<div class="alignleft actions"> |
9 | 376 |
<?php |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
377 |
if ( 'top' === $which ) { |
9 | 378 |
?> |
379 |
<label class="screen-reader-text" for="filter-by-comment-type"><?php _e( 'Filter by comment type' ); ?></label> |
|
380 |
<select id="filter-by-comment-type" name="comment_type"> |
|
381 |
<option value=""><?php _e( 'All comment types' ); ?></option> |
|
382 |
<?php |
|
5 | 383 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
384 |
* Filters the comment types dropdown menu. |
5 | 385 |
* |
386 |
* @since 2.7.0 |
|
387 |
* |
|
9 | 388 |
* @param string[] $comment_types An array of comment types. Accepts 'Comments', 'Pings'. |
5 | 389 |
*/ |
9 | 390 |
$comment_types = apply_filters( |
391 |
'admin_comment_types_dropdown', |
|
392 |
array( |
|
393 |
'comment' => __( 'Comments' ), |
|
394 |
'pings' => __( 'Pings' ), |
|
395 |
) |
|
396 |
); |
|
0 | 397 |
|
9 | 398 |
foreach ( $comment_types as $type => $label ) { |
399 |
echo "\t" . '<option value="' . esc_attr( $type ) . '"' . selected( $comment_type, $type, false ) . ">$label</option>\n"; |
|
400 |
} |
|
0 | 401 |
?> |
9 | 402 |
</select> |
403 |
<?php |
|
5 | 404 |
/** |
405 |
* Fires just before the Filter submit button for comment types. |
|
406 |
* |
|
407 |
* @since 3.5.0 |
|
408 |
*/ |
|
0 | 409 |
do_action( 'restrict_manage_comments' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
410 |
submit_button( __( 'Filter' ), '', 'filter_action', false, array( 'id' => 'post-query-submit' ) ); |
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 ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
458 |
/* translators: column name or table row header */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
459 |
$columns['response'] = __( 'In Response To' ); |
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 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
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 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
468 |
* @return array |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
469 |
*/ |
5 | 470 |
protected function get_sortable_columns() { |
0 | 471 |
return array( |
472 |
'author' => 'comment_author', |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
473 |
'response' => 'comment_post_ID', |
9 | 474 |
'date' => 'comment_date', |
0 | 475 |
); |
476 |
} |
|
477 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
478 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
479 |
* Get the name of the default primary column. |
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 |
* @since 4.3.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
482 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
483 |
* @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
|
484 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
485 |
protected function get_default_primary_column_name() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
486 |
return 'comment'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
487 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
488 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
489 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
490 |
*/ |
5 | 491 |
public function display() { |
9 | 492 |
wp_nonce_field( 'fetch-list-' . get_class( $this ), '_ajax_fetch_list_nonce' ); |
0 | 493 |
|
494 |
$this->display_tablenav( 'top' ); |
|
495 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
496 |
$this->screen->render_screen_reader_content( 'heading_list' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
497 |
|
9 | 498 |
?> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
499 |
<table class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>"> |
0 | 500 |
<thead> |
501 |
<tr> |
|
502 |
<?php $this->print_column_headers(); ?> |
|
503 |
</tr> |
|
504 |
</thead> |
|
505 |
||
506 |
<tbody id="the-comment-list" data-wp-lists="list:comment"> |
|
507 |
<?php $this->display_rows_or_placeholder(); ?> |
|
508 |
</tbody> |
|
509 |
||
510 |
<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
|
511 |
<?php |
9 | 512 |
/* |
513 |
* Back up the items to restore after printing the extra items markup. |
|
514 |
* The extra items may be empty, which will prevent the table nav from displaying later. |
|
515 |
*/ |
|
516 |
$items = $this->items; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
517 |
$this->items = $this->extra_items; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
518 |
$this->display_rows_or_placeholder(); |
9 | 519 |
$this->items = $items; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
520 |
?> |
0 | 521 |
</tbody> |
5 | 522 |
|
523 |
<tfoot> |
|
524 |
<tr> |
|
525 |
<?php $this->print_column_headers( false ); ?> |
|
526 |
</tr> |
|
527 |
</tfoot> |
|
528 |
||
0 | 529 |
</table> |
9 | 530 |
<?php |
0 | 531 |
|
532 |
$this->display_tablenav( 'bottom' ); |
|
533 |
} |
|
534 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
535 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
536 |
* @global WP_Post $post |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
537 |
* @global WP_Comment $comment |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
538 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
539 |
* @param WP_Comment $item |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
540 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
541 |
public function single_row( $item ) { |
0 | 542 |
global $post, $comment; |
543 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
544 |
$comment = $item; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
545 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
546 |
$the_comment_class = wp_get_comment_status( $comment ); |
5 | 547 |
if ( ! $the_comment_class ) { |
548 |
$the_comment_class = ''; |
|
549 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
550 |
$the_comment_class = join( ' ', get_comment_class( $the_comment_class, $comment, $comment->comment_post_ID ) ); |
0 | 551 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
552 |
if ( $comment->comment_post_ID > 0 ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
553 |
$post = get_post( $comment->comment_post_ID ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
554 |
} |
0 | 555 |
$this->user_can = current_user_can( 'edit_comment', $comment->comment_ID ); |
556 |
||
557 |
echo "<tr id='comment-$comment->comment_ID' class='$the_comment_class'>"; |
|
558 |
$this->single_row_columns( $comment ); |
|
559 |
echo "</tr>\n"; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
560 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
561 |
unset( $GLOBALS['post'], $GLOBALS['comment'] ); |
0 | 562 |
} |
563 |
||
9 | 564 |
/** |
565 |
* Generate and display row actions links. |
|
566 |
* |
|
567 |
* @since 4.3.0 |
|
568 |
* |
|
569 |
* @global string $comment_status Status for the current listed comments. |
|
570 |
* |
|
571 |
* @param WP_Comment $comment The comment object. |
|
572 |
* @param string $column_name Current column name. |
|
573 |
* @param string $primary Primary column name. |
|
574 |
* @return string|void Comment row actions output. |
|
575 |
*/ |
|
576 |
protected function handle_row_actions( $comment, $column_name, $primary ) { |
|
577 |
global $comment_status; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
578 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
579 |
if ( $primary !== $column_name ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
580 |
return ''; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
581 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
582 |
|
9 | 583 |
if ( ! $this->user_can ) { |
584 |
return; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
585 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
586 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
587 |
$the_comment_status = wp_get_comment_status( $comment ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
588 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
589 |
$out = ''; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
590 |
|
9 | 591 |
$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
|
592 |
$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
|
593 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
594 |
$url = "comment.php?c=$comment->comment_ID"; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
595 |
|
9 | 596 |
$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
|
597 |
$unapprove_url = esc_url( $url . "&action=unapprovecomment&$approve_nonce" ); |
9 | 598 |
$spam_url = esc_url( $url . "&action=spamcomment&$del_nonce" ); |
599 |
$unspam_url = esc_url( $url . "&action=unspamcomment&$del_nonce" ); |
|
600 |
$trash_url = esc_url( $url . "&action=trashcomment&$del_nonce" ); |
|
601 |
$untrash_url = esc_url( $url . "&action=untrashcomment&$del_nonce" ); |
|
602 |
$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
|
603 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
604 |
// Preorder it: Approve | Reply | Quick Edit | Edit | Spam | Trash. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
605 |
$actions = array( |
9 | 606 |
'approve' => '', |
607 |
'unapprove' => '', |
|
608 |
'reply' => '', |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
609 |
'quickedit' => '', |
9 | 610 |
'edit' => '', |
611 |
'spam' => '', |
|
612 |
'unspam' => '', |
|
613 |
'trash' => '', |
|
614 |
'untrash' => '', |
|
615 |
'delete' => '', |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
616 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
617 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
618 |
// Not looking at all comments. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
619 |
if ( $comment_status && 'all' != $comment_status ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
620 |
if ( 'approved' === $the_comment_status ) { |
9 | 621 |
$actions['unapprove'] = "<a href='$unapprove_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&new=unapproved' class='vim-u vim-destructive aria-button-if-js' aria-label='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
622 |
} elseif ( 'unapproved' === $the_comment_status ) { |
9 | 623 |
$actions['approve'] = "<a href='$approve_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&new=approved' class='vim-a vim-destructive aria-button-if-js' aria-label='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
624 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
625 |
} else { |
9 | 626 |
$actions['approve'] = "<a href='$approve_url' data-wp-lists='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=approved' class='vim-a aria-button-if-js' aria-label='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>'; |
627 |
$actions['unapprove'] = "<a href='$unapprove_url' data-wp-lists='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=unapproved' class='vim-u aria-button-if-js' aria-label='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>'; |
|
7
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 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
630 |
if ( 'spam' !== $the_comment_status ) { |
9 | 631 |
$actions['spam'] = "<a href='$spam_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::spam=1' class='vim-s vim-destructive aria-button-if-js' aria-label='" . esc_attr__( 'Mark this comment as spam' ) . "'>" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . '</a>'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
632 |
} elseif ( 'spam' === $the_comment_status ) { |
9 | 633 |
$actions['unspam'] = "<a href='$unspam_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID:66cc66:unspam=1' class='vim-z vim-destructive aria-button-if-js' aria-label='" . esc_attr__( 'Restore this comment from the spam' ) . "'>" . _x( 'Not Spam', 'comment' ) . '</a>'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
634 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
635 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
636 |
if ( 'trash' === $the_comment_status ) { |
9 | 637 |
$actions['untrash'] = "<a href='$untrash_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID:66cc66:untrash=1' class='vim-z vim-destructive aria-button-if-js' aria-label='" . esc_attr__( 'Restore this comment from the Trash' ) . "'>" . __( 'Restore' ) . '</a>'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
638 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
639 |
|
9 | 640 |
if ( 'spam' === $the_comment_status || 'trash' === $the_comment_status || ! EMPTY_TRASH_DAYS ) { |
641 |
$actions['delete'] = "<a href='$delete_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::delete=1' class='delete vim-d vim-destructive aria-button-if-js' aria-label='" . esc_attr__( 'Delete this comment permanently' ) . "'>" . __( 'Delete Permanently' ) . '</a>'; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
642 |
} else { |
9 | 643 |
$actions['trash'] = "<a href='$trash_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::trash=1' class='delete vim-d vim-destructive aria-button-if-js' aria-label='" . esc_attr__( 'Move this comment to the Trash' ) . "'>" . _x( 'Trash', 'verb' ) . '</a>'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
644 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
645 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
646 |
if ( 'spam' !== $the_comment_status && 'trash' !== $the_comment_status ) { |
9 | 647 |
$actions['edit'] = "<a href='comment.php?action=editcomment&c={$comment->comment_ID}' aria-label='" . esc_attr__( 'Edit this comment' ) . "'>" . __( 'Edit' ) . '</a>'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
648 |
|
9 | 649 |
$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
|
650 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
651 |
$actions['quickedit'] = sprintf( $format, $comment->comment_ID, $comment->comment_post_ID, 'edit', 'vim-q comment-inline', esc_attr__( 'Quick edit this comment inline' ), __( 'Quick Edit' ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
652 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
653 |
$actions['reply'] = sprintf( $format, $comment->comment_ID, $comment->comment_post_ID, 'replyto', 'vim-r comment-inline', esc_attr__( 'Reply to this comment' ), __( 'Reply' ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
654 |
} |
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 |
/** 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
|
657 |
$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
|
658 |
|
9 | 659 |
$i = 0; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
660 |
$out .= '<div class="row-actions">'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
661 |
foreach ( $actions as $action => $link ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
662 |
++$i; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
663 |
( ( ( 'approve' === $action || 'unapprove' === $action ) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | '; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
664 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
665 |
// Reply and quickedit need a hide-if-no-js span when not added with ajax |
9 | 666 |
if ( ( 'reply' === $action || 'quickedit' === $action ) && ! wp_doing_ajax() ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
667 |
$action .= ' hide-if-no-js'; |
9 | 668 |
} elseif ( ( $action === 'untrash' && $the_comment_status === 'trash' ) || ( $action === 'unspam' && $the_comment_status === 'spam' ) ) { |
669 |
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
|
670 |
$action .= ' approve'; |
9 | 671 |
} else { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
672 |
$action .= ' unapprove'; |
9 | 673 |
} |
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 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
676 |
$out .= "<span class='$action'>$sep$link</span>"; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
677 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
678 |
$out .= '</div>'; |
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 .= '<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
|
681 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
682 |
return $out; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
683 |
} |
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 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
686 |
* @param WP_Comment $comment The comment object. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
687 |
*/ |
5 | 688 |
public function column_cb( $comment ) { |
9 | 689 |
if ( $this->user_can ) { |
690 |
?> |
|
0 | 691 |
<label class="screen-reader-text" for="cb-select-<?php echo $comment->comment_ID; ?>"><?php _e( 'Select comment' ); ?></label> |
692 |
<input id="cb-select-<?php echo $comment->comment_ID; ?>" type="checkbox" name="delete_comments[]" value="<?php echo $comment->comment_ID; ?>" /> |
|
9 | 693 |
<?php |
0 | 694 |
} |
695 |
} |
|
696 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
697 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
698 |
* @param WP_Comment $comment The comment object. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
699 |
*/ |
5 | 700 |
public function column_comment( $comment ) { |
701 |
echo '<div class="comment-author">'; |
|
702 |
$this->column_author( $comment ); |
|
703 |
echo '</div>'; |
|
704 |
||
0 | 705 |
if ( $comment->comment_parent ) { |
706 |
$parent = get_comment( $comment->comment_parent ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
707 |
if ( $parent ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
708 |
$parent_link = esc_url( get_comment_link( $parent ) ); |
9 | 709 |
$name = get_comment_author( $parent ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
710 |
printf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
711 |
/* translators: %s: comment link */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
712 |
__( 'In reply to %s.' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
713 |
'<a href="' . $parent_link . '">' . $name . '</a>' |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
714 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
715 |
} |
0 | 716 |
} |
717 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
718 |
comment_text( $comment ); |
9 | 719 |
|
720 |
if ( $this->user_can ) { |
|
5 | 721 |
/** This filter is documented in wp-admin/includes/comment.php */ |
9 | 722 |
$comment_content = apply_filters( 'comment_edit_pre', $comment->comment_content ); |
723 |
?> |
|
724 |
<div id="inline-<?php echo $comment->comment_ID; ?>" class="hidden"> |
|
725 |
<textarea class="comment" rows="1" cols="1"><?php echo esc_textarea( $comment_content ); ?></textarea> |
|
726 |
<div class="author-email"><?php echo esc_attr( $comment->comment_author_email ); ?></div> |
|
727 |
<div class="author"><?php echo esc_attr( $comment->comment_author ); ?></div> |
|
728 |
<div class="author-url"><?php echo esc_attr( $comment->comment_author_url ); ?></div> |
|
729 |
<div class="comment_status"><?php echo $comment->comment_approved; ?></div> |
|
0 | 730 |
</div> |
9 | 731 |
<?php |
0 | 732 |
} |
733 |
} |
|
734 |
||
7
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 |
* @global string $comment_status |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
737 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
738 |
* @param WP_Comment $comment The comment object. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
739 |
*/ |
5 | 740 |
public function column_author( $comment ) { |
0 | 741 |
global $comment_status; |
742 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
743 |
$author_url = get_comment_author_url( $comment ); |
0 | 744 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
745 |
$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
|
746 |
if ( strlen( $author_url_display ) > 50 ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
747 |
$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
|
748 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
749 |
|
9 | 750 |
echo '<strong>'; |
751 |
comment_author( $comment ); |
|
752 |
echo '</strong><br />'; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
753 |
if ( ! empty( $author_url_display ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
754 |
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
|
755 |
} |
0 | 756 |
|
757 |
if ( $this->user_can ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
758 |
if ( ! empty( $comment->comment_author_email ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
759 |
/** 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
|
760 |
$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
|
761 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
762 |
if ( ! empty( $email ) && '@' !== $email ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
763 |
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
|
764 |
} |
0 | 765 |
} |
5 | 766 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
767 |
$author_ip = get_comment_author_IP( $comment ); |
5 | 768 |
if ( $author_ip ) { |
9 | 769 |
$author_ip_url = add_query_arg( |
770 |
array( |
|
771 |
's' => $author_ip, |
|
772 |
'mode' => 'detail', |
|
773 |
), |
|
774 |
admin_url( 'edit-comments.php' ) |
|
775 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
776 |
if ( 'spam' === $comment_status ) { |
5 | 777 |
$author_ip_url = add_query_arg( 'comment_status', 'spam', $author_ip_url ); |
778 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
779 |
printf( '<a href="%1$s">%2$s</a>', esc_url( $author_ip_url ), esc_html( $author_ip ) ); |
5 | 780 |
} |
0 | 781 |
} |
782 |
} |
|
783 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
784 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
785 |
* @param WP_Comment $comment The comment object. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
786 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
787 |
public function column_date( $comment ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
788 |
/* translators: 1: comment date, 2: comment time */ |
9 | 789 |
$submitted = sprintf( |
790 |
__( '%1$s at %2$s' ), |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
791 |
/* translators: comment date format. See https://secure.php.net/date */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
792 |
get_comment_date( __( 'Y/m/d' ), $comment ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
793 |
get_comment_date( __( 'g:i a' ), $comment ) |
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 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
796 |
echo '<div class="submitted-on">'; |
9 | 797 |
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
|
798 |
printf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
799 |
'<a href="%s">%s</a>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
800 |
esc_url( get_comment_link( $comment ) ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
801 |
$submitted |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
802 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
803 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
804 |
echo $submitted; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
805 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
806 |
echo '</div>'; |
0 | 807 |
} |
808 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
809 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
810 |
* @param WP_Comment $comment The comment object. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
811 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
812 |
public function column_response( $comment ) { |
0 | 813 |
$post = get_post(); |
814 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
815 |
if ( ! $post ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
816 |
return; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
817 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
818 |
|
9 | 819 |
if ( isset( $this->pending_count[ $post->ID ] ) ) { |
820 |
$pending_comments = $this->pending_count[ $post->ID ]; |
|
0 | 821 |
} else { |
822 |
$_pending_count_temp = get_pending_comments_num( array( $post->ID ) ); |
|
9 | 823 |
$pending_comments = $this->pending_count[ $post->ID ] = $_pending_count_temp[ $post->ID ]; |
0 | 824 |
} |
825 |
||
826 |
if ( current_user_can( 'edit_post', $post->ID ) ) { |
|
9 | 827 |
$post_link = "<a href='" . get_edit_post_link( $post->ID ) . "' class='comments-edit-item-link'>"; |
5 | 828 |
$post_link .= esc_html( get_the_title( $post->ID ) ) . '</a>'; |
0 | 829 |
} else { |
5 | 830 |
$post_link = esc_html( get_the_title( $post->ID ) ); |
0 | 831 |
} |
832 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
833 |
echo '<div class="response-links">'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
834 |
if ( 'attachment' === $post->post_type && ( $thumb = wp_get_attachment_image( $post->ID, array( 80, 60 ), true ) ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
835 |
echo $thumb; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
836 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
837 |
echo $post_link; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
838 |
$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
|
839 |
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
|
840 |
echo '<span class="post-com-count-wrapper post-com-count-', $post->ID, '">'; |
0 | 841 |
$this->comments_bubble( $post->ID, $pending_comments ); |
842 |
echo '</span> '; |
|
843 |
echo '</div>'; |
|
844 |
} |
|
845 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
846 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
847 |
* @param WP_Comment $comment The comment object. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
848 |
* @param string $column_name The custom column's name. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
849 |
*/ |
5 | 850 |
public function column_default( $comment, $column_name ) { |
851 |
/** |
|
852 |
* Fires when the default column output is displayed for a single row. |
|
853 |
* |
|
854 |
* @since 2.8.0 |
|
855 |
* |
|
856 |
* @param string $column_name The custom column's name. |
|
857 |
* @param int $comment->comment_ID The custom column's unique ID number. |
|
858 |
*/ |
|
0 | 859 |
do_action( 'manage_comments_custom_column', $column_name, $comment->comment_ID ); |
860 |
} |
|
861 |
} |