/**
 * Return the search's query args
 *
 * @since bbPress (r4579)
 *
 * @uses bbp_get_search_terms() To get the search terms
 * @return array Query arguments
 */
function bbp_get_search_query_args()
{
    // Get search terms
    $search_terms = bbp_get_search_terms();
    $retval = !empty($search_terms) ? array('s' => $search_terms) : array();
    return apply_filters('bbp_get_search_query_args', $retval);
}
<form role="search" method="get" class="searchform bbp-search-form search-form" action="<?php 
bbp_search_url();
?>
">
	<div class="search-table">
		<label class="screen-reader-text hidden" for="bbp_search"><?php 
_e('Search for:', 'bbpress');
?>
</label>
		<input type="hidden" name="action" value="bbp-search-request" />
		<div class="search-field">
			<input tabindex="<?php 
bbp_tab_index();
?>
" type="text" value="<?php 
echo esc_attr(bbp_get_search_terms());
?>
" placeholder="<?php 
_e('Search the Forum...', 'Avada');
?>
" name="bbp_search" id="bbp_search" />
		</div>
		<div class="search-button">
			<input tabindex="<?php 
bbp_tab_index();
?>
" class="fusion-button button submit" type="submit" id="bbp_search_submit" value="&#xf002;" />
		</div>
		<div class="clearfix"></div>
	</div>
</form>
	<?php 
do_action('bbp_template_before_search');
?>

	<?php 
