/** * Redirect to search results page if needed * * @since 2.4.0 bbPress (r4928) * * @return If a redirect is not needed */ function bbp_search_results_redirect() { // Bail if not a search request action if (empty($_GET['action']) || 'bbp-search-request' !== $_GET['action']) { return; } // Bail if not using pretty permalinks if (!bbp_use_pretty_urls()) { return; } // Get the redirect URL $redirect_to = bbp_get_search_results_url(); if (empty($redirect_to)) { return; } // Redirect and bail bbp_redirect($redirect_to); }
/** * Return the link of the current tag * * @since 2.0.0 bbPress (r3348) * * @uses get_term_by() * @uses get_queried_object() * @uses get_query_var() * @uses apply_filters() * * @return string Term Name */ function bbp_get_topic_tag_edit_link($tag = '') { // Get the term if (!empty($tag)) { $term = get_term_by('slug', $tag, bbp_get_topic_tag_tax_id()); } else { $tag = get_query_var('term'); $term = get_queried_object(); } // Add before and after if description exists if (!empty($term->term_id)) { // Pretty if (bbp_use_pretty_urls()) { $retval = user_trailingslashit(trailingslashit(bbp_get_topic_tag_link()) . bbp_get_edit_rewrite_id()); // Ugly } else { $retval = add_query_arg(array(bbp_get_edit_rewrite_id() => '1'), bbp_get_topic_tag_link()); } // No link } else { $retval = ''; } return apply_filters('bbp_get_topic_tag_edit_link', $retval, $tag, $term); }
/** * Return the link to the user's replies * * @since 2.2.0 bbPress (r4225) * * @param int $user_id Optional. User id * @uses bbp_get_user_profile_url() To get the user profile url * @uses apply_filters() Calls 'bbp_get_favorites_permalink' with the * user profile url and user id * @return string Permanent link to user profile page */ function bbp_get_user_replies_created_url($user_id = 0) { // 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_url = apply_filters('bbp_pre_get_user_replies_created_url', $user_id); if (is_string($early_url)) { return $early_url; } // Get user profile URL $profile_url = bbp_get_user_profile_url($user_id); // Pretty permalinks if (bbp_use_pretty_urls()) { $url = trailingslashit($profile_url) . bbp_get_reply_archive_slug(); $url = user_trailingslashit($url); // Unpretty permalinks } else { $url = add_query_arg(array(bbp_get_user_replies_rewrite_id() => '1'), $profile_url); } return apply_filters('bbp_get_user_replies_created_url', $url, $user_id); }
/** * Return URL to the reply edit page * * @since 2.0.0 bbPress (r2753) * * @param int $reply_id Optional. Reply id * @uses bbp_get_reply_id() To get the reply id * @uses bbp_get_reply() To get the reply * @uses bbp_get_reply_post_type() To get the reply post type * @uses add_query_arg() To add custom args to the url * @uses apply_filters() Calls 'bbp_get_reply_edit_url' with the edit * url and reply id * @return string Reply edit url */ function bbp_get_reply_edit_url($reply_id = 0) { $reply = bbp_get_reply($reply_id); if (empty($reply)) { return; } $reply_link = bbp_remove_view_all(bbp_get_reply_permalink($reply_id)); // Pretty permalinks if (bbp_use_pretty_urls()) { $url = trailingslashit($reply_link) . bbp_get_edit_rewrite_id(); $url = user_trailingslashit($url); // Unpretty permalinks } else { $url = add_query_arg(array(bbp_get_reply_post_type() => $reply->post_name, bbp_get_edit_rewrite_id() => '1'), $reply_link); } // Maybe add view all $url = bbp_add_view_all($url); return apply_filters('bbp_get_reply_edit_url', $url, $reply_id); }
/** * 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 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); }
/** * Remove the canonical redirect to allow pretty pagination * * @since 2.0.0 bbPress (r2628) * * @param string $redirect_url Redirect url * @uses bbp_use_pretty_urls() To check if the blog is using permalinks * @uses bbp_get_paged() To get the current page number * @uses bbp_is_single_topic() To check if it's a topic page * @uses bbp_is_single_forum() To check if it's a forum page * * @return bool|string False if it's a topic/forum and their first page, * otherwise the redirect url */ function bbp_redirect_canonical($redirect_url) { // Canonical is for the beautiful if (bbp_use_pretty_urls()) { // If viewing beyond page 1 of several if (1 < bbp_get_paged()) { // Only on single topics... if (bbp_is_single_topic()) { $redirect_url = false; // ...and single forums... } elseif (bbp_is_single_forum()) { $redirect_url = false; // ...and single replies... } elseif (bbp_is_single_reply()) { $redirect_url = false; // ...and any single anything else... // // @todo - Find a more accurate way to disable paged canonicals for // paged shortcode usage within other posts. } elseif (is_page() || is_singular()) { $redirect_url = false; } // If editing a topic } elseif (bbp_is_topic_edit()) { $redirect_url = false; // If editing a reply } elseif (bbp_is_reply_edit()) { $redirect_url = false; } } return $redirect_url; }