207 |
205 |
208 /** |
206 /** |
209 * @return array |
207 * @return array |
210 */ |
208 */ |
211 protected function get_sortable_columns() { |
209 protected function get_sortable_columns() { |
|
210 $taxonomy = $this->screen->taxonomy; |
|
211 |
|
212 if ( ! isset( $_GET['orderby'] ) && is_taxonomy_hierarchical( $taxonomy ) ) { |
|
213 $name_orderby_text = __( 'Table ordered hierarchically.' ); |
|
214 } else { |
|
215 $name_orderby_text = __( 'Table ordered by Name.' ); |
|
216 } |
|
217 |
212 return array( |
218 return array( |
213 'name' => 'name', |
219 'name' => array( 'name', false, _x( 'Name', 'term name' ), $name_orderby_text, 'asc' ), |
214 'description' => 'description', |
220 'description' => array( 'description', false, __( 'Description' ), __( 'Table ordered by Description.' ) ), |
215 'slug' => 'slug', |
221 'slug' => array( 'slug', false, __( 'Slug' ), __( 'Table ordered by Slug.' ) ), |
216 'posts' => 'count', |
222 'posts' => array( 'count', false, _x( 'Count', 'Number/count of items' ), __( 'Table ordered by Posts Count.' ) ), |
217 'links' => 'count', |
223 'links' => array( 'count', false, __( 'Links' ), __( 'Table ordered by Links.' ) ), |
218 ); |
224 ); |
219 } |
225 } |
220 |
226 |
221 /** |
227 /** |
222 */ |
228 */ |
356 // Restores the more descriptive, specific name for use within this method. |
363 // Restores the more descriptive, specific name for use within this method. |
357 $tag = $item; |
364 $tag = $item; |
358 |
365 |
359 if ( current_user_can( 'delete_term', $tag->term_id ) ) { |
366 if ( current_user_can( 'delete_term', $tag->term_id ) ) { |
360 return sprintf( |
367 return sprintf( |
361 '<label class="screen-reader-text" for="cb-select-%1$s">%2$s</label>' . |
368 '<input type="checkbox" name="delete_tags[]" value="%1$s" id="cb-select-%1$s" />' . |
362 '<input type="checkbox" name="delete_tags[]" value="%1$s" id="cb-select-%1$s" />', |
369 '<label for="cb-select-%1$s"><span class="screen-reader-text">%2$s</span></label>', |
363 $tag->term_id, |
370 $tag->term_id, |
364 /* translators: %s: Taxonomy term name. */ |
371 /* translators: Hidden accessibility text. %s: Taxonomy term name. */ |
365 sprintf( __( 'Select %s' ), $tag->name ) |
372 sprintf( __( 'Select %s' ), $tag->name ) |
366 ); |
373 ); |
367 } |
374 } |
368 |
375 |
369 return ' '; |
376 return ' '; |
412 esc_attr( sprintf( __( '“%s” (Edit)' ), $tag->name ) ), |
419 esc_attr( sprintf( __( '“%s” (Edit)' ), $tag->name ) ), |
413 $name |
420 $name |
414 ); |
421 ); |
415 } |
422 } |
416 |
423 |
417 $out = sprintf( |
424 $output = sprintf( |
418 '<strong>%s</strong><br />', |
425 '<strong>%s</strong><br />', |
419 $name |
426 $name |
420 ); |
427 ); |
421 |
428 |
422 $out .= '<div class="hidden" id="inline_' . $qe_data->term_id . '">'; |
429 /** This filter is documented in wp-admin/includes/class-wp-terms-list-table.php */ |
423 $out .= '<div class="name">' . $qe_data->name . '</div>'; |
430 $quick_edit_enabled = apply_filters( 'quick_edit_enabled_for_taxonomy', true, $taxonomy ); |
424 |
431 |
425 /** This filter is documented in wp-admin/edit-tag-form.php */ |
432 if ( $quick_edit_enabled ) { |
426 $out .= '<div class="slug">' . apply_filters( 'editable_slug', $qe_data->slug, $qe_data ) . '</div>'; |
433 $output .= '<div class="hidden" id="inline_' . $qe_data->term_id . '">'; |
427 $out .= '<div class="parent">' . $qe_data->parent . '</div></div>'; |
434 $output .= '<div class="name">' . $qe_data->name . '</div>'; |
428 |
435 |
429 return $out; |
436 /** This filter is documented in wp-admin/edit-tag-form.php */ |
|
437 $output .= '<div class="slug">' . apply_filters( 'editable_slug', $qe_data->slug, $qe_data ) . '</div>'; |
|
438 $output .= '<div class="parent">' . $qe_data->parent . '</div></div>'; |
|
439 } |
|
440 |
|
441 return $output; |
430 } |
442 } |
431 |
443 |
432 /** |
444 /** |
433 * Gets the name of the default primary column. |
445 * Gets the name of the default primary column. |
434 * |
446 * |
456 if ( $primary !== $column_name ) { |
468 if ( $primary !== $column_name ) { |
457 return ''; |
469 return ''; |
458 } |
470 } |
459 |
471 |
460 // Restores the more descriptive, specific name for use within this method. |
472 // Restores the more descriptive, specific name for use within this method. |
461 $tag = $item; |
473 $tag = $item; |
|
474 |
462 $taxonomy = $this->screen->taxonomy; |
475 $taxonomy = $this->screen->taxonomy; |
463 $tax = get_taxonomy( $taxonomy ); |
|
464 $uri = wp_doing_ajax() ? wp_get_referer() : $_SERVER['REQUEST_URI']; |
476 $uri = wp_doing_ajax() ? wp_get_referer() : $_SERVER['REQUEST_URI']; |
465 |
|
466 $edit_link = add_query_arg( |
|
467 'wp_http_referer', |
|
468 urlencode( wp_unslash( $uri ) ), |
|
469 get_edit_term_link( $tag, $taxonomy, $this->screen->post_type ) |
|
470 ); |
|
471 |
477 |
472 $actions = array(); |
478 $actions = array(); |
473 |
479 |
474 if ( current_user_can( 'edit_term', $tag->term_id ) ) { |
480 if ( current_user_can( 'edit_term', $tag->term_id ) ) { |
475 $actions['edit'] = sprintf( |
481 $actions['edit'] = sprintf( |
476 '<a href="%s" aria-label="%s">%s</a>', |
482 '<a href="%s" aria-label="%s">%s</a>', |
477 esc_url( $edit_link ), |
483 esc_url( |
|
484 add_query_arg( |
|
485 'wp_http_referer', |
|
486 urlencode( wp_unslash( $uri ) ), |
|
487 get_edit_term_link( $tag, $taxonomy, $this->screen->post_type ) |
|
488 ) |
|
489 ), |
478 /* translators: %s: Taxonomy term name. */ |
490 /* translators: %s: Taxonomy term name. */ |
479 esc_attr( sprintf( __( 'Edit “%s”' ), $tag->name ) ), |
491 esc_attr( sprintf( __( 'Edit “%s”' ), $tag->name ) ), |
480 __( 'Edit' ) |
492 __( 'Edit' ) |
481 ); |
493 ); |
482 $actions['inline hide-if-no-js'] = sprintf( |
494 |
483 '<button type="button" class="button-link editinline" aria-label="%s" aria-expanded="false">%s</button>', |
495 /** |
484 /* translators: %s: Taxonomy term name. */ |
496 * Filters whether Quick Edit should be enabled for the given taxonomy. |
485 esc_attr( sprintf( __( 'Quick edit “%s” inline' ), $tag->name ) ), |
497 * |
486 __( 'Quick Edit' ) |
498 * @since 6.4.0 |
487 ); |
499 * |
|
500 * @param bool $enable Whether to enable the Quick Edit functionality. Default true. |
|
501 * @param string $taxonomy Taxonomy name. |
|
502 */ |
|
503 $quick_edit_enabled = apply_filters( 'quick_edit_enabled_for_taxonomy', true, $taxonomy ); |
|
504 |
|
505 if ( $quick_edit_enabled ) { |
|
506 $actions['inline hide-if-no-js'] = sprintf( |
|
507 '<button type="button" class="button-link editinline" aria-label="%s" aria-expanded="false">%s</button>', |
|
508 /* translators: %s: Taxonomy term name. */ |
|
509 esc_attr( sprintf( __( 'Quick edit “%s” inline' ), $tag->name ) ), |
|
510 __( 'Quick Edit' ) |
|
511 ); |
|
512 } |
488 } |
513 } |
489 |
514 |
490 if ( current_user_can( 'delete_term', $tag->term_id ) ) { |
515 if ( current_user_can( 'delete_term', $tag->term_id ) ) { |
491 $actions['delete'] = sprintf( |
516 $actions['delete'] = sprintf( |
492 '<a href="%s" class="delete-tag aria-button-if-js" aria-label="%s">%s</a>', |
517 '<a href="%s" class="delete-tag aria-button-if-js" aria-label="%s">%s</a>', |
495 esc_attr( sprintf( __( 'Delete “%s”' ), $tag->name ) ), |
520 esc_attr( sprintf( __( 'Delete “%s”' ), $tag->name ) ), |
496 __( 'Delete' ) |
521 __( 'Delete' ) |
497 ); |
522 ); |
498 } |
523 } |
499 |
524 |
500 if ( is_taxonomy_viewable( $tax ) ) { |
525 if ( is_term_publicly_viewable( $tag ) ) { |
501 $actions['view'] = sprintf( |
526 $actions['view'] = sprintf( |
502 '<a href="%s" aria-label="%s">%s</a>', |
527 '<a href="%s" aria-label="%s">%s</a>', |
503 get_term_link( $tag ), |
528 get_term_link( $tag ), |
504 /* translators: %s: Taxonomy term name. */ |
529 /* translators: %s: Taxonomy term name. */ |
505 esc_attr( sprintf( __( 'View “%s” archive' ), $tag->name ) ), |
530 esc_attr( sprintf( __( 'View “%s” archive' ), $tag->name ) ), |
616 * @param WP_Term $item Term object. |
644 * @param WP_Term $item Term object. |
617 * @param string $column_name Name of the column. |
645 * @param string $column_name Name of the column. |
618 * @return string |
646 * @return string |
619 */ |
647 */ |
620 public function column_default( $item, $column_name ) { |
648 public function column_default( $item, $column_name ) { |
|
649 // Restores the more descriptive, specific name for use within this method. |
|
650 $tag = $item; |
|
651 |
621 /** |
652 /** |
622 * Filters the displayed columns in the terms list table. |
653 * Filters the displayed columns in the terms list table. |
623 * |
654 * |
624 * The dynamic portion of the hook name, `$this->screen->taxonomy`, |
655 * The dynamic portion of the hook name, `$this->screen->taxonomy`, |
625 * refers to the slug of the current taxonomy. |
656 * refers to the slug of the current taxonomy. |
633 * |
664 * |
634 * @param string $string Custom column output. Default empty. |
665 * @param string $string Custom column output. Default empty. |
635 * @param string $column_name Name of the column. |
666 * @param string $column_name Name of the column. |
636 * @param int $term_id Term ID. |
667 * @param int $term_id Term ID. |
637 */ |
668 */ |
638 return apply_filters( "manage_{$this->screen->taxonomy}_custom_column", '', $column_name, $item->term_id ); |
669 return apply_filters( "manage_{$this->screen->taxonomy}_custom_column", '', $column_name, $tag->term_id ); |
639 } |
670 } |
640 |
671 |
641 /** |
672 /** |
642 * Outputs the hidden row displayed when inline editing |
673 * Outputs the hidden row displayed when inline editing |
643 * |
674 * |
664 <label> |
695 <label> |
665 <span class="title"><?php _ex( 'Name', 'term name' ); ?></span> |
696 <span class="title"><?php _ex( 'Name', 'term name' ); ?></span> |
666 <span class="input-text-wrap"><input type="text" name="name" class="ptitle" value="" /></span> |
697 <span class="input-text-wrap"><input type="text" name="name" class="ptitle" value="" /></span> |
667 </label> |
698 </label> |
668 |
699 |
669 <?php if ( ! global_terms_enabled() ) : ?> |
700 <label> |
670 <label> |
701 <span class="title"><?php _e( 'Slug' ); ?></span> |
671 <span class="title"><?php _e( 'Slug' ); ?></span> |
702 <span class="input-text-wrap"><input type="text" name="slug" class="ptitle" value="" /></span> |
672 <span class="input-text-wrap"><input type="text" name="slug" class="ptitle" value="" /></span> |
703 </label> |
673 </label> |
|
674 <?php endif; ?> |
|
675 </div> |
704 </div> |
676 </fieldset> |
705 </fieldset> |
677 |
706 |
678 <?php |
707 <?php |
679 $core_columns = array( |
708 $core_columns = array( |
703 |
732 |
704 <?php wp_nonce_field( 'taxinlineeditnonce', '_inline_edit', false ); ?> |
733 <?php wp_nonce_field( 'taxinlineeditnonce', '_inline_edit', false ); ?> |
705 <input type="hidden" name="taxonomy" value="<?php echo esc_attr( $this->screen->taxonomy ); ?>" /> |
734 <input type="hidden" name="taxonomy" value="<?php echo esc_attr( $this->screen->taxonomy ); ?>" /> |
706 <input type="hidden" name="post_type" value="<?php echo esc_attr( $this->screen->post_type ); ?>" /> |
735 <input type="hidden" name="post_type" value="<?php echo esc_attr( $this->screen->post_type ); ?>" /> |
707 |
736 |
708 <div class="notice notice-error notice-alt inline hidden"> |
737 <?php |
709 <p class="error"></p> |
738 wp_admin_notice( |
710 </div> |
739 '<p class="error"></p>', |
|
740 array( |
|
741 'type' => 'error', |
|
742 'additional_classes' => array( 'notice-alt', 'inline', 'hidden' ), |
|
743 'paragraph_wrap' => false, |
|
744 ) |
|
745 ); |
|
746 ?> |
711 </div> |
747 </div> |
712 </div> |
748 </div> |
713 |
749 |
714 </td></tr> |
750 </td></tr> |
715 |
751 |