Make WordPress Core

source: trunk/wp-commentsrss2.php @ 1599

Last change on this file since 1599 was 1599, checked in by saxmatt, 21 years ago

Massive options cleanup and another step of cleaning up the upgrade/install.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.9 KB
Line 
1<?php 
2if (! $feed) {
3    require('wp-blog-header.php');
4}
5
6header('Content-type: text/xml;charset=' . get_settings('blog_charset'), true);
7
8echo '<?xml version="1.0" encoding="'.get_settings('blog_charset').'"?'.'>'; 
9?>
10<!-- generator="wordpress/<?php echo $wp_version ?>" -->
11<rss version="2.0"
12        xmlns:content="http://purl.org/rss/1.0/modules/content/">
13<channel>
14<?php
15$i = 0;
16foreach ($posts as $post) { start_wp();
17        if ($i < 1) {
18                $i++;
19?>
20        <title><?php if (isset($_REQUEST["p"]) || isset($_REQUEST["name"])) { echo "Comments on: "; the_title_rss(); } else { bloginfo_rss("name"); echo " Comments"; } ?></title>
21        <link><?php (isset($_REQUEST["p"]) || isset($_REQUEST["name"])) ? permalink_single_rss() : bloginfo_rss("url") ?></link>
22        <description><?php bloginfo_rss("description") ?></description>
23        <pubDate><?php echo gmdate('r'); ?></pubDate>
24        <generator>http://wordpress.org/?v=<?php echo $wp_version ?></generator>
25
26<?php 
27                if (isset($_REQUEST["p"]) || isset($_REQUEST["name"])) {
28                        $comments = $wpdb->get_results("SELECT comment_ID, comment_author, comment_author_email,
29                        comment_author_url, comment_date, comment_content, comment_post_ID,
30                        $wpdb->posts.ID, $wpdb->posts.post_password FROM $wpdb->comments 
31                        LEFT JOIN $wpdb->posts ON comment_post_id = id WHERE comment_post_ID = '$id'
32                        AND $wpdb->comments.comment_approved = '1' AND $wpdb->posts.post_status = 'publish'
33                        AND post_date < '".date("Y-m-d H:i:59")."'
34                        ORDER BY comment_date LIMIT " . get_settings('posts_per_rss') );
35                } else { // if no post id passed in, we'll just ue the last 10 comments.
36                        $comments = $wpdb->get_results("SELECT comment_ID, comment_author, comment_author_email,
37                        comment_author_url, comment_date, comment_content, comment_post_ID,
38                        $wpdb->posts.ID, $wpdb->posts.post_password FROM $wpdb->comments 
39                        LEFT JOIN $wpdb->posts ON comment_post_id = id WHERE $wpdb->posts.post_status = 'publish'
40                        AND $wpdb->comments.comment_approved = '1' AND post_date < '".date("Y-m-d H:i:s")."' 
41                        ORDER BY comment_date DESC LIMIT " . get_settings('posts_per_rss') );
42                }
43        // this line is WordPress' motor, do not delete it.
44                if ($comments) {
45                        foreach ($comments as $comment) {
46?>
47        <item>
48                <title>by: <?php comment_author_rss() ?></title>
49                <link><?php comment_link_rss() ?></link>
50                <pubDate><?php comment_time('r'); ?></pubDate>
51                <guid isPermaLink="false"><?php comment_ID(); echo ":".$comment->comment_post_ID; ?>@<?php bloginfo_rss("url") ?></guid>
52                        <?php 
53                        if (!empty($comment->post_password) && $_COOKIE['wp-postpass'] != $comment->post_password) {
54                        ?>
55                <description>Protected Comments: Please enter your password to view comments.</description>
56                <content:encoded><![CDATA[<?php echo get_the_password_form() ?>]]></content:encoded>
57                        <?php
58                        } else {
59                        ?>
60                <description><?php comment_text_rss() ?></description>
61                <content:encoded><![CDATA[<?php comment_text() ?>]]></content:encoded>
62                        <?php 
63                        } // close check for password
64                        ?>
65        </item>
66<?php 
67                        }
68                }
69        }
70}
71?>
72</channel>
73</rss>
Note: See TracBrowser for help on using the repository browser.