Example #1
0
 /**
  * @covers ::bbp_topic_post_count
  * @covers ::bbp_get_topic_post_count
  */
 public function test_bbp_get_topic_post_count()
 {
     $f = $this->factory->forum->create();
     $int_topics = 1;
     $int_replies = 3;
     $int_value = $int_topics + $int_replies;
     $formatted_value = bbp_number_format($int_value);
     $t = $this->factory->topic->create(array('post_parent' => $f, 'topic_meta' => array('forum_id' => $f)));
     $this->factory->reply->create_many($int_replies, array('post_parent' => $t, 'reply_meta' => array('forum_id' => $f, 'topic_id' => $t)));
     bbp_update_topic_reply_count($t);
     // Output
     $this->expectOutputString($formatted_value);
     bbp_topic_post_count($t);
     // Formatted string
     $count = bbp_get_topic_post_count($t, false);
     $this->assertSame($formatted_value, $count);
     // Integer
     $count = bbp_get_topic_post_count($t, true);
     $this->assertSame($int_value, $count);
 }
Example #2
0
/**
 * Output total post count of a topic
 *
 * @since 2.0.0 bbPress (r2954)
 *
 * @param int $topic_id Optional. Topic id
 * @param boolean $integer Optional. Whether or not to format the result
 * @uses bbp_get_topic_post_count() To get the topic post count
 */
function bbp_topic_post_count($topic_id = 0, $integer = false)
{
    echo bbp_get_topic_post_count($topic_id, $integer);
}
>

	<div class="forum-content">
		<h3 class="forum-title">
			<a href="<?php 
bbp_topic_permalink();
?>
" title="Read <?php 
bbp_topic_title();
?>
"><?php 
bbp_topic_title();
?>
</a>
			<?php 
if (bbp_get_topic_post_count() > 1) {
    ?>
				<a class="last-reply-link" href="<?php 
    bbp_topic_last_reply_url();
    ?>
" title="Jump to the last reply">&rarr;</a>
			<?php 
}
?>
		</h3>
		<p class="forum-description">
			Started by <?php 
bbp_topic_author_link(array('type' => 'name'));
?>
		
			<?php 
			<?php 
bbp_topic_row_actions();
?>

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


	</li>

	<li class="topic-activity">
		<div class="stat"><span class="number"><?php 
bbp_topic_voice_count();
?>
</span> <?php 
_ex('Voices', 'bbPress', 'bunyad');
?>
</div>
		
		<div class="stat"><?php 
echo bbp_show_lead_topic() ? '<span class="number">' . bbp_get_topic_reply_count() . '</span> ' . _x('Replies', 'bbPress', 'bunyad') : '<span class="number">' . bbp_get_topic_post_count() . '</span> ' . _x('Posts', 'bbPress', 'bunyad');
?>
</div>
	</li>

</ul><!-- #bbp-topic-<?php 
bbp_topic_id();
?>
 -->
Example #5
0
/**
 * Output total post count of a topic
 *
 * @since bbPress (r2954)
 *
 * @param int $topic_id Optional. Topic id
 * @uses bbp_get_topic_post_count() To get the topic post count
 */
function bbp_topic_post_count($topic_id = 0)
{
    echo bbp_get_topic_post_count($topic_id);
}
 /**
  * Get the data being exported
  *
  * @access public
  * @since 1.0
  * @return array $data Data for Export
  */
 public function get_data()
 {
     $topics = get_posts(array('post_parent' => $this->forum_id, 'nopaging' => true, 'post_type' => bbp_get_topic_post_type()));
     foreach ($topics as $topic) {
         $topic_anonymous = bbp_is_topic_anonymous($topic->ID);
         if ($topic_anonymous) {
             $email = get_post_meta($topic->ID, '_bbp_anonymous_email', true);
         } else {
             $email = get_the_author_meta('email', $topic->post_author);
         }
         $data[] = array('post_type' => bbp_get_topic_post_type(), 'post_author' => $email, 'user_login' => get_the_author_meta('user_login', $topic->post_author), 'post_parent' => $topic->post_parent, 'post_content' => htmlentities($topic->post_content), 'post_title' => $topic->post_title, 'post_date_gmt' => $topic->post_date_gmt, 'post_date' => $topic->post_date, 'anonymous' => $topic_anonymous ? '1' : '0', 'voices' => bbp_get_topic_voice_count($topic->ID), 'reply_count' => bbp_get_topic_post_count($topic->ID), 'resolved' => function_exists('bbps_topic_resolved') && bbps_topic_resolved($topic->ID) ? '1' : 0);
         $replies = get_posts(array('post_parent' => $topic->ID, 'nopaging' => true, 'post_type' => bbp_get_reply_post_type()));
         if ($replies) {
             foreach ($replies as $reply) {
                 $reply_anonymous = bbp_is_reply_anonymous($reply->ID);
                 if ($reply_anonymous) {
                     $reply_email = get_post_meta($topic->ID, '_bbp_anonymous_email', true);
                 } else {
                     $reply_email = get_the_author_meta('email', $reply->post_author);
                 }
                 $data[] = array('post_type' => bbp_get_reply_post_type(), 'post_author' => $reply_email, 'user_login' => get_the_author_meta('user_login', $reply->post_author), 'post_parent' => $reply->post_parent, 'post_content' => htmlentities($reply->post_content), 'post_title' => $reply->post_title, 'post_date_gmt' => $reply->post_date_gmt, 'post_date' => $reply->post_date, 'anonymous' => $reply_anonymous ? '1' : '0', 'voices' => '0', 'reply_count' => '0', 'resolved' => '0');
             }
         }
     }
     $data = apply_filters('bbp_export_get_data', $data);
     return $data;
 }
Example #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);
 }