Ejemplo n.º 1
0
 /**
  * @group canonical
  * @covers ::bbp_insert_forum
  */
 public function test_bbp_insert_forum()
 {
     $f = $this->factory->forum->create(array('post_title' => 'Forum 1', 'post_content' => 'Content of Forum 1'));
     $now = time();
     $post_date = date('Y-m-d H:i:s', $now - 60 * 60 * 100);
     $t = $this->factory->topic->create(array('post_parent' => $f, 'post_date' => $post_date, 'topic_meta' => array('forum_id' => $f)));
     $r = $this->factory->reply->create(array('post_parent' => $t, 'post_date' => $post_date, 'reply_meta' => array('forum_id' => $f, 'topic_id' => $t)));
     // Get the forum.
     $forum = bbp_get_forum($f);
     // Forum post.
     $this->assertSame('Forum 1', bbp_get_forum_title($f));
     $this->assertSame('Content of Forum 1', bbp_get_forum_content($f));
     $this->assertSame('open', bbp_get_forum_status($f));
     $this->assertSame('forum', bbp_get_forum_type($f));
     $this->assertTrue(bbp_is_forum_public($f));
     $this->assertSame(0, bbp_get_forum_parent_id($f));
     $this->assertEquals('http://' . WP_TESTS_DOMAIN . '/?forum=' . $forum->post_name, $forum->guid);
     // Forum meta.
     $this->assertSame(0, bbp_get_forum_subforum_count($f, true));
     $this->assertSame(1, bbp_get_forum_topic_count($f, false, true));
     $this->assertSame(1, bbp_get_forum_topic_count($f, true, true));
     $this->assertSame(0, bbp_get_forum_topic_count_hidden($f, true));
     $this->assertSame(1, bbp_get_forum_reply_count($f, false, true));
     $this->assertSame(1, bbp_get_forum_reply_count($f, true, true));
     $this->assertSame(2, bbp_get_forum_post_count($f, false, true));
     $this->assertSame(2, bbp_get_forum_post_count($f, true, true));
     $this->assertSame($t, bbp_get_forum_last_topic_id($f));
     $this->assertSame($r, bbp_get_forum_last_reply_id($f));
     $this->assertSame($r, bbp_get_forum_last_active_id($f));
     $this->assertSame('4 days, 4 hours ago', bbp_get_forum_last_active_time($f));
 }
Ejemplo n.º 2
0
/**
 * Output total post count of a forum
 *
 * @since bbPress (r2954)
 *
 * @param int $forum_id Optional. Forum id
 * @param bool $total_count Optional. To get the total count or normal count?
 * @uses bbp_get_forum_post_count() To get the forum post count
 */
function bbp_forum_post_count($forum_id = 0, $total_count = true)
{
    echo bbp_get_forum_post_count($forum_id, $total_count);
}
Ejemplo n.º 3
0
/**
 * Output total post count of a forum
 *
 * @since bbPress (r2954)
 *
 * @param int $forum_id Optional. Forum id
 * @param bool $total_count Optional. To get the total count or normal count?
 * @param boolean $integer Optional. Whether or not to format the result
 * @uses bbp_get_forum_post_count() To get the forum post count
 */
