/** * Return the search url * * @since 2.4.0 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() { // Get the search terms $search_terms = bbp_get_search_terms(); // Pretty permalinks if (bbp_use_pretty_urls()) { // Root search URL $url = bbp_get_root_url() . bbp_get_search_slug(); // Append search terms if (!empty($search_terms)) { $url = trailingslashit($url) . urlencode($search_terms); } // Run through home_url() $url = user_trailingslashit($url); $url = home_url($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); }
/** * Return URL to the profile page of a user * * @since 2.0.0 bbPress (r2688) * * @param int $user_id Optional. User id * @param string $user_nicename Optional. User nicename * @uses bbp_get_user_id() To get user id * @uses bbp_use_pretty_urls() To check if the site is using pretty URLs * @uses add_query_arg() To add custom args to the url * @uses home_url() To get blog home url * @uses apply_filters() Calls 'bbp_get_user_profile_url' with the user * profile url, user id and user nicename * @return string User profile url */ function bbp_get_user_profile_url($user_id = 0, $user_nicename = '') { // Use displayed user ID if there is one, and one isn't requested $user_id = bbp_get_user_id($user_id); if (empty($user_id)) { return false; } // Allow early overriding of the profile URL to cut down on processing $early_profile_url = apply_filters('bbp_pre_get_user_profile_url', $user_id); if (is_string($early_profile_url)) { return $early_profile_url; } // Pretty permalinks if (bbp_use_pretty_urls()) { // Get username if not passed if (empty($user_nicename)) { $user_nicename = bbp_get_user_nicename($user_id); } $url = trailingslashit(bbp_get_root_url() . bbp_get_user_slug()) . $user_nicename; $url = user_trailingslashit($url); $url = home_url($url); // Unpretty permalinks } else { $url = add_query_arg(array(bbp_get_user_rewrite_id() => $user_id), home_url('/')); } return apply_filters('bbp_get_user_profile_url', $url, $user_id, $user_nicename); }
/** * Return the view url * * @since 2.0.0 bbPress (r2789) * * @param string $view Optional. View id * @uses sanitize_title() To sanitize the view id * @uses home_url() To get blog home url * @uses add_query_arg() To add custom args to the url * @uses apply_filters() Calls 'bbp_get_view_url' with the view url, * used view id * @return string View url (or home url if the view was not found) */ function bbp_get_view_url($view = false) { $view = bbp_get_view_id($view); if (empty($view)) { return home_url(); } // Pretty permalinks if (bbp_use_pretty_urls()) { $url = trailingslashit(bbp_get_root_url() . bbp_get_view_slug()) . $view; $url = user_trailingslashit($url); $url = home_url($url); // Unpretty permalinks } else { $url = add_query_arg(array(bbp_get_view_rewrite_id() => $view), home_url('/')); } return apply_filters('bbp_get_view_link', $url, $view); }