Ticket #32942: 32942.1.diff
| File 32942.1.diff, 6.8 KB (added by , 3 years ago) |
|---|
-
src/wp-admin/includes/class-wp-terms-list-table.php
diff --git a/src/wp-admin/includes/class-wp-terms-list-table.php b/src/wp-admin/includes/class-wp-terms-list-table.php index 3c277d6a61..3606e74651 100644
a b class WP_Terms_List_Table extends WP_List_Table { 195 195 'slug' => __( 'Slug' ), 196 196 ); 197 197 198 // Check if current taxonomy assigned in multiple post type 199 if ( 'attachment' != $this->screen->post_type ) { 200 $taxonomy_object = get_taxonomy( $this->screen->taxonomy ); 201 if ($taxonomy_object) { 202 $assigned_post_types = $taxonomy_object->object_type; 203 204 if (is_array($assigned_post_types) && count($assigned_post_types) > 1) { 205 // If assigned multiple post type then only below column will add. 206 $columns['otherposts'] = _x( 'Current Count', 'Number/count of items' ); 207 } 208 } 209 } 210 198 211 if ( 'link_category' === $this->screen->taxonomy ) { 199 212 $columns['links'] = __( 'Links' ); 200 213 } else { … … class WP_Terms_List_Table extends WP_List_Table { 220 233 'name' => array( 'name', false, _x( 'Name', 'term name' ), $name_orderby_text, 'asc' ), 221 234 'description' => array( 'description', false, __( 'Description' ), __( 'Table ordered by Description.' ) ), 222 235 'slug' => array( 'slug', false, __( 'Slug' ), __( 'Table ordered by Slug.' ) ), 236 'otherposts' => array( 'count', false, _x( 'Count', 'Number/count of items' ), __( 'Table ordered by Current Posts Count.' ) ), 223 237 'posts' => array( 'count', false, _x( 'Count', 'Number/count of items' ), __( 'Table ordered by Posts Count.' ) ), 224 238 'links' => array( 'count', false, __( 'Links' ), __( 'Table ordered by Links.' ) ), 225 239 ); … … class WP_Terms_List_Table extends WP_List_Table { 571 585 return apply_filters( 'editable_slug', $tag->slug, $tag ); 572 586 } 573 587 588 /** 589 * @param WP_Term $tag Term object. 590 * @return string 591 */ 592 public function column_otherposts( $tag ) { 593 $count = number_format_i18n( $tag->count ); 594 595 $tax = get_taxonomy( $this->screen->taxonomy ); 596 597 $ptype_object = get_post_type_object( $this->screen->post_type ); 598 if ( ! $ptype_object->show_ui ) { 599 return $count; 600 } 601 602 if ( $tax->query_var ) { 603 $args = array( $tax->query_var => $tag->slug ); 604 } else { 605 $args = array( 606 'taxonomy' => $tax->name, 607 'term' => $tag->slug, 608 ); 609 } 610 611 if ( 'post' !== $this->screen->post_type ) { 612 $args['post_type'] = $this->screen->post_type; 613 } 614 615 $query_args = array( 616 'post_type' => $this->screen->post_type, 617 'post_status' => 'publish', 618 'tax_query' => array( 619 array( 620 'taxonomy' => $this->screen->taxonomy, 621 'field' => 'id', 622 'terms' => array( $tag->term_id ), 623 ), 624 ), 625 ); 626 $the_query = new WP_Query( $query_args ); 627 628 if ( isset( $the_query->found_posts ) ) { 629 630 return "<a href='" . esc_url( add_query_arg( $args, 'edit.php' ) ) . "'>$the_query->found_posts</a>"; 631 } 632 633 return "<a href='" . esc_url( add_query_arg( $args, 'edit.php' ) ) . "'>$count</a>"; 634 } 635 574 636 /** 575 637 * @param WP_Term $tag Term object. 576 638 * @return string … … class WP_Terms_List_Table extends WP_List_Table { 688 750 'description' => true, 689 751 'name' => true, 690 752 'slug' => true, 753 'otherposts' => true, 691 754 'posts' => true, 692 755 ); 693 756