Open dhiraj28691 opened 1 year ago
Steps to Reproduce.
it is showing double / incorrect count.
The reason for this is, linked account posts are considered twice as per the code.
get_guest_author_post_count function is returning only linked account posts if there is a linked account attached with guest author profile.
public function get_guest_author_post_count( $guest_author ) { if ( ! is_object( $guest_author ) ) { return; } $term = $this->get_author_term( $guest_author ); $guest_term = get_term_by( 'slug', 'cap-' . $guest_author->user_nicename, $this->coauthor_taxonomy ); if ( is_object( $guest_term ) && ! empty( $guest_author->linked_account ) && $guest_term->count ) { return count_user_posts( get_user_by( 'login', $guest_author->linked_account )->ID ); } elseif ( $term ) { return $term->count; } else { return 0; } }
In the below function which is used to display posts count, it is calculating the posts for that guest author and adding linked account posts.
get_guest_author_post_count is already returning linked account posts.
function column_posts( $item ) { global $coauthors_plus; $count = $coauthors_plus->get_guest_author_post_count( $item ); if ( ! empty( $item->linked_account ) ) { global $coauthors_plus; // Add user term count to guest author term count. $term = get_term_by( 'slug', 'cap-' . $item->linked_account, $coauthors_plus->coauthor_taxonomy ); if ( is_object( $term ) ) { $count = $count + $term->count; } } return '<a href="' . esc_url( add_query_arg( 'author_name', rawurlencode( $item->user_login ), admin_url( 'edit.php' ) ) ) . '">' . $count . '</a>'; }
Hello anyone? This is a serious issue.
Steps to Reproduce.
it is showing double / incorrect count.
The reason for this is, linked account posts are considered twice as per the code.
get_guest_author_post_count function is returning only linked account posts if there is a linked account attached with guest author profile.
In the below function which is used to display posts count, it is calculating the posts for that guest author and adding linked account posts.
get_guest_author_post_count is already returning linked account posts.