Esempio 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));
 }
Esempio n. 2
0
 /**
  * @covers ::bbp_forum_topic_count
  * @covers ::bbp_get_forum_topic_count
  */
 public function test_bbp_get_forum_topic_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)));
     $int_value = 3;
     $formatted_value = bbp_number_format($int_value);
     $this->factory->topic->create_many($int_value, array('post_parent' => $f));
     bbp_update_forum_topic_count($c);
     bbp_update_forum_topic_count($f);
     // Forum output.
     $count = bbp_get_forum_topic_count($f, true, false);
     $this->expectOutputString($formatted_value);
     bbp_forum_topic_count($f);
     // Forum formatted string.
     $count = bbp_get_forum_topic_count($f, true, false);
     $this->assertSame($formatted_value, $count);
     // Forum integer.
     $count = bbp_get_forum_topic_count($f, true, true);
     $this->assertSame($int_value, $count);
     // Category topic count.
     $count = bbp_get_forum_topic_count($c, false, true);
     $this->assertSame(0, $count);
     // Category total topic count.
     $count = bbp_get_forum_topic_count($c, true, true);
     $this->assertSame($int_value, $count);
 }
Esempio n. 3
0
 /**
  * @covers ::bbp_forum_topic_count
  * @covers ::bbp_get_forum_topic_count
  */
 public function test_bbp_get_forum_topic_count()
 {
     $f = $this->factory->forum->create();
     $int_value = 3;
     $formatted_value = bbp_number_format($int_value);
     $this->factory->topic->create_many($int_value, array('post_parent' => $f));
     bbp_update_forum_topic_count($f);
     // Output
     $count = bbp_get_forum_topic_count($f, true, false);
     $this->expectOutputString($formatted_value);
     bbp_forum_topic_count($f);
     // Formatted string
     $count = bbp_get_forum_topic_count($f, true, false);
     $this->assertSame($formatted_value, $count);
     // Integer
     $count = bbp_get_forum_topic_count($f, true, true);
     $this->assertSame($int_value, $count);
 }
Esempio n. 4
0
/**
 * Display nested subforums with a hierarchical structure using their parent category
 * @version 2.0
 */
function apoc_loop_subforums()
{
    // Exclude private forums
    $private = apoc_private_forum_ids();
    // Check for subforums
    $subs = bbp_forum_get_subforums(array('post__not_in' => $private));
    if (empty($subs)) {
        return;
    }
    // Buffer output
    ob_start();
    // Print a header
    ?>
	<header class="forum-header">
		<div class="forum-content"><h2><?php 
    bbp_forum_title();
    ?>
</h2></div>
		<div class="forum-count">Topics</div>
		<div class="forum-freshness">Latest Post</div>
	</header>
	<ol class="forums category <?php 
    bbp_forum_status();
    ?>
"><?php 
    // Loop over forums
    foreach ($subs as $count => $sub) {
        // Get forum details
        $sub_id = $sub->ID;
        $title = $sub->post_title;
        $desc = $sub->post_content;
        $permalink = bbp_get_forum_permalink($sub_id);
        // Get topic counts
        $topics = bbp_get_forum_topic_count($sub_id, false);
        // Get the most recent reply and its topic
        $reply_id = bbp_get_forum_last_reply_id($sub_id);
        $topic_id = bbp_is_reply($reply_id) ? bbp_get_reply_topic_id($reply_id) : $reply_id;
        $topic_title = bbp_get_topic_title($topic_id);
        $link = bbp_get_reply_url($reply_id);
        // Get the author avatar
        $user_id = bbp_get_reply_author_id($reply_id);
        $avatar = apoc_get_avatar(array('user_id' => $user_id, 'link' => true, 'size' => 50));
        // Toggle html class
        $class = $count % 2 ? 'odd' : 'even';
        // Print output
        ?>
		<li id="forum-<?php 
        echo $sub_id;
        ?>
" class="forum <?php 
        echo $class;
        ?>
">
			<div class="forum-content">
				<h3 class="forum-title"><a href="<?php 
        echo $permalink;
        ?>
" title="Browse <?php 
        echo $title;
        ?>
"><?php 
        echo $title;
        ?>
</a></h3>
				<p class="forum-description"><?php 
        echo $desc;
        ?>
</p>
			</div>

			<div class="forum-count">
				<?php 
        echo $topics;
        ?>
			</div>

			<div class="forum-freshness">
				<?php 
        echo $avatar;
        ?>
				<div class="freshest-meta">
					<a class="freshest-title" href="<?php 
        echo $link;
        ?>
" title="<?php 
        echo $topic_title;
        ?>
"><?php 
        echo $topic_title;
        ?>
</a>
					<span class="freshest-author">By <?php 
        bbp_author_link(array('post_id' => $reply_id, 'type' => 'name'));
        ?>
</span>
					<span class="freshest-time"><?php 
        bbp_topic_last_active_time($topic_id);
        ?>
</span>
				</div>
			</div>
		</li>
	<?php 
    }
    ?>
	</ol>
		
	<?php 
    // Retrieve from buffer
    $output = ob_get_contents();
    ob_end_clean();
    echo $output;
}
function td_show_forum($forum_object)
{
    $last_active = bbp_get_forum_last_active_id($forum_object->ID);
    $time_since = '';
    $last_updated_by_avatar = '';
    if (!empty($last_active)) {
        $time_since = bbp_get_forum_freshness_link($forum_object->ID);
        $last_updated_by_avatar = bbp_get_author_link(array('post_id' => $last_active, 'size' => 40, 'type' => 'avatar'));
        //echo $time_since;
    }
    ?>
    <div class="clearfix"></div>
    <ul class="td-forum-list-table td-forum-content">
        <li class="td-forum-category-title<?php 
    if (empty($forum_object->post_content)) {
        echo ' td-forum-title-no-desc';
    }
    ?>
">
            <div class="td-forum-index-padd">
                <a class="bbp-forum-title" href="<?php 
    bbp_forum_permalink($forum_object->ID);
    ?>
"><?php 
    bbp_forum_title($forum_object->ID);
    ?>
</a>
                <?php 
    if (!empty($forum_object->post_content)) {
        ?>
                    <div class="td-forum-description"><?php 
        echo $forum_object->post_content;
        ?>
</div>
                <?php 
    }
    ?>

                </li><li class="td-forum-replies">
                    <div><?php 
    echo bbp_get_forum_topic_count($forum_object->ID);
    ?>
 topics</div>
                    <div><?php 
    echo bbp_get_forum_reply_count($forum_object->ID);
    ?>
 replies</div>
                </li><li class="td-forum-last-comment">

                <div>
                    <?php 
    echo $last_updated_by_avatar;
    ?>
                </div>



                <div class="td-forum-last-comment-content">
                    <div class="td-forum-author-name">
                        by <a class="td-forum-last-author" href="<?php 
    bbp_reply_author_url($last_active);
    ?>
"><?php 
    echo bbp_get_topic_author_display_name($last_active);
    ?>
</a>
                    </div>
                    <div class="td-forum-time-comment">
                        <?php 
    bbp_forum_freshness_link($forum_object->ID);
    ?>
                    </div>
                </div>
        </li>
    </ul>
    <div class="clearfix"></div>
    <?php 
}
Esempio n. 6
0
            <span class="padding-left-20"><a class="bbp-forum-title" href="<?php 
                echo bbp_get_forum_permalink($sub_forum->ID);
                ?>
