| | 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 | $current_count = ucfirst( $this->screen->post_type ) . ' Count'; |
| | 207 | $columns['otherposts'] = _x( $current_count, 'Number/count of items' ); |
| | 208 | } |
| | 209 | } |
| | 210 | } |
| | 211 | |
| 220 | 234 | 'name' => array( 'name', false, _x( 'Name', 'term name' ), $name_orderby_text, 'asc' ), |
| 221 | 235 | 'description' => array( 'description', false, __( 'Description' ), __( 'Table ordered by Description.' ) ), |
| 222 | 236 | 'slug' => array( 'slug', false, __( 'Slug' ), __( 'Table ordered by Slug.' ) ), |
| | 589 | /** |
| | 590 | * @param WP_Term $tag Term object. |
| | 591 | * @return string |
| | 592 | */ |
| | 593 | public function column_otherposts( $tag ) { |
| | 594 | $count = number_format_i18n( $tag->count ); |
| | 595 | |
| | 596 | $tax = get_taxonomy( $this->screen->taxonomy ); |
| | 597 | |
| | 598 | $ptype_object = get_post_type_object( $this->screen->post_type ); |
| | 599 | if ( ! $ptype_object->show_ui ) { |
| | 600 | return $count; |
| | 601 | } |
| | 602 | |
| | 603 | if ( $tax->query_var ) { |
| | 604 | $args = array( $tax->query_var => $tag->slug ); |
| | 605 | } else { |
| | 606 | $args = array( |
| | 607 | 'taxonomy' => $tax->name, |
| | 608 | 'term' => $tag->slug, |
| | 609 | ); |
| | 610 | } |
| | 611 | |
| | 612 | if ( 'post' !== $this->screen->post_type ) { |
| | 613 | $args['post_type'] = $this->screen->post_type; |
| | 614 | } |
| | 615 | |
| | 616 | $query_args = array( |
| | 617 | 'post_type' => $this->screen->post_type, |
| | 618 | 'post_status' => 'publish', |
| | 619 | 'tax_query' => array( |
| | 620 | array( |
| | 621 | 'taxonomy' => $this->screen->taxonomy, |
| | 622 | 'field' => 'id', |
| | 623 | 'terms' => array( $tag->term_id ), |
| | 624 | ), |
| | 625 | ), |
| | 626 | ); |
| | 627 | $the_query = new WP_Query( $query_args ); |
| | 628 | |
| | 629 | if ( isset( $the_query->found_posts ) ) { |
| | 630 | |
| | 631 | return "<a href='" . esc_url( add_query_arg( $args, 'edit.php' ) ) . "'>$the_query->found_posts</a>"; |
| | 632 | } |
| | 633 | |
| | 634 | return "<a href='" . esc_url( add_query_arg( $args, 'edit.php' ) ) . "'>$count</a>"; |
| | 635 | } |
| | 636 | |