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