Index: wp-admin/includes/class-wp-posts-list-table.php
===================================================================
--- wp-admin/includes/class-wp-posts-list-table.php (revision 21372)
+++ wp-admin/includes/class-wp-posts-list-table.php (working copy)
@@ -275,6 +275,28 @@
if ( empty( $post_type ) || is_object_in_taxonomy( $post_type, 'post_tag' ) )
$posts_columns['tags'] = __( 'Tags' );
+ $post_type_object = get_post_type_object( $post_type );
+ $registered_taxonomies = get_object_taxonomies( $post_type );
+
+ if ( $post_type_object->show_taxonomy_columns && is_array( $post_type_object->show_taxonomy_columns ) )
+ $taxonomies = $post_type_object->show_taxonomy_columns;
+ elseif ( $post_type_object->show_taxonomy_columns )
+ $taxonomies = $registered_taxonomies;
+ else
+ $taxonomies = array();
+
+ $taxonomies = array_diff( $taxonomies, array( 'category', 'post_tag' ) );
+ $this->taxonomy_columns = array_merge( array( 'categories', 'tags' ), $taxonomies );
+ $this->taxonomy_columns = apply_filters( 'show_taxonomy_columns', $this->taxonomy_columns, $post_type );
+
+ foreach ( $this->taxonomy_columns as $taxonomy ) {
+ if ( ! in_array( $taxonomy, $registered_taxonomies ) )
+ continue;
+
+ $taxonomy_object = get_taxonomy( $taxonomy );
+ $posts_columns[ $taxonomy ] = $taxonomy_object->labels->name;
+ }
+
$post_status = !empty( $_REQUEST['post_status'] ) ? $_REQUEST['post_status'] : 'all';
if ( post_type_supports( $post_type, 'comments' ) && !in_array( $post_status, array( 'pending', 'draft', 'future' ) ) )
$posts_columns['comments'] = '';
@@ -529,7 +551,7 @@
}
else {
$attributes = 'class="post-title page-title column-title"' . $style;
-
+
$pad = str_repeat( '— ', $level );
?>
>post_status != 'trash' ) { ?>
@@ -603,43 +625,29 @@
echo ' | ';
break;
- case 'categories':
- ?>
- >%s',
- esc_url( add_query_arg( array( 'post_type' => $post->post_type, 'category_name' => $c->slug ), 'edit.php' ) ),
- esc_html( sanitize_term_field( 'name', $c->name, $c->term_id, 'category', 'display' ) )
- );
- }
- /* translators: used between list items, there is a space after the comma */
- echo join( __( ', ' ), $out );
- } else {
- _e( 'Uncategorized' );
- }
- ?> |
- taxonomy_columns ) ) :
+ $taxonomy = $column_name;
+ if ( 'categories' == $column_name )
+ $taxonomy = 'category';
+ elseif ( 'tags' == $column_name )
+ $taxonomy = 'post_tag';
- case 'tags':
+ $taxonomy_object = get_taxonomy( $taxonomy );
?>
>ID );
- if ( !empty( $tags ) ) {
+ $terms = get_the_terms( $post->ID, $taxonomy );
+ if ( !empty( $terms ) ) {
$out = array();
- foreach ( $tags as $c ) {
+ foreach ( $terms as $t ) {
$out[] = sprintf( '%s',
- esc_url( add_query_arg( array( 'post_type' => $post->post_type, 'tag' => $c->slug ), 'edit.php' ) ),
- esc_html( sanitize_term_field( 'name', $c->name, $c->term_id, 'tag', 'display' ) )
+ esc_url( add_query_arg( array( 'post_type' => $post->post_type, $taxonomy_object->query_var => $t->slug ), 'edit.php' ) ),
+ esc_html( sanitize_term_field( 'name', $t->name, $t->term_id, $taxonomy, 'display' ) )
);
}
/* translators: used between list items, there is a space after the comma */
echo join( __( ', ' ), $out );
} else {
- _e( 'No Tags' );
+ echo $taxonomy_object->labels->no_items;
}
?> |
'post',
'map_meta_cap' => true,
'hierarchical' => false,
+ 'show_taxonomy_columns' => array( 'category', 'post_tag' ),
'rewrite' => false,
'query_var' => false,
'delete_with_user' => true,
@@ -980,7 +981,8 @@
'_builtin' => false, '_edit_link' => 'post.php?post=%d', 'hierarchical' => false,
'public' => false, 'rewrite' => true, 'has_archive' => false, 'query_var' => true,
'supports' => array(), 'register_meta_box_cb' => null,
- 'taxonomies' => array(), 'show_ui' => null, 'menu_position' => null, 'menu_icon' => null,
+ 'taxonomies' => array(), 'show_taxonomy_columns' => false,
+ 'show_ui' => null, 'menu_position' => null, 'menu_icon' => null,
'can_export' => true,
'show_in_nav_menus' => null, 'show_in_menu' => null, 'show_in_admin_bar' => null,
'delete_with_user' => null,
Index: wp-includes/taxonomy.php
===================================================================
--- wp-includes/taxonomy.php (revision 21372)
+++ wp-includes/taxonomy.php (working copy)
@@ -43,6 +43,9 @@
register_taxonomy( 'category', 'post', array(
'hierarchical' => true,
+ 'labels' => array(
+ 'no_items' => __( 'Uncategorized' ),
+ ),
'query_var' => 'category_name',
'rewrite' => $rewrite['category'],
'public' => true,
@@ -416,6 +419,7 @@
'search_items' => array( __( 'Search Tags' ), __( 'Search Categories' ) ),
'popular_items' => array( __( 'Popular Tags' ), null ),
'all_items' => array( __( 'All Tags' ), __( 'All Categories' ) ),
+ 'no_items' => array( __( 'No Tags' ), __( 'No Categories' ) ),
'parent_item' => array( null, __( 'Parent Category' ) ),
'parent_item_colon' => array( null, __( 'Parent Category:' ) ),
'edit_item' => array( __( 'Edit Tag' ), __( 'Edit Category' ) ),