">
              <?php 
                echo get_the_post_thumbnail($sub_forum->ID, array(70, 70));
                ?>
              <span><?php 
                echo bbp_get_forum_title($sub_forum->ID);
                ?>
</span>
            </a></span>
          </li>

          <li class="bbp-forum-topic-count"><?php 
                echo bbp_get_forum_topic_count($sub_forum->ID);
                ?>
</li>
          <li class="bbp-forum-reply-count"><?php 
                echo bbp_get_forum_reply_count($sub_forum->ID);
                ?>
</li>
          <li class="bbp-forum-freshness">

            <div class="author-avatar">
              <?php 
                $last_reply_avatar = bbp_get_reply_author_avatar(bbp_get_forum_last_reply_id($sub_forum->ID), 50);
                if ($last_reply_avatar != '') {
                    echo $last_reply_avatar;
                } else {
                    echo bbp_get_topic_author_avatar($sub_forum->ID, 50);
Esempio n. 7
0
 /**
  * @covers ::bbp_move_topic_handler
  */
 public function test_bbp_move_topic_handler()
 {
     $old_current_user = 0;
     $this->old_current_user = get_current_user_id();
     $this->set_current_user($this->factory->user->create(array('role' => 'administrator')));
     $this->keymaster_id = get_current_user_id();
     bbp_set_user_role($this->keymaster_id, bbp_get_keymaster_role());
     $old_forum_id = $this->factory->forum->create();
     $topic_id = $this->factory->topic->create(array('post_parent' => $old_forum_id, 'topic_meta' => array('forum_id' => $old_forum_id)));
     $reply_id = $this->factory->reply->create(array('post_parent' => $topic_id, 'reply_meta' => array('forum_id' => $old_forum_id, 'topic_id' => $topic_id)));
     // Topic post parent
     $topic_parent = wp_get_post_parent_id($topic_id);
     $this->assertSame($old_forum_id, $topic_parent);
     // Forum meta
     $this->assertSame(1, bbp_get_forum_topic_count($old_forum_id, true, true));
     $this->assertSame(1, bbp_get_forum_reply_count($old_forum_id, true, true));
     $this->assertSame($topic_id, bbp_get_forum_last_topic_id($old_forum_id));
     $this->assertSame($reply_id, bbp_get_forum_last_reply_id($old_forum_id));
     $this->assertSame($reply_id, bbp_get_forum_last_active_id($old_forum_id));
     // Topic meta
     $this->assertSame($old_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($reply_id, bbp_get_topic_last_reply_id($topic_id));
     $this->assertSame($reply_id, bbp_get_topic_last_active_id($topic_id));
     // Reply Meta
     $this->assertSame($old_forum_id, bbp_get_reply_forum_id($reply_id));
     $this->assertSame($topic_id, bbp_get_reply_topic_id($reply_id));
     // Create a new forum
     $new_forum_id = $this->factory->forum->create();
     // Move the topic into the new forum
     bbp_move_topic_handler($topic_id, $old_forum_id, $new_forum_id);
     // Topic post parent
     $topic_parent = wp_get_post_parent_id($topic_id);
     $this->assertSame($new_forum_id, $topic_parent);
     // Forum meta
     $this->assertSame(1, bbp_get_forum_topic_count($new_forum_id, true, true));
     $this->assertSame(1, bbp_get_forum_reply_count($new_forum_id, true, true));
     $this->assertSame($topic_id, bbp_get_forum_last_topic_id($new_forum_id));
     $this->assertSame($reply_id, bbp_get_forum_last_reply_id($new_forum_id));
     $this->assertSame($reply_id, bbp_get_forum_last_active_id($new_forum_id));
     // Topic meta
     $this->assertSame($new_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($reply_id, bbp_get_topic_last_reply_id($topic_id));
     $this->assertSame($reply_id, bbp_get_topic_last_active_id($topic_id));
     // Reply Meta
     $this->assertSame($new_forum_id, bbp_get_reply_forum_id($reply_id));
     $this->assertSame($topic_id, bbp_get_reply_topic_id($reply_id));
     // Retore the user
     $this->set_current_user($this->old_current_user);
 }
Esempio n. 8
0
 /**
  * @covers ::bbp_unspam_topic
  */
 public function test_bbp_unspam_topic()
 {
     $f = $this->factory->forum->create();
     $now = time();
     $post_date_topic = date('Y-m-d H:i:s', $now - 60 * 60 * 100);
     $post_date_reply = date('Y-m-d H:i:s', $now - 60 * 60 * 80);
     $topic_time = '4 days, 4 hours ago';
     $reply_time = '3 days, 8 hours ago';
     $t = $this->factory->topic->create(array('post_parent' => $f, 'post_date' => $post_date_topic, 'topic_meta' => array('forum_id' => $f)));
     $r = $this->factory->reply->create_many(2, array('post_parent' => $t, 'post_date' => $post_date_reply, 'reply_meta' => array('forum_id' => $f, 'topic_id' => $t)));
     bbp_spam_topic($t);
     bbp_unspam_topic($t);
     $topic_status = get_post_status($t);
     $this->assertSame(bbp_get_public_status_id(), $topic_status);
     $this->assertEquals('', get_post_meta($t, '_bbp_pre_spammed_replies', true));
     $this->assertEquals(array(), get_post_meta($t, '_bbp_pre_spammed_replies', false));
     $this->assertEquals('', get_post_meta($t, '_bbp_spam_meta_status', true));
     $this->assertEquals(array(), get_post_meta($t, '_bbp_spam_meta_status', false));
     $count = bbp_get_forum_topic_count($f, false, true);
     $this->assertSame(1, $count);
     $count = bbp_get_forum_topic_count_hidden($f, true);
     $this->assertSame(0, $count);
     $count = bbp_get_forum_reply_count($f, false, true);
     $this->assertSame(2, $count);
     $last_topic_id = bbp_get_forum_last_topic_id($f);
     $this->assertSame($t, $last_topic_id);
     $last_reply_id = bbp_get_forum_last_reply_id($f);
     $this->assertSame($r[1], $last_reply_id);
     $last_active_id = bbp_get_forum_last_active_id($f);
     $this->assertSame($r[1], $last_active_id);
     $last_active_time = bbp_get_forum_last_active_time($f);
     $this->assertSame($reply_time, $last_active_time);
     $count = bbp_get_topic_reply_count($t, true, true);
     $this->assertSame(2, $count);
     $count = bbp_get_topic_reply_count_hidden($t, true, true);
     $this->assertSame(0, $count);
     $last_reply_id = bbp_get_topic_last_reply_id($t);
     $this->assertSame($r[1], $last_reply_id);
     $last_active_id = bbp_get_topic_last_active_id($t);
     $this->assertSame($r[1], $last_active_id);
     $last_active_time = bbp_get_topic_last_active_time($t);
     $this->assertSame($reply_time, $last_active_time);
 }
function custom_list_forums($args = '')
{
    // Define used variables
    global $rpg_settingsg;
    global $rpg_settingsf;
    $output = $sub_forums = $topic_count = $reply_count = $counts = '';
    $i = 0;
    $count = array();
    // Parse arguments against default values
    $r = bbp_parse_args($args, array('before' => '<ul class="bbp-forums-list">', 'after' => '</ul>', 'link_before' => '<li class="bbp-forum">', 'link_after' => '</li>', 'count_before' => ' (', 'count_after' => ')', 'count_sep' => ', ', 'separator' => '<br> ', 'forum_id' => '', 'show_topic_count' => true, 'show_reply_count' => true), 'listb_forums');
    // Loop through forums and create a list
    $sub_forums = bbp_forum_get_subforums($r['forum_id']);
    if (!empty($sub_forums)) {
        // Total count (for separator)
        $total_subs = count($sub_forums);
        foreach ($sub_forums as $sub_forum) {
            $i++;
            // Separator count
            // Get forum details
            $count = array();
            $show_sep = $total_subs > $i ? $r['separator'] : '';
            $permalink = bbp_get_forum_permalink($sub_forum->ID);
            $title = bbp_get_forum_title($sub_forum->ID);
            $content = bbp_get_forum_content($sub_forum->ID);
            if ($rpg_settingsg['activate_descriptions'] == true) {
                $content = bbp_get_forum_content($sub_forum->ID);
            } else {
                $content = '';
            }
            // Show topic count
            if (!empty($r['show_topic_count']) && !bbp_is_forum_category($sub_forum->ID)) {
                $count['topic'] = bbp_get_forum_topic_count($sub_forum->ID);
            }
            // Show reply count
            if (!empty($r['show_reply_count']) && !bbp_is_forum_category($sub_forum->ID)) {
                $count['reply'] = bbp_get_forum_reply_count($sub_forum->ID);
            }
            // Counts to show
            if (!empty($count)) {
                $counts = $r['count_before'] . implode($r['count_sep'], $count) . $r['count_after'];
            }
            if ($rpg_settingsg['hide_counts'] == true) {
                $counts = '';
            }
            //Build this sub forums link
            if (bbp_is_forum_private($sub_forum->ID)) {
                if (!current_user_can('read_private_forums')) {
                    if (!$rpg_settingsf['redirect_page']) {
                        $link = '/home';
                    } else {
                        $link = $rpg_settingsf['redirect_page'];
                    }
                    $output .= $r['before'] . $r['link_before'] . '<a href="' . $link . '" class="bbp-forum-link">' . $title . $counts . '</a>' . $show_sep . $r['link_after'] . '<div class="bbp-forum-content">' . $content . '</div>' . $r['after'];
                } else {
                    $output .= $r['before'] . $r['link_before'] . '<a href="' . esc_url($permalink) . '" class="bbp-forum-link">' . $title . $counts . '</a>' . $show_sep . $r['link_after'] . '<div class="bbp-forum-content">' . $content . '</div>' . $r['after'];
                }
            } else {
                $output .= $r['before'] . $r['link_before'] . '<a href="' . esc_url($permalink) . '" class="bbp-forum-link">' . $title . $counts . '</a>' . $show_sep . $r['link_after'] . '<div class="bbp-forum-content">' . $content . '</div>' . $r['after'];
            }
        }
        //Output the list
        return $output;
    }
}
Esempio n. 10
0
    <?php 
        if (isset($_REQUEST['orderby']) && $_REQUEST['orderby'] && $_REQUEST['orderby'] == 'most_votes') {
            echo 'class="order-active"';
        }
        ?>
    >Most Votes</a>
  <?php 
    }
}
?>
<div id="bbp-forum-<?php 
bbp_forum_id();
?>
" class="bbp-topics">
<?php 
if (bbp_get_forum_topic_count() > 0) {
    $bbp_loop_args = array('meta_key' => '_bbp_last_active_time', 'orderby' => 'meta_value', 'order' => 'DESC');
    if (isset($_REQUEST['order']) && $_REQUEST['order']) {
        if ($_REQUEST['order'] == 'ASC') {
            $bbp_loop_args['order'] = 'ASC';
        } else {
            $bbp_loop_args['order'] = 'DESC';
        }
    }
    if (isset($_REQUEST['orderby']) && $_REQUEST['orderby']) {
        if ($_REQUEST['orderby'] == 'most_replies') {
            $bbp_loop_args['meta_key'] = '_bbp_reply_count';
            $bbp_loop_args['orderby'] = 'meta_value_num';
        }
    }
    if (isset($_REQUEST['orderby']) && $_REQUEST['orderby']) {
" title="<?php 
    bbp_forum_title();
    ?>
"><?php 
    bbp_forum_title();
    ?>
</a>
			<?php 
    the_content();
    ?>
		</div>

		<div class="bbp-forum-topic-count">

			<i class="fa fa-list-ul"></i><?php 
    echo bbp_get_forum_topic_count(bbp_get_forum_id());
    ?>
<br />
			<i class="fa fa-comments-o"></i><?php 
    echo bbp_get_forum_reply_count(bbp_get_forum_id());
    ?>
		</div>

	<?php 
}
?>

		<?php 
do_action('bbp_theme_before_forum_sub_forums');
nice_bbp_list_forums(array('before' => '<ul class="bbp-forums-list">', 'after' => '</ul>', 'link_before' => '<li class="bbp-forum">', 'link_after' => '</li>', 'count_before' => '<div class="topic-reply-counts"><i class="fa fa-list-ul"></i>', 'count_after' => '</div>', 'count_sep' => '<br /><i class="fa fa-comments-o"></i>', 'separator' => '<div style="clear:both;"></div>', 'forum_id' => '', 'show_topic_count' => true, 'show_reply_count' => true, 'show_freshness_link' => false));
do_action('bbp_theme_after_forum_sub_forums');
Esempio n. 12
0
/**
 * Return a fancy description of the current forum, including total
 * topics, total replies, and last activity.
 *
 * @since Boss 1.0.0
 *
 * @param mixed $args This function supports these arguments:
 *  - forum_id: Forum id
 *  - before: Before the text
 *  - after: After the text
 *  - size: Size of the avatar
 * @uses bbp_get_forum_id() To get the forum id
 * @uses bbp_get_forum_topic_count() To get the forum topic count
 * @uses bbp_get_forum_reply_count() To get the forum reply count
 * @uses bbp_get_forum_freshness_link() To get the forum freshness link
 * @uses bbp_get_forum_last_active_id() To get the forum last active id
 * @uses bbp_get_author_link() To get the author link
 * @uses add_filter() To add the 'view all' filter back
 * @uses apply_filters() Calls 'bbp_get_single_forum_description' with
 *                        the description and args
 * @return string Filtered forum description
 */
function buddyboss_bbp_get_single_forum_description($args = '')
{
    // Parse arguments against default values
    $r = bbp_parse_args($args, array('forum_id' => 0, 'before' => '<div class="bbp-template-notice info"><p class="bbp-forum-description">', 'after' => '</p></div>', 'size' => 14, 'feed' => true), 'get_single_forum_description');
    // Validate forum_id
    $forum_id = bbp_get_forum_id($r['forum_id']);
    // Unhook the 'view all' query var adder
    remove_filter('bbp_get_forum_permalink', 'bbp_add_view_all');
    // Get some forum data
    $tc_int = bbp_get_forum_topic_count($forum_id, false);
    $rc_int = bbp_get_forum_reply_count($forum_id, false);
    $topic_count = bbp_get_forum_topic_count($forum_id);
    $reply_count = bbp_get_forum_reply_count($forum_id);
    $last_active = bbp_get_forum_last_active_id($forum_id);
    // Has replies
    if (!empty($reply_count)) {
        $reply_text = sprintf(_n('%s reply', '%s replies', $rc_int, 'boss'), $reply_count);
    }
    // Forum has active data
    if (!empty($last_active)) {
        $topic_text = bbp_get_forum_topics_link($forum_id);
        $time_since = bbp_get_forum_freshness_link($forum_id);
        $last_updated_by = bbp_get_author_link(array('post_id' => $last_active, 'size' => $r['size']));
        // Forum has no last active data
    } else {
        $topic_text = sprintf(_n('%s topic', '%s topics', $tc_int, 'boss'), $topic_count);
    }
    // Forum has active data
    if (!empty($last_active)) {
        if (!empty($reply_count)) {
            if (bbp_is_forum_category($forum_id)) {
                $retstr = sprintf(__('<span class="post-num">%1$s and %2$s</span> <span class="last-activity">Last updated by %3$s %4$s</span>', 'boss'), $topic_text, $reply_text, $last_updated_by, $time_since);
            } else {
                $retstr = sprintf(__('<span class="post-num">%1$s and %2$s</span> <span class="last-activity">Last updated by %3$s %4$s<span>', 'boss'), $topic_text, $reply_text, $last_updated_by, $time_since);
            }
        } else {
            if (bbp_is_forum_category($forum_id)) {
                $retstr = sprintf(__('<span class="post-num">%1$s</span> <span class="last-activity">Last updated by %2$s %3$s</span>', 'boss'), $topic_text, $last_updated_by, $time_since);
            } else {
                $retstr = sprintf(__('<span class="post-num">%1$s</span> <span class="last-activity">Last updated by %2$s %3$s</span>', 'boss'), $topic_text, $last_updated_by, $time_since);
            }
        }
        // Forum has no last active data
    } else {
        if (!empty($reply_count)) {
            if (bbp_is_forum_category($forum_id)) {
                $retstr = sprintf(__('<span class="post-num">%1$s and %2$s</span>', 'boss'), $topic_text, $reply_text);
            } else {
                $retstr = sprintf(__('<span class="post-num">%1$s and %2$s</span>', 'boss'), $topic_text, $reply_text);
            }
        } else {
            if (!empty($topic_count)) {
                if (bbp_is_forum_category($forum_id)) {
                    $retstr = sprintf(__('<span class="post-num">%1$s</span>', 'boss'), $topic_text);
                } else {
                    $retstr = sprintf(__('<span class="post-num">%1$s</span>', 'boss'), $topic_text);
                }
            } else {
                $retstr = __('<span class="post-num">0 topics and 0 posts</span>', 'boss');
            }
        }
    }
    // Add feeds
    //$feed_links = ( !empty( $r['feed'] ) ) ? bbp_get_forum_topics_feed_link ( $forum_id ) . bbp_get_forum_replies_feed_link( $forum_id ) : '';
    // Add the 'view all' filter back
    add_filter('bbp_get_forum_permalink', 'bbp_add_view_all');
    // Combine the elements together
    $retstr = $r['before'] . $retstr . $r['after'];
    // Return filtered result
    return apply_filters('bbp_get_single_forum_description', $retstr, $r);
}
Esempio n. 13
0
		<?php 
do_action('bbp_theme_after_topic_freshness_link');
?>

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

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

			<span class="bbp-topic-freshness-author"><?php 
bbp_author_link(array('post_id' => bbp_get_topic_last_active_id(), 'size' => 40));
?>
            <?php 
$count_tp = bbp_get_forum_topic_count();
$class_tp = '';
if ($count_tp != 0) {
    $class_tp = 'date-post';
}
?>
            <div class="<?php 
echo $class_tp;
?>
"><?php 
bbp_topic_freshness_link();
?>
</div>
            </span>

			<?php 
Esempio n. 14
0
 /**
  * @covers ::bbp_update_forum_topic_count_hidden
  */
 public function test_bbp_update_forum_topic_count_hidden()
 {
     $f = $this->factory->forum->create();
     $count = bbp_get_forum_topic_count($f, false, true);
     $this->assertSame(0, $count);
     $t = $this->factory->topic->create_many(3, array('post_parent' => $f, 'topic_meta' => array('forum_id' => $f)));
     bbp_update_forum_topic_count_hidden($f);
     $count = bbp_get_forum_topic_count_hidden($f, true);
     $this->assertSame(0, $count);
     bbp_spam_topic($t[2]);
     bbp_update_forum_topic_count_hidden($f);
     $count = bbp_get_forum_topic_count_hidden($f, true);
     $this->assertSame(1, $count);
     bbp_unapprove_topic($t[0]);
     bbp_update_forum_topic_count_hidden($f);
     $count = bbp_get_forum_topic_count_hidden($f, true);
     $this->assertSame(2, $count);
 }
Esempio n. 15
0
 /**
  * @covers ::bbp_admin_repair_forum_topic_count
  */
 public function test_bbp_admin_repair_forum_topic_count()
 {
     $c = $this->factory->forum->create(array('forum_meta' => array('forum_type' => 'category', 'status' => 'open')));
     $f = $this->factory->forum->create(array('post_parent' => $c, 'forum_meta' => array('forum_id' => $c, 'forum_type' => 'forum', 'status' => 'open')));
     $t = $this->factory->topic->create(array('post_parent' => $f, 'topic_meta' => array('forum_id' => $f)));
     $count = bbp_get_forum_topic_count($f, true, true);
     $this->assertSame(1, $count);
     $t = $this->factory->topic->create_many(3, array('post_parent' => $f, 'topic_meta' => array('forum_id' => $f)));
     bbp_update_forum_topic_count($c);
     bbp_update_forum_topic_count($f);
     // Category topic count.
     $count = bbp_get_forum_topic_count($c, false, true);
     $this->assertSame(0, $count);
     // Category total topic count.
     $count = bbp_get_forum_topic_count($c, true, true);
     $this->assertSame(4, $count);
     // Category topic count hidden.
     $count = bbp_get_forum_topic_count_hidden($c, true);
     $this->assertSame(0, $count);
     // Forum topic count.
     $count = bbp_get_forum_topic_count($f, false, true);
     $this->assertSame(4, $count);
     // Forum total topic count.
     $count = bbp_get_forum_topic_count($f, true, true);
     $this->assertSame(4, $count);
     // Forum topic count hidden.
     $count = bbp_get_forum_topic_count_hidden($f, true);
     $this->assertSame(0, $count);
     bbp_spam_topic($t[0]);
     bbp_unapprove_topic($t[2]);
     // Category topic count.
     $count = bbp_get_forum_topic_count($c, false, true);
     $this->assertSame(0, $count);
     // Category total topic count.
     $count = bbp_get_forum_topic_count($c, true, true);
     $this->assertSame(2, $count);
     // Category topic count hidden.
     $count = bbp_get_forum_topic_count_hidden($c, true);
     $this->assertSame(0, $count);
     // Forum topic count.
     $count = bbp_get_forum_topic_count($f, false, true);
     $this->assertSame(2, $count);
     // Forum total topic count.
     $count = bbp_get_forum_topic_count($f, true, true);
     $this->assertSame(2, $count);
     // Forum topic count hidden.
     $count = bbp_get_forum_topic_count_hidden($f, true);
     $this->assertSame(2, $count);
     // Delete the _bbp_total_topic_count meta key.
     $this->assertTrue(delete_post_meta_by_key('_bbp_topic_count_hidden'));
     // Delete the _bbp_total_topic_count meta key.
     $this->assertTrue(delete_post_meta_by_key('_bbp_total_topic_count'));
     // Delete the  _bbp_topic_count meta key.
     $this->assertTrue(delete_post_meta_by_key('_bbp_topic_count'));
     // Category topic count.
     $count = bbp_get_forum_topic_count($c, false, true);
     $this->assertSame(0, $count);
     // Category total topic count.
     $count = bbp_get_forum_topic_count($c, true, true);
     $this->assertSame(0, $count);
     // Category topic count hidden.
     $count = bbp_get_forum_topic_count_hidden($c, true);
     $this->assertSame(0, $count);
     // Forum topic count.
     $count = bbp_get_forum_topic_count($f, false, true);
     $this->assertSame(0, $count);
     // Forum total topic count.
     $count = bbp_get_forum_topic_count($f, true, true);
     $this->assertSame(0, $count);
     // Forum topic count hidden.
     $count = bbp_get_forum_topic_count_hidden($f, true);
     $this->assertSame(0, $count);
     // Repair the forum topic count meta.
     bbp_admin_repair_forum_topic_count();
     // Category topic count.
     $count = bbp_get_forum_topic_count($c, false, true);
     $this->assertSame(0, $count);
     // Category total topic count.
     $count = bbp_get_forum_topic_count($c, true, true);
     $this->assertSame(2, $count);
     // Category topic count hidden.
     $count = bbp_get_forum_topic_count_hidden($c, true);
     $this->assertSame(0, $count);
     // Forum topic count.
     $count = bbp_get_forum_topic_count($f, false, true);
     $this->assertSame(2, $count);
     // Forum total topic count.
     $count = bbp_get_forum_topic_count($f, true, true);
     $this->assertSame(2, $count);
     // Forum topic count hidden.
     $count = bbp_get_forum_topic_count_hidden($f, true);
     $this->assertSame(2, $count);
 }
Esempio n. 16
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));
 }
