Skip to content

Commit

Permalink
improved count topics (post statuses)
Browse files Browse the repository at this point in the history
  • Loading branch information
gordielachance authored and gordielachance committed Sep 9, 2016
1 parent 8f545b4 commit 339ee84
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion bbpress-pencil-unread.php
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ function has_user_read_all_forum_topics( $forum_id,$user_id=false ){
if(!$user_id) $user_id = get_current_user_id();
if(!$user_id) return true;

//count topics
//count topics - check bbPress function bbp_has_topics()

$topics_args = array(
'post_type' => bbp_get_topic_post_type(),
Expand All @@ -706,6 +706,22 @@ function has_user_read_all_forum_topics( $forum_id,$user_id=false ){

);

// Default view=all statuses
$post_statuses = array(
bbp_get_public_status_id(),
bbp_get_closed_status_id(),
//bbp_get_spam_status_id(),
//bbp_get_trash_status_id()
);

// Add support for private status
if ( current_user_can( 'read_private_topics' ) ) {
$post_statuses[] = bbp_get_private_status_id();
}

// Join post statuses together
$topics_args['post_status'] = implode( ',', $post_statuses );

$topics_query = new WP_Query( $topics_args );
$topics_total = $topics_query->found_posts;

Expand Down

0 comments on commit 339ee84

Please sign in to comment.