/** * Update counts after a reply is inserted via `bbp_insert_reply`. * * @since 2.6.0 bbPress (r6036) * * @param int $reply_id The reply id. * @param int $topic_id The topic id. * @param int $forum_id The forum id. * * @uses bbp_get_reply_status() To get the reply status * @uses bbp_get_public_status_id() To get the public status id * @uses bbp_increase_topic_reply_count() To bump the topics reply count by 1 * @uses bbp_increase_forum_reply_count() To bump the forums reply count by 1 * @uses bbp_increase_topic_reply_count_hidden() To bump the topics hidden reply * count by 1 * * @return void */ function bbp_insert_reply_update_counts($reply_id = 0, $topic_id = 0, $forum_id = 0) { // If the reply is public, update the forum/topic reply counts. if (bbp_get_reply_status($reply_id) === bbp_get_public_status_id()) { bbp_increase_topic_reply_count($topic_id); bbp_increase_forum_reply_count($forum_id); // If the reply isn't public only update the topic reply hidden count. } else { bbp_increase_topic_reply_count_hidden($topic_id); } }
/** * @covers ::bbp_increase_topic_reply_count */ public function test_bbp_increase_topic_reply_count() { $t = $this->factory->topic->create(); $count = bbp_get_topic_reply_count($t); $this->assertSame('0', $count); bbp_increase_topic_reply_count($t); $count = bbp_get_topic_reply_count($t); $this->assertSame('1', $count); }