Esempio n. 17
0
 function wm_bbp_post_custom_metas($empty, $meta, $args)
 {
     //Requirements check
     if (!in_array($meta, array('forum-update', 'forum-replies', 'forum-topics'))) {
         return $empty;
     }
     //Helper variables
     $meta_output = $output = $title = '';
     if ('forum-update' === $meta) {
         $title = __('Last update', 'mustang');
         $meta_output = bbp_get_forum_freshness_link($args['post_id']);
     } elseif ('forum-topics' === $meta) {
         $title = __('Topics count', 'mustang');
         $meta_output = bbp_get_forum_topic_count($args['post_id']);
     } elseif ('forum-replies' === $meta) {
         $title = __('Replies count', 'mustang');
         $meta_output = bbp_get_forum_reply_count($args['post_id']);
     }
     //Add new meta
     $replacements = array('{attributes}' => ' title="' . $title . '"', '{class}' => 'entry-' . $meta . ' entry-meta-element', '{content}' => $meta_output);
     $replacements = apply_filters('wmhook_wm_bbp_post_custom_metas_replacements_' . $meta, $replacements);
     if (isset($args['html_custom'][$meta])) {
         $output .= strtr($args['html_custom'][$meta], $replacements);
     } else {
         $output .= strtr($args['html'], $replacements);
     }
     //Output
     return apply_filters('wmhook_wm_bbp_post_custom_metas_output', $empty . $output, $meta);
 }
