224 $page = $args['page']; |
225 $page = $args['page']; |
225 |
226 |
226 // Set variable because $args['number'] can be subsequently overridden. |
227 // Set variable because $args['number'] can be subsequently overridden. |
227 $number = $args['number']; |
228 $number = $args['number']; |
228 |
229 |
229 $args['offset'] = $offset = ( $page - 1 ) * $number; |
230 $offset = ( $page - 1 ) * $number; |
|
231 $args['offset'] = $offset; |
230 |
232 |
231 // Convert it to table rows. |
233 // Convert it to table rows. |
232 $count = 0; |
234 $count = 0; |
233 |
235 |
234 if ( is_taxonomy_hierarchical( $taxonomy ) && ! isset( $args['orderby'] ) ) { |
236 if ( is_taxonomy_hierarchical( $taxonomy ) && ! isset( $args['orderby'] ) ) { |
235 // We'll need the full set of terms then. |
237 // We'll need the full set of terms then. |
236 $args['number'] = $args['offset'] = 0; |
238 $args['number'] = 0; |
237 } |
239 $args['offset'] = $args['number']; |
238 $terms = get_terms( $taxonomy, $args ); |
240 } |
|
241 |
|
242 $terms = get_terms( $args ); |
239 |
243 |
240 if ( empty( $terms ) || ! is_array( $terms ) ) { |
244 if ( empty( $terms ) || ! is_array( $terms ) ) { |
241 echo '<tr class="no-items"><td class="colspanchange" colspan="' . $this->get_column_count() . '">'; |
245 echo '<tr class="no-items"><td class="colspanchange" colspan="' . $this->get_column_count() . '">'; |
242 $this->no_items(); |
246 $this->no_items(); |
243 echo '</td></tr>'; |
247 echo '</td></tr>'; |
248 if ( ! empty( $args['search'] ) ) {// Ignore children on searches. |
252 if ( ! empty( $args['search'] ) ) {// Ignore children on searches. |
249 $children = array(); |
253 $children = array(); |
250 } else { |
254 } else { |
251 $children = _get_term_hierarchy( $taxonomy ); |
255 $children = _get_term_hierarchy( $taxonomy ); |
252 } |
256 } |
253 // Some funky recursion to get the job done( Paging & parents mainly ) is contained within, Skip it for non-hierarchical taxonomies for performance sake |
257 |
|
258 /* |
|
259 * Some funky recursion to get the job done (paging & parents mainly) is contained within. |
|
260 * Skip it for non-hierarchical taxonomies for performance sake. |
|
261 */ |
254 $this->_rows( $taxonomy, $terms, $children, $offset, $number, $count ); |
262 $this->_rows( $taxonomy, $terms, $children, $offset, $number, $count ); |
255 } else { |
263 } else { |
256 foreach ( $terms as $term ) { |
264 foreach ( $terms as $term ) { |
257 $this->single_row( $term ); |
265 $this->single_row( $term ); |
258 } |
266 } |
259 } |
267 } |
260 } |
268 } |
261 |
269 |
262 /** |
270 /** |
263 * @param string $taxonomy |
271 * @param string $taxonomy |
264 * @param array $terms |
272 * @param array $terms |
265 * @param array $children |
273 * @param array $children |
266 * @param int $start |
274 * @param int $start |
267 * @param int $per_page |
275 * @param int $per_page |
268 * @param int $count |
276 * @param int $count |
269 * @param int $parent |
277 * @param int $parent |
270 * @param int $level |
278 * @param int $level |
271 */ |
279 */ |
272 private function _rows( $taxonomy, $terms, &$children, $start, $per_page, &$count, $parent = 0, $level = 0 ) { |
280 private function _rows( $taxonomy, $terms, &$children, $start, $per_page, &$count, $parent = 0, $level = 0 ) { |
273 |
281 |
274 $end = $start + $per_page; |
282 $end = $start + $per_page; |
275 |
283 |
283 continue; |
291 continue; |
284 } |
292 } |
285 |
293 |
286 // If the page starts in a subtree, print the parents. |
294 // If the page starts in a subtree, print the parents. |
287 if ( $count == $start && $term->parent > 0 && empty( $_REQUEST['s'] ) ) { |
295 if ( $count == $start && $term->parent > 0 && empty( $_REQUEST['s'] ) ) { |
288 $my_parents = $parent_ids = array(); |
296 $my_parents = array(); |
|
297 $parent_ids = array(); |
289 $p = $term->parent; |
298 $p = $term->parent; |
290 while ( $p ) { |
299 while ( $p ) { |
291 $my_parent = get_term( $p, $taxonomy ); |
300 $my_parent = get_term( $p, $taxonomy ); |
292 $my_parents[] = $my_parent; |
301 $my_parents[] = $my_parent; |
293 $p = $my_parent->parent; |
302 $p = $my_parent->parent; |
294 if ( in_array( $p, $parent_ids ) ) { // Prevent parent loops. |
303 if ( in_array( $p, $parent_ids, true ) ) { // Prevent parent loops. |
295 break; |
304 break; |
296 } |
305 } |
297 $parent_ids[] = $p; |
306 $parent_ids[] = $p; |
298 } |
307 } |
299 unset( $parent_ids ); |
308 unset( $parent_ids ); |
456 $actions = array(); |
471 $actions = array(); |
457 if ( current_user_can( 'edit_term', $tag->term_id ) ) { |
472 if ( current_user_can( 'edit_term', $tag->term_id ) ) { |
458 $actions['edit'] = sprintf( |
473 $actions['edit'] = sprintf( |
459 '<a href="%s" aria-label="%s">%s</a>', |
474 '<a href="%s" aria-label="%s">%s</a>', |
460 esc_url( $edit_link ), |
475 esc_url( $edit_link ), |
461 /* translators: %s: taxonomy term name */ |
476 /* translators: %s: Taxonomy term name. */ |
462 esc_attr( sprintf( __( 'Edit “%s”' ), $tag->name ) ), |
477 esc_attr( sprintf( __( 'Edit “%s”' ), $tag->name ) ), |
463 __( 'Edit' ) |
478 __( 'Edit' ) |
464 ); |
479 ); |
465 $actions['inline hide-if-no-js'] = sprintf( |
480 $actions['inline hide-if-no-js'] = sprintf( |
466 '<button type="button" class="button-link editinline" aria-label="%s" aria-expanded="false">%s</button>', |
481 '<button type="button" class="button-link editinline" aria-label="%s" aria-expanded="false">%s</button>', |
467 /* translators: %s: taxonomy term name */ |
482 /* translators: %s: Taxonomy term name. */ |
468 esc_attr( sprintf( __( 'Quick edit “%s” inline' ), $tag->name ) ), |
483 esc_attr( sprintf( __( 'Quick edit “%s” inline' ), $tag->name ) ), |
469 __( 'Quick Edit' ) |
484 __( 'Quick Edit' ) |
470 ); |
485 ); |
471 } |
486 } |
472 if ( current_user_can( 'delete_term', $tag->term_id ) ) { |
487 if ( current_user_can( 'delete_term', $tag->term_id ) ) { |
473 $actions['delete'] = sprintf( |
488 $actions['delete'] = sprintf( |
474 '<a href="%s" class="delete-tag aria-button-if-js" aria-label="%s">%s</a>', |
489 '<a href="%s" class="delete-tag aria-button-if-js" aria-label="%s">%s</a>', |
475 wp_nonce_url( "edit-tags.php?action=delete&taxonomy=$taxonomy&tag_ID=$tag->term_id", 'delete-tag_' . $tag->term_id ), |
490 wp_nonce_url( "edit-tags.php?action=delete&taxonomy=$taxonomy&tag_ID=$tag->term_id", 'delete-tag_' . $tag->term_id ), |
476 /* translators: %s: taxonomy term name */ |
491 /* translators: %s: Taxonomy term name. */ |
477 esc_attr( sprintf( __( 'Delete “%s”' ), $tag->name ) ), |
492 esc_attr( sprintf( __( 'Delete “%s”' ), $tag->name ) ), |
478 __( 'Delete' ) |
493 __( 'Delete' ) |
479 ); |
494 ); |
480 } |
495 } |
481 if ( is_taxonomy_viewable( $tax ) ) { |
496 if ( is_taxonomy_viewable( $tax ) ) { |
482 $actions['view'] = sprintf( |
497 $actions['view'] = sprintf( |
483 '<a href="%s" aria-label="%s">%s</a>', |
498 '<a href="%s" aria-label="%s">%s</a>', |
484 get_term_link( $tag ), |
499 get_term_link( $tag ), |
485 /* translators: %s: taxonomy term name */ |
500 /* translators: %s: Taxonomy term name. */ |
486 esc_attr( sprintf( __( 'View “%s” archive' ), $tag->name ) ), |
501 esc_attr( sprintf( __( 'View “%s” archive' ), $tag->name ) ), |
487 __( 'View' ) |
502 __( 'View' ) |
488 ); |
503 ); |
489 } |
504 } |
490 |
505 |
491 /** |
506 /** |
492 * Filters the action links displayed for each term in the Tags list table. |
507 * Filters the action links displayed for each term in the Tags list table. |
493 * |
508 * |
494 * @since 2.8.0 |
509 * @since 2.8.0 |
495 * @deprecated 3.0.0 Use {$taxonomy}_row_actions instead. |
510 * @since 3.0.0 Deprecated in favor of {@see '{$taxonomy}_row_actions'} filter. |
|
511 * @since 5.4.2 Restored (un-deprecated). |
496 * |
512 * |
497 * @param string[] $actions An array of action links to be displayed. Default |
513 * @param string[] $actions An array of action links to be displayed. Default |
498 * 'Edit', 'Quick Edit', 'Delete', and 'View'. |
514 * 'Edit', 'Quick Edit', 'Delete', and 'View'. |
499 * @param WP_Term $tag Term object. |
515 * @param WP_Term $tag Term object. |
500 */ |
516 */ |
615 if ( ! current_user_can( $tax->cap->edit_terms ) ) { |
631 if ( ! current_user_can( $tax->cap->edit_terms ) ) { |
616 return; |
632 return; |
617 } |
633 } |
618 ?> |
634 ?> |
619 |
635 |
620 <form method="get"><table style="display: none"><tbody id="inlineedit"> |
636 <form method="get"> |
621 <tr id="inline-edit" class="inline-edit-row" style="display: none"><td colspan="<?php echo $this->get_column_count(); ?>" class="colspanchange"> |
637 <table style="display: none"><tbody id="inlineedit"> |
|
638 |
|
639 <tr id="inline-edit" class="inline-edit-row" style="display: none"> |
|
640 <td colspan="<?php echo $this->get_column_count(); ?>" class="colspanchange"> |
622 |
641 |
623 <fieldset> |
642 <fieldset> |
624 <legend class="inline-edit-legend"><?php _e( 'Quick Edit' ); ?></legend> |
643 <legend class="inline-edit-legend"><?php _e( 'Quick Edit' ); ?></legend> |
625 <div class="inline-edit-col"> |
644 <div class="inline-edit-col"> |
626 <label> |
645 <label> |
627 <span class="title"><?php _ex( 'Name', 'term name' ); ?></span> |
646 <span class="title"><?php _ex( 'Name', 'term name' ); ?></span> |
628 <span class="input-text-wrap"><input type="text" name="name" class="ptitle" value="" /></span> |
647 <span class="input-text-wrap"><input type="text" name="name" class="ptitle" value="" /></span> |
629 </label> |
648 </label> |
630 <?php if ( ! global_terms_enabled() ) { ?> |
649 |
631 <label> |
650 <?php if ( ! global_terms_enabled() ) : ?> |
632 <span class="title"><?php _e( 'Slug' ); ?></span> |
651 <label> |
633 <span class="input-text-wrap"><input type="text" name="slug" class="ptitle" value="" /></span> |
652 <span class="title"><?php _e( 'Slug' ); ?></span> |
634 </label> |
653 <span class="input-text-wrap"><input type="text" name="slug" class="ptitle" value="" /></span> |
635 <?php } ?> |
654 </label> |
636 </div></fieldset> |
655 <?php endif; ?> |
|
656 </div> |
|
657 </fieldset> |
|
658 |
|
659 <?php |
|
660 $core_columns = array( |
|
661 'cb' => true, |
|
662 'description' => true, |
|
663 'name' => true, |
|
664 'slug' => true, |
|
665 'posts' => true, |
|
666 ); |
|
667 |
|
668 list( $columns ) = $this->get_column_info(); |
|
669 |
|
670 foreach ( $columns as $column_name => $column_display_name ) { |
|
671 if ( isset( $core_columns[ $column_name ] ) ) { |
|
672 continue; |
|
673 } |
|
674 |
|
675 /** This action is documented in wp-admin/includes/class-wp-posts-list-table.php */ |
|
676 do_action( 'quick_edit_custom_box', $column_name, 'edit-tags', $this->screen->taxonomy ); |
|
677 } |
|
678 ?> |
|
679 |
|
680 <div class="inline-edit-save submit"> |
|
681 <button type="button" class="cancel button alignleft"><?php _e( 'Cancel' ); ?></button> |
|
682 <button type="button" class="save button button-primary alignright"><?php echo $tax->labels->update_item; ?></button> |
|
683 <span class="spinner"></span> |
|
684 |
|
685 <?php wp_nonce_field( 'taxinlineeditnonce', '_inline_edit', false ); ?> |
|
686 <input type="hidden" name="taxonomy" value="<?php echo esc_attr( $this->screen->taxonomy ); ?>" /> |
|
687 <input type="hidden" name="post_type" value="<?php echo esc_attr( $this->screen->post_type ); ?>" /> |
|
688 <br class="clear" /> |
|
689 |
|
690 <div class="notice notice-error notice-alt inline hidden"> |
|
691 <p class="error"></p> |
|
692 </div> |
|
693 </div> |
|
694 |
|
695 </td></tr> |
|
696 |
|
697 </tbody></table> |
|
698 </form> |
637 <?php |
699 <?php |
638 |
|
639 $core_columns = array( |
|
640 'cb' => true, |
|
641 'description' => true, |
|
642 'name' => true, |
|
643 'slug' => true, |
|
644 'posts' => true, |
|
645 ); |
|
646 |
|
647 list( $columns ) = $this->get_column_info(); |
|
648 |
|
649 foreach ( $columns as $column_name => $column_display_name ) { |
|
650 if ( isset( $core_columns[ $column_name ] ) ) { |
|
651 continue; |
|
652 } |
|
653 |
|
654 /** This action is documented in wp-admin/includes/class-wp-posts-list-table.php */ |
|
655 do_action( 'quick_edit_custom_box', $column_name, 'edit-tags', $this->screen->taxonomy ); |
|
656 } |
|
657 |
|
658 ?> |
|
659 |
|
660 <div class="inline-edit-save submit"> |
|
661 <button type="button" class="cancel button alignleft"><?php _e( 'Cancel' ); ?></button> |
|
662 <button type="button" class="save button button-primary alignright"><?php echo $tax->labels->update_item; ?></button> |
|
663 <span class="spinner"></span> |
|
664 <?php wp_nonce_field( 'taxinlineeditnonce', '_inline_edit', false ); ?> |
|
665 <input type="hidden" name="taxonomy" value="<?php echo esc_attr( $this->screen->taxonomy ); ?>" /> |
|
666 <input type="hidden" name="post_type" value="<?php echo esc_attr( $this->screen->post_type ); ?>" /> |
|
667 <br class="clear" /> |
|
668 <div class="notice notice-error notice-alt inline hidden"> |
|
669 <p class="error"></p> |
|
670 </div> |
|
671 </div> |
|
672 </td></tr> |
|
673 </tbody></table></form> |
|
674 <?php |
|
675 } |
700 } |
676 } |
701 } |