Changeset 4927 for trunk/wp-commentsrss2.php
- Timestamp:
- 02/23/2007 02:50:05 AM (19 years ago)
- File:
-
- 1 edited
-
trunk/wp-commentsrss2.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-commentsrss2.php
r4635 r4927 6 6 } 7 7 8 header('Content-type: text/xml;charset=' . get_option('blog_charset'), true);8 require (ABSPATH . WPINC . '/feed-rss2-comments.php'); 9 9 10 echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>';11 10 ?> 12 <!-- generator="wordpress/<?php echo $wp_version ?>" -->13 <rss version="2.0"14 xmlns:content="http://purl.org/rss/1.0/modules/content/">15 <channel>16 <?php17 $i = 0;18 if (have_posts()) :19 while (have_posts()) : the_post();20 if ($i < 1) {21 $i++;22 ?>23 <title><?php if (is_single() || is_page() ) { printf(__('Comments on: %s'), get_the_title_rss()); } else { printf(__('Comments for %s'), get_bloginfo_rss("name")); } ?></title>24 <link><?php (is_single()) ? permalink_single_rss() : bloginfo_rss("url") ?></link>25 <description><?php bloginfo_rss("description") ?></description>26 <pubDate><?php echo gmdate('r'); ?></pubDate>27 <generator>http://wordpress.org/?v=<?php echo $wp_version ?></generator>28 29 <?php30 if (is_single() || is_page()) {31 $comments = $wpdb->get_results("SELECT comment_ID, comment_author, comment_author_email,32 comment_author_url, comment_date, comment_date_gmt, comment_content, comment_post_ID,33 $wpdb->posts.ID, $wpdb->posts.post_password FROM $wpdb->comments34 LEFT JOIN $wpdb->posts ON comment_post_id = id WHERE comment_post_ID = '" . get_the_ID() . "'35 AND $wpdb->comments.comment_approved = '1' AND $wpdb->posts.post_status = 'publish'36 AND post_date_gmt < '" . gmdate("Y-m-d H:i:59") . "'37 ORDER BY comment_date_gmt ASC" );38 } else { // if no post id passed in, we'll just ue the last 10 comments.39 $comments = $wpdb->get_results("SELECT comment_ID, comment_author, comment_author_email,40 comment_author_url, comment_date, comment_date_gmt, comment_content, comment_post_ID,41 $wpdb->posts.ID, $wpdb->posts.post_password FROM $wpdb->comments42 LEFT JOIN $wpdb->posts ON comment_post_id = id WHERE $wpdb->posts.post_status = 'publish'43 AND $wpdb->comments.comment_approved = '1' AND post_date_gmt < '" . gmdate("Y-m-d H:i:s") . "'44 ORDER BY comment_date_gmt DESC LIMIT " . get_option('posts_per_rss') );45 }46 // this line is WordPress' motor, do not delete it.47 if ($comments) {48 foreach ($comments as $comment) {49 $GLOBALS['comment'] =& $comment;50 // Some plugins may need to know the metadata51 // associated with this comment's post:52 get_post_custom($comment->comment_post_ID);53 ?>54 <item>55 <title><?php if ( ! (is_single() || is_page()) ) {56 $title = get_the_title($comment->comment_post_ID);57 $title = apply_filters('the_title', $title);58 $title = apply_filters('the_title_rss', $title);59 printf(__('Comment on %1$s by %2$s'), $title, get_comment_author_rss());60 } else {61 printf(__('By: %s'), get_comment_author_rss());62 } ?></title>63 <link><?php comment_link() ?></link>64 <author><?php echo get_comment_author_rss() ?></author>65 <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_comment_time('Y-m-d H:i:s', true), false); ?></pubDate>66 <guid><?php comment_link() ?></guid>67 <?php68 if (!empty($comment->post_password) && $_COOKIE['wp-postpass'] != $comment->post_password) {69 ?>70 <description><?php _e('Protected Comments: Please enter your password to view comments.'); ?></description>71 <content:encoded><![CDATA[<?php echo get_the_password_form() ?>]]></content:encoded>72 <?php73 } else {74 ?>75 <description><?php comment_text_rss() ?></description>76 <content:encoded><![CDATA[<?php comment_text() ?>]]></content:encoded>77 <?php78 } // close check for password79 do_action('commentrss2_item', $comment->comment_ID, $comment->comment_post_ID);80 ?>81 </item>82 <?php83 }84 }85 }86 endwhile; endif;87 ?>88 </channel>89 </rss>
Note: See TracChangeset
for help on using the changeset viewer.