示例#1
0
/**
 * Update counts after a topic is inserted via `bbp_insert_topic`.
 *
 * @since 2.6.0 bbPress (r6036)
 *
 * @param int $topic_id The topic id.
 * @param int $forum_id The forum id.
 *
 * @uses bbp_get_topic_status() To get the post status
 * @uses bbp_get_public_status_id() To get the public status id
 * @uses bbp_increase_forum_topic_count() To bump the topic's forum topic count by 1
 * @uses bbp_increase_forum_topic_count_hidden() To bump the topic's forum topic
 *                                               hidden count by 1
 *
 * @return void
 */
function bbp_insert_topic_update_counts($topic_id = 0, $forum_id = 0)
{
    // If the topic is public, update the forum topic counts.
    if (bbp_get_topic_status($topic_id) === bbp_get_public_status_id()) {
        bbp_increase_forum_topic_count($forum_id);
        // If the topic isn't public only update the forum topic hidden count.
    } else {
        bbp_increase_forum_topic_count_hidden($forum_id);
    }
}
示例#2
0
 /**
  * @covers ::bbp_increase_forum_topic_count
  */
 public function test_bbp_increase_forum_topic_count()
 {
     $f = $this->factory->forum->create();
     $count = bbp_get_forum_topic_count($f);
     $this->assertSame('0', $count);
     bbp_increase_forum_topic_count($f);
     $count = bbp_get_forum_topic_count($f);
     $this->assertSame('1', $count);
 }