if (bbp_has_search_results()) {
    ?>

		 <?php 
    bbp_get_template_part('loop', 'search');
    ?>


	<?php 
} elseif (bbp_get_search_terms()) {
    ?>

		 <?php 
    bbp_get_template_part('feedback', 'no-search');
    ?>

	<?php 
} else {
    ?>

		<?php 
    bbp_get_template_part('form', 'search');
    ?>

	<?php 
Exemple #4
0
/**
 * Output the search terms
 *
 * @since bbPress (r4579)
 *
 * @param string $search_terms Optional. Search terms
 * @uses bbp_get_search_terms() To get the search terms
 */
function bbp_search_terms($search_terms = '')
{
    echo bbp_get_search_terms($search_terms);
}
Exemple #5
0
/**
 * Return a breadcrumb ( forum -> topic -> reply )
 *
 * @since bbPress (r2589)
 *
 * @param string $sep Separator. Defaults to '&larr;'
 * @param bool $current_page Include the current item
 * @param bool $root Include the root page if one exists
 *
 * @uses get_post() To get the post
 * @uses bbp_get_forum_permalink() To get the forum link
 * @uses bbp_get_topic_permalink() To get the topic link
 * @uses bbp_get_reply_permalink() To get the reply link
 * @uses get_permalink() To get the permalink
 * @uses bbp_get_forum_post_type() To get the forum post type
 * @uses bbp_get_topic_post_type() To get the topic post type
 * @uses bbp_get_reply_post_type() To get the reply post type
 * @uses bbp_get_forum_title() To get the forum title
 * @uses bbp_get_topic_title() To get the topic title
 * @uses bbp_get_reply_title() To get the reply title
 * @uses get_the_title() To get the title
 * @uses apply_filters() Calls 'bbp_get_breadcrumb' with the crumbs
 * @return string Breadcrumbs
 */
function bbp_get_breadcrumb($args = array())
{
    // Turn off breadcrumbs
    if (apply_filters('bbp_no_breadcrumb', is_front_page())) {
        return;
    }
    // Define variables
    $front_id = $root_id = 0;
    $ancestors = $crumbs = $tag_data = array();
    $pre_root_text = $pre_front_text = $pre_current_text = '';
    $pre_include_root = $pre_include_home = $pre_include_current = true;
    /** Home Text *********************************************************/
    // No custom home text
    if (empty($args['home_text'])) {
        $front_id = get_option('page_on_front');
        // Set home text to page title
        if (!empty($front_id)) {
            $pre_front_text = get_the_title($front_id);
            // Default to 'Home'
        } else {
            $pre_front_text = __('Home', 'bbpress');
        }
    }
    /** Root Text *********************************************************/
    // No custom root text
    if (empty($args['root_text'])) {
        $page = bbp_get_page_by_path(bbp_get_root_slug());
        if (!empty($page)) {
            $root_id = $page->ID;
        }
        $pre_root_text = bbp_get_forum_archive_title();
    }
    /** Includes **********************************************************/
    // Root slug is also the front page
    if (!empty($front_id) && $front_id === $root_id) {
        $pre_include_root = false;
    }
    // Don't show root if viewing forum archive
    if (bbp_is_forum_archive()) {
        $pre_include_root = false;
    }
    // Don't show root if viewing page in place of forum archive
    if (!empty($root_id) && ((is_single() || is_page()) && $root_id === get_the_ID())) {
        $pre_include_root = false;
    }
    /** Current Text ******************************************************/
    // Search page
    if (bbp_is_search()) {
        $pre_current_text = bbp_get_search_title();
        // Forum archive
    } elseif (bbp_is_forum_archive()) {
        $pre_current_text = bbp_get_forum_archive_title();
        // Topic archive
    } elseif (bbp_is_topic_archive()) {
        $pre_current_text = bbp_get_topic_archive_title();
        // View
    } elseif (bbp_is_single_view()) {
        $pre_current_text = bbp_get_view_title();
        // Single Forum
    } elseif (bbp_is_single_forum()) {
        $pre_current_text = bbp_get_forum_title();
        // Single Topic
    } elseif (bbp_is_single_topic()) {
        $pre_current_text = bbp_get_topic_title();
        // Single Topic
    } elseif (bbp_is_single_reply()) {
        $pre_current_text = bbp_get_reply_title();
        // Topic Tag (or theme compat topic tag)
    } elseif (bbp_is_topic_tag() || get_query_var('bbp_topic_tag') && !bbp_is_topic_tag_edit()) {
        // Always include the tag name
        $tag_data[] = bbp_get_topic_tag_name();
        // If capable, include a link to edit the tag
        if (current_user_can('manage_topic_tags')) {
            $tag_data[] = '<a href="' . esc_url(bbp_get_topic_tag_edit_link()) . '" class="bbp-edit-topic-tag-link">' . esc_html__('(Edit)', 'bbpress') . '</a>';
        }
        // Implode the results of the tag data
        $pre_current_text = sprintf(__('Topic Tag: %s', 'bbpress'), implode(' ', $tag_data));
        // Edit Topic Tag
    } elseif (bbp_is_topic_tag_edit()) {
        $pre_current_text = __('Edit', 'bbpress');
        // Single
    } else {
        $pre_current_text = get_the_title();
    }
    /** Parse Args ********************************************************/
    // Parse args
    $r = bbp_parse_args($args, array('before' => '<div class="bbp-breadcrumb"><p>', 'after' => '</p></div>', 'sep' => is_rtl() ? __('&lsaquo;', 'bbpress') : __('&rsaquo;', 'bbpress'), 'pad_sep' => 1, 'sep_before' => '<span class="bbp-breadcrumb-sep">', 'sep_after' => '</span>', 'crumb_before' => '', 'crumb_after' => '', 'include_home' => $pre_include_home, 'home_text' => $pre_front_text, 'include_root' => $pre_include_root, 'root_text' => $pre_root_text, 'include_current' => $pre_include_current, 'current_text' => $pre_current_text, 'current_before' => '<span class="bbp-breadcrumb-current">', 'current_after' => '</span>'), 'get_breadcrumb');
    /** Ancestors *********************************************************/
    // Get post ancestors
    if (is_singular() || bbp_is_forum_edit() || bbp_is_topic_edit() || bbp_is_reply_edit()) {
        $ancestors = array_reverse((array) get_post_ancestors(get_the_ID()));
    }
    // Do we want to include a link to home?
    if (!empty($r['include_home']) || empty($r['home_text'])) {
        $crumbs[] = '<a href="' . trailingslashit(home_url()) . '" class="bbp-breadcrumb-home">' . $r['home_text'] . '</a>';
    }
    // Do we want to include a link to the forum root?
    if (!empty($r['include_root']) || empty($r['root_text'])) {
        // Page exists at root slug path, so use its permalink
        $page = bbp_get_page_by_path(bbp_get_root_slug());
        if (!empty($page)) {
            $root_url = get_permalink($page->ID);
            // Use the root slug
        } else {
            $root_url = get_post_type_archive_link(bbp_get_forum_post_type());
        }
        // Add the breadcrumb
        $crumbs[] = '<a href="' . esc_url($root_url) . '" class="bbp-breadcrumb-root">' . $r['root_text'] . '</a>';
    }
    // Ancestors exist
    if (!empty($ancestors)) {
        // Loop through parents
        foreach ((array) $ancestors as $parent_id) {
            // Parents
            $parent = get_post($parent_id);
            // Skip parent if empty or error
            if (empty($parent) || is_wp_error($parent)) {
                continue;
            }
            // Switch through post_type to ensure correct filters are applied
            switch ($parent->post_type) {
                // Forum
                case bbp_get_forum_post_type():
                    $crumbs[] = '<a href="' . esc_url(bbp_get_forum_permalink($parent->ID)) . '" class="bbp-breadcrumb-forum">' . bbp_get_forum_title($parent->ID) . '</a>';
                    break;
                    // Topic
                // Topic
                case bbp_get_topic_post_type():
                    $crumbs[] = '<a href="' . esc_url(bbp_get_topic_permalink($parent->ID)) . '" class="bbp-breadcrumb-topic">' . bbp_get_topic_title($parent->ID) . '</a>';
                    break;
                    // Reply (Note: not in most themes)
                // Reply (Note: not in most themes)
                case bbp_get_reply_post_type():
                    $crumbs[] = '<a href="' . esc_url(bbp_get_reply_permalink($parent->ID)) . '" class="bbp-breadcrumb-reply">' . bbp_get_reply_title($parent->ID) . '</a>';
                    break;
                    // WordPress Post/Page/Other
                // WordPress Post/Page/Other
                default:
                    $crumbs[] = '<a href="' . esc_url(get_permalink($parent->ID)) . '" class="bbp-breadcrumb-item">' . get_the_title($parent->ID) . '</a>';
                    break;
            }
        }
        // Edit topic tag
    } elseif (bbp_is_topic_tag_edit()) {
        $crumbs[] = '<a href="' . esc_url(get_term_link(bbp_get_topic_tag_id(), bbp_get_topic_tag_tax_id())) . '" class="bbp-breadcrumb-topic-tag">' . sprintf(__('Topic Tag: %s', 'bbpress'), bbp_get_topic_tag_name()) . '</a>';
        // Search
    } elseif (bbp_is_search() && bbp_get_search_terms()) {
        $crumbs[] = '<a href="' . esc_url(bbp_get_search_url()) . '" class="bbp-breadcrumb-search">' . esc_html__('Search', 'bbpress') . '</a>';
    }
    /** Current ***********************************************************/
    // Add current page to breadcrumb
    if (!empty($r['include_current']) || empty($r['current_text'])) {
        $crumbs[] = $r['current_before'] . $r['current_text'] . $r['current_after'];
    }
    /** Separator *********************************************************/
    // Wrap the separator in before/after before padding and filter
    if (!empty($r['sep'])) {
        $sep = $r['sep_before'] . $r['sep'] . $r['sep_after'];
    }
    // Pad the separator
    if (!empty($r['pad_sep'])) {
        if (function_exists('mb_strlen')) {
            $sep = str_pad($sep, mb_strlen($sep) + (int) $r['pad_sep'] * 2, ' ', STR_PAD_BOTH);
        } else {
            $sep = str_pad($sep, strlen($sep) + (int) $r['pad_sep'] * 2, ' ', STR_PAD_BOTH);
        }
    }
    /** Finish Up *********************************************************/
    // Filter the separator and breadcrumb
    $sep = apply_filters('bbp_breadcrumb_separator', $sep);
    $crumbs = apply_filters('bbp_breadcrumbs', $crumbs);
    // Build the trail
    $trail = !empty($crumbs) ? $r['before'] . $r['crumb_before'] . implode($sep . $r['crumb_after'] . $r['crumb_before'], $crumbs) . $r['crumb_after'] . $r['after'] : '';
    return apply_filters('bbp_get_breadcrumb', $trail, $crumbs, $r);
}
    /**
     * Render a special "new search" form on top of the search results page.
     */
    public function add_search_page_search_form()
    {
        ?>
		<div class="search-page-search-form search-page-search-form-top">
			<h2><?php 
        echo __('Need a new search?', 'Avada');
        ?>
</h2>
			<p><?php 
        echo __('If you didn\'t find what you were looking for, try a new search!', 'Avada');
        ?>
</p>
			<form role="search" method="get" class="bbp-search-form seach-form searchform" action="<?php 
        bbp_search_url();
        ?>
">
				<div class="search-table">
					<label class="screen-reader-text hidden" for="bbp_search"><?php 
        _e('Search for:', 'bbpress');
        ?>
</label>
					<input type="hidden" name="action" value="bbp-search-request" />
					<div class="search-field">
						<input tabindex="<?php 
        bbp_tab_index();
        ?>
" type="text" value="<?php 
        echo esc_attr(bbp_get_search_terms());
        ?>
" placeholder="<?php 
        _e('Search the Forum...', 'Avada');
        ?>
" name="bbp_search" id="bbp_search" />
					</div>
					<div class="search-button">
						<input tabindex="<?php 
        bbp_tab_index();
        ?>
" class="fusion-button button submit" type="submit" id="bbp_search_submit" value="&#xf002;" />
					</div>
				</div>
			</form>
		</div>
		<?php 
    }
/**
 * Add checks for bbPress conditions to parse_query action
 *
 * If it's a user page, WP_Query::bbp_is_single_user is set to true.
 * If it's a user edit page, WP_Query::bbp_is_single_user_edit is set to true
 * and the the 'wp-admin/includes/user.php' file is included.
 * In addition, on user/user edit pages, WP_Query::home is set to false & query
 * vars 'bbp_user_id' with the displayed user id and 'author_name' with the
 * displayed user's nicename are added.
 *
 * If it's a forum edit, WP_Query::bbp_is_forum_edit is set to true
 * If it's a topic edit, WP_Query::bbp_is_topic_edit is set to true
 * If it's a reply edit, WP_Query::bbp_is_reply_edit is set to true.
 *
 * If it's a view page, WP_Query::bbp_is_view is set to true
 * If it's a search page, WP_Query::bbp_is_search is set to true
 *
 * @since bbPress (r2688)
 *
 * @param WP_Query $posts_query
 *
 * @uses get_query_var() To get {@link WP_Query} query var
 * @uses is_email() To check if the string is an email
 * @uses get_user_by() To try to get the user by email and nicename
 * @uses get_userdata() to get the user data
 * @uses current_user_can() To check if the current user can edit the user
 * @uses is_user_member_of_blog() To check if user profile page exists
 * @uses WP_Query::set_404() To set a 404 status
 * @uses apply_filters() Calls 'enable_edit_any_user_configuration' with true
 * @uses bbp_get_view_query_args() To get the view query args
 * @uses bbp_get_forum_post_type() To get the forum post type
 * @uses bbp_get_topic_post_type() To get the topic post type
 * @uses bbp_get_reply_post_type() To get the reply post type
 * @uses remove_action() To remove the auto save post revision action
 */
function bbp_parse_query($posts_query)
{
    // Bail if $posts_query is not the main loop
    if (!$posts_query->is_main_query()) {
        return;
    }
    // Bail if filters are suppressed on this query
    if (true === $posts_query->get('suppress_filters')) {
        return;
    }
    // Bail if in admin
    if (is_admin()) {
        return;
    }
    // Get query variables
    $bbp_view = $posts_query->get(bbp_get_view_rewrite_id());
    $bbp_user = $posts_query->get(bbp_get_user_rewrite_id());
    $is_edit = $posts_query->get(bbp_get_edit_rewrite_id());
    // It is a user page - We'll also check if it is user edit
    if (!empty($bbp_user)) {
        /** Find User *********************************************************/
        // Setup the default user variable
        $the_user = false;
        // If using pretty permalinks, use the email or slug
        if (get_option('permalink_structure')) {
            // Email was passed
            if (is_email($bbp_user)) {
                $the_user = get_user_by('email', $bbp_user);
                // Try nicename
            } else {
                $the_user = get_user_by('slug', $bbp_user);
            }
        }
        // No user found by slug/email, so try the ID if it's numeric
        if (empty($the_user) && is_numeric($bbp_user)) {
            $the_user = get_user_by('id', $bbp_user);
        }
        // 404 and bail if user does not have a profile
        if (empty($the_user->ID) || !bbp_user_has_profile($the_user->ID)) {
            $posts_query->set_404();
            return;
        }
        /** User Exists *******************************************************/
        $is_favs = $posts_query->get(bbp_get_user_favorites_rewrite_id());
        $is_subs = $posts_query->get(bbp_get_user_subscriptions_rewrite_id());
        $is_topics = $posts_query->get(bbp_get_user_topics_rewrite_id());
        $is_replies = $posts_query->get(bbp_get_user_replies_rewrite_id());
        // View or edit?
        if (!empty($is_edit)) {
            // We are editing a profile
            $posts_query->bbp_is_single_user_edit = true;
            // Load the core WordPress contact methods
            if (!function_exists('_wp_get_user_contactmethods')) {
                include_once ABSPATH . 'wp-includes/registration.php';
            }
            // Load the edit_user functions
            if (!function_exists('edit_user')) {
                require_once ABSPATH . 'wp-admin/includes/user.php';
            }
            // Load the grant/revoke super admin functions
            if (is_multisite() && !function_exists('revoke_super_admin')) {
                require_once ABSPATH . 'wp-admin/includes/ms.php';
            }
            // Editing a user
            $posts_query->bbp_is_edit = true;
            // User favorites
        } elseif (!empty($is_favs)) {
            $posts_query->bbp_is_single_user_favs = true;
            // User subscriptions
        } elseif (!empty($is_subs)) {
            $posts_query->bbp_is_single_user_subs = true;
            // User topics
        } elseif (!empty($is_topics)) {
            $posts_query->bbp_is_single_user_topics = true;
            // User topics
        } elseif (!empty($is_replies)) {
            $posts_query->bbp_is_single_user_replies = true;
            // User profile
        } else {
            $posts_query->bbp_is_single_user_profile = true;
        }
        // Looking at a single user
        $posts_query->bbp_is_single_user = true;
        // Make sure 404 is not set
        $posts_query->is_404 = false;
        // Correct is_home variable
        $posts_query->is_home = false;
        // User is looking at their own profile
        if (get_current_user_id() === $the_user->ID) {
            $posts_query->bbp_is_single_user_home = true;
        }
        // Set bbp_user_id for future reference
        $posts_query->set('bbp_user_id', $the_user->ID);
        // Set author_name as current user's nicename to get correct posts
        $posts_query->set('author_name', $the_user->user_nicename);
        // Set the displayed user global to this user
        bbpress()->displayed_user = $the_user;
        // View Page
    } elseif (!empty($bbp_view)) {
        // Check if the view exists by checking if there are query args are set
        $view_args = bbp_get_view_query_args($bbp_view);
        // Bail if view args is false (view isn't registered)
        if (false === $view_args) {
            $posts_query->set_404();
            return;
        }
        // Correct is_home variable
        $posts_query->is_home = false;
        // We are in a custom topic view
        $posts_query->bbp_is_view = true;
        // Search Page
    } elseif (isset($posts_query->query_vars[bbp_get_search_rewrite_id()])) {
        // Check if there are search query args set
        $search_terms = bbp_get_search_terms();
        if (!empty($search_terms)) {
            $posts_query->bbp_search_terms = $search_terms;
        }
        // Correct is_home variable
        $posts_query->is_home = false;
        // We are in a search query
        $posts_query->bbp_is_search = true;
        // Forum/Topic/Reply Edit Page
    } elseif (!empty($is_edit)) {
        // Get the post type from the main query loop
        $post_type = $posts_query->get('post_type');
        // Check which post_type we are editing, if any
        if (!empty($post_type)) {
            switch ($post_type) {
                // We are editing a forum
                case bbp_get_forum_post_type():
                    $posts_query->bbp_is_forum_edit = true;
                    $posts_query->bbp_is_edit = true;
                    break;
                    // We are editing a topic
                // We are editing a topic
                case bbp_get_topic_post_type():
                    $posts_query->bbp_is_topic_edit = true;
                    $posts_query->bbp_is_edit = true;
                    break;
                    // We are editing a reply
                // We are editing a reply
                case bbp_get_reply_post_type():
                    $posts_query->bbp_is_reply_edit = true;
                    $posts_query->bbp_is_edit = true;
                    break;
            }
            // We are editing a topic tag
        } elseif (bbp_is_topic_tag()) {
            $posts_query->bbp_is_topic_tag_edit = true;
            $posts_query->bbp_is_edit = true;
        }
        // We save post revisions on our own
        remove_action('pre_post_update', 'wp_save_post_revision');
        // Topic tag page
    } elseif (bbp_is_topic_tag()) {
        $posts_query->set('bbp_topic_tag', get_query_var('term'));
        $posts_query->set('post_type', bbp_get_topic_post_type());
        $posts_query->set('posts_per_page', bbp_get_topics_per_page());
        // Do topics on forums root
    } elseif (is_post_type_archive(array(bbp_get_forum_post_type(), bbp_get_topic_post_type())) && 'topics' === bbp_show_on_root()) {
        $posts_query->bbp_show_topics_on_root = true;
    }
}
function myfossil_bbpress_highlight_search_results()
{
    myfossil_highlight_search_results();
    // Get search terms
    $search_terms = bbp_get_search_terms();
    echo "<script>jQuery('#bbp-search-results').highlight('" . $search_terms . "');</script>";
}
 /**
  * Display the contents of search results in an output buffer and return to
  * ensure that post/page contents are displayed first.
  *
  * @since bbPress (r4579)
  *
  * @param array $attr
  * @param string $content
  * @uses bbp_search_query()
  * @uses get_template_part()
  */
 public function display_search($attr, $content = '')
 {
     // Sanity check required info
     if (!empty($content)) {
         return $content;
     }
     // Bail if search is disabled
     if (!bbp_allow_search()) {
         return;
     }
     // Trim search attribute if it's set
     if (isset($attr['search'])) {
         $attr['search'] = trim($attr['search']);
     }
     // Set passed attribute to $search_terms for clarity
     $search_terms = empty($attr['search']) ? bbp_get_search_terms() : $attr['search'];
     // Unset globals
     $this->unset_globals();
     // Set terms for query
     set_query_var(bbp_get_search_rewrite_id(), $search_terms);
     // Start output buffer
     $this->start(bbp_get_search_rewrite_id());
     // Output template
     bbp_get_template_part('content', 'search');
     // Return contents of output buffer
     return $this->end();
 }
function pg_has_search_results($args = '')
{
    global $wp_rewrite;
    //start with code as per bbp search !
    /** Defaults **************************************************************/
    $default_post_type = array(bbp_get_forum_post_type(), bbp_get_topic_post_type(), bbp_get_reply_post_type());
    // Default query args
    $default = array('post_type' => $default_post_type, 'posts_per_page' => bbp_get_replies_per_page(), 'paged' => bbp_get_paged(), 'orderby' => 'date', 'order' => 'DESC', 'ignore_sticky_posts' => true, 's' => bbp_get_search_terms());
    // 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';
    }
    //PG then loop to find allowable forums
    //Get an array of IDs which the current user has permissions to view
    $allowed_posts = private_groups_get_permitted_post_ids(new WP_Query($default));
    // The default forum query with allowed forum ids array added
    $default['post__in'] = $allowed_posts;
    if (empty($allowed_posts)) {
        $default['post__in'] = array(0);
    }
    //then return to bbp search code
    /** Setup *****************************************************************/
    // Parse arguments against default values
    $r = bbp_parse_args($args, $default, 'has_search_results');
    // Get bbPress
    $bbp = bbpress();
    // Call the query
    if (!empty($r['s'])) {
        $bbp->search_query = new WP_Query($r);
    }
    // Add pagination values to query object
    $bbp->search_query->posts_per_page = $r['posts_per_page'];
    $bbp->search_query->paged = $r['paged'];
    // Never home, regardless of what parse_query says
    $bbp->search_query->is_home = false;
    // Only add pagination is query returned results
    if (!empty($bbp->search_query->found_posts) && !empty($bbp->search_query->posts_per_page)) {
        // Array of arguments to add after pagination links
        $add_args = array();
        // If pretty permalinks are enabled, make our pagination pretty
        if ($wp_rewrite->using_permalinks()) {
            // Shortcode territory
            if (is_page() || is_single()) {
                $base = trailingslashit(get_permalink());
                // Default search location
            } else {
                $base = trailingslashit(bbp_get_search_results_url());
            }
            // Add pagination base
            $base = $base . user_trailingslashit($wp_rewrite->pagination_base . '/%#%/');
            // Unpretty permalinks
        } else {
            $base = add_query_arg('paged', '%#%');
        }
        // Add args
        if (bbp_get_view_all()) {
            $add_args['view'] = 'all';
        }
        // Add pagination to query object
        $bbp->search_query->pagination_links = paginate_links(apply_filters('bbp_search_results_pagination', array('base' => $base, 'format' => '', 'total' => ceil((int) $bbp->search_query->found_posts / (int) $r['posts_per_page']), 'current' => (int) $bbp->search_query->paged, 'prev_text' => is_rtl() ? '&rarr;' : '&larr;', 'next_text' => is_rtl() ? '&larr;' : '&rarr;', 'mid_size' => 1, 'add_args' => $add_args)));
        // Remove first page from pagination
        if ($wp_rewrite->using_permalinks()) {
            $bbp->search_query->pagination_links = str_replace($wp_rewrite->pagination_base . '/1/', '', $bbp->search_query->pagination_links);
        } else {
            $bbp->search_query->pagination_links = str_replace('&#038;paged=1', '', $bbp->search_query->pagination_links);
        }
    }
    //finally filter to return
    // Return object
    return apply_filters('pg_has_search_results', $bbp->search_query->have_posts(), $bbp->search_query);
}