function bbp_forum_post_count($forum_id = 0, $total_count = true, $integer = false)
{
    echo bbp_get_forum_post_count($forum_id, $total_count, $integer);
}
Ejemplo n.º 4
0
 /**
  * @group canonical
  * @covers ::bbp_create_initial_content
  */
 public function test_bbp_create_initial_content()
 {
     $category_id = $this->factory->forum->create(array('forum_meta' => array('_bbp_forum_type' => 'category', '_bbp_status' => 'open')));
     bbp_create_initial_content(array('forum_parent' => $category_id));
     $forum_id = bbp_forum_query_subforum_ids($category_id);
     $forum_id = (int) $forum_id[0];
     $topic_id = bbp_get_forum_last_topic_id($forum_id);
     $reply_id = bbp_get_forum_last_reply_id($forum_id);
     // Forum post
     $this->assertSame('General', bbp_get_forum_title($forum_id));
     $this->assertSame('General chit-chat', bbp_get_forum_content($forum_id));
     $this->assertSame('open', bbp_get_forum_status($forum_id));
     $this->assertTrue(bbp_is_forum_public($forum_id));
     $this->assertSame($category_id, bbp_get_forum_parent_id($forum_id));
     // Topic post
     $this->assertSame($forum_id, bbp_get_topic_forum_id($topic_id));
     $this->assertSame('Hello World!', bbp_get_topic_title($topic_id));
     remove_all_filters('bbp_get_topic_content');
     $topic_content = "I am the first topic in your new forums.";
     $this->assertSame($topic_content, bbp_get_topic_content($topic_id));
     $this->assertSame('publish', bbp_get_topic_status($topic_id));
     $this->assertTrue(bbp_is_topic_published($topic_id));
     // Reply post
     $this->assertSame($forum_id, bbp_get_reply_forum_id($reply_id));
     $this->assertSame('Reply To: Hello World!', bbp_get_reply_title($reply_id));
     $this->assertSame($reply_id, bbp_get_reply_title_fallback($reply_id));
     remove_all_filters('bbp_get_reply_content');
     $reply_content = "Oh, and this is what a reply looks like.";
     $this->assertSame($reply_content, bbp_get_reply_content($reply_id));
     $this->assertSame('publish', bbp_get_reply_status($reply_id));
     $this->assertTrue(bbp_is_reply_published($reply_id));
     // Category meta
     $this->assertSame(1, bbp_get_forum_subforum_count($category_id, true));
     $this->assertSame(0, bbp_get_forum_topic_count($category_id, false, true));
     $this->assertSame(0, bbp_get_forum_topic_count_hidden($category_id, true));
     $this->assertSame(0, bbp_get_forum_reply_count($category_id, false, true));
     $this->assertSame(1, bbp_get_forum_topic_count($category_id, true, true));
     $this->assertSame(1, bbp_get_forum_reply_count($category_id, true, true));
     $this->assertSame(0, bbp_get_forum_post_count($category_id, false, true));
     $this->assertSame(2, bbp_get_forum_post_count($category_id, true, true));
     $this->assertSame($topic_id, bbp_get_forum_last_topic_id($category_id));
     $this->assertSame('Hello World!', bbp_get_forum_last_topic_title($category_id));
     $this->assertSame($reply_id, bbp_get_forum_last_reply_id($category_id));
     $this->assertSame('Reply To: Hello World!', bbp_get_forum_last_reply_title($category_id));
     $this->assertSame($reply_id, bbp_get_forum_last_active_id($category_id));
     $this->assertSame('1 day, 16 hours ago', bbp_get_forum_last_active_time($category_id));
     // Forum meta
     $this->assertSame(0, bbp_get_forum_subforum_count($forum_id, true));
     $this->assertSame(1, bbp_get_forum_topic_count($forum_id, false, true));
     $this->assertSame(0, bbp_get_forum_topic_count_hidden($forum_id, true));
     $this->assertSame(1, bbp_get_forum_reply_count($forum_id, false, true));
     $this->assertSame(1, bbp_get_forum_topic_count($forum_id, true, true));
     $this->assertSame(1, bbp_get_forum_reply_count($forum_id, true, true));
     $this->assertSame(2, bbp_get_forum_post_count($forum_id, false, true));
     $this->assertSame(2, bbp_get_forum_post_count($forum_id, true, true));
     $this->assertSame($topic_id, bbp_get_forum_last_topic_id($forum_id));
     $this->assertSame('Hello World!', bbp_get_forum_last_topic_title($forum_id));
     $this->assertSame($reply_id, bbp_get_forum_last_reply_id($forum_id));
     $this->assertSame('Reply To: Hello World!', bbp_get_forum_last_reply_title($forum_id));
     $this->assertSame($reply_id, bbp_get_forum_last_active_id($forum_id));
     $this->assertSame('1 day, 16 hours ago', bbp_get_forum_last_active_time($forum_id));
     // Topic meta
     $this->assertSame('127.0.0.1', bbp_current_author_ip($topic_id));
     $this->assertSame($forum_id, bbp_get_topic_forum_id($topic_id));
     $this->assertSame(1, bbp_get_topic_voice_count($topic_id, true));
     $this->assertSame(1, bbp_get_topic_reply_count($topic_id, true));
     $this->assertSame(0, bbp_get_topic_reply_count_hidden($topic_id, true));
     $this->assertSame($reply_id, bbp_get_topic_last_reply_id($topic_id));
     $this->assertSame($reply_id, bbp_get_topic_last_active_id($topic_id));
     $this->assertSame('1 day, 16 hours ago', bbp_get_topic_last_active_time($topic_id));
     // Reply Meta
     $this->assertSame('127.0.0.1', bbp_current_author_ip($reply_id));
     $this->assertSame($forum_id, bbp_get_reply_forum_id($reply_id));
     $this->assertSame($topic_id, bbp_get_reply_topic_id($reply_id));
 }
