Esempio n. 1
0
/**
 * 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);
    }
}
Esempio n. 2
0
/**
 * Increase the total reply count of a topic by one.
 *
 * @since 2.6.0 bbPress (r6036)
 *
 * @param int $topic_id The topic id.
 *
 * @uses bbp_is_reply() To check if the passed topic id is a reply
 * @uses bbp_get_reply_topic_id() To get the replies topic id
 * @uses bbp_is_reply_published() To check if the reply is published
 * @uses bbp_increase_topic_reply_count_hidden() To increase the topics reply
 *                                                hidden count by 1
 * @uses bbp_bump_topic_reply_count() To bump the topic reply count
 *
 * @return void
 */
function bbp_increase_topic_reply_count($topic_id = 0)
{
    // Bail early if no id is passed.
    if (empty($topic_id)) {
        return;
    }
    // If it's a reply, get the topic id.
    if (bbp_is_reply($topic_id)) {
        $reply_id = $topic_id;
        $topic_id = bbp_get_reply_topic_id($reply_id);
        // If this is a new, unpublished, reply, update hidden count and bail.
        if ('bbp_new_reply' === current_filter() && !bbp_is_reply_published($reply_id)) {
            bbp_increase_topic_reply_count_hidden($topic_id);
            return;
        }
    }
    bbp_bump_topic_reply_count($topic_id);
}
Esempio n. 3
0
 /**
  * @covers ::bbp_increase_topic_reply_count_hidden
  */
 public function test_bbp_increase_topic_reply_count_hidden()
 {
     $t = $this->factory->topic->create();
     $count = bbp_get_topic_reply_count_hidden($t);
     $this->assertSame('0', $count);
     bbp_increase_topic_reply_count_hidden($t);
     $count = bbp_get_topic_reply_count_hidden($t);
     $this->assertSame('1', $count);
 }