| | 277 | $taxonomies = apply_filters( "manage_taxonomies_for_{$post_type}_columns", $taxonomies, $post_type ); |
| | 278 | $taxonomies = array_filter( $taxonomies, 'taxonomy_exists' ); |
| | 279 | |
| | 280 | foreach ( $taxonomies as $taxonomy ) { |
| | 281 | if ( 'category' == $taxonomy ) |
| | 282 | $column_key = 'categories'; |
| | 283 | elseif ( 'post_tag' == $taxonomy ) |
| | 284 | $column_key = 'tags'; |
| | 285 | else |
| | 286 | $column_key = 'taxonomy-' . $taxonomy; |
| | 287 | |
| | 288 | $posts_columns[ $column_key ] = get_taxonomy( $taxonomy )->labels->name; |
| | 289 | } |
| | 290 | |
| 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 | | |
| | 642 | if ( $column_name == 'categories' ) |
| | 643 | $taxonomy = 'category'; |
| | 644 | elseif ( $column_name == 'tags' ) |
| | 645 | $taxonomy = 'post_tag'; |
| | 646 | elseif ( 0 === strpos( $column_name, 'taxonomy-' ) ) |
| | 647 | $taxonomy = substr( $column_name, 9 ); |
| | 648 | |
| | 649 | if ( ! empty( $taxonomy ) ) { |
| | 650 | $taxonomy_object = get_taxonomy( $taxonomy ); |
| | 651 | echo '<td ' . $attributes . '>'; |
| | 652 | if ( $terms = get_the_terms( $post->ID, $taxonomy ) ) { |
| | 653 | $out = array(); |
| | 654 | foreach ( $terms as $t ) { |
| | 655 | $posts_in_term_qv = array(); |
| | 656 | if ( 'post' != $post->post_type ) |
| | 657 | $posts_in_term_qv['post_type'] = $post->post_type; |
| | 658 | if ( $taxonomy_object->query_var ) { |
| | 659 | $posts_in_term_qv[ $taxonomy_object->query_var ] = $t->slug; |
| | 660 | } else { |
| | 661 | $posts_in_term_qv['taxonomy'] = $taxonomy; |
| | 662 | $posts_in_term_qv['term'] = $t->slug; |
| | 663 | } |
| | 664 | |
| | 665 | $out[] = sprintf( '<a href="%s">%s</a>', |
| | 666 | esc_url( add_query_arg( $posts_in_term_qv, 'edit.php' ) ), |
| | 667 | esc_html( sanitize_term_field( 'name', $t->name, $t->term_id, $taxonomy, 'display' ) ) |
| | 668 | ); |
| | 669 | } |
| | 670 | /* translators: used between list items, there is a space after the comma */ |
| | 671 | echo join( __( ', ' ), $out ); |
| | 672 | } else { |
| | 673 | if ( 'category' == $taxonomy ) |
| | 674 | echo __( 'Uncategorized' ); |
| | 675 | else |
| | 676 | echo '—'; |
| | 677 | } |
| | 678 | echo '</td>'; |
| | 679 | break; |
| | 680 | } |