Ticket #21240: 21240.diff
File 21240.diff, 7.2 KB (added by , 13 years ago) |
---|
-
wp-includes/post.php
977 977 $defaults = array( 978 978 'labels' => array(), 'description' => '', 'publicly_queryable' => null, 'exclude_from_search' => null, 979 979 'capability_type' => 'post', 'capabilities' => array(), 'map_meta_cap' => null, 980 '_builtin' => false, '_edit_link' => 'post.php?post=%d', 'hierarchical' => false, 980 '_builtin' => false, '_edit_link' => 'post.php?post=%d', 'hierarchical' => false, 'show_taxonomy_columns' => false, 981 981 'public' => false, 'rewrite' => true, 'has_archive' => false, 'query_var' => true, 982 982 'supports' => array(), 'register_meta_box_cb' => null, 983 983 'taxonomies' => array(), 'show_ui' => null, 'menu_position' => null, 'menu_icon' => null, -
wp-admin/includes/screen.php
23 23 if ( ! isset( $column_headers[ $screen->id ] ) ) 24 24 $column_headers[ $screen->id ] = apply_filters( 'manage_' . $screen->id . '_columns', array() ); 25 25 26 return $column_headers[ $screen->id ]; 26 $tax_columns = ( $screen->post_type ) ? get_taxonomy_column_headers( $screen ) : array(); 27 28 return array_merge( $column_headers[ $screen->id ], $tax_columns ); 27 29 } 28 30 29 31 /** 32 * Get a list of registered taxonomy column headers. 33 * 34 * @since 3.5.0 35 * 36 * @param object|WP_Screen $screen The screen you want the headers for 37 * @return array Containing the headers in the format id => UI String 38 */ 39 function get_taxonomy_column_headers( $screen ) { 40 $columns = array(); 41 42 $post_type_object = get_post_type_object( $screen->post_type ); 43 44 if ( $post_type_object->show_taxonomy_columns ) { 45 46 if ( is_array( $post_type_object->show_taxonomy_columns ) ) 47 $taxonomies = $post_type_object->show_taxonomy_columns; 48 else 49 $taxonomies = get_object_taxonomies( $screen->post_type ); 50 51 if ( empty( $taxonomies ) ) 52 return $columns; 53 54 foreach ( $taxonomies as $registered_taxonomy ) { 55 56 $taxonomy_object = get_taxonomy( $registered_taxonomy ); 57 $columns[$registered_taxonomy.'_taxonomy_column'] = apply_filters( 'taxonomy_column_header', $taxonomy_object->label, $post_type_object, $taxonomy_object ); 58 59 } 60 } 61 return $columns; 62 } 63 64 /** 30 65 * Get a list of hidden columns. 31 66 * 32 67 * @since 2.7.0 -
wp-admin/includes/class-wp-posts-list-table.php
469 469 $edit_link = get_edit_post_link( $post->ID ); 470 470 $title = _draft_or_post_title(); 471 471 $post_type_object = get_post_type_object( $post->post_type ); 472 if ( $post_type_object->show_taxonomy_columns ) { 473 if ( is_array( $post_type_object->show_taxonomy_columns ) ) 474 $taxonomies_columns = $post_type_object->show_taxonomy_columns; 475 else 476 $taxonomies_columns = get_object_taxonomies( $post_type_object->name ); 477 } 472 478 $can_edit_post = current_user_can( $post_type_object->cap->edit_post, $post->ID ); 473 479 474 480 $alternate = 'alternate' == $alternate ? '' : 'alternate'; … … 529 535 } 530 536 else { 531 537 $attributes = 'class="post-title page-title column-title"' . $style; 532 538 533 539 $pad = str_repeat( '— ', $level ); 534 540 ?> 535 541 <td <?php echo $attributes ?>><strong><?php if ( $can_edit_post && $post->post_status != 'trash' ) { ?><a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo esc_attr( sprintf( __( 'Edit “%s”' ), $title ) ); ?>"><?php echo $pad; echo $title ?></a><?php } else { echo $pad; echo $title; }; _post_states( $post ); ?></strong> … … 604 610 break; 605 611 606 612 case 'categories': 607 ?> 608 <td <?php echo $attributes ?>><?php 609 $categories = get_the_category(); 610 if ( !empty( $categories ) ) { 611 $out = array(); 612 foreach ( $categories as $c ) { 613 $out[] = sprintf( '<a href="%s">%s</a>', 614 esc_url( add_query_arg( array( 'post_type' => $post->post_type, 'category_name' => $c->slug ), 'edit.php' ) ), 615 esc_html( sanitize_term_field( 'name', $c->name, $c->term_id, 'category', 'display' ) ) 616 ); 617 } 618 /* translators: used between list items, there is a space after the comma */ 619 echo join( __( ', ' ), $out ); 620 } else { 621 _e( 'Uncategorized' ); 622 } 623 ?></td> 624 <?php 613 $this->taxonomy_column( array( 'attributes' => $attributes, 'empty' => __( 'Uncategorized' ) ) ); 625 614 break; 626 615 627 616 case 'tags': 628 ?> 629 <td <?php echo $attributes ?>><?php 630 $tags = get_the_tags( $post->ID ); 631 if ( !empty( $tags ) ) { 632 $out = array(); 633 foreach ( $tags as $c ) { 634 $out[] = sprintf( '<a href="%s">%s</a>', 635 esc_url( add_query_arg( array( 'post_type' => $post->post_type, 'tag' => $c->slug ), 'edit.php' ) ), 636 esc_html( sanitize_term_field( 'name', $c->name, $c->term_id, 'tag', 'display' ) ) 637 ); 638 } 639 /* translators: used between list items, there is a space after the comma */ 640 echo join( __( ', ' ), $out ); 641 } else { 642 _e( 'No Tags' ); 643 } 644 ?></td> 645 <?php 617 $this->taxonomy_column( array( 'taxonomy' => 'post_tag', 'attributes' => $attributes ) ); 646 618 break; 647 619 620 case ( is_array( $taxonomies_columns ) && in_array( $registered_taxonomy = str_replace( '_taxonomy_column', '', $column_name ), $taxonomies_columns ) ) : 621 622 $defaults = array( 623 'taxonomy' => $registered_taxonomy, 624 'attributes' => $attributes, 625 ); 626 $args = apply_filters( 'taxonomy_column_args', $defaults, $post_type_object, $registered_taxonomy ); 627 628 $this->taxonomy_column( $args ); 629 break; 630 648 631 case 'comments': 649 632 ?> 650 633 <td <?php echo $attributes ?>><div class="post-com-count-wrapper"> … … 679 662 ?></td> 680 663 <?php 681 664 break; 665 } 682 666 } 683 }684 667 ?> 685 668 </tr> 686 669 <?php … … 688 671 } 689 672 690 673 /** 674 * Creates internal taxonomy columns as well as registered taxonomies 675 * 676 * @since 3.5.0 677 */ 678 function taxonomy_column( $atts = array() ) { 679 global $post; 680 681 $defaults = array( 682 'taxonomy' => 'category', 683 'attributes' => '', 684 'empty' => '', 685 ); 686 $args = wp_parse_args( (array) $atts, $defaults ); 687 extract( $args, EXTR_SKIP ); 688 689 $attributes = !empty( $attributes ) ? $attributes : 'class="column-'. $taxonomy .'"'; 690 $taxonomy_object = get_taxonomy( $taxonomy ); 691 $empty = !empty( $empty ) ? $empty : __( 'No '. $taxonomy_object->label ); 692 693 ?> 694 <td <?php echo $attributes ?>><?php 695 $terms = get_the_terms( $post->ID, $taxonomy ); 696 if ( !empty( $terms ) ) { 697 $out = array(); 698 foreach ( $terms as $t ) { 699 $out[] = sprintf( '<a href="%s">%s</a>', 700 esc_url( add_query_arg( array( 'post_type' => $post->post_type, $taxonomy_object->query_var => $t->slug ), 'edit.php' ) ), 701 esc_html( sanitize_term_field( 'name', $t->name, $t->term_id, $taxonomy, 'display' ) ) 702 ); 703 } 704 /* translators: used between list items, there is a space after the comma */ 705 echo join( __( ', ' ), $out ); 706 } else { 707 echo $empty; 708 } 709 ?></td> 710 <?php 711 } 712 713 /** 691 714 * Outputs the hidden row displayed when inline editing 692 715 * 693 716 * @since 3.1.0