/** * @covers ::bbp_get_user_favorites */ public function test_bbp_get_user_favorites() { $u = $this->factory->user->create(); $t = $this->factory->topic->create_many(3); // Add topic favorites. bbp_add_user_favorite($u, $t[0]); bbp_add_user_favorite($u, $t[1]); bbp_add_user_favorite($u, $t[2]); $expected = bbp_has_topics(array('post__in' => array($t[0], $t[1], $t[2]))); $favorites = bbp_get_user_favorites($u); $this->assertEquals($expected, $favorites); // Remove user favorite. bbp_remove_user_favorite($u, $t[1]); $expected = bbp_has_topics(array('post__in' => array($t[0], $t[2]))); $favorites = bbp_get_user_favorites($u); $this->assertEquals($expected, $favorites); }
public function getTopicList() { if (is_null($_POST['param']) || empty($_POST['param'])) { $this->_die(); } $return = array(); $loadFrom = empty($_POST['param']['from']) ? 0 : $_POST['param']['from']; $loadTo = empty($_POST['param']['to']) ? 0 : $_POST['param']['to']; $param = array('post_parent' => $this->forumId); if (!bbp_has_topics($param)) { $this->_die(); } while (bbp_topics()) { bbp_the_topic(); $topicId = bbp_get_topic_id(); $topic = new ForumBbpAjaxIntegratorPost($topicId, 'topic'); $returnItem = $topic->getPostData(); $returnItem['replyList'] = $this->getReplyList($topicId); $return[] = $returnItem; } wp_die(json_encode($return)); }
function st_bbp_get_user_topics_started($user_id = 0, $limit = 3, $max_num_pages = 1) { // Validate user $user_id = bbp_get_user_id($user_id); if (empty($user_id)) { return false; } // Query defaults $default_query = array('author' => $user_id, 'show_stickies' => false, 'order' => 'DESC', 'posts_per_page' => $limit, 'max_num_pages' => $max_num_pages); // Try to get the topics $query = bbp_has_topics($default_query); if (empty($query)) { return false; } return apply_filters('bbp_get_user_topics_started', $query, $user_id); }
?> <div id="post-<?php the_ID(); ?> " <?php post_class(); ?> > <div class="entry-content"> <div id="bbpress-forums"> <?php if (bbp_has_topics($args)) { ?> <?php bbp_get_template_part('loop', 'topics'); ?> <?php bbp_get_template_part('pagination', 'topics'); ?> <?php } else { ?> Sorry, no results found for <strong><?php
/** * Output the forums for a group in the edit screens * * @since bbPress (r3653) * @uses bp_get_current_group_id() * @uses bbp_get_group_forum_ids() * @uses bbp_has_forums() * @uses bbp_get_template_part() */ public function display_forums($offset = 0) { // Allow actions immediately before group forum output do_action('bbp_before_group_forum_display'); // Load up bbPress once $bbp = bbpress(); // Forum data $forum_slug = bp_action_variable($offset); $forum_ids = bbp_get_group_forum_ids(bp_get_current_group_id()); $forum_args = array('post__in' => $forum_ids, 'post_parent' => null); // Unset global queries $bbp->forum_query = new stdClass(); $bbp->topic_query = new stdClass(); $bbp->reply_query = new stdClass(); // Unset global ID's $bbp->current_forum_id = 0; $bbp->current_topic_id = 0; $bbp->current_reply_id = 0; $bbp->current_topic_tag_id = 0; // Reset the post data wp_reset_postdata(); // Allow admins special views $post_status = array(bbp_get_closed_status_id(), bbp_get_public_status_id()); if (is_super_admin() || current_user_can('moderate') || bp_is_item_admin() || bp_is_item_mod()) { $post_status = array_merge($post_status, array(bbp_get_spam_status_id(), bbp_get_trash_status_id())); } ?> <div id="bbpress-forums"> <?php // Looking at the group forum root if (empty($forum_slug) || 'page' == $forum_slug) { // Query forums and show them if they exist if (!empty($forum_ids) && bbp_has_forums($forum_args)) { // Only one forum found if (1 == $bbp->forum_query->post_count) { // Remove 'name' check for paginated requests if ('page' == $forum_slug) { $forum_args = array('post_type' => bbp_get_forum_post_type()); } else { $forum_args = array('name' => $forum_slug, 'post_type' => bbp_get_forum_post_type()); } // Get the forums $forums = get_posts($forum_args); bbp_the_forum(); // Forum exists if (!empty($forums)) { $forum = $forums[0]; // Suppress subforums for now add_filter('bbp_get_forum_subforum_count', '__return_false'); // Set up forum data bbpress()->current_forum_id = $forum->ID; bbp_set_query_name('bbp_single_forum'); ?> <h3><?php bbp_forum_title(); ?> </h3> <?php bbp_get_template_part('content', 'single-forum'); ?> <?php // Remove the subforum suppression filter remove_filter('bbp_get_forum_subforum_count', '__return_false'); ?> <?php } else { ?> <?php bbp_get_template_part('feedback', 'no-topics'); ?> <?php bbp_get_template_part('form', 'topic'); ?> <?php } // More than 1 forum found or group forum admin screen } elseif (1 < $bbp->forum_query->post_count) { ?> <h3><?php _e('Forums', 'bbpress'); ?> </h3> <?php bbp_get_template_part('loop', 'forums'); ?> <h3><?php _e('Topics', 'bbpress'); ?> </h3> <?php if (bbp_has_topics(array('post_parent__in' => $forum_ids))) { ?> <?php bbp_get_template_part('pagination', 'topics'); ?> <?php bbp_get_template_part('loop', 'topics'); ?> <?php bbp_get_template_part('pagination', 'topics'); ?> <?php bbp_get_template_part('form', 'topic'); ?> <?php } else { ?> <?php bbp_get_template_part('feedback', 'no-topics'); ?> <?php bbp_get_template_part('form', 'topic'); ?> <?php } // No forums found } else { ?> <div id="message" class="info"> <p><?php _e('This group does not currently have any forums.', 'bbpress'); ?> </p> </div> <?php } // No forums found } else { ?> <div id="message" class="info"> <p><?php _e('This group does not currently have any forums.', 'bbpress'); ?> </p> </div> <?php } // Single forum } elseif (bp_action_variable($offset) != $this->slug && bp_action_variable($offset) != $this->topic_slug && bp_action_variable($offset) != $this->reply_slug) { // Get forum data $forum_slug = bp_action_variable($offset); $forum_args = array('name' => $forum_slug, 'post_type' => bbp_get_forum_post_type()); $forums = get_posts($forum_args); // Forum exists if (!empty($forums)) { $forum = $forums[0]; // Set up forum data $forum_id = bbpress()->current_forum_id = $forum->ID; // Reset necessary forum_query attributes for forums loop to function $bbp->forum_query->query_vars['post_type'] = bbp_get_forum_post_type(); $bbp->forum_query->in_the_loop = true; $bbp->forum_query->post = get_post($forum_id); // Forum edit if (bp_action_variable($offset + 1) == $bbp->edit_id) { global $wp_query, $post; $wp_query->bbp_is_edit = true; $wp_query->bbp_is_forum_edit = true; $post = $forum; bbp_set_query_name('bbp_forum_form'); bbp_get_template_part('form', 'forum'); } else { bbp_set_query_name('bbp_single_forum'); ?> <h3><?php bbp_forum_title(); ?> </h3> <?php bbp_get_template_part('content', 'single-forum'); } } else { bbp_get_template_part('feedback', 'no-topics'); bbp_get_template_part('form', 'topic'); } // Single topic } elseif (bp_action_variable($offset) == $this->topic_slug) { // Get topic data $topic_slug = bp_action_variable($offset + 1); $topic_args = array('name' => $topic_slug, 'post_type' => bbp_get_topic_post_type(), 'post_status' => $post_status); $topics = get_posts($topic_args); // Topic exists if (!empty($topics)) { $topic = $topics[0]; // Set up topic data $topic_id = bbpress()->current_topic_id = $topic->ID; $forum_id = bbp_get_topic_forum_id($topic_id); // Reset necessary forum_query attributes for topics loop to function $bbp->forum_query->query_vars['post_type'] = bbp_get_forum_post_type(); $bbp->forum_query->in_the_loop = true; $bbp->forum_query->post = get_post($forum_id); // Reset necessary topic_query attributes for topics loop to function $bbp->topic_query->query_vars['post_type'] = bbp_get_topic_post_type(); $bbp->topic_query->in_the_loop = true; $bbp->topic_query->post = $topic; // Topic edit if (bp_action_variable($offset + 2) == $bbp->edit_id) { global $wp_query, $post; $wp_query->bbp_is_edit = true; $wp_query->bbp_is_topic_edit = true; $post = $topic; // Merge if (!empty($_GET['action']) && 'merge' == $_GET['action']) { bbp_set_query_name('bbp_topic_merge'); bbp_get_template_part('form', 'topic-merge'); // Split } elseif (!empty($_GET['action']) && 'split' == $_GET['action']) { bbp_set_query_name('bbp_topic_split'); bbp_get_template_part('form', 'topic-split'); // Edit } else { bbp_set_query_name('bbp_topic_form'); bbp_get_template_part('form', 'topic'); } // Single Topic } else { bbp_set_query_name('bbp_single_topic'); ?> <h3><?php bbp_topic_title(); ?> </h3> <?php bbp_get_template_part('content', 'single-topic'); } // No Topics } else { bbp_get_template_part('feedback', 'no-topics'); bbp_get_template_part('form', 'topic'); } // Single reply } elseif (bp_action_variable($offset) == $this->reply_slug) { // Get reply data $reply_slug = bp_action_variable($offset + 1); $reply_args = array('name' => $reply_slug, 'post_type' => bbp_get_reply_post_type()); $replies = get_posts($reply_args); if (empty($replies)) { return; } // Get the first reply $reply = $replies[0]; // Set up reply data $reply_id = bbpress()->current_reply_id = $reply->ID; $topic_id = bbp_get_reply_topic_id($reply_id); $forum_id = bbp_get_reply_forum_id($reply_id); // Reset necessary forum_query attributes for reply to function $bbp->forum_query->query_vars['post_type'] = bbp_get_forum_post_type(); $bbp->forum_query->in_the_loop = true; $bbp->forum_query->post = get_post($forum_id); // Reset necessary topic_query attributes for reply to function $bbp->topic_query->query_vars['post_type'] = bbp_get_topic_post_type(); $bbp->topic_query->in_the_loop = true; $bbp->topic_query->post = get_post($topic_id); // Reset necessary reply_query attributes for reply to function $bbp->reply_query->query_vars['post_type'] = bbp_get_reply_post_type(); $bbp->reply_query->in_the_loop = true; $bbp->reply_query->post = $reply; if (bp_action_variable($offset + 2) == $bbp->edit_id) { global $wp_query, $post; $wp_query->bbp_is_edit = true; $wp_query->bbp_is_reply_edit = true; $post = $reply; bbp_set_query_name('bbp_reply_form'); bbp_get_template_part('form', 'reply'); } } ?> </div> <?php // Allow actions immediately after group forum output do_action('bbp_after_group_forum_display'); }
<?php do_action('bbp_after_statistics'); ?> </dl> <?php do_action('bbp_before_popular_topics'); ?> <?php bbp_set_query_name('bbp_popular_topics'); ?> <?php if (bbp_has_topics(array('meta_key' => '_bbp_reply_count', 'posts_per_page' => 15, 'max_num_pages' => 1, 'orderby' => 'meta_value_num', 'show_stickies' => false))) { ?> <h2 class="entry-title"><?php _e('Popular Topics', 'bbpress'); ?> </h2> <?php bbp_get_template_part('bbpress/pagination', 'topics'); ?> <?php bbp_get_template_part('bbpress/loop', 'topics'); ?>
/** * Output an RSS2 feed of topics, based on the query passed. * * @since bbPress (r3171) * * @uses bbp_version() * @uses bbp_is_single_topic() * @uses bbp_user_can_view_forum() * @uses bbp_get_topic_forum_id() * @uses bbp_show_load_topic() * @uses bbp_topic_permalink() * @uses bbp_topic_title() * @uses bbp_get_topic_reply_count() * @uses bbp_topic_content() * @uses bbp_has_topics() * @uses bbp_topics() * @uses bbp_the_topic() * @uses get_wp_title_rss() * @uses get_option() * @uses bloginfo_rss * @uses self_link() * @uses the_author() * @uses get_post_time() * @uses rss_enclosure() * @uses do_action() * @uses apply_filters() * * @param array $topics_query */ function bbp_display_topics_feed_rss2($topics_query = array()) { // User cannot access this forum if (bbp_is_single_forum() && !bbp_user_can_view_forum(array('forum_id' => bbp_get_forum_id()))) { return; } // Display the feed header('Content-Type: ' . feed_content_type('rss2') . '; charset=' . get_option('blog_charset'), true); header('Status: 200 OK'); echo '<?xml version="1.0" encoding="' . get_option('blog_charset') . '"?' . '>'; ?> <rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" <?php do_action('bbp_feed'); ?> > <channel> <title><?php bloginfo_rss('name'); ?> » <?php _e('All Topics', 'bbpress'); ?> </title> <atom:link href="<?php self_link(); ?> " rel="self" type="application/rss+xml" /> <link><?php self_link(); ?> </link> <description><?php // ?> </description> <pubDate><?php echo mysql2date('D, d M Y H:i:s O', current_time('mysql'), false); ?> </pubDate> <generator>http://bbpress.org/?v=<?php bbp_version(); ?> </generator> <language><?php bloginfo_rss('language'); ?> </language> <?php do_action('bbp_feed_head'); ?> <?php if (bbp_has_topics($topics_query)) { ?> <?php while (bbp_topics()) { bbp_the_topic(); ?> <item> <guid><?php bbp_topic_permalink(); ?> </guid> <title><![CDATA[<?php bbp_topic_title(); ?> ]]></title> <link><?php bbp_topic_permalink(); ?> </link> <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_post_meta(bbp_get_topic_id(), '_bbp_last_active_time', true)); ?> </pubDate> <dc:creator><?php the_author(); ?> </dc:creator> <?php if (!post_password_required()) { ?> <description> <![CDATA[ <p><?php printf(esc_html__('Replies: %s', 'bbpress'), bbp_get_topic_reply_count()); ?> </p> <?php bbp_topic_content(); ?> ]]> </description> <?php rss_enclosure(); ?> <?php } ?> <?php do_action('bbp_feed_item'); ?> </item> <?php } ?> <?php } ?> <?php do_action('bbp_feed_footer'); ?> </channel> </rss> <?php exit; }
/** * Run the view's query * * @since 2.0.0 bbPress (r2789) * * @param string $view Optional. View id * @param mixed $new_args New arguments. See {@link bbp_has_topics()} * @uses bbp_get_view_id() To get the view id * @uses bbp_get_view_query_args() To get the view query args * @uses sanitize_title() To sanitize the view name * @uses bbp_has_topics() To make the topics query * @return bool False if the view doesn't exist, otherwise if topics are there */ function bbp_view_query($view = '', $new_args = '') { $view = bbp_get_view_id($view); if (empty($view)) { return false; } $query_args = bbp_get_view_query_args($view); if (!empty($new_args)) { $new_args = bbp_parse_args($new_args, '', 'view_query'); $query_args = array_merge($query_args, $new_args); } return bbp_has_topics($query_args); }
*/ ?> <?php get_header(); ?> <div id="content" role="main"> <?php apoc_breadcrumbs(); ?> <div id="forums"> <?php // Recent topics found if (bbp_has_topics(array('post_parent__not_in' => array(5459), 'meta_value' => date('Y-m-d', strtotime('-30 days')), 'meta_compare' => '>='))) { ?> <?php bbp_get_template_part('loop', 'topics'); ?> <?php bbp_get_template_part('pagination', 'topics'); ?> <?php // No topics found } else { ?> <p class="warning">Sorry, but no recent topics were found.</p> <?php
?> </li> <li class="bbp-topic-reply-count"><?php bbp_show_lead_topic() ? _e('Replies', 'bbpress') : _e('Posts', 'bbpress'); ?> </li> <li class="bbp-topic-freshness"><?php _e('Freshness', 'bbpress'); ?> </li> </ul> <div class="clearfix"></div> </li> <?php if (strpos($_SERVER['REQUEST_URI'], '/forums/view/') || bbp_has_topics($bbp_loop_args)) { ?> <?php while (bbp_topics()) { bbp_the_topic(); ?> <?php bbp_get_template_part('loop', 'single-topic'); ?> <?php } ?> <?php }
function load_more_topics() { $content = ''; ob_start(); $forum_id = $_POST['forum']; if ($topics = bbp_has_topics(array('post_parent' => $forum_id, 'posts_per_page' => 11, 'paged' => $_POST['list']))) { $counter = 0; while (bbp_topics()) { bbp_the_topic(); if (++$counter == 12) { break; } ?> <div class="topics_list_single_topic <?php $postUser = new WP_User(bbp_get_topic_author_id()); echo $postUser->has_cap('bbp_keymaster') || $postUser->has_cap('bbp_moderator') ? "isAdmin" : ""; ?> " id="topic-<?php echo bbp_get_topic_id(); ?> " data-bbp_forum_id="<?php echo $forum_id; ?> " data-id="<?php echo bbp_get_topic_id(); ?> "> <div class="single_topic_header"> <div class="photo"> <a href="<?php echo bp_core_get_user_domain(bbp_get_topic_author_id()); ?> "><?php echo bp_core_fetch_avatar(array('item_id' => bbp_get_topic_author_id(), 'height' => 40, 'width' => 40)); ?> </a> </div> <div class="info"> <div class="name"> <a href="<?php echo bp_core_get_user_domain(bbp_get_topic_author_id()); ?> "><?php echo bbp_get_topic_author_display_name(bbp_get_topic_id()); ?> </a> <?php if ($postUser->has_cap('bbp_keymaster')) { echo "<small>(Администратор форума)</small>"; } elseif ($postUser->has_cap('bbp_moderator')) { echo "<small>(Преподаватель)</small>"; } ?> </div> <div class="date"><?php echo get_post_time('j F ', false, bbp_get_topic_id(), true) . __('at', 'qode') . get_post_time(' H:i', false, bbp_get_topic_id(), true); ?> </div> </div> <?php if (bbp_get_topic_author_id() == get_current_user_id()) { ?> <a href="#" class="addi_actions_open"></a> <div class="addi_actions" style="display: none"> <ul> <li><a class="edit_action" href="#">Редактировать</a></li> <li><a class="remove_action" href="#">Удалить</a></li> </ul> </div> <?php } ?> </div> <div class="single_topic_content"> <?php $content = bbp_get_topic_content(); if (mb_strlen($content) > 500) { echo '<div class="show">' . mb_substr($content, 0, 500) . '... <a href="#" class="show_all">' . __('More', 'qode') . '</a></div>'; ?> <div class="hide"><?php echo $content; ?> </div> <?php } else { echo $content; } ?> </div> <div style="display: none" class="single_topic_content_edit"> <textarea class="edit_content"><?php echo get_post_field('post_content', bbp_get_topic_id()); ?> </textarea> <div class="edit_actions"> <button class="cancel"><?php _e('Cancel', 'qode'); ?> </button> <button class="save"><?php _e('Save', 'qode'); ?> </button> </div> </div> <div class="single_topic_replies_container"> <div class="single_topic_replies"> <?php $replies = get_posts($default = array('post_type' => bbp_get_reply_post_type(), 'post_parent' => bbp_get_topic_id(), 'posts_per_page' => 5, 'orderby' => 'date', 'order' => 'DESC', 'ignore_sticky_posts' => true)); // Stickies not supported $i = count($replies); if ($i == 5) { $count = new WP_Query($default = array('numberposts' => -1, 'post_type' => bbp_get_reply_post_type(), 'post_parent' => bbp_get_topic_id(), 'posts_per_page' => 5, 'orderby' => 'date', 'order' => 'DESC', 'ignore_sticky_posts' => true)); // Stickies not supported $count = $count->found_posts - 4; ?> <a href="#" class="load_all_replies"><i class="comments_img"></i>Просмотреть еще <?php echo $count . ' ' . custom_plural_form($count, 'комментарий', 'комментария', 'комментариев'); ?> </a> <?php } $replies = array_reverse($replies); //array_shift ( $replies ); foreach ($replies as $reply) { ?> <div class="single_topic_reply <?php $postUser = new WP_User($reply->post_author); echo $postUser->has_cap('bbp_keymaster') || $postUser->has_cap('bbp_moderator') ? "isAdmin" : ""; ?> " data-id="<?php echo $reply->ID; ?> "> <div class="photo"> <a href="<?php echo bp_core_get_user_domain($reply->post_author); ?> "><?php echo bp_core_fetch_avatar(array('item_id' => $reply->post_author, 'height' => 32, 'width' => 32)); ?> </a> </div> <div class="content_wrapper"> <div class="reply_content"> <a class="author-link" href="<?php echo bp_core_get_user_domain($reply->post_author); ?> "><?php echo bbp_get_reply_author_display_name($reply->ID); ?> </a> <?php if ($postUser->has_cap('bbp_keymaster')) { echo "<small>(Администратор форума)</small>"; } elseif ($postUser->has_cap('bbp_moderator')) { echo "<small>(Преподаватель)</small>"; } ?> <?php echo bbp_get_reply_content($reply->ID); ?> </div> <div style="display: none" class="reply_content_edit"> <textarea class="reply_content_edit_textarea"><?php echo get_post_field('post_content', $reply->ID); ?> </textarea> <div class="edit_actions"> <a class="cancel" href="#">Отменить</a> </div> </div> <div class="date"> <?php echo get_post_time('j F ', false, $reply->ID, true) . __('at', 'qode') . get_post_time(' H:i', false, $reply->ID, true); ?> </span><?php $like = get_post_meta($reply->ID, 'like_' . get_current_user_id(), true); ?> </div> </div> <?php if ($reply->post_author == get_current_user_id()) { ?> <a class="addi_actions_open" href="#"></a> <div class="addi_actions" style="display: none"> <ul> <li><a class="edit_action" href="#">Редактировать</a></li> <li><a class="remove_action" href="#">Удалить</a></li> </ul> </div> <?php } ?> </div> <?php } $url = (isset($_SERVER['HTTPS']) ? "https" : "http") . "://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"; ?> </div> <div class="single_topic_reply_form"> <form action="<?php echo $url; ?> #topic-<?php echo bbp_get_topic_id(); ?> " data-bbp_forum_id="<?php echo $forum_id; ?> " data-bbp_topic_id="<?php echo bbp_get_topic_id(); ?> " method="post"> <div class="photo"> <a href="<?php echo bp_core_get_user_domain(get_current_user_id()); ?> "><?php echo bp_core_fetch_avatar(array('item_id' => get_current_user_id(), 'height' => 32, 'width' => 32)); ?> </a> </div> <div class="reply-form"> <textarea placeholder="<?php _e('Введите текст сообщения...', 'qode'); ?> " name="content"></textarea> </div> <input type="hidden" name="bbp_forum_id" value="<?php echo $forum_id; ?> "> <input type="hidden" name="bbp_topic_id" value="<?php echo bbp_get_topic_id(); ?> "> <input type="hidden" name="action" value="custom-bbp-reply-create"> <input type="hidden" name="security" value="<?php echo wp_create_nonce('custom-bbp-reply-create'); ?> "> </form> </div> </div> </div> <?php } if ($counter == 11) { ?> <a class="load_more_topics" href="#"><?php _e('Load more discussions', 'qode'); ?> </a> <?php } } $content = ob_get_contents(); ob_end_clean(); die(json_encode(array('result' => 'OK', 'content' => $content))); }
/** * @covers ::bbp_get_user_topic_subscriptions */ public function test_bbp_get_user_topic_subscriptions() { $u = $this->factory->user->create(); $t = $this->factory->topic->create_many(3); // Add topic subscriptions. bbp_add_user_topic_subscription($u, $t[0]); bbp_add_user_topic_subscription($u, $t[1]); bbp_add_user_topic_subscription($u, $t[2]); $expected = bbp_has_topics(array('post__in' => array($t[0], $t[1], $t[2]))); $subscriptions = bbp_get_user_topic_subscriptions($u); $this->assertEquals($expected, $subscriptions); // Remove topic subscription. bbp_remove_user_topic_subscription($u, $t[1]); $expected = bbp_has_topics(array('post__in' => array($t[0], $t[2]))); $subscriptions = bbp_get_user_topic_subscriptions($u); $this->assertEquals($expected, $subscriptions); }
?> <?php // Topic Loop ?> <section class="section-wrap topics row-vertical"> <a href="<?php bloginfo('url'); ?> /forums"><h1 class="section-header">Recent Topics</h1></a> <?php do_action('bbp_template_before_topics_index'); ?> <?php if (bbp_has_topics(array('author' => 0, 'show_stickies' => false, 'order' => 'DESC', 'post_parent' => 'any', 'posts_per_page' => 3))) { ?> <?php bbp_get_template_part('loop', 'topics'); ?> <?php } else { ?> <?php bbp_get_template_part('feedback', 'no-topics'); ?> <?php
/** * Output the forums for a group in the edit screens * * @since bbPress (r3653) * @uses bp_get_current_group_id() * @uses bbp_get_group_forum_ids() * @uses bbp_has_forums() * @uses bbp_get_template_part() */ public function display_forums($offset = 0) { global $wpdb; $bbp = bbpress(); // Forum data $forum_ids = bbp_get_group_forum_ids(bp_get_current_group_id()); $forum_args = array('post__in' => $forum_ids, 'post_parent' => null); ?> <div id="bbpress-forums"> <?php // Looking at the group forum root if (!bp_action_variable($offset)) { // Query forums and show them if if (!empty($forum_ids) && bbp_has_forums($forum_args)) { bbp_the_forum(); // Only one forum found if ($bbp->forum_query->post_count == 1) { ?> <h3><?php _e('Forum', 'bbpress'); ?> </h3> <?php bbp_set_query_name('bbp_single_forum'); ?> <?php if (bbp_has_topics(array('post_parent' => bbp_get_forum_id()))) { ?> <?php bbp_get_template_part('pagination', 'topics'); ?> <?php bbp_get_template_part('loop', 'topics'); ?> <?php bbp_get_template_part('pagination', 'topics'); ?> <?php bbp_get_template_part('form', 'topic'); ?> <?php } else { ?> <?php bbp_get_template_part('feedback', 'no-topics'); ?> <?php bbp_get_template_part('form', 'topic'); ?> <?php } // More than 1 forum found } elseif ($bbp->forum_query->post_count > 1) { ?> <h3><?php _e('Forums', 'bbpress'); ?> </h3> <?php bbp_get_template_part('loop', 'forums'); ?> <h3><?php _e('Topics', 'bbpress'); ?> </h3> <?php if (bbp_has_topics(array('post_parent__in' => $forum_ids))) { ?> <?php bbp_get_template_part('pagination', 'topics'); ?> <?php bbp_get_template_part('loop', 'topics'); ?> <?php bbp_get_template_part('pagination', 'topics'); ?> <?php bbp_get_template_part('form', 'topic'); ?> <?php } else { ?> <?php bbp_get_template_part('feedback', 'no-topics'); ?> <?php bbp_get_template_part('form', 'topic'); ?> <?php } // No forums found } else { ?> <div id="message" class="info"> <p><?php _e('This group does not currently have any forums.', 'bbpress'); ?> </p> </div> <?php if (bp_is_group_admin_screen($this->slug)) { bbp_get_template_part('form', 'forum'); } } // No forums found } else { ?> <div id="message" class="info"> <p><?php _e('This group does not currently have any forums.', 'bbpress'); ?> </p> </div> <?php if (bp_is_group_admin_screen($this->slug)) { bbp_get_template_part('form', 'forum'); } } // Single forum } elseif (bp_action_variable($offset) != $this->slug && bp_action_variable($offset) != $this->topic_slug) { // Get the forum $forum_post_type = bbp_get_forum_post_type(); $forum_slug = bp_action_variable($offset); $forums = $wpdb->get_row("SELECT ID FROM {$wpdb->posts} WHERE post_name = '{$forum_slug}' AND post_type = '{$forum_post_type}'", ARRAY_N); // Forum exists if (!empty($forums)) { $forum_id = $forums[0]; $bbp->current_forum_id = $forum_id; bbp_set_query_name('bbp_single_forum'); ?> <h3><?php bbp_forum_title(); ?> </h3> <?php bbp_get_template_part('content', 'single-forum'); ?> <?php } else { ?> <?php bbp_get_template_part('feedback', 'no-topics'); ?> <?php bbp_get_template_part('form', 'topic'); ?> <?php } // Single topic } elseif (bp_action_variable($offset) != $this->slug && bp_action_variable($offset) == $this->topic_slug) { // Get the topic $topic_post_type = bbp_get_topic_post_type(); $topic_slug = bp_action_variable($offset + 1); $topics = $wpdb->get_row("SELECT ID FROM {$wpdb->posts} WHERE post_name = '{$topic_slug}' AND post_type = '{$topic_post_type}'", ARRAY_N); // Topic exists if (!empty($topics)) { $topic_id = $topics[0]; $bbp->current_topic_id = $topic_id; bbp_set_query_name('bbp_single_topic'); ?> <h3><?php bbp_topic_title(); ?> </h3> <?php bbp_get_template_part('content', 'single-topic'); ?> <?php } else { ?> <?php bbp_get_template_part('feedback', 'no-topics'); ?> <?php bbp_get_template_part('form', 'topic'); ?> <?php } } ?> </div> <?php }
/** * Get the topics that a user created * * @since bbPress (r2660) * * @param int $user_id Optional. User id * @uses bbp_get_user_id() To get the topic id * @uses bbp_has_topics() To get the topics created by the user * @return array|bool Results if the user has created topics, otherwise false */ function bbp_get_user_topics_started($user_id = 0) { // Validate user $user_id = bbp_get_user_id($user_id); if (empty($user_id)) { return false; } // Try to get the topics $query = bbp_has_topics(array('author' => $user_id)); return apply_filters('bbp_get_user_topics_started', $query, $user_id); }
<?php the_content(); ?> <div id="bbpress-forums"> <?php bbp_breadcrumb(); ?> <?php bbp_set_query_name('bbp_no_replies'); ?> <?php if (bbp_has_topics(array('meta_key' => '_bbp_reply_count', 'meta_value' => '1', 'meta_compare' => '<', 'orderby' => 'date', 'show_stickies' => false))) { ?> <?php bbp_get_template_part('pagination', 'topics'); ?> <?php bbp_get_template_part('loop', 'topics'); ?> <?php bbp_get_template_part('pagination', 'topics'); ?> <?php
<?php if ( bbp_allow_search() ) : ?> <div class="bbp-search-form"> <?php bbp_get_template_part( 'form', 'search' ); ?> </div> <?php endif; ?> <?php if ( bbp_is_topic_tag() ) bbp_topic_tag_description(); ?> <?php do_action( 'bbp_template_before_topics_index' ); ?> <?php if ( bbp_has_topics() ) : ?> <?php bbp_get_template_part( 'pagination', 'topics' ); ?> <?php bbp_get_template_part( 'loop', 'topics' ); ?> <?php bbp_get_template_part( 'pagination', 'topics' ); ?> <?php else : ?> <?php bbp_get_template_part( 'feedback', 'no-topics' ); ?> <?php endif; ?> <?php do_action( 'bbp_template_after_topics_index' ); ?>
<?php bbp_breadcrumb(); ?> <?php if (bbp_is_topic_tag()) { bbp_topic_tag_description(); } ?> <?php do_action('bbp_template_before_topics_index'); ?> <?php if (bbp_has_topics()) { ?> <?php bbp_get_template_part('pagination', 'topics'); ?> <?php bbp_get_template_part('loop', 'topics'); ?> <?php bbp_get_template_part('pagination', 'topics'); ?> <?php
<p class="warning">Sorry, but no <?php echo $context; ?> were found that match this search.</p> <?php } ?> </div> <?php // Forum Topics } elseif ($context == 'topics') { ?> <div id="forums"> <?php if (bbp_has_topics($search->query)) { bbp_get_template_part('loop', 'topics'); } else { ?> <p class="warning">Sorry, but no <?php echo $context; ?> were found that match this search.</p> <?php } ?> </div> <?php // Members and Groups } elseif ($context == 'members') {
/** * Get the topics that a user created * * @since bbPress (r2660) * * @param int $user_id Optional. User id * @uses bbp_get_user_id() To get the topic id * @uses bbp_has_topics() To get the topics created by the user * @return array|bool Results if the user has created topics, otherwise false */ function bbp_get_user_topics_started($user_id = 0) { // Validate user $user_id = bbp_get_user_id($user_id); if (empty($user_id)) { return false; } // Query defaults $default_query = array('author' => $user_id, 'show_stickies' => false, 'order' => 'DESC'); // Try to get the topics $query = bbp_has_topics($default_query); if (empty($query)) { return false; } return apply_filters('bbp_get_user_topics_started', $query, $user_id); }
<div class="topics_list" data-list="2" data-forum="<?php echo $forum_id; ?> "> <?php $isForumModerator = bbp_get_user_role(get_current_user_id()) != 'bbp_moderator' && bbp_get_user_role(get_current_user_id()) != 'bbp_keymaster'; if (bbp_has_forums($buddypress_id)) { $topics = false; while (bbp_forums()) { bbp_the_forum(); if ($forum_id != bbp_get_forum_id()) { continue; } $topics = bbp_has_topics(array('post_parent' => $forum_id, 'posts_per_page' => 11)); if (!$topics) { _e('This forum does not have topics', 'qode'); break; } $counter = 0; if (bp_group_is_visible($group)) { global $post; $post = bbp_get_forum($forum_id); $counter = 0; while (bbp_topics()) { bbp_the_topic(); if (++$counter == 12) { break; } ?>
</div></div> <?php if (bbp_get_forum_subforum_count() && bbp_has_forums()) { ?> <?php bbp_get_template_part('loop', 'forums'); ?> <?php } ?> <?php if (!bbp_is_forum_category() && bbp_has_topics()) { ?> <?php //bbp_get_template_part( 'pagination', 'topics' ); ?> <?php bbp_get_template_part('loop', 'topics'); ?> <?php bbp_get_template_part('pagination', 'topics'); ?> <?php
/** * Output the forums for a group in the edit screens * * As of right now, bbPress only supports 1-to-1 group forum relationships. * In the future, many-to-many should be allowed. * * @since bbPress (r3653) * @uses bp_get_current_group_id() * @uses bbp_get_group_forum_ids() * @uses bbp_has_forums() * @uses bbp_get_template_part() */ public function display_forums($offset = 0) { global $wp_query; // Allow actions immediately before group forum output do_action('bbp_before_group_forum_display'); // Load up bbPress once $bbp = bbpress(); /** Query Resets ******************************************************/ // Forum data $forum_action = bp_action_variable($offset); $forum_ids = bbp_get_group_forum_ids(bp_get_current_group_id()); $forum_id = array_shift($forum_ids); // Always load up the group forum bbp_has_forums(array('p' => $forum_id, 'post_parent' => null)); // Set the global forum ID $bbp->current_forum_id = $forum_id; // Assume forum query bbp_set_query_name('bbp_single_forum'); ?> <div id="bbpress-forums"> <?php switch ($forum_action) { /** Single Forum **********************************************/ case false: case 'page': // Strip the super stickies from topic query add_filter('bbp_get_super_stickies', array($this, 'no_super_stickies'), 10, 1); // Unset the super sticky option on topic form add_filter('bbp_get_topic_types', array($this, 'unset_super_sticky'), 10, 1); // Query forums and show them if they exist if (bbp_forums()) { // Setup the forum bbp_the_forum(); ?> <h3><?php bbp_forum_title(); ?> </h3> <?php bbp_get_template_part('content', 'single-forum'); // No forums found } else { ?> <div id="message" class="info"> <p><?php esc_html_e('This group does not currently have a forum.', 'bbpress'); ?> </p> </div> <?php } break; /** Single Topic **********************************************/ /** Single Topic **********************************************/ case $this->topic_slug: // hide the 'to front' admin links add_filter('bbp_get_topic_stick_link', array($this, 'hide_super_sticky_admin_link'), 10, 2); // Get the topic bbp_has_topics(array('name' => bp_action_variable($offset + 1), 'posts_per_page' => 1, 'show_stickies' => false)); // If no topic, 404 if (!bbp_topics()) { bp_do_404(bbp_get_forum_permalink($forum_id)); ?> <h3><?php bbp_forum_title(); ?> </h3> <?php bbp_get_template_part('feedback', 'no-topics'); return; } // Setup the topic bbp_the_topic(); ?> <h3><?php bbp_topic_title(); ?> </h3> <?php // Topic edit if (bp_action_variable($offset + 2) === bbp_get_edit_rewrite_id()) { // Unset the super sticky link on edit topic template add_filter('bbp_get_topic_types', array($this, 'unset_super_sticky'), 10, 1); // Set the edit switches $wp_query->bbp_is_edit = true; $wp_query->bbp_is_topic_edit = true; // Setup the global forum ID $bbp->current_topic_id = get_the_ID(); // Merge if (!empty($_GET['action']) && 'merge' === $_GET['action']) { bbp_set_query_name('bbp_topic_merge'); bbp_get_template_part('form', 'topic-merge'); // Split } elseif (!empty($_GET['action']) && 'split' === $_GET['action']) { bbp_set_query_name('bbp_topic_split'); bbp_get_template_part('form', 'topic-split'); // Edit } else { bbp_set_query_name('bbp_topic_form'); bbp_get_template_part('form', 'topic'); } // Single Topic } else { bbp_set_query_name('bbp_single_topic'); bbp_get_template_part('content', 'single-topic'); } break; /** Single Reply **********************************************/ /** Single Reply **********************************************/ case $this->reply_slug: // Get the reply bbp_has_replies(array('name' => bp_action_variable($offset + 1), 'posts_per_page' => 1)); // If no topic, 404 if (!bbp_replies()) { bp_do_404(bbp_get_forum_permalink($forum_id)); ?> <h3><?php bbp_forum_title(); ?> </h3> <?php bbp_get_template_part('feedback', 'no-replies'); return; } // Setup the reply bbp_the_reply(); ?> <h3><?php bbp_reply_title(); ?> </h3> <?php if (bp_action_variable($offset + 2) === bbp_get_edit_rewrite_id()) { // Set the edit switches $wp_query->bbp_is_edit = true; $wp_query->bbp_is_reply_edit = true; // Setup the global reply ID $bbp->current_reply_id = get_the_ID(); // Move if (!empty($_GET['action']) && 'move' === $_GET['action']) { bbp_set_query_name('bbp_reply_move'); bbp_get_template_part('form', 'reply-move'); // Edit } else { bbp_set_query_name('bbp_reply_form'); bbp_get_template_part('form', 'reply'); } } break; } // Reset the query wp_reset_query(); ?> </div> <?php // Allow actions immediately after group forum output do_action('bbp_after_group_forum_display'); }
" /> <label for="bbp_reply_move_option_reply"><?php printf(__('New topic in <strong>%s</strong> titled:', 'bbpress'), bbp_get_forum_title(bbp_get_reply_forum_id(bbp_get_reply_id()))); ?> </label> <input type="text" id="bbp_reply_move_destination_title" value="<?php printf(__('Moved: %s', 'bbpress'), bbp_get_reply_title()); ?> " tabindex="<?php bbp_tab_index(); ?> " size="35" name="bbp_reply_move_destination_title" /> </div> <?php if (bbp_has_topics(array('show_stickies' => false, 'post_parent' => bbp_get_reply_forum_id(bbp_get_reply_id()), 'post__not_in' => array(bbp_get_reply_topic_id(bbp_get_reply_id()))))) { ?> <div> <input name="bbp_reply_move_option" id="bbp_reply_move_option_existing" type="radio" value="existing" tabindex="<?php bbp_tab_index(); ?> " /> <label for="bbp_reply_move_option_existing"><?php _e('Use an existing topic in this forum:', 'bbpress'); ?> </label> <?php bbp_dropdown(array('post_type' => bbp_get_topic_post_type(), 'post_parent' => bbp_get_reply_forum_id(bbp_get_reply_id()), 'selected' => -1, 'exclude' => bbp_get_reply_topic_id(bbp_get_reply_id()), 'select_id' => 'bbp_destination_topic')); ?>
function pg_get_user_unread($user_id = 0) { // Default to the displayed user $user_id = bbp_get_user_id($user_id); if (empty($user_id)) { return false; } // If user has unread topics, load them $read_ids = (string) get_user_meta($user_id, '_bbp_mar_read_ids', true); $read_ids = (array) explode(',', $read_ids); $read_ids = array_filter($read_ids); if (!empty($read_ids)) { //so we have unreads, so need to create a list of unread that the user can see //so first we create a list of topics the user can see global $wpdb; $topic = bbp_get_topic_post_type(); $post_ids = $wpdb->get_col("select ID from {$wpdb->posts} where post_type = '{$topic}'"); //check this list against those the user is allowed to see, and create a list of valid ones for the wp_query in bbp_has_topics $allowed_posts = check_private_groups_topic_ids($post_ids); //now we need to take out of that list all read topics for that user foreach ($read_ids as $read_id) { if (($key = array_search($read_id, $allowed_posts)) !== false) { unset($allowed_posts[$key]); } } //so now we have an allowed list that has only topics the user can see, but not topics the user has read //now we use the code from bbp_has_topics to run the list - we can't call it as PG already filters the original function global $wp_rewrite; /** Defaults **************************************************************/ // Other defaults $default_topic_search = !empty($_REQUEST['ts']) ? $_REQUEST['ts'] : false; $default_show_stickies = (bool) (bbp_is_single_forum() || bbp_is_topic_archive()) && false === $default_topic_search; $default_post_parent = bbp_is_single_forum() ? bbp_get_forum_id() : 'any'; // Default argument array $default = array('post_type' => bbp_get_topic_post_type(), 'post_parent' => $default_post_parent, 'meta_key' => '_bbp_last_active_time', 'orderby' => 'meta_value', 'order' => 'DESC', 'posts_per_page' => bbp_get_topics_per_page(), 'paged' => bbp_get_paged(), 's' => $default_topic_search, 'show_stickies' => $default_show_stickies, 'max_num_pages' => false, 'post__in' => $allowed_posts); // What are the default allowed statuses (based on user caps) if (bbp_get_view_all()) { // Default view=all statuses $post_statuses = array(bbp_get_public_status_id(), bbp_get_closed_status_id(), bbp_get_spam_status_id(), bbp_get_trash_status_id()); // Add support for private status if (current_user_can('read_private_topics')) { $post_statuses[] = bbp_get_private_status_id(); } // Join post statuses together $default['post_status'] = implode(',', $post_statuses); // Lean on the 'perm' query var value of 'readable' to provide statuses } else { $default['perm'] = 'readable'; } // Maybe query for topic tags if (bbp_is_topic_tag()) { $default['term'] = bbp_get_topic_tag_slug(); $default['taxonomy'] = bbp_get_topic_tag_tax_id(); } /** Setup *****************************************************************/ // Parse arguments against default values //stopped to prevent parsing //$r = bbp_parse_args( $args, $default, 'has_topics' ); // Get bbPress $bbp = bbpress(); // Call the query //now query the original default $bbp->topic_query = new WP_Query($default); // Set post_parent back to 0 if originally set to 'any' if ('any' === $r['post_parent']) { $r['post_parent'] = 0; } // Limited the number of pages shown if (!empty($r['max_num_pages'])) { $bbp->topic_query->max_num_pages = $r['max_num_pages']; } /** Stickies **************************************************************/ // Put sticky posts at the top of the posts array if (!empty($r['show_stickies']) && $r['paged'] <= 1) { // Get super stickies and stickies in this forum $stickies = bbp_get_super_stickies(); // Get stickies for current forum if (!empty($r['post_parent'])) { $stickies = array_merge($stickies, bbp_get_stickies($r['post_parent'])); } // Remove any duplicate stickies $stickies = array_unique($stickies); // We have stickies if (is_array($stickies) && !empty($stickies)) { // Start the offset at -1 so first sticky is at correct 0 offset $sticky_offset = -1; // Loop over topics and relocate stickies to the front. foreach ($stickies as $sticky_index => $sticky_ID) { // Get the post offset from the posts array $post_offsets = wp_filter_object_list($bbp->topic_query->posts, array('ID' => $sticky_ID), 'OR', 'ID'); // Continue if no post offsets if (empty($post_offsets)) { continue; } // Loop over posts in current query and splice them into position foreach (array_keys($post_offsets) as $post_offset) { $sticky_offset++; $sticky = $bbp->topic_query->posts[$post_offset]; // Remove sticky from current position array_splice($bbp->topic_query->posts, $post_offset, 1); // Move to front, after other stickies array_splice($bbp->topic_query->posts, $sticky_offset, 0, array($sticky)); // Cleanup unset($stickies[$sticky_index]); unset($sticky); } // Cleanup unset($post_offsets); } // Cleanup unset($sticky_offset); // If any posts have been excluded specifically, Ignore those that are sticky. if (!empty($stickies) && !empty($r['post__not_in'])) { $stickies = array_diff($stickies, $r['post__not_in']); } // Fetch sticky posts that weren't in the query results if (!empty($stickies)) { // Query to use in get_posts to get sticky posts $sticky_query = array('post_type' => bbp_get_topic_post_type(), 'post_parent' => 'any', 'meta_key' => '_bbp_last_active_time', 'orderby' => 'meta_value', 'order' => 'DESC', 'include' => $stickies); // Cleanup unset($stickies); // Conditionally exclude private/hidden forum ID's $exclude_forum_ids = bbp_exclude_forum_ids('array'); if (!empty($exclude_forum_ids)) { $sticky_query['post_parent__not_in'] = $exclude_forum_ids; } // What are the default allowed statuses (based on user caps) if (bbp_get_view_all()) { $sticky_query['post_status'] = $r['post_status']; // Lean on the 'perm' query var value of 'readable' to provide statuses } else { $sticky_query['post_status'] = $r['perm']; } // Get all stickies $sticky_posts = get_posts($sticky_query); if (!empty($sticky_posts)) { // Get a count of the visible stickies $sticky_count = count($sticky_posts); // Merge the stickies topics with the query topics . $bbp->topic_query->posts = array_merge($sticky_posts, $bbp->topic_query->posts); // Adjust loop and counts for new sticky positions $bbp->topic_query->found_posts = (int) $bbp->topic_query->found_posts + (int) $sticky_count; $bbp->topic_query->post_count = (int) $bbp->topic_query->post_count + (int) $sticky_count; // Cleanup unset($sticky_posts); } } } } // If no limit to posts per page, set it to the current post_count if (-1 === $r['posts_per_page']) { $r['posts_per_page'] = $bbp->topic_query->post_count; } // Add pagination values to query object $bbp->topic_query->posts_per_page = $r['posts_per_page']; $bbp->topic_query->paged = $r['paged']; // Only add pagination if query returned results if (((int) $bbp->topic_query->post_count || (int) $bbp->topic_query->found_posts) && (int) $bbp->topic_query->posts_per_page) { // Limit the number of topics shown based on maximum allowed pages if (!empty($r['max_num_pages']) && $bbp->topic_query->found_posts > $bbp->topic_query->max_num_pages * $bbp->topic_query->post_count) { $bbp->topic_query->found_posts = $bbp->topic_query->max_num_pages * $bbp->topic_query->post_count; } // If pretty permalinks are enabled, make our pagination pretty if ($wp_rewrite->using_permalinks()) { // User's topics if (bbp_is_single_user_topics()) { $base = bbp_get_user_topics_created_url(bbp_get_displayed_user_id()); // User's favorites } elseif (bbp_is_favorites()) { $base = bbp_get_favorites_permalink(bbp_get_displayed_user_id()); // User's subscriptions } elseif (bbp_is_subscriptions()) { $base = bbp_get_subscriptions_permalink(bbp_get_displayed_user_id()); // Root profile page } elseif (bbp_is_single_user()) { $base = bbp_get_user_profile_url(bbp_get_displayed_user_id()); // View } elseif (bbp_is_single_view()) { $base = bbp_get_view_url(); // Topic tag } elseif (bbp_is_topic_tag()) { $base = bbp_get_topic_tag_link(); // Page or single post } elseif (is_page() || is_single()) { $base = get_permalink(); // Forum archive } elseif (bbp_is_forum_archive()) { $base = bbp_get_forums_url(); // Topic archive } elseif (bbp_is_topic_archive()) { $base = bbp_get_topics_url(); // Default } else { $base = get_permalink((int) $r['post_parent']); } // Use pagination base $base = trailingslashit($base) . user_trailingslashit($wp_rewrite->pagination_base . '/%#%/'); // Unpretty pagination } else { $base = add_query_arg('paged', '%#%'); } // Pagination settings with filter $bbp_topic_pagination = apply_filters('bbp_topic_pagination', array('base' => $base, 'format' => '', 'total' => $r['posts_per_page'] === $bbp->topic_query->found_posts ? 1 : ceil((int) $bbp->topic_query->found_posts / (int) $r['posts_per_page']), 'current' => (int) $bbp->topic_query->paged, 'prev_text' => is_rtl() ? '→' : '←', 'next_text' => is_rtl() ? '←' : '→', 'mid_size' => 1)); // Add pagination to query object $bbp->topic_query->pagination_links = paginate_links($bbp_topic_pagination); // Remove first page from pagination $bbp->topic_query->pagination_links = str_replace($wp_rewrite->pagination_base . "/1/'", "'", $bbp->topic_query->pagination_links); } // Return object return apply_filters('pg_get_user_unread', $bbp->topic_query->have_posts(), $bbp->topic_query); } //if no unread return bbp_has_topics(); // default query }