Ejemplo n.º 5
0
function og_groups_update_num_posts_and_rank_options($args = array())
{
    // wp-content/plugins/buddypress/bp-groups/bp-groups-forums.php
    //error_log("og group post count here ".print_r($args,true));
    //echo "og here";
    $group_id = 0;
    $og_my_postcount = 0;
    //error_log("og group post count here");
    $group = groups_get_current_group();
    //Taken from wp-content/plugins/bbpress/includes/extend/buddypress/groups.php
    // Not posting from a BuddyPress group? stop now!
    if (!empty($group)) {
        $group_id = $group->id;
        //bp_get_current_group_id(); //$bp->groups->current_group->id;
        error_log("og group post count id " . $group_id);
    } else {
        return $args;
    }
    //Taken from wp-content/plugins/bbpress/includes/extend/buddypress/groups.php
    $my_forum_ids = bbp_get_group_forum_ids($my_group_id);
    $forum_id = null;
    // Get the first forum ID
    if (!empty($my_forum_ids)) {
        $forum_id = (int) is_array($my_forum_ids) ? $my_forum_ids[0] : $my_forum_ids;
        $og_my_postcount = bbp_show_lead_topic() ? bbp_get_forum_reply_count($forum_id) : bbp_get_forum_post_count($forum_id);
    }
    // Update the group's post count
    //error_log("og group post count ".$og_my_postcount);
    groups_update_groupmeta($group_id, 'og_num_posts', $og_my_postcount);
    // Taken from p-content/plugins/buddypress/bp-groups/bp-groups-forums.php
    // Update the group's rank, based on its previous rank
    $og_rank_arg = 'og_rank';
    // Get the previous rank
    $og_prev_grp_rank = groups_get_groupmeta($group_id, $og_rank_arg);
    //error_log("og group post rank ".empty($og_prev_grp_rank));
    // If the rank doesn't exist yet, make it 0
    if (empty($og_prev_grp_rank == null)) {
        $og_prev_grp_rank = 0;
    }
    // Update the rank as follows: rank = .7*prev rank + .3*current unix time
    // groups_update_groupmeta .5*og_rank+.5*lastactivitytimeinunix
    groups_update_groupmeta($group_id, $og_rank_arg, 0.7 * $og_prev_grp_rank + 0.3 * microtime(true));
    return $args;
}
Ejemplo n.º 6
0
 /**
  * @covers ::bbp_forum_post_count
  * @covers ::bbp_get_forum_post_count
  */
 public function test_bbp_get_forum_post_count()
 {
     $c = $this->factory->forum->create(array('forum_meta' => array('forum_type' => 'category')));
     $f = $this->factory->forum->create(array('post_parent' => $c, 'forum_meta' => array('forum_id' => $c)));
     $t = $this->factory->topic->create(array('post_parent' => $f));
     $int_value = 3;
     // Topic + Replies.
     $result = 4;
     $formatted_result = bbp_number_format($result);
     $this->factory->reply->create_many($int_value, array('post_parent' => $t));
     bbp_update_forum_topic_count($c);
     bbp_update_forum_topic_count($f);
     bbp_update_forum_reply_count($c);
     bbp_update_forum_reply_count($f);
     // Forum output.
     $count = bbp_get_forum_post_count($f, true, false);
     $this->expectOutputString($formatted_result);
     bbp_forum_post_count($f);
     // Forum formatted string.
     $count = bbp_get_forum_post_count($f, true, false);
     $this->assertSame($formatted_result, $count);
     // Forum integer.
     $count = bbp_get_forum_post_count($f, true, true);
     $this->assertSame($result, $count);
     // Category post count.
     $count = bbp_get_forum_post_count($c, false, true);
     $this->assertSame(0, $count);
     // Category total post count.
     $count = bbp_get_forum_post_count($c, true, true);
     $this->assertSame($result, $count);
 }
