本文整理汇总了PHP中bbp_get_forum_reply_count函数的典型用法代码示例。如果您正苦于以下问题:PHP bbp_get_forum_reply_count函数的具体用法?PHP bbp_get_forum_reply_count怎么用?PHP bbp_get_forum_reply_count使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bbp_get_forum_reply_count函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_bbp_insert_forum
/**
* @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));
}
示例2: test_bbp_get_forum_reply_count
/**
* @covers ::bbp_forum_reply_count
* @covers ::bbp_get_forum_reply_count
*/
public function test_bbp_get_forum_reply_count()
{
$f = $this->factory->forum->create();
$t = $this->factory->topic->create(array('post_parent' => $f));
$int_value = 3;
$formatted_value = bbp_number_format($int_value);
$this->factory->reply->create_many($int_value, array('post_parent' => $t));
bbp_update_forum_reply_count($f);
// Output
$count = bbp_get_forum_reply_count($f, true, false);
$this->expectOutputString($formatted_value);
bbp_forum_reply_count($f);
// Formatted string
$count = bbp_get_forum_reply_count($f, true, false);
$this->assertSame($formatted_value, $count);
// Integer
$count = bbp_get_forum_reply_count($f, true, true);
$this->assertSame($int_value, $count);
}
示例3: st_bbp_list_forums
function st_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;
}
if (!empty($show_freshness_link)) {
$freshness_link = "<div class='freshness-forum-link'>" . st_get_last_poster_block($sub_forum->ID) . "</div>";
}
// 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"><a href="' . $permalink . '" class="bbp-forum-link">' . $title . '</a><p class="bbp-forum-description">' . $description . '</p></div>' . $counts . $freshness_link . $link_after . "</ul></li>";
}
// Output the list
echo apply_filters('bbp_list_forums', $before . $output . $after, $args);
}
}
示例4: test_bbp_unspam_topic_replies
/**
* @covers ::bbp_unspam_topic_replies
*/
public function test_bbp_unspam_topic_replies()
{
$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_replies($t);
bbp_unspam_topic_replies($t);
$this->assertEquals('', get_post_meta($t, '_bbp_pre_spammed_replies', true));
$this->assertEquals(array(), get_post_meta($t, '_bbp_pre_spammed_replies', false));
foreach ($r as $reply) {
$reply_status = get_post_status($reply);
$this->assertSame(bbp_get_public_status_id(), $reply_status);
$this->assertEquals('', get_post_meta($reply, '_wp_trash_meta_status', true));
$this->assertEquals(array(), get_post_meta($reply, '_wp_trash_meta_status', false));
}
$count = bbp_get_forum_reply_count($f, false, true);
$this->assertSame(2, $count);
$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);
}
示例5: test_bbp_create_initial_content
/**
* @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));
}
示例6: og_groups_update_num_posts_and_rank_options
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;
}
示例7: test_bbp_admin_repair_forum_reply_count
/**
* @covers ::bbp_admin_repair_forum_reply_count
*/
public function test_bbp_admin_repair_forum_reply_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)));
$r = $this->factory->reply->create(array('post_parent' => $t, 'reply_meta' => array('forum_id' => $f, 'topic_id' => $t)));
$count = bbp_get_forum_reply_count($f, true, true);
$this->assertSame(1, $count);
$r = $this->factory->reply->create_many(3, array('post_parent' => $t, 'reply_meta' => array('forum_id' => $f, 'topic_id' => $t)));
bbp_update_forum_reply_count($c);
bbp_update_forum_reply_count($f);
// Category reply count.
$count = bbp_get_forum_reply_count($c, false, true);
$this->assertSame(0, $count);
// Category total reply count.
$count = bbp_get_forum_reply_count($c, true, true);
$this->assertSame(4, $count);
// Forum reply count.
$count = bbp_get_forum_reply_count($f, false, true);
$this->assertSame(4, $count);
// Forum total reply count.
$count = bbp_get_forum_reply_count($f, true, true);
$this->assertSame(4, $count);
bbp_spam_reply($r[0]);
bbp_unapprove_reply($r[2]);
// Category reply count.
$count = bbp_get_forum_reply_count($c, false, true);
$this->assertSame(0, $count);
// Category total reply count.
$count = bbp_get_forum_reply_count($c, true, true);
$this->assertSame(2, $count);
// Forum reply count.
$count = bbp_get_forum_reply_count($f, false, true);
$this->assertSame(2, $count);
// Forum total reply count.
$count = bbp_get_forum_reply_count($f, true, true);
$this->assertSame(2, $count);
// Delete the _bbp_total_reply_count meta key.
$this->assertTrue(delete_post_meta_by_key('_bbp_total_reply_count'));
// Delete the _bbp_reply_count meta key.
$this->assertTrue(delete_post_meta_by_key('_bbp_reply_count'));
// Category reply count.
$count = bbp_get_forum_reply_count($c, false, true);
$this->assertSame(0, $count);
// Category total reply count.
$count = bbp_get_forum_reply_count($c, true, true);
$this->assertSame(0, $count);
// Forum reply count.
$count = bbp_get_forum_reply_count($f, false, true);
$this->assertSame(0, $count);
// Forum total reply count.
$count = bbp_get_forum_reply_count($f, true, true);
$this->assertSame(0, $count);
// Repair the forum reply count meta.
bbp_admin_repair_forum_reply_count();
// Category reply count.
$count = bbp_get_forum_reply_count($c, false, true);
$this->assertSame(0, $count);
// Category total reply count.
$count = bbp_get_forum_reply_count($c, true, true);
$this->assertSame(2, $count);
// Forum reply count.
$count = bbp_get_forum_reply_count($f, false, true);
$this->assertSame(2, $count);
// Forum total reply count.
$count = bbp_get_forum_reply_count($f, true, true);
$this->assertSame(2, $count);
}
示例8: bbp_forum_row_actions
<?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
示例9: test_bbp_move_topic_handler
/**
* @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);
}
示例10: bbp_bump_forum_reply_count
/**
* 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_reply_count' with the topic
* count, forum id, and difference
* @return int Forum topic count
*/
function bbp_bump_forum_reply_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_reply_count($forum_id, false, true);
$total_reply_count = bbp_get_forum_reply_count($forum_id, true, true);
$difference = (int) $difference;
// Update this forum id
update_post_meta($forum_id, '_bbp_reply_count', (int) ($topic_count + $difference));
update_post_meta($forum_id, '_bbp_total_reply_count', (int) ($total_reply_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 reply count when an ancestor is not a category.
if (!bbp_is_forum_category($parent_forum_id)) {
$parent_reply_count = bbp_get_forum_reply_count($parent_forum_id, false, true);
update_post_meta($parent_forum_id, '_bbp_reply_count', (int) ($parent_reply_count + $difference));
}
// Update the total reply count.
$parent_total_reply_count = bbp_get_forum_reply_count($parent_forum_id, true, true);
update_post_meta($parent_forum_id, '_bbp_total_reply_count', (int) ($parent_total_reply_count + $difference));
}
}
}
$forum_reply_count = (int) ($total_reply_count + $difference);
return (int) apply_filters('bbp_bump_forum_reply_count', $forum_reply_count, $forum_id, $difference, $update_ancestors);
}
示例11: wm_bbp_post_custom_metas
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);
}
示例12: custom_list_forums
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;
}
}
示例13: bbp_forum_title
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');
?>
<?php
bbp_forum_row_actions();
示例14: buddyboss_bbp_get_single_forum_description
/**
* 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);
}
示例15: test_bbp_update_forum_reply_count
/**
* @covers ::bbp_update_forum_reply_count
*/
public function test_bbp_update_forum_reply_count()
{
$f1 = $this->factory->forum->create();
$f2 = $this->factory->forum->create(array('post_parent' => $f1));
$t1 = $this->factory->topic->create(array('post_parent' => $f1, 'topic_meta' => array('forum_id' => $f1)));
$t2 = $this->factory->topic->create(array('post_parent' => $f2, 'topic_meta' => array('forum_id' => $f2)));
$count = bbp_get_forum_reply_count($f1, false, true);
$this->assertSame(0, $count);
$count = bbp_update_forum_reply_count($f1);
$this->assertSame(0, $count);
$this->factory->reply->create_many(3, array('post_parent' => $t1, 'reply_meta' => array('forum_id' => $f1, 'topic_id' => $t1)));
$count = bbp_update_forum_reply_count($f1);
$this->assertSame(3, $count);
$this->factory->reply->create_many(3, array('post_parent' => $t2, 'reply_meta' => array('forum_id' => $f2, 'topic_id' => $t2)));
$count = bbp_update_forum_reply_count($f1);
$this->assertSame(6, $count);
$count = bbp_update_forum_reply_count($f2);
$this->assertSame(3, $count);
}