function st_get_last_poster_block($subforum_id = "")
{
    if (!empty($subforum_id)) {
        // Main forum display with sub forums
        $st_forum_topic_count_two = bbp_get_forum_topic_count($subforum_id);
        if ($st_forum_topic_count_two == 0) {
            $output = "<div class='last-posted-topic-title no-topics'>";
            $output .= "No Topics";
        } else {
            $output = "<div class='last-posted-topic-title'>";
            // Get and crop title lenth if needed
            $st_topic_last_reply_title = bbp_get_topic_last_reply_title(bbp_get_forum_last_active_id($subforum_id));
            $st_topic_last_reply_title_print = strlen($st_topic_last_reply_title) > 50 ? substr($st_topic_last_reply_title, 0, 53) . '&hellip;' : $st_topic_last_reply_title;
            $output .= "<a href='" . bbp_get_forum_last_topic_permalink($subforum_id) . "'>" . $st_topic_last_reply_title_print . "</a>";
            $output .= "</div>";
            $output .= "<div class='last-posted-topic-time'>";
            $output .= bbp_get_forum_last_active_time($subforum_id);
        }
        $output .= "</div>";
    } else {
        // forum category display (no sub forums list)
        $st_forum_topic_count = bbp_get_forum_topic_count();
        if ($st_forum_topic_count == 0) {
            $output = "<div class='last-posted-topic-title no-topics'>";
            $output .= "No Topics";
        } else {
            $output = "<div class='last-posted-topic-title'>";
            // Get and crop title lenth if needed
            $st_topic_last_reply_title = bbp_get_topic_last_reply_title(bbp_get_forum_last_active_id($subforum_id));
            $st_topic_last_reply_title_print = strlen($st_topic_last_reply_title) > 50 ? substr($st_topic_last_reply_title, 0, 53) . '&hellip;' : $st_topic_last_reply_title;
            $output .= "<a href='" . bbp_get_forum_last_topic_permalink() . "'>" . $st_topic_last_reply_title_print . "</a>";
            $output .= "</div>";
            $output .= "<div class='last-posted-topic-time'>";
            $output .= bbp_get_forum_last_active_time();
        }
        $output .= "</div>";
    }
    return $output;
}
function nice_bbp_list_forums($args = '')
{
    // Define used variables
    $output = $sub_forums = $topic_count = $reply_count = $counts = '';
    $i = 0;
    $count = array();
    // Defaults and arguments
    $defaults = array('before' => '<ul class="bbp-forums-list">', 'after' => '</ul>', 'link_before' => '<li class="bbp-forum">', 'link_after' => '</li>', 'count_before' => ' (', 'count_after' => ')', 'count_sep' => ', ', 'separator' => ', ', 'forum_id' => '', 'show_topic_count' => true, 'show_reply_count' => true, 'show_freshness_link' => true);
    $r = bbp_parse_args($args, $defaults, 'list_forums');
    extract($r, EXTR_SKIP);
    // Bail if there are no subforums
    if (!bbp_get_forum_subforum_count($forum_id)) {
        return;
    }
    // Loop through forums and create a list
    $sub_forums = bbp_forum_get_subforums($forum_id);
    if (!empty($sub_forums)) {
        // Total count (for separator)
        $total_subs = count($sub_forums);
        foreach ($sub_forums as $sub_forum) {
            $i++;
            // Separator count
            // Get forum details
            $count = array();
            $show_sep = $total_subs > $i ? $separator : '';
            $permalink = bbp_get_forum_permalink($sub_forum->ID);
            $title = bbp_get_forum_title($sub_forum->ID);
            $description = bbp_get_forum_content($sub_forum->ID);
            // Show topic count
            if (!empty($show_topic_count) && !bbp_is_forum_category($sub_forum->ID)) {
                $count['topic'] = bbp_get_forum_topic_count($sub_forum->ID);
            }
            // Show reply count
            if (!empty($show_reply_count) && !bbp_is_forum_category($sub_forum->ID)) {
                $count['reply'] = bbp_get_forum_reply_count($sub_forum->ID);
            }
            // Counts to show
            if (!empty($count)) {
                $counts = $count_before . implode($count_sep, $count) . $count_after;
            }
            // Build this sub forums link
            if ($i % 2) {
                $class = "odd-forum-row";
            } else {
                $class = "even-forum-row";
            }
            $output .= "<li class='{$class}'><ul>" . $link_before . '<div class="bbp-forum-title-container"><h4><a href="' . $permalink . '" class="bbp-forum-link">' . $title . '</a></h4><p class="bbp-forum-description">' . $description . '</p></div>' . $counts . $link_after . "</ul></li>";
        }
        // Output the list
        echo apply_filters('bbp_list_forums', $before . $output . $after, $args);
    }
}
Esempio n. 20
0
/**
 * Return a fancy description of the current forum, including total
 * topics, total replies, and last activity.
 *
 * @since bbPress (r2860)
 *
 * @param mixed $args This function supports these arguments:
 *  - forum_id: Forum id
 *  - before: Before the text
 *  - after: After the text
 *  - size: Size of the avatar
 * @uses bbp_get_forum_id() To get the forum id
 * @uses bbp_get_forum_topic_count() To get the forum topic count
 * @uses bbp_get_forum_reply_count() To get the forum reply count
 * @uses bbp_get_forum_subforum_count() To get the forum subforum count
 * @uses bbp_get_forum_freshness_link() To get the forum freshness link
 * @uses bbp_get_forum_last_active_id() To get the forum last active id
 * @uses bbp_get_author_link() To get the author link
 * @uses add_filter() To add the 'view all' filter back
 * @uses apply_filters() Calls 'bbp_get_single_forum_description' with
 *                        the description and args
 * @return string Filtered forum description
 */
