Changeset 21788
- Timestamp:
- 09/08/2012 03:18:36 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/class-wp-posts-list-table.php
r21743 r21788 270 270 $posts_columns['author'] = __( 'Author' ); 271 271 272 if ( empty( $post_type ) || is_object_in_taxonomy( $post_type, 'category' ) ) 273 $posts_columns['categories'] = __( 'Categories' ); 274 275 if ( empty( $post_type ) || is_object_in_taxonomy( $post_type, 'post_tag' ) ) 276 $posts_columns['tags'] = __( 'Tags' ); 272 $taxonomies = array(); 273 274 $taxonomies = get_object_taxonomies( $post_type, 'objects' ); 275 $taxonomies = wp_filter_object_list( $taxonomies, array( 'show_admin_column' => true ), 'and', 'name' ); 276 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 } 277 290 278 291 $post_status = !empty( $_REQUEST['post_status'] ) ? $_REQUEST['post_status'] : 'all'; … … 603 616 break; 604 617 605 case 'categories':606 ?>607 <td <?php echo $attributes ?>><?php608 $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 <?php624 break;625 626 case 'tags':627 ?>628 <td <?php echo $attributes ?>><?php629 $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 <?php645 break;646 647 618 case 'comments': 648 619 ?> … … 669 640 670 641 default: 642 if ( 'categories' == $column_name ) 643 $taxonomy = 'category'; 644 elseif ( 'tags' == $column_name ) 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 } 671 681 ?> 672 682 <td <?php echo $attributes ?>><?php … … 679 689 <?php 680 690 break; 681 }682 }691 } 692 } 683 693 ?> 684 694 </tr> -
trunk/wp-includes/taxonomy.php
r21766 r21788 48 48 'public' => true, 49 49 'show_ui' => true, 50 'show_admin_column' => true, 50 51 '_builtin' => true, 51 52 ) ); … … 57 58 'public' => true, 58 59 'show_ui' => true, 60 'show_admin_column' => true, 59 61 '_builtin' => true, 60 62 ) );
Note: See TracChangeset
for help on using the changeset viewer.