| 277 | if ( is_object_in_taxonomy( $post_type, 'post_tag' ) ) |
| 278 | $taxonomies[] = 'post_tag'; |
| 279 | |
| 280 | $taxonomies = apply_filters( "manage_taxonomies_for_{$post_type}_columns", $taxonomies, $post_type ); |
| 281 | $taxonomies = array_filter( $taxonomies, 'taxonomy_exists' ); |
| 282 | |
| 283 | foreach ( $taxonomies as $taxonomy ) { |
| 284 | if ( 'category' == $taxonomy ) |
| 285 | $column_key = 'categories'; |
| 286 | elseif ( 'post_tag' == $taxonomy ) |
| 287 | $column_key = 'tags'; |
| 288 | else |
| 289 | $column_key = 'taxonomy-' . $taxonomy; |
| 290 | |
| 291 | $posts_columns[ $column_key ] = get_taxonomy( $taxonomy )->labels->name; |
| 292 | } |
| 293 | |
605 | | case 'categories': |
606 | | ?> |
607 | | <td <?php echo $attributes ?>><?php |
608 | | $categories = get_the_category(); |
609 | | if ( !empty( $categories ) ) { |
610 | | $out = array(); |
611 | | foreach ( $categories as $c ) { |
612 | | $out[] = sprintf( '<a href="%s">%s</a>', |
613 | | esc_url( add_query_arg( array( 'post_type' => $post->post_type, 'category_name' => $c->slug ), 'edit.php' ) ), |
614 | | esc_html( sanitize_term_field( 'name', $c->name, $c->term_id, 'category', 'display' ) ) |
615 | | ); |
616 | | } |
617 | | /* translators: used between list items, there is a space after the comma */ |
618 | | echo join( __( ', ' ), $out ); |
619 | | } else { |
620 | | _e( 'Uncategorized' ); |
621 | | } |
622 | | ?></td> |
623 | | <?php |
624 | | break; |
625 | | |
626 | | case 'tags': |
627 | | ?> |
628 | | <td <?php echo $attributes ?>><?php |
629 | | $tags = get_the_tags( $post->ID ); |
630 | | if ( !empty( $tags ) ) { |
631 | | $out = array(); |
632 | | foreach ( $tags as $c ) { |
633 | | $out[] = sprintf( '<a href="%s">%s</a>', |
634 | | esc_url( add_query_arg( array( 'post_type' => $post->post_type, 'tag' => $c->slug ), 'edit.php' ) ), |
635 | | esc_html( sanitize_term_field( 'name', $c->name, $c->term_id, 'tag', 'display' ) ) |
636 | | ); |
637 | | } |
638 | | /* translators: used between list items, there is a space after the comma */ |
639 | | echo join( __( ', ' ), $out ); |
640 | | } else { |
641 | | _e( 'No Tags' ); |
642 | | } |
643 | | ?></td> |
644 | | <?php |
645 | | break; |
646 | | |
| 645 | if ( $column_name == 'categories' ) |
| 646 | $taxonomy = 'category'; |
| 647 | elseif ( $column_name == 'tags' ) |
| 648 | $taxonomy = 'post_tag'; |
| 649 | elseif ( 0 === strpos( $column_name, 'taxonomy-' ) ) |
| 650 | $taxonomy = substr( $column_name, 9 ); |
| 651 | |
| 652 | if ( ! empty( $taxonomy ) ) { |
| 653 | $taxonomy_object = get_taxonomy( $taxonomy ); |
| 654 | echo '<td ' . $attributes . '>'; |
| 655 | if ( $terms = get_the_terms( $post->ID, $taxonomy ) ) { |
| 656 | $out = array(); |
| 657 | foreach ( $terms as $t ) { |
| 658 | $posts_in_term_qv = array(); |
| 659 | if ( 'post' != $post->post_type ) |
| 660 | $posts_in_term_qv['post_type'] = $post->post_type; |
| 661 | if ( $taxonomy_object->query_var ) { |
| 662 | $posts_in_term_qv[ $taxonomy_object->query_var ] = $t->slug; |
| 663 | } else { |
| 664 | $posts_in_term_qv['taxonomy'] = $taxonomy; |
| 665 | $posts_in_term_qv['term'] = $t->slug; |
| 666 | } |
| 667 | |
| 668 | $out[] = sprintf( '<a href="%s">%s</a>', |
| 669 | esc_url( add_query_arg( $posts_in_term_qv, 'edit.php' ) ), |
| 670 | esc_html( sanitize_term_field( 'name', $t->name, $t->term_id, $taxonomy, 'display' ) ) |
| 671 | ); |
| 672 | } |
| 673 | /* translators: used between list items, there is a space after the comma */ |
| 674 | echo join( __( ', ' ), $out ); |
| 675 | } else { |
| 676 | if ( 'category' == $taxonomy ) |
| 677 | echo __( 'Uncategorized' ); |
| 678 | else |
| 679 | echo '—'; |
| 680 | } |
| 681 | echo '</td>'; |
| 682 | break; |
| 683 | } |