function bbp_get_single_forum_description($args = '')
{
    // Default arguments
    $defaults = array('forum_id' => 0, 'before' => '<div class="bbp-template-notice info"><p class="bbp-forum-description">', 'after' => '</p></div>', 'size' => 14, 'feed' => true);
    $r = bbp_parse_args($args, $defaults, 'get_single_forum_description');
    extract($r);
    // Validate forum_id
    $forum_id = bbp_get_forum_id($forum_id);
    // Unhook the 'view all' query var adder
    remove_filter('bbp_get_forum_permalink', 'bbp_add_view_all');
    // Get some forum data
    $topic_count = bbp_get_forum_topic_count($forum_id);
    $reply_count = bbp_get_forum_reply_count($forum_id);
    $last_active = bbp_get_forum_last_active_id($forum_id);
    // Has replies
    if (!empty($reply_count)) {
        $reply_text = sprintf(_n('%s reply', '%s replies', $reply_count, 'bbpress'), $reply_count);
    }
    // Forum has active data
    if (!empty($last_active)) {
        $topic_text = bbp_get_forum_topics_link($forum_id);
        $time_since = bbp_get_forum_freshness_link($forum_id);
        $last_updated_by = bbp_get_author_link(array('post_id' => $last_active, 'size' => $size));
        // Forum has no last active data
    } else {
        $topic_text = sprintf(_n('%s topic', '%s topics', $topic_count, 'bbpress'), $topic_count);
    }
    // Forum has active data
    if (!empty($last_active)) {
        if (!empty($reply_count)) {
            if (bbp_is_forum_category($forum_id)) {
                $retstr = sprintf(__('This category contains %1$s and %2$s, and was last updated by %3$s %4$s.', 'bbpress'), $topic_text, $reply_text, $last_updated_by, $time_since);
            } else {
                $retstr = sprintf(__('This forum contains %1$s and %2$s, and was last updated by %3$s %4$s.', 'bbpress'), $topic_text, $reply_text, $last_updated_by, $time_since);
            }
        } else {
            if (bbp_is_forum_category($forum_id)) {
                $retstr = sprintf(__('This category contains %1$s, and was last updated by %2$s %3$s.', 'bbpress'), $topic_text, $last_updated_by, $time_since);
            } else {
                $retstr = sprintf(__('This forum contains %1$s, and was last updated by %2$s %3$s.', 'bbpress'), $topic_text, $last_updated_by, $time_since);
            }
        }
        // Forum has no last active data
    } else {
        if (!empty($reply_count)) {
            if (bbp_is_forum_category($forum_id)) {
                $retstr = sprintf(__('This category contains %1$s and %2$s.', 'bbpress'), $topic_text, $reply_text);
            } else {
                $retstr = sprintf(__('This forum contains %1$s and %2$s.', 'bbpress'), $topic_text, $reply_text);
            }
        } else {
            if (!empty($topic_count)) {
                if (bbp_is_forum_category($forum_id)) {
                    $retstr = sprintf(__('This category contains %1$s.', 'bbpress'), $topic_text);
                } else {
                    $retstr = sprintf(__('This forum contains %1$s.', 'bbpress'), $topic_text);
                }
            } else {
                $retstr = __('This forum is empty.', 'bbpress');
            }
        }
    }
    // Add feeds
    //$feed_links = ( !empty( $feed ) ) ? bbp_get_forum_topics_feed_link ( $forum_id ) . bbp_get_forum_replies_feed_link( $forum_id ) : '';
    // Add the 'view all' filter back
    add_filter('bbp_get_forum_permalink', 'bbp_add_view_all');
    // Combine the elements together
    $retstr = $before . $retstr . $after;
    // Return filtered result
    return apply_filters('bbp_get_single_forum_description', $retstr, $args);
}
Esempio n. 21
0
		<?php 
		// Buffer output
		ob_start();
		
			// Loop over forums
		foreach ( $subs as $count => $sub ) :

				// Get forum details
			$sub_id			= $sub->ID;
			$title			= $sub->post_title;
			$desc			= $sub->post_content;
			$permalink		= bbp_get_forum_permalink( $sub_id );

					// Get topic counts
			$topics	 		= bbp_get_forum_topic_count( $sub_id , true );

					// Get the most recent reply and its topic
			$reply_id		= bbp_get_forum_last_reply_id( $sub_id );
			$topic_id		= bbp_is_reply( $reply_id ) ? bbp_get_reply_topic_id( $reply_id ) : $reply_id;
			$topic_title	= bbp_get_topic_title( $topic_id );
			$link 			= bbp_get_reply_url( $reply_id );

					// Get the author 
			$user_id 		= bbp_get_reply_author_id( $reply_id );

					// Toggle html class?>

			<tr>
				<td><a class="bbp-forum-title" href="<?php echo $permalink; ?>"><?php echo $title; ?></a></td>
				<td><?php echo $topics; ?></td>