Ejemplo n.º 7
0
 function wm_bbp_additional_class($classes)
 {
     //Helper variables
     $voices_count = bbp_get_topic_voice_count();
     $replies_count = bbp_show_lead_topic() ? bbp_get_topic_reply_count() : bbp_get_topic_post_count();
     if (bbp_get_forum_post_type() == get_post_type()) {
         $voices_count = bbp_get_forum_topic_count();
         $replies_count = bbp_show_lead_topic() ? bbp_get_forum_reply_count() : bbp_get_forum_post_count();
     }
     //Preparing output
     $classes[] = 1 < $voices_count ? 'multi-voices' : 'single-voice';
     $classes[] = 1 < $replies_count ? 'multi-replies' : 'single-reply';
     //Output
     return apply_filters('wmhook_wm_bbp_additional_class_output', $classes);
 }
		<?php 
bbp_forum_row_actions();
?>

	</li>

	<li class="bbp-forum-topic-count">
		<div><span class="number"><?php 
bbp_forum_topic_count();
?>
</span> <?php 
_ex('topics', 'bbpress', 'bunyad');
?>
</div>
		<div><?php 
echo bbp_show_lead_topic() ? '<span class="number">' . bbp_get_forum_reply_count() . '</span> ' . _x('replies', 'bbpress', 'bunyad') : '<span class="number">' . bbp_get_forum_post_count() . '</span> ' . _x('posts', 'bbpress', 'bunyad');
?>
</li>

	<li class="bbp-forum-freshness">

		<p class="bbp-topic-meta">

			<?php 
do_action('bbp_theme_before_topic_author');
?>
			

			<span class="bbp-topic-freshness-author">
			
				<?php 
Ejemplo n.º 9
0
 /**
  * @covers ::bbp_forum_post_count
  * @covers ::bbp_get_forum_post_count
  */
 public function test_bbp_get_forum_post_count()
 {
     $f = $this->factory->forum->create();
     $t = $this->factory->topic->create(array('post_parent' => $f));
     $int_value = 3;
     // Topic + Replies
     $result = 4;
     $formatted_result = bbp_number_format($result);
     $this->factory->reply->create_many($int_value, array('post_parent' => $t));
     bbp_update_forum_topic_count($f);
     bbp_update_forum_reply_count($f);
     // Output
     $count = bbp_get_forum_post_count($f, true, false);
     $this->expectOutputString($formatted_result);
     bbp_forum_post_count($f);
     // Formatted string
     $count = bbp_get_forum_post_count($f, true, false);
     $this->assertSame($formatted_result, $count);
     // Integer
     $count = bbp_get_forum_post_count($f, true, true);
     $this->assertSame($result, $count);
 }