Make WordPress Core

Ticket #21240: 21240.7.diff

File 21240.7.diff, 4.8 KB (added by nacin, 13 years ago)
  • wp-admin/includes/class-wp-posts-list-table.php

     
    269269                if ( post_type_supports( $post_type, 'author' ) )
    270270                        $posts_columns['author'] = __( 'Author' );
    271271
    272                 if ( empty( $post_type ) || is_object_in_taxonomy( $post_type, 'category' ) )
    273                         $posts_columns['categories'] = __( 'Categories' );
     272                $taxonomies = array();
    274273
    275                 if ( empty( $post_type ) || is_object_in_taxonomy( $post_type, 'post_tag' ) )
    276                         $posts_columns['tags'] = __( 'Tags' );
     274                if ( is_object_in_taxonomy( $post_type, 'category' ) )
     275                        $taxonomies[] = 'category';
    277276
     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
    278294                $post_status = !empty( $_REQUEST['post_status'] ) ? $_REQUEST['post_status'] : 'all';
    279295                if ( post_type_supports( $post_type, 'comments' ) && !in_array( $post_status, array( 'pending', 'draft', 'future' ) ) )
    280296                        $posts_columns['comments'] = '<span class="vers"><img alt="' . esc_attr__( 'Comments' ) . '" src="' . esc_url( admin_url( 'images/comment-grey-bubble.png' ) ) . '" /></span>';
     
    602618                                echo '</td>';
    603619                        break;
    604620
    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 
    647621                        case 'comments':
    648622                        ?>
    649623                        <td <?php echo $attributes ?>><div class="post-com-count-wrapper">
     
    668642                        break;
    669643
    670644                        default:
     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 '&#8212;';
     680                                        }
     681                                        echo '</td>';
     682                                        break;
     683                                }
    671684                        ?>
    672685                        <td <?php echo $attributes ?>><?php
    673686                                if ( is_post_type_hierarchical( $post->post_type ) )
     
    678691                        ?></td>
    679692                        <?php
    680693                        break;
     694                        }
    681695                }
    682         }
    683696        ?>
    684697                </tr>
    685698        <?php