Esempio n. 22
0
/**
 * Bump the total topic count of a forum
 *
 * @since bbPress (r3825)
 *
 * @param int $forum_id Optional. Forum id.
 * @param int $difference Optional. Default 1
 * @param bool $update_ancestors Optional. Default true
 * @uses bbp_get_forum_id() To get the forum id
 * @uses update_post_meta() To update the forum's topic count meta
 * @uses apply_filters() Calls 'bbp_bump_forum_topic_count' with the topic
 *                        count, forum id, and difference
 * @return int Forum topic count
 */
function bbp_bump_forum_topic_count($forum_id = 0, $difference = 1, $update_ancestors = true)
{
    // Get some counts
    $forum_id = bbp_get_forum_id($forum_id);
    $topic_count = bbp_get_forum_topic_count($forum_id, false, true);
    $total_topic_count = bbp_get_forum_topic_count($forum_id, true, true);
    // Update this forum id
    update_post_meta($forum_id, '_bbp_topic_count', (int) $topic_count + (int) $difference);
    update_post_meta($forum_id, '_bbp_total_topic_count', (int) $total_topic_count + (int) $difference);
    // Check for ancestors
    if (true === $update_ancestors) {
        // Get post ancestors
        $forum = get_post($forum_id);
        $ancestors = get_post_ancestors($forum);
        // If has ancestors, loop through them...
        if (!empty($ancestors)) {
            foreach ((array) $ancestors as $parent_forum_id) {
                // Get forum counts
                $parent_topic_count = bbp_get_forum_topic_count($parent_forum_id, false, true);
                $parent_total_topic_count = bbp_get_forum_topic_count($parent_forum_id, true, true);
                // Update counts
                update_post_meta($parent_forum_id, '_bbp_topic_count', (int) $parent_topic_count + (int) $difference);
                update_post_meta($parent_forum_id, '_bbp_total_topic_count', (int) $parent_total_topic_count + (int) $difference);
            }
        }
    }
    return (int) apply_filters('bbp_bump_forum_topic_count', (int) $total_topic_count + (int) $difference, $forum_id, (int) $difference, (bool) $update_ancestors);
}
Esempio n. 23
0
/**
 * Bump the total topic count of a forum
 *
 * @since 2.1.0 bbPress (r3825)
 *
 * @param int $forum_id Optional. Forum id.
 * @param int $difference Optional. Default 1
 * @param bool $update_ancestors Optional. Default true
 * @uses bbp_get_forum_id() To get the forum id
 * @uses update_post_meta() To update the forum's topic count meta
 * @uses apply_filters() Calls 'bbp_bump_forum_topic_count' with the topic
 *                        count, forum id, and difference
 * @return int Forum topic count
 */
