Skip to:
Content

bbPress.org


Ignore:
Timestamp:
05/18/2011 12:08:18 PM (16 years ago)
Author:
johnjamesjacoby
Message:

First pass at RSS feeds. See #1422.

File:
1 edited

Legend:

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

    r3125 r3171  
    937937}
    938938
     939/** Feeds *********************************************************************/
     940
     941/**
     942 * Output an RSS2 feed of replies, based on the query passed.
     943 *
     944 * @since bbPress (r3171)
     945 *
     946 * @global bbPress $bbp
     947 *
     948 * @uses bbp_exclude_forum_ids()
     949 * @uses bbp_is_topic()
     950 * @uses bbp_user_can_view_forum()
     951 * @uses bbp_get_topic_forum_id()
     952 * @uses bbp_show_load_topic()
     953 * @uses bbp_topic_permalink()
     954 * @uses bbp_topic_title()
     955 * @uses bbp_get_topic_reply_count()
     956 * @uses bbp_topic_content()
     957 * @uses bbp_has_replies()
     958 * @uses bbp_replies()
     959 * @uses bbp_the_reply()
     960 * @uses bbp_reply_url()
     961 * @uses bbp_reply_title()
     962 * @uses bbp_reply_content()
     963 * @uses get_wp_title_rss()
     964 * @uses get_option()
     965 * @uses bloginfo_rss
     966 * @uses self_link()
     967 * @uses the_author()
     968 * @uses get_post_time()
     969 * @uses rss_enclosure()
     970 * @uses do_action()
     971 * @uses apply_filters()
     972 *
     973 * @param array $replies_query
     974 */
     975function bbp_display_replies_feed_rss2( $replies_query = array() ) {
     976        global $bbp;
     977
     978        // User cannot access forum this topic is in
     979        if ( bbp_is_topic() && !bbp_user_can_view_forum( array( 'forum_id' => bbp_get_topic_forum_id() ) ) )
     980                return;
     981
     982        // Remove any replies from hidden forums
     983        $replies_query = bbp_exclude_forum_ids( $replies_query );
     984
     985        // Adjust the title based on context
     986        if ( bbp_is_topic() && bbp_user_can_view_forum( array( 'forum_id' => bbp_get_topic_forum_id() ) ) )
     987                $title = apply_filters( 'wp_title_rss', get_wp_title_rss( ' » ' ) );
     988        elseif ( !bbp_show_lead_topic() )
     989                $title = ' » ' .  __( 'All Posts',   'bbpress' );
     990        else
     991                $title = ' » ' .  __( 'All Replies', 'bbpress' );
     992
     993        // Display the feed
     994        header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), true );
     995        header( 'Status: 200 OK' );
     996        echo '<?xml version="1.0" encoding="' . get_option( 'blog_charset' ) . '"?' . '>'; ?>
     997
     998        <rss version="2.0"
     999                xmlns:content="http://purl.org/rss/1.0/modules/content/"
     1000                xmlns:wfw="http://wellformedweb.org/CommentAPI/"
     1001                xmlns:dc="http://purl.org/dc/elements/1.1/"
     1002                xmlns:atom="http://www.w3.org/2005/Atom"
     1003
     1004                <?php do_action( 'bbp_feed' ); ?>
     1005        >
     1006
     1007        <channel>
     1008                <title><?php bloginfo_rss('name'); echo $title; ?></title>
     1009                <atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
     1010                <link><?php self_link(); ?></link>
     1011                <description><?php //?></description>
     1012                <pubDate><?php echo mysql2date( 'D, d M Y H:i:s O', '', false ); ?></pubDate>
     1013                <generator>http://bbpress.org/?v=<?php echo BBP_VERSION; ?></generator>
     1014                <language><?php echo get_option( 'rss_language' ); ?></language>
     1015
     1016                <?php do_action( 'bbp_feed_head' ); ?>
     1017
     1018                <?php if ( bbp_is_topic() ) : ?>
     1019                        <?php if ( bbp_user_can_view_forum( array( 'forum_id' => bbp_get_topic_forum_id() ) ) ) : ?>
     1020                                <?php if ( bbp_show_lead_topic() ) : ?>
     1021
     1022                                        <item>
     1023                                                <guid><?php bbp_topic_permalink(); ?></guid>
     1024                                                <title><![CDATA[<?php bbp_topic_title(); ?>]]></title>
     1025                                                <link><?php bbp_topic_permalink(); ?></link>
     1026                                                <pubDate><?php echo mysql2date( 'D, d M Y H:i:s +0000', get_post_time( 'Y-m-d H:i:s', true ), false ); ?></pubDate>
     1027                                                <dc:creator><?php the_author(); ?></dc:creator>
     1028
     1029                                                <description>
     1030                                                        <![CDATA[
     1031                                                        <p><?php printf( __( 'Replies: %s', 'bbpress' ), bbp_get_topic_reply_count() ); ?></p>
     1032                                                        <?php bbp_topic_content(); ?>
     1033                                                        ]]>
     1034                                                </description>
     1035
     1036                                                <?php rss_enclosure(); ?>
     1037
     1038                                                <?php do_action( 'bbp_feed_item' ); ?>
     1039
     1040                                        </item>
     1041
     1042                                <?php endif; ?>
     1043                        <?php endif; ?>
     1044                <?php endif; ?>
     1045
     1046                <?php if ( bbp_has_replies( $replies_query ) ) : ?>
     1047                        <?php while ( bbp_replies() ) : bbp_the_reply(); ?>
     1048
     1049                                <item>
     1050                                        <guid><?php bbp_reply_url(); ?></guid>
     1051                                        <title><![CDATA[<?php bbp_reply_title(); ?>]]></title>
     1052                                        <link><?php bbp_reply_url(); ?></link>
     1053                                        <pubDate><?php echo mysql2date( 'D, d M Y H:i:s +0000', get_post_time( 'Y-m-d H:i:s', true ), false ); ?></pubDate>
     1054                                        <dc:creator><?php the_author() ?></dc:creator>
     1055
     1056                                        <description>
     1057                                                <![CDATA[
     1058                                                <?php bbp_reply_content(); ?>
     1059                                                ]]>
     1060                                        </description>
     1061
     1062                                        <?php rss_enclosure(); ?>
     1063
     1064                                        <?php do_action( 'bbp_feed_item' ); ?>
     1065
     1066                                </item>
     1067
     1068                        <?php endwhile; ?>
     1069                <?php endif; ?>
     1070
     1071                <?php do_action( 'bbp_feed_footer' ); ?>
     1072
     1073        </channel>
     1074        </rss>
     1075
     1076<?php
     1077
     1078        // We're done here
     1079        exit();
     1080}
    9391081
    9401082?>
Note: See TracChangeset for help on using the changeset viewer.