Skip to:
Content

bbPress.org

Changeset 3435


Ignore:
Timestamp:
08/21/2011 02:33:27 AM (15 years ago)
Author:
johnjamesjacoby
Message:

Feed me 2.0! Improvements to feeds, allowing to filter by topic, reply, and defaulting to all. Works with single forums, topics, and their related content.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/plugin/bbp-includes/bbp-common-functions.php

    r3433 r3435  
    11801180                                        if ( isset( $query_vars[bbp_get_forum_post_type()] ) ) {
    11811181
     1182                                                // Get the forum by the path
     1183                                                $forum    = get_page_by_path( $query_vars[bbp_get_forum_post_type()], OBJECT, bbp_get_forum_post_type() );
     1184                                                $forum_id = $forum->ID;
     1185
    11821186                                                // Load up our own query
    11831187                                                $wp_query = new WP_Query( array(
    11841188                                                        'post_type' => bbp_get_forum_post_type(),
    1185                                                         'name'      => $query_vars[bbp_get_forum_post_type()]
     1189                                                        'ID'        => $forum_id
    11861190                                                ) );
    11871191
    1188                                                 // Forum replies
    1189                                                 if ( !empty( $_GET['type'] ) && ( bbp_get_reply_post_type() == $_GET['type'] ) ) {
    1190 
    1191                                                         // The query
    1192                                                         $the_query = array(
    1193                                                                 'author'         => 0,
    1194                                                                 'post_type'      => bbp_get_reply_post_type(),
    1195                                                                 'post_parent'    => 'any',
    1196                                                                 'post_status'    => join( ',', array( 'publish', $bbp->closed_status_id ) ),
    1197                                                                 'posts_per_page' => get_option( '_bbp_replies_per_rss_page', 25 ),
    1198                                                                 'order'          => 'DESC',
    1199                                                                 'meta_query'     => array( array(
    1200                                                                         'key'        => '_bbp_forum_id',
    1201                                                                         'value'      => bbp_get_forum_id(),
    1202                                                                         'compare'    => '='
    1203                                                                 ) )
    1204                                                         );
    1205 
    1206                                                         // Output the feed
    1207                                                         bbp_display_replies_feed_rss2( $the_query );
    1208 
    1209                                                 // Forum topics
    1210                                                 } else {
    1211 
    1212                                                         // The query
    1213                                                         $the_query = array(
    1214                                                                 'author'         => 0,
    1215                                                                 'post_type'      => bbp_get_topic_post_type(),
    1216                                                                 'post_parent'    => bbp_get_forum_id(),
    1217                                                                 'post_status'    => join( ',', array( 'publish', $bbp->closed_status_id ) ),
    1218                                                                 'posts_per_page' => get_option( '_bbp_topics_per_rss_page', 25 ),
    1219                                                                 'order'          => 'DESC',
    1220                                                                 'meta_query'     => array( array(
    1221                                                                         'key'        => '_bbp_forum_id',
    1222                                                                         'value'      => bbp_get_forum_id(),
    1223                                                                         'compare'    => '='
    1224                                                                 ) )
    1225                                                         );
    1226 
    1227                                                         // Output the feed
    1228                                                         bbp_display_topics_feed_rss2( $the_query );
    1229                                                 }
     1192                                                // Restrict to specific forum ID
     1193                                                $meta_query = array( array(
     1194                                                        'key'     => '_bbp_forum_id',
     1195                                                        'value'   => $forum_id,
     1196                                                        'compare' => '='
     1197                                                ) );
     1198                                               
     1199                                        // No restrictions on forum ID
     1200                                        } else {
     1201                                                $meta_query = array();
    12301202                                        }
    12311203
     1204                                        // Only forum replies
     1205                                        if ( !empty( $_GET['type'] ) && ( bbp_get_reply_post_type() == $_GET['type'] ) ) {
     1206
     1207                                                // The query
     1208                                                $the_query = array(
     1209                                                        'author'         => 0,
     1210                                                        'post_type'      => bbp_get_reply_post_type(),
     1211                                                        'post_parent'    => 'any',
     1212                                                        'post_status'    => join( ',', array( 'publish', $bbp->closed_status_id ) ),
     1213                                                        'posts_per_page' => get_option( '_bbp_replies_per_rss_page', 25 ),
     1214                                                        'order'          => 'DESC',
     1215                                                        'meta_query'     => $meta_query
     1216                                                );
     1217
     1218                                                // Output the feed
     1219                                                bbp_display_replies_feed_rss2( $the_query );
     1220
     1221                                        // Only forum topics
     1222                                        } elseif ( !empty( $_GET['type'] ) && ( bbp_get_topic_post_type() == $_GET['type'] ) ) {
     1223
     1224                                                // The query
     1225                                                $the_query = array(
     1226                                                        'author'         => 0,
     1227                                                        'post_type'      => bbp_get_topic_post_type(),
     1228                                                        'post_parent'    => 'any',
     1229                                                        'post_status'    => join( ',', array( 'publish', $bbp->closed_status_id ) ),
     1230                                                        'posts_per_page' => get_option( '_bbp_topics_per_rss_page', 25 ),
     1231                                                        'order'          => 'DESC',
     1232                                                        'meta_query'     => $meta_query
     1233                                                );
     1234
     1235                                                // Output the feed
     1236                                                bbp_display_topics_feed_rss2( $the_query );
     1237
     1238                                        // All forum topics and replies
     1239                                        } else {
     1240
     1241                                                // The query
     1242                                                $the_query = array(
     1243                                                        'author'         => 0,
     1244                                                        'post_type'      => array( bbp_get_reply_post_type(), bbp_get_topic_post_type() ),
     1245                                                        'post_parent'    => 'any',
     1246                                                        'post_status'    => join( ',', array( 'publish', $bbp->closed_status_id ) ),
     1247                                                        'posts_per_page' => get_option( '_bbp_replies_per_rss_page', 25 ),
     1248                                                        'order'          => 'DESC',
     1249                                                        'meta_query'     => $meta_query
     1250                                                );
     1251
     1252                                                // Output the feed
     1253                                                bbp_display_replies_feed_rss2( $the_query );
     1254                                        }
     1255
    12321256                                        break;
    12331257
    1234                                 // Topic - Show replies
     1258                                // Topic feed - Show replies
    12351259                                case bbp_get_topic_post_type() :
    12361260
Note: See TracChangeset for help on using the changeset viewer.