1 | <?php |
---|
2 | if (! $feed) { |
---|
3 | require('wp-blog-header.php'); |
---|
4 | } |
---|
5 | |
---|
6 | header('Content-type: text/xml', true); |
---|
7 | |
---|
8 | echo '<?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; |
---|
16 | foreach ($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 | <language><?php echo get_settings('rss_language'); ?></language> |
---|
24 | <pubDate><?php echo gmdate('r'); ?></pubDate> |
---|
25 | <generator>http://wordpress.org/?v=<?php echo $wp_version ?></generator> |
---|
26 | |
---|
27 | <?php |
---|
28 | if (isset($_REQUEST["p"]) || isset($_REQUEST["name"])) { |
---|
29 | $comments = $wpdb->get_results("SELECT comment_ID, comment_author, comment_author_email, |
---|
30 | comment_author_url, comment_date, comment_content, comment_post_ID, |
---|
31 | $wpdb->posts.ID, $wpdb->posts.post_password FROM $wpdb->comments |
---|
32 | LEFT JOIN $wpdb->posts ON comment_post_id = id WHERE comment_post_ID = '$id' |
---|
33 | AND $wpdb->comments.comment_approved = '1' AND $wpdb->posts.post_status = 'publish' |
---|
34 | AND post_date < '".date("Y-m-d H:i:59")."' |
---|
35 | ORDER BY comment_date LIMIT " . get_settings('posts_per_rss') ); |
---|
36 | } else { // if no post id passed in, we'll just ue the last 10 comments. |
---|
37 | $comments = $wpdb->get_results("SELECT comment_ID, comment_author, comment_author_email, |
---|
38 | comment_author_url, comment_date, comment_content, comment_post_ID, |
---|
39 | $wpdb->posts.ID, $wpdb->posts.post_password FROM $wpdb->comments |
---|
40 | LEFT JOIN $wpdb->posts ON comment_post_id = id WHERE $wpdb->posts.post_status = 'publish' |
---|
41 | AND $wpdb->comments.comment_approved = '1' AND post_date < '".date("Y-m-d H:i:s")."' |
---|
42 | ORDER BY comment_date DESC LIMIT " . get_settings('posts_per_rss') ); |
---|
43 | } |
---|
44 | // this line is WordPress' motor, do not delete it. |
---|
45 | if ($comments) { |
---|
46 | foreach ($comments as $comment) { |
---|
47 | ?> |
---|
48 | <item> |
---|
49 | <title>by: <?php comment_author_rss() ?></title> |
---|
50 | <link><?php comment_link_rss() ?></link> |
---|
51 | <pubDate><?php comment_time('r'); ?></pubDate> |
---|
52 | <guid isPermaLink="false"><?php comment_ID(); echo ":".$comment->comment_post_ID; ?>@<?php bloginfo_rss("url") ?></guid> |
---|
53 | <?php |
---|
54 | if (!empty($comment->post_password) && $_COOKIE['wp-postpass'] != $comment->post_password) { |
---|
55 | ?> |
---|
56 | <description>Protected Comments: Please enter your password to view comments.</description> |
---|
57 | <content:encoded><![CDATA[<?php echo get_the_password_form() ?>]]></content:encoded> |
---|
58 | <?php |
---|
59 | } else { |
---|
60 | ?> |
---|
61 | <description><?php comment_text_rss() ?></description> |
---|
62 | <content:encoded><![CDATA[<?php comment_text() ?>]]></content:encoded> |
---|
63 | <?php |
---|
64 | } // close check for password |
---|
65 | ?> |
---|
66 | </item> |
---|
67 | <?php |
---|
68 | } |
---|
69 | } |
---|
70 | } |
---|
71 | } |
---|
72 | ?> |
---|
73 | </channel> |
---|
74 | </rss> |
---|