_query = array(); // Single forum if ( ! empty( $select_query_vars ) ) { // Load up our own query query_posts( array_merge( array( 'post_type' => bbp_get_forum_post_type(), 'feed' => true ), $select_query_vars ) ); // Restrict to specific forum ID $meta_query = array( array( 'key' => '_bbp_forum_id', 'value' => bbp_get_forum_id(), 'type' => 'NUMERIC', 'compare' => '=' ) ); } // Only forum replies if ( ! empty( $_GET['type'] ) && ( bbp_get_reply_post_type() === $_GET['type'] ) ) { // The query $the_query = array( 'author' => 0, 'feed' => true, 'post_type' => bbp_get_reply_post_type(), 'post_parent' => 'any', 'post_status' => bbp_get_public_reply_statuses(), 'posts_per_page' => bbp_get_replies_per_rss_page(), 'order' => 'DESC', 'meta_query' => $meta_query ); // Output the feed bbp_display_replies_feed_rss2( $the_query ); // Only forum topics } elseif ( ! empty( $_GET['type'] ) && ( bbp_get_topic_post_type() === $_GET['type'] ) ) { // The query $the_query = array( 'author' => 0, 'feed' => true, 'post_type' => bbp_get_topic_post_type(), 'post_parent' => bbp_get_forum_id(), 'post_status' => bbp_get_public_topic_statuses(), 'posts_per_page' => bbp_get_topics_per_rss_page(), 'order' => 'DESC' ); // Output the feed bbp_display_topics_feed_rss2( $the_query ); // All forum topics and replies } else { // Exclude private/hidden forums if not looking at single if ( empty( $select_query_vars ) ) { $meta_query = array( bbp_exclude_forum_ids( 'meta_query' ) ); } // The query $the_query = array( 'author' => 0, 'feed' => true, 'post_type' => array( bbp_get_reply_post_type(), bbp_get_topic_post_type() ), 'post_parent' => 'any', 'post_status' => bbp_get_public_topic_statuses(), 'posts_per_page' => bbp_get_replies_per_rss_page(), 'order' => 'DESC', 'meta_query' => $meta_query ); // Output the feed bbp_display_replies_feed_rss2( $the_query ); } break; // Topic feed - Show replies case bbp_get_topic_post_type() : // Single topic if ( ! empty( $select_query_vars ) ) { // Load up our own query query_posts( array_merge( array( 'post_type' => bbp_get_topic_post_type(), 'feed' => true ), $select_query_vars ) ); // Output the feed bbp_display_replies_feed_rss2( array( 'feed' => true ) ); // All topics } else { // The query $the_query = array( 'author' => 0, 'feed' => true, 'post_parent' => 'any', 'posts_per_page' => bbp_get_topics_per_rss_page(), 'show_stickies' => false ); // Output the feed bbp_display_topics_feed_rss2( $the_query ); } break; // Replies case bbp_get_reply_post_type() : // The query $the_query = array( 'posts_per_page' => bbp_get_replies_per_rss_page(), 'meta_query' => array( array( ) ), 'feed' => true ); // All replies if ( empty( $select_query_vars ) ) { bbp_display_replies_feed_rss2( $the_query ); } break; } } // Single Topic Vview } elseif ( isset( $query_vars[ bbp_get_view_rewrite_id() ] ) ) { // Get the view $view = $query_vars[ bbp_get_view_rewrite_id() ]; // We have a view to display a feed if ( ! empty( $view ) ) { // Get the view query $the_query = bbp_get_view_query_args( $view ); // Output the feed bbp_display_topics_feed_rss2( $the_query ); } } // @todo User 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 ); }