function bbp_bump_forum_topic_count($forum_id = 0, $difference = 1, $update_ancestors = true)
{
    // Bail if no bump
    if (empty($difference)) {
        return false;
    }
    // Get some counts
    $forum_id = bbp_get_forum_id($forum_id);
    $topic_count = bbp_get_forum_topic_count($forum_id, false, true);
    $total_topic_count = bbp_get_forum_topic_count($forum_id, true, true);
    $difference = (int) $difference;
    // Update this forum id
    update_post_meta($forum_id, '_bbp_topic_count', (int) ($topic_count + $difference));
    update_post_meta($forum_id, '_bbp_total_topic_count', (int) ($total_topic_count + $difference));
    // Check for ancestors
    if (true === $update_ancestors) {
        // Get post ancestors
        $forum = get_post($forum_id);
        $ancestors = get_post_ancestors($forum);
        // If has ancestors, loop through them...
        if (!empty($ancestors)) {
            foreach ((array) $ancestors as $parent_forum_id) {
                // Only update topic count when an ancestor is not a category.
                if (!bbp_is_forum_category($parent_forum_id)) {
                    $parent_topic_count = bbp_get_forum_topic_count($parent_forum_id, false, true);
                    update_post_meta($parent_forum_id, '_bbp_topic_count', (int) ($parent_topic_count + $difference));
                }
                // Update the total topic count.
                $parent_total_topic_count = bbp_get_forum_topic_count($parent_forum_id, true, true);
                update_post_meta($parent_forum_id, '_bbp_total_topic_count', (int) ($parent_total_topic_count + $difference));
            }
        }
    }
    $forum_topic_count = (int) ($total_topic_count + $difference);
    return (int) apply_filters('bbp_bump_forum_topic_count', $forum_topic_count, $forum_id, $difference, $update_ancestors);
}