author | ymh <ymh.work@gmail.com> |
Fri, 05 Sep 2025 18:40:08 +0200 | |
changeset 21 | 48c4eec2b7e6 |
parent 19 | 3d72ae0968f4 |
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_Terms_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 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
7 |
* @since 3.1.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
8 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
9 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
10 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
11 |
* Core class used to implement displaying terms in a list table. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
12 |
* |
0 | 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_Terms_List_Table extends WP_List_Table { |
|
18 |
||
5 | 19 |
public $callback_args; |
20 |
||
21 |
private $level; |
|
0 | 22 |
|
5 | 23 |
/** |
24 |
* Constructor. |
|
25 |
* |
|
26 |
* @since 3.1.0 |
|
27 |
* |
|
28 |
* @see WP_List_Table::__construct() for more information on default arguments. |
|
29 |
* |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
30 |
* @global string $post_type Global post type. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
31 |
* @global string $taxonomy Global taxonomy. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
32 |
* @global string $action |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
33 |
* @global object $tax |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
34 |
* |
5 | 35 |
* @param array $args An associative array of arguments. |
36 |
*/ |
|
37 |
public function __construct( $args = array() ) { |
|
0 | 38 |
global $post_type, $taxonomy, $action, $tax; |
39 |
||
9 | 40 |
parent::__construct( |
41 |
array( |
|
42 |
'plural' => 'tags', |
|
43 |
'singular' => 'tag', |
|
44 |
'screen' => isset( $args['screen'] ) ? $args['screen'] : null, |
|
45 |
) |
|
46 |
); |
|
0 | 47 |
|
48 |
$action = $this->screen->action; |
|
49 |
$post_type = $this->screen->post_type; |
|
50 |
$taxonomy = $this->screen->taxonomy; |
|
51 |
||
9 | 52 |
if ( empty( $taxonomy ) ) { |
0 | 53 |
$taxonomy = 'post_tag'; |
9 | 54 |
} |
0 | 55 |
|
9 | 56 |
if ( ! taxonomy_exists( $taxonomy ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
57 |
wp_die( __( 'Invalid taxonomy.' ) ); |
9 | 58 |
} |
0 | 59 |
|
60 |
$tax = get_taxonomy( $taxonomy ); |
|
61 |
||
62 |
// @todo Still needed? Maybe just the show_ui part. |
|
16 | 63 |
if ( empty( $post_type ) || ! in_array( $post_type, get_post_types( array( 'show_ui' => true ) ), true ) ) { |
0 | 64 |
$post_type = 'post'; |
9 | 65 |
} |
0 | 66 |
} |
67 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
68 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
69 |
* @return bool |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
70 |
*/ |
5 | 71 |
public function ajax_user_can() { |
0 | 72 |
return current_user_can( get_taxonomy( $this->screen->taxonomy )->cap->manage_terms ); |
73 |
} |
|
74 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
75 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
76 |
*/ |
5 | 77 |
public function prepare_items() { |
19 | 78 |
$taxonomy = $this->screen->taxonomy; |
0 | 79 |
|
19 | 80 |
$tags_per_page = $this->get_items_per_page( "edit_{$taxonomy}_per_page" ); |
81 |
||
82 |
if ( 'post_tag' === $taxonomy ) { |
|
5 | 83 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
84 |
* Filters the number of terms displayed per page for the Tags list table. |
5 | 85 |
* |
86 |
* @since 2.8.0 |
|
87 |
* |
|
88 |
* @param int $tags_per_page Number of tags to be displayed. Default 20. |
|
89 |
*/ |
|
0 | 90 |
$tags_per_page = apply_filters( 'edit_tags_per_page', $tags_per_page ); |
5 | 91 |
|
92 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
93 |
* Filters the number of terms displayed per page for the Tags list table. |
5 | 94 |
* |
95 |
* @since 2.7.0 |
|
16 | 96 |
* @deprecated 2.8.0 Use {@see 'edit_tags_per_page'} instead. |
5 | 97 |
* |
98 |
* @param int $tags_per_page Number of tags to be displayed. Default 20. |
|
99 |
*/ |
|
16 | 100 |
$tags_per_page = apply_filters_deprecated( 'tagsperpage', array( $tags_per_page ), '2.8.0', 'edit_tags_per_page' ); |
19 | 101 |
} elseif ( 'category' === $taxonomy ) { |
5 | 102 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
103 |
* Filters the number of terms displayed per page for the Categories list table. |
5 | 104 |
* |
105 |
* @since 2.8.0 |
|
106 |
* |
|
107 |
* @param int $tags_per_page Number of categories to be displayed. Default 20. |
|
108 |
*/ |
|
109 |
$tags_per_page = apply_filters( 'edit_categories_per_page', $tags_per_page ); |
|
0 | 110 |
} |
111 |
||
9 | 112 |
$search = ! empty( $_REQUEST['s'] ) ? trim( wp_unslash( $_REQUEST['s'] ) ) : ''; |
0 | 113 |
|
114 |
$args = array( |
|
19 | 115 |
'taxonomy' => $taxonomy, |
116 |
'search' => $search, |
|
117 |
'page' => $this->get_pagenum(), |
|
118 |
'number' => $tags_per_page, |
|
119 |
'hide_empty' => 0, |
|
0 | 120 |
); |
121 |
||
9 | 122 |
if ( ! empty( $_REQUEST['orderby'] ) ) { |
0 | 123 |
$args['orderby'] = trim( wp_unslash( $_REQUEST['orderby'] ) ); |
9 | 124 |
} |
0 | 125 |
|
9 | 126 |
if ( ! empty( $_REQUEST['order'] ) ) { |
0 | 127 |
$args['order'] = trim( wp_unslash( $_REQUEST['order'] ) ); |
9 | 128 |
} |
0 | 129 |
|
19 | 130 |
$args['offset'] = ( $args['page'] - 1 ) * $args['number']; |
131 |
||
132 |
// Save the values because 'number' and 'offset' can be subsequently overridden. |
|
0 | 133 |
$this->callback_args = $args; |
134 |
||
19 | 135 |
if ( is_taxonomy_hierarchical( $taxonomy ) && ! isset( $args['orderby'] ) ) { |
136 |
// We'll need the full set of terms then. |
|
137 |
$args['number'] = 0; |
|
138 |
$args['offset'] = $args['number']; |
|
139 |
} |
|
140 |
||
141 |
$this->items = get_terms( $args ); |
|
142 |
||
9 | 143 |
$this->set_pagination_args( |
144 |
array( |
|
18 | 145 |
'total_items' => wp_count_terms( |
146 |
array( |
|
19 | 147 |
'taxonomy' => $taxonomy, |
18 | 148 |
'search' => $search, |
149 |
) |
|
150 |
), |
|
9 | 151 |
'per_page' => $tags_per_page, |
152 |
) |
|
153 |
); |
|
0 | 154 |
} |
155 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
156 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
157 |
*/ |
5 | 158 |
public function no_items() { |
159 |
echo get_taxonomy( $this->screen->taxonomy )->labels->not_found; |
|
160 |
} |
|
161 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
162 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
163 |
* @return array |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
164 |
*/ |
5 | 165 |
protected function get_bulk_actions() { |
0 | 166 |
$actions = array(); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
167 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
168 |
if ( current_user_can( get_taxonomy( $this->screen->taxonomy )->cap->delete_terms ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
169 |
$actions['delete'] = __( 'Delete' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
170 |
} |
0 | 171 |
|
172 |
return $actions; |
|
173 |
} |
|
174 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
175 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
176 |
* @return string |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
177 |
*/ |
5 | 178 |
public function current_action() { |
18 | 179 |
if ( isset( $_REQUEST['action'] ) && isset( $_REQUEST['delete_tags'] ) && 'delete' === $_REQUEST['action'] ) { |
0 | 180 |
return 'bulk-delete'; |
9 | 181 |
} |
0 | 182 |
|
183 |
return parent::current_action(); |
|
184 |
} |
|
185 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
186 |
/** |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
187 |
* @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
|
188 |
*/ |
5 | 189 |
public function get_columns() { |
0 | 190 |
$columns = array( |
191 |
'cb' => '<input type="checkbox" />', |
|
192 |
'name' => _x( 'Name', 'term name' ), |
|
193 |
'description' => __( 'Description' ), |
|
194 |
'slug' => __( 'Slug' ), |
|
195 |
); |
|
196 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
197 |
if ( 'link_category' === $this->screen->taxonomy ) { |
0 | 198 |
$columns['links'] = __( 'Links' ); |
199 |
} else { |
|
5 | 200 |
$columns['posts'] = _x( 'Count', 'Number/count of items' ); |
0 | 201 |
} |
202 |
||
203 |
return $columns; |
|
204 |
} |
|
205 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
206 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
207 |
* @return array |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
208 |
*/ |
5 | 209 |
protected function get_sortable_columns() { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
210 |
$taxonomy = $this->screen->taxonomy; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
211 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
212 |
if ( ! isset( $_GET['orderby'] ) && is_taxonomy_hierarchical( $taxonomy ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
213 |
$name_orderby_text = __( 'Table ordered hierarchically.' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
214 |
} else { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
215 |
$name_orderby_text = __( 'Table ordered by Name.' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
216 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
217 |
|
0 | 218 |
return array( |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
219 |
'name' => array( 'name', false, _x( 'Name', 'term name' ), $name_orderby_text, 'asc' ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
220 |
'description' => array( 'description', false, __( 'Description' ), __( 'Table ordered by Description.' ) ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
221 |
'slug' => array( 'slug', false, __( 'Slug' ), __( 'Table ordered by Slug.' ) ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
222 |
'posts' => array( 'count', false, _x( 'Count', 'Number/count of items' ), __( 'Table ordered by Posts Count.' ) ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
223 |
'links' => array( 'count', false, __( 'Links' ), __( 'Table ordered by Links.' ) ), |
0 | 224 |
); |
225 |
} |
|
226 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
227 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
228 |
*/ |
5 | 229 |
public function display_rows_or_placeholder() { |
0 | 230 |
$taxonomy = $this->screen->taxonomy; |
231 |
||
19 | 232 |
$number = $this->callback_args['number']; |
233 |
$offset = $this->callback_args['offset']; |
|
0 | 234 |
|
5 | 235 |
// Convert it to table rows. |
0 | 236 |
$count = 0; |
237 |
||
19 | 238 |
if ( empty( $this->items ) || ! is_array( $this->items ) ) { |
0 | 239 |
echo '<tr class="no-items"><td class="colspanchange" colspan="' . $this->get_column_count() . '">'; |
240 |
$this->no_items(); |
|
241 |
echo '</td></tr>'; |
|
242 |
return; |
|
243 |
} |
|
244 |
||
19 | 245 |
if ( is_taxonomy_hierarchical( $taxonomy ) && ! isset( $this->callback_args['orderby'] ) ) { |
246 |
if ( ! empty( $this->callback_args['search'] ) ) {// Ignore children on searches. |
|
0 | 247 |
$children = array(); |
5 | 248 |
} else { |
0 | 249 |
$children = _get_term_hierarchy( $taxonomy ); |
5 | 250 |
} |
16 | 251 |
|
252 |
/* |
|
253 |
* Some funky recursion to get the job done (paging & parents mainly) is contained within. |
|
254 |
* Skip it for non-hierarchical taxonomies for performance sake. |
|
255 |
*/ |
|
19 | 256 |
$this->_rows( $taxonomy, $this->items, $children, $offset, $number, $count ); |
0 | 257 |
} else { |
19 | 258 |
foreach ( $this->items as $term ) { |
0 | 259 |
$this->single_row( $term ); |
5 | 260 |
} |
0 | 261 |
} |
262 |
} |
|
263 |
||
5 | 264 |
/** |
265 |
* @param string $taxonomy |
|
16 | 266 |
* @param array $terms |
267 |
* @param array $children |
|
268 |
* @param int $start |
|
269 |
* @param int $per_page |
|
270 |
* @param int $count |
|
19 | 271 |
* @param int $parent_term |
16 | 272 |
* @param int $level |
5 | 273 |
*/ |
19 | 274 |
private function _rows( $taxonomy, $terms, &$children, $start, $per_page, &$count, $parent_term = 0, $level = 0 ) { |
0 | 275 |
|
276 |
$end = $start + $per_page; |
|
277 |
||
278 |
foreach ( $terms as $key => $term ) { |
|
279 |
||
9 | 280 |
if ( $count >= $end ) { |
0 | 281 |
break; |
9 | 282 |
} |
0 | 283 |
|
19 | 284 |
if ( $term->parent !== $parent_term && empty( $_REQUEST['s'] ) ) { |
0 | 285 |
continue; |
9 | 286 |
} |
0 | 287 |
|
288 |
// If the page starts in a subtree, print the parents. |
|
18 | 289 |
if ( $count === $start && $term->parent > 0 && empty( $_REQUEST['s'] ) ) { |
16 | 290 |
$my_parents = array(); |
291 |
$parent_ids = array(); |
|
9 | 292 |
$p = $term->parent; |
18 | 293 |
|
0 | 294 |
while ( $p ) { |
9 | 295 |
$my_parent = get_term( $p, $taxonomy ); |
0 | 296 |
$my_parents[] = $my_parent; |
9 | 297 |
$p = $my_parent->parent; |
18 | 298 |
|
16 | 299 |
if ( in_array( $p, $parent_ids, true ) ) { // Prevent parent loops. |
0 | 300 |
break; |
9 | 301 |
} |
18 | 302 |
|
0 | 303 |
$parent_ids[] = $p; |
304 |
} |
|
18 | 305 |
|
0 | 306 |
unset( $parent_ids ); |
307 |
||
308 |
$num_parents = count( $my_parents ); |
|
18 | 309 |
|
0 | 310 |
while ( $my_parent = array_pop( $my_parents ) ) { |
311 |
echo "\t"; |
|
312 |
$this->single_row( $my_parent, $level - $num_parents ); |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
313 |
--$num_parents; |
0 | 314 |
} |
315 |
} |
|
316 |
||
317 |
if ( $count >= $start ) { |
|
318 |
echo "\t"; |
|
319 |
$this->single_row( $term, $level ); |
|
320 |
} |
|
321 |
||
322 |
++$count; |
|
323 |
||
9 | 324 |
unset( $terms[ $key ] ); |
0 | 325 |
|
9 | 326 |
if ( isset( $children[ $term->term_id ] ) && empty( $_REQUEST['s'] ) ) { |
0 | 327 |
$this->_rows( $taxonomy, $terms, $children, $start, $per_page, $count, $term->term_id, $level + 1 ); |
9 | 328 |
} |
0 | 329 |
} |
330 |
} |
|
331 |
||
5 | 332 |
/** |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
333 |
* @global string $taxonomy Global taxonomy. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
334 |
* |
16 | 335 |
* @param WP_Term $tag Term object. |
336 |
* @param int $level |
|
5 | 337 |
*/ |
338 |
public function single_row( $tag, $level = 0 ) { |
|
339 |
global $taxonomy; |
|
9 | 340 |
$tag = sanitize_term( $tag, $taxonomy ); |
0 | 341 |
|
342 |
$this->level = $level; |
|
343 |
||
9 | 344 |
if ( $tag->parent ) { |
345 |
$count = count( get_ancestors( $tag->term_id, $taxonomy, 'taxonomy' ) ); |
|
346 |
$level = 'level-' . $count; |
|
347 |
} else { |
|
348 |
$level = 'level-0'; |
|
349 |
} |
|
350 |
||
351 |
echo '<tr id="tag-' . $tag->term_id . '" class="' . $level . '">'; |
|
0 | 352 |
$this->single_row_columns( $tag ); |
353 |
echo '</tr>'; |
|
354 |
} |
|
355 |
||
5 | 356 |
/** |
19 | 357 |
* @since 5.9.0 Renamed `$tag` to `$item` to match parent class for PHP 8 named parameter support. |
358 |
* |
|
359 |
* @param WP_Term $item Term object. |
|
5 | 360 |
* @return string |
361 |
*/ |
|
19 | 362 |
public function column_cb( $item ) { |
363 |
// Restores the more descriptive, specific name for use within this method. |
|
364 |
$tag = $item; |
|
365 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
366 |
if ( current_user_can( 'delete_term', $tag->term_id ) ) { |
16 | 367 |
return sprintf( |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
368 |
'<input type="checkbox" name="delete_tags[]" value="%1$s" id="cb-select-%1$s" />' . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
369 |
'<label for="cb-select-%1$s"><span class="screen-reader-text">%2$s</span></label>', |
16 | 370 |
$tag->term_id, |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
371 |
/* translators: Hidden accessibility text. %s: Taxonomy term name. */ |
16 | 372 |
sprintf( __( 'Select %s' ), $tag->name ) |
373 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
374 |
} |
0 | 375 |
|
376 |
return ' '; |
|
377 |
} |
|
378 |
||
5 | 379 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
380 |
* @param WP_Term $tag Term object. |
5 | 381 |
* @return string |
382 |
*/ |
|
383 |
public function column_name( $tag ) { |
|
0 | 384 |
$taxonomy = $this->screen->taxonomy; |
385 |
||
386 |
$pad = str_repeat( '— ', max( 0, $this->level ) ); |
|
5 | 387 |
|
388 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
389 |
* Filters display of the term name in the terms list table. |
5 | 390 |
* |
391 |
* The default output may include padding due to the term's |
|
392 |
* current level in the term hierarchy. |
|
393 |
* |
|
394 |
* @since 2.5.0 |
|
395 |
* |
|
396 |
* @see WP_Terms_List_Table::column_name() |
|
397 |
* |
|
398 |
* @param string $pad_tag_name The term name, padded if not top-level. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
399 |
* @param WP_Term $tag Term object. |
5 | 400 |
*/ |
0 | 401 |
$name = apply_filters( 'term_name', $pad . ' ' . $tag->name, $tag ); |
5 | 402 |
|
0 | 403 |
$qe_data = get_term( $tag->term_id, $taxonomy, OBJECT, 'edit' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
404 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
405 |
$uri = wp_doing_ajax() ? wp_get_referer() : $_SERVER['REQUEST_URI']; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
406 |
|
19 | 407 |
$edit_link = get_edit_term_link( $tag, $taxonomy, $this->screen->post_type ); |
9 | 408 |
|
409 |
if ( $edit_link ) { |
|
410 |
$edit_link = add_query_arg( |
|
411 |
'wp_http_referer', |
|
412 |
urlencode( wp_unslash( $uri ) ), |
|
413 |
$edit_link |
|
414 |
); |
|
415 |
$name = sprintf( |
|
416 |
'<a class="row-title" href="%s" aria-label="%s">%s</a>', |
|
417 |
esc_url( $edit_link ), |
|
16 | 418 |
/* translators: %s: Taxonomy term name. */ |
9 | 419 |
esc_attr( sprintf( __( '“%s” (Edit)' ), $tag->name ) ), |
420 |
$name |
|
421 |
); |
|
422 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
423 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
424 |
$output = sprintf( |
9 | 425 |
'<strong>%s</strong><br />', |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
426 |
$name |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
427 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
428 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
429 |
/** This filter is documented in wp-admin/includes/class-wp-terms-list-table.php */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
430 |
$quick_edit_enabled = apply_filters( 'quick_edit_enabled_for_taxonomy', true, $taxonomy ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
431 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
432 |
if ( $quick_edit_enabled ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
433 |
$output .= '<div class="hidden" id="inline_' . $qe_data->term_id . '">'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
434 |
$output .= '<div class="name">' . $qe_data->name . '</div>'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
435 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
436 |
/** This filter is documented in wp-admin/edit-tag-form.php */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
437 |
$output .= '<div class="slug">' . apply_filters( 'editable_slug', $qe_data->slug, $qe_data ) . '</div>'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
438 |
$output .= '<div class="parent">' . $qe_data->parent . '</div></div>'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
439 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
440 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
441 |
return $output; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
442 |
} |
0 | 443 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
444 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
445 |
* Gets the name of the default primary column. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
446 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
447 |
* @since 4.3.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
448 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
449 |
* @return string Name of the default primary column, in this case, 'name'. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
450 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
451 |
protected function get_default_primary_column_name() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
452 |
return 'name'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
453 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
454 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
455 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
456 |
* Generates and displays row action links. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
457 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
458 |
* @since 4.3.0 |
19 | 459 |
* @since 5.9.0 Renamed `$tag` to `$item` to match parent class for PHP 8 named parameter support. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
460 |
* |
19 | 461 |
* @param WP_Term $item Tag being acted upon. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
462 |
* @param string $column_name Current column name. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
463 |
* @param string $primary Primary column name. |
16 | 464 |
* @return string Row actions output for terms, or an empty string |
465 |
* if the current column is not the primary column. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
466 |
*/ |
19 | 467 |
protected function handle_row_actions( $item, $column_name, $primary ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
468 |
if ( $primary !== $column_name ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
469 |
return ''; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
470 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
471 |
|
19 | 472 |
// 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
|
473 |
$tag = $item; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
474 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
475 |
$taxonomy = $this->screen->taxonomy; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
476 |
$uri = wp_doing_ajax() ? wp_get_referer() : $_SERVER['REQUEST_URI']; |
0 | 477 |
|
478 |
$actions = array(); |
|
18 | 479 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
480 |
if ( current_user_can( 'edit_term', $tag->term_id ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
481 |
$actions['edit'] = sprintf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
482 |
'<a href="%s" aria-label="%s">%s</a>', |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
483 |
esc_url( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
484 |
add_query_arg( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
485 |
'wp_http_referer', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
486 |
urlencode( wp_unslash( $uri ) ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
487 |
get_edit_term_link( $tag, $taxonomy, $this->screen->post_type ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
488 |
) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
489 |
), |
16 | 490 |
/* translators: %s: Taxonomy term name. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
491 |
esc_attr( sprintf( __( 'Edit “%s”' ), $tag->name ) ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
492 |
__( 'Edit' ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
493 |
); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
494 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
495 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
496 |
* Filters whether Quick Edit should be enabled for the given taxonomy. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
497 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
498 |
* @since 6.4.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
499 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
500 |
* @param bool $enable Whether to enable the Quick Edit functionality. Default true. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
501 |
* @param string $taxonomy Taxonomy name. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
502 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
503 |
$quick_edit_enabled = apply_filters( 'quick_edit_enabled_for_taxonomy', true, $taxonomy ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
504 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
505 |
if ( $quick_edit_enabled ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
506 |
$actions['inline hide-if-no-js'] = sprintf( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
507 |
'<button type="button" class="button-link editinline" aria-label="%s" aria-expanded="false">%s</button>', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
508 |
/* translators: %s: Taxonomy term name. */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
509 |
esc_attr( sprintf( __( 'Quick edit “%s” inline' ), $tag->name ) ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
510 |
__( 'Quick Edit' ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
511 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
512 |
} |
0 | 513 |
} |
18 | 514 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
515 |
if ( current_user_can( 'delete_term', $tag->term_id ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
516 |
$actions['delete'] = sprintf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
517 |
'<a href="%s" class="delete-tag aria-button-if-js" aria-label="%s">%s</a>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
518 |
wp_nonce_url( "edit-tags.php?action=delete&taxonomy=$taxonomy&tag_ID=$tag->term_id", 'delete-tag_' . $tag->term_id ), |
16 | 519 |
/* translators: %s: Taxonomy term name. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
520 |
esc_attr( sprintf( __( 'Delete “%s”' ), $tag->name ) ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
521 |
__( 'Delete' ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
522 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
523 |
} |
18 | 524 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
525 |
if ( is_term_publicly_viewable( $tag ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
526 |
$actions['view'] = sprintf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
527 |
'<a href="%s" aria-label="%s">%s</a>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
528 |
get_term_link( $tag ), |
16 | 529 |
/* translators: %s: Taxonomy term name. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
530 |
esc_attr( sprintf( __( 'View “%s” archive' ), $tag->name ) ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
531 |
__( 'View' ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
532 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
533 |
} |
0 | 534 |
|
5 | 535 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
536 |
* Filters the action links displayed for each term in the Tags list table. |
5 | 537 |
* |
538 |
* @since 2.8.0 |
|
16 | 539 |
* @since 3.0.0 Deprecated in favor of {@see '{$taxonomy}_row_actions'} filter. |
540 |
* @since 5.4.2 Restored (un-deprecated). |
|
5 | 541 |
* |
9 | 542 |
* @param string[] $actions An array of action links to be displayed. Default |
543 |
* 'Edit', 'Quick Edit', 'Delete', and 'View'. |
|
544 |
* @param WP_Term $tag Term object. |
|
5 | 545 |
*/ |
0 | 546 |
$actions = apply_filters( 'tag_row_actions', $actions, $tag ); |
5 | 547 |
|
548 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
549 |
* Filters the action links displayed for each term in the terms list table. |
5 | 550 |
* |
551 |
* The dynamic portion of the hook name, `$taxonomy`, refers to the taxonomy slug. |
|
552 |
* |
|
18 | 553 |
* Possible hook names include: |
554 |
* |
|
555 |
* - `category_row_actions` |
|
556 |
* - `post_tag_row_actions` |
|
557 |
* |
|
5 | 558 |
* @since 3.0.0 |
559 |
* |
|
9 | 560 |
* @param string[] $actions An array of action links to be displayed. Default |
561 |
* 'Edit', 'Quick Edit', 'Delete', and 'View'. |
|
562 |
* @param WP_Term $tag Term object. |
|
5 | 563 |
*/ |
0 | 564 |
$actions = apply_filters( "{$taxonomy}_row_actions", $actions, $tag ); |
565 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
566 |
return $this->row_actions( $actions ); |
0 | 567 |
} |
568 |
||
5 | 569 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
570 |
* @param WP_Term $tag Term object. |
5 | 571 |
* @return string |
572 |
*/ |
|
573 |
public function column_description( $tag ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
574 |
if ( $tag->description ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
575 |
return $tag->description; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
576 |
} else { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
577 |
return '<span aria-hidden="true">—</span><span class="screen-reader-text">' . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
578 |
/* translators: Hidden accessibility text. */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
579 |
__( 'No description' ) . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
580 |
'</span>'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
581 |
} |
0 | 582 |
} |
583 |
||
5 | 584 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
585 |
* @param WP_Term $tag Term object. |
5 | 586 |
* @return string |
587 |
*/ |
|
588 |
public function column_slug( $tag ) { |
|
589 |
/** This filter is documented in wp-admin/edit-tag-form.php */ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
590 |
return apply_filters( 'editable_slug', $tag->slug, $tag ); |
0 | 591 |
} |
592 |
||
5 | 593 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
594 |
* @param WP_Term $tag Term object. |
5 | 595 |
* @return string |
596 |
*/ |
|
597 |
public function column_posts( $tag ) { |
|
0 | 598 |
$count = number_format_i18n( $tag->count ); |
599 |
||
600 |
$tax = get_taxonomy( $this->screen->taxonomy ); |
|
601 |
||
602 |
$ptype_object = get_post_type_object( $this->screen->post_type ); |
|
9 | 603 |
if ( ! $ptype_object->show_ui ) { |
0 | 604 |
return $count; |
9 | 605 |
} |
0 | 606 |
|
607 |
if ( $tax->query_var ) { |
|
608 |
$args = array( $tax->query_var => $tag->slug ); |
|
609 |
} else { |
|
9 | 610 |
$args = array( |
611 |
'taxonomy' => $tax->name, |
|
612 |
'term' => $tag->slug, |
|
613 |
); |
|
0 | 614 |
} |
615 |
||
16 | 616 |
if ( 'post' !== $this->screen->post_type ) { |
0 | 617 |
$args['post_type'] = $this->screen->post_type; |
9 | 618 |
} |
0 | 619 |
|
9 | 620 |
if ( 'attachment' === $this->screen->post_type ) { |
621 |
return "<a href='" . esc_url( add_query_arg( $args, 'upload.php' ) ) . "'>$count</a>"; |
|
622 |
} |
|
0 | 623 |
|
9 | 624 |
return "<a href='" . esc_url( add_query_arg( $args, 'edit.php' ) ) . "'>$count</a>"; |
0 | 625 |
} |
626 |
||
5 | 627 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
628 |
* @param WP_Term $tag Term object. |
5 | 629 |
* @return string |
630 |
*/ |
|
631 |
public function column_links( $tag ) { |
|
0 | 632 |
$count = number_format_i18n( $tag->count ); |
18 | 633 |
|
9 | 634 |
if ( $count ) { |
0 | 635 |
$count = "<a href='link-manager.php?cat_id=$tag->term_id'>$count</a>"; |
9 | 636 |
} |
18 | 637 |
|
0 | 638 |
return $count; |
639 |
} |
|
640 |
||
5 | 641 |
/** |
19 | 642 |
* @since 5.9.0 Renamed `$tag` to `$item` to match parent class for PHP 8 named parameter support. |
643 |
* |
|
644 |
* @param WP_Term $item Term object. |
|
16 | 645 |
* @param string $column_name Name of the column. |
5 | 646 |
* @return string |
647 |
*/ |
|
19 | 648 |
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
|
649 |
// 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
|
650 |
$tag = $item; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
651 |
|
5 | 652 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
653 |
* Filters the displayed columns in the terms list table. |
5 | 654 |
* |
655 |
* The dynamic portion of the hook name, `$this->screen->taxonomy`, |
|
656 |
* refers to the slug of the current taxonomy. |
|
657 |
* |
|
18 | 658 |
* Possible hook names include: |
659 |
* |
|
660 |
* - `manage_category_custom_column` |
|
661 |
* - `manage_post_tag_custom_column` |
|
662 |
* |
|
5 | 663 |
* @since 2.8.0 |
664 |
* |
|
19 | 665 |
* @param string $string Custom column output. Default empty. |
5 | 666 |
* @param string $column_name Name of the column. |
667 |
* @param int $term_id Term ID. |
|
668 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
669 |
return apply_filters( "manage_{$this->screen->taxonomy}_custom_column", '', $column_name, $tag->term_id ); |
0 | 670 |
} |
671 |
||
672 |
/** |
|
673 |
* Outputs the hidden row displayed when inline editing |
|
674 |
* |
|
675 |
* @since 3.1.0 |
|
676 |
*/ |
|
5 | 677 |
public function inline_edit() { |
0 | 678 |
$tax = get_taxonomy( $this->screen->taxonomy ); |
679 |
||
9 | 680 |
if ( ! current_user_can( $tax->cap->edit_terms ) ) { |
0 | 681 |
return; |
9 | 682 |
} |
683 |
?> |
|
0 | 684 |
|
16 | 685 |
<form method="get"> |
686 |
<table style="display: none"><tbody id="inlineedit"> |
|
687 |
||
688 |
<tr id="inline-edit" class="inline-edit-row" style="display: none"> |
|
689 |
<td colspan="<?php echo $this->get_column_count(); ?>" class="colspanchange"> |
|
19 | 690 |
<div class="inline-edit-wrapper"> |
0 | 691 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
692 |
<fieldset> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
693 |
<legend class="inline-edit-legend"><?php _e( 'Quick Edit' ); ?></legend> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
694 |
<div class="inline-edit-col"> |
0 | 695 |
<label> |
696 |
<span class="title"><?php _ex( 'Name', 'term name' ); ?></span> |
|
697 |
<span class="input-text-wrap"><input type="text" name="name" class="ptitle" value="" /></span> |
|
698 |
</label> |
|
16 | 699 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
700 |
<label> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
701 |
<span class="title"><?php _e( 'Slug' ); ?></span> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
702 |
<span class="input-text-wrap"><input type="text" name="slug" class="ptitle" value="" /></span> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
703 |
</label> |
16 | 704 |
</div> |
705 |
</fieldset> |
|
0 | 706 |
|
16 | 707 |
<?php |
708 |
$core_columns = array( |
|
709 |
'cb' => true, |
|
710 |
'description' => true, |
|
711 |
'name' => true, |
|
712 |
'slug' => true, |
|
713 |
'posts' => true, |
|
714 |
); |
|
0 | 715 |
|
16 | 716 |
list( $columns ) = $this->get_column_info(); |
0 | 717 |
|
16 | 718 |
foreach ( $columns as $column_name => $column_display_name ) { |
719 |
if ( isset( $core_columns[ $column_name ] ) ) { |
|
720 |
continue; |
|
721 |
} |
|
0 | 722 |
|
16 | 723 |
/** This action is documented in wp-admin/includes/class-wp-posts-list-table.php */ |
724 |
do_action( 'quick_edit_custom_box', $column_name, 'edit-tags', $this->screen->taxonomy ); |
|
725 |
} |
|
726 |
?> |
|
0 | 727 |
|
16 | 728 |
<div class="inline-edit-save submit"> |
19 | 729 |
<button type="button" class="save button button-primary"><?php echo $tax->labels->update_item; ?></button> |
730 |
<button type="button" class="cancel button"><?php _e( 'Cancel' ); ?></button> |
|
16 | 731 |
<span class="spinner"></span> |
0 | 732 |
|
16 | 733 |
<?php wp_nonce_field( 'taxinlineeditnonce', '_inline_edit', false ); ?> |
734 |
<input type="hidden" name="taxonomy" value="<?php echo esc_attr( $this->screen->taxonomy ); ?>" /> |
|
735 |
<input type="hidden" name="post_type" value="<?php echo esc_attr( $this->screen->post_type ); ?>" /> |
|
736 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
737 |
<?php |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
738 |
wp_admin_notice( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
739 |
'<p class="error"></p>', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
740 |
array( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
741 |
'type' => 'error', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
742 |
'additional_classes' => array( 'notice-alt', 'inline', 'hidden' ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
743 |
'paragraph_wrap' => false, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
744 |
) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
745 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
746 |
?> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
747 |
</div> |
19 | 748 |
</div> |
16 | 749 |
|
750 |
</td></tr> |
|
751 |
||
752 |
</tbody></table> |
|
753 |
</form> |
|
9 | 754 |
<?php |
0 | 755 |
} |
756 |
} |