r profile feeds } // No feed so continue on return $query_vars; } /** Templates ******************************************************************/ /** * Used to guess if page exists at requested path * * @since 2.0.0 bbPress (r3304) * * @param string $path * @return mixed False if no page, Page object if true */ function bbp_get_page_by_path( $path = '' ) { // Default to false $retval = false; // Path is not empty if ( ! empty( $path ) ) { // Pretty permalinks are on so path might exist if ( get_option( 'permalink_structure' ) ) { $retval = get_page_by_path( $path ); } } // Filter & return return apply_filters( 'bbp_get_page_by_path', $retval, $path ); } /** * Sets the 404 status. * * Used primarily with topics/replies inside hidden forums. * * @since 2.0.0 bbPress (r3051) * @since 2.6.0 bbPress (r6583) Use status_header() & nocache_headers() * * @param WP_Query $query The query being checked * * @return bool Always returns true */ function bbp_set_404( $query = null ) { // Global fallback if ( empty( $query ) ) { $query = bbp_get_wp_query(); } // Setup environment $query->set_404(); // Setup request status_header( 404 ); nocache_headers(); } /** * Sets the 200 status header. * * @since 2.6.0 bbPress (r6583) */ function bbp_set_200() { status_header( 200 ); } /** * Maybe handle the default 404 handling for some bbPress conditions * * Some conditions (like private/hidden forums and edits) have their own checks * on `bbp_template_redirect` and are not currently 404s. * * @since 2.6.0 bbPress (r6555) * * @param bool $override Whether to override the default handler * @param WP_Query $wp_query The posts query being referenced * * @return bool False to leave alone, true to override */ function bbp_pre_handle_404( $override = false, $wp_query = false ) { // Handle a bbPress 404 condition if ( isset( $wp_query->bbp_is_404 ) ) { // Either force a 404 when 200, or a 200 when 404 $override = ( true === $wp_query->bbp_is_404 ) ? bbp_set_404( $wp_query ) : bbp_set_200(); } // Return, maybe overridden return $override; } /** * Maybe pre-assign the posts that are returned from a WP_Query. * * This effectively short-circuits the default query for posts, which is * currently only used to avoid calling the main query when it's not necessary. * * @since 2.6.0 bbPress (r6580) * * @param mixed $posts Default null. Array of posts (possibly empty) * @param WP_Query $wp_query * * @return mixed Null if no override. Array if overridden. */ function bbp_posts_pre_query( $posts = null, $wp_query = false ) { // Custom 404 handler is set, so set posts to empty array to avoid 2 queries if ( ! empty( $wp_query->bbp_is_404 ) ) { $posts = array(); } // Return, maybe overridden return $posts; } /** * Get scheme for a URL based on is_ssl() results. * * @since 2.6.0 bbPress (r6759) * * @return string https:// if is_ssl(), otherwise http:// */ function bbp_get_url_scheme() { return is_ssl() ? 'https://' : 'http://'; } /** Titles ********************************************************************/ /** * Is a title longer that the maximum title length? * * Uses mb_strlen() in `8bit` mode to treat strings as raw. This matches the * behavior present in Comments, PHPMailer, RandomCompat, and others. * * @since 2.6.0 bbPress (r6783) * * @param string $title * @return bool */ function bbp_is_title_too_long( $title = '' ) { $max = bbp_get_title_max_length(); $len = mb_strlen( $title, '8bit' ); $result = ( $len > $max ); // Filter & return return (bool) apply_filters( 'bbp_is_title_too_long', $result, $title, $max, $len ); }