/** * Return the search url * * @since bbPress (r4928) * * @uses user_trailingslashit() To fix slashes * @uses trailingslashit() To fix slashes * @uses bbp_get_forums_url() To get the root forums url * @uses bbp_get_search_slug() To get the search slug * @uses add_query_arg() To help make unpretty permalinks * @return string Search url */ function bbp_get_search_results_url() { global $wp_rewrite; // Get the search terms $search_terms = bbp_get_search_terms(); // Pretty permalinks if ($wp_rewrite->using_permalinks()) { // Root search URL $url = $wp_rewrite->root . bbp_get_search_slug(); // Append search terms if (!empty($search_terms)) { $url = trailingslashit($url) . user_trailingslashit(urlencode($search_terms)); } // Run through home_url() $url = home_url(user_trailingslashit($url)); // Unpretty permalinks } else { $url = add_query_arg(array(bbp_get_search_rewrite_id() => urlencode($search_terms)), home_url('/')); } return apply_filters('bbp_get_search_results_url', $url); }
/** * Add permalink structures for new archive-style destinations. * * - Users * - Topic Views * - Search * * @since bbPress (r4930) */ public static function add_permastructs() { // Get unique ID's $user_id = bbp_get_user_rewrite_id(); $view_id = bbp_get_view_rewrite_id(); $search_id = bbp_get_search_rewrite_id(); // Get root slugs $user_slug = bbp_get_user_slug(); $view_slug = bbp_get_view_slug(); $search_slug = bbp_get_search_slug(); // User Permastruct add_permastruct($user_id, $user_slug . '/%' . $user_id . '%', array('with_front' => false, 'ep_mask' => EP_NONE, 'paged' => false, 'feed' => false, 'forcomments' => false, 'walk_dirs' => true, 'endpoints' => false)); // Topic View Permastruct add_permastruct($view_id, $view_slug . '/%' . $view_id . '%', array('with_front' => false, 'ep_mask' => EP_NONE, 'paged' => false, 'feed' => false, 'forcomments' => false, 'walk_dirs' => true, 'endpoints' => false)); // Search Permastruct add_permastruct($user_id, $search_slug . '/%' . $search_id . '%', array('with_front' => false, 'ep_mask' => EP_NONE, 'paged' => true, 'feed' => false, 'forcomments' => false, 'walk_dirs' => true, 'endpoints' => false)); }