root/tags/1.5.1/wp-commentsrss2.php

Revision 2543, 3.1 kB (checked in by ryan, 3 years ago)

Use UTC in comments rss feed. http://mosquito.wordpress.org/view.php?id=1256 Props: nbachiyski

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