[ Index ]

WordPress Source Cross Reference

title

Body

[close]

/ -> wp-commentsrss2.php (source)

   1  <?php 
   2  
   3  if (empty($wp)) {
   4      require_once('wp-config.php');
   5      wp('feed=rss2&withcomments=1');
   6  }
   7  
   8  header('Content-type: text/xml;charset=' . get_settings('blog_charset'), true);
   9  
  10  echo '<?xml version="1.0" encoding="'.get_settings('blog_charset').'"?'.'>'; 
  11  ?>
  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  <?php
  17  $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  <?php 
  30          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->comments 
  34              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 DESC LIMIT " . get_settings('posts_per_rss') );
  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->comments 
  42              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_settings('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 metadata
  51                  // 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          <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_comment_time('Y-m-d H:i:s', true), false); ?></pubDate>
  65          <guid><?php comment_link() ?></guid>
  66              <?php 
  67              if (!empty($comment->post_password) && $_COOKIE['wp-postpass'] != $comment->post_password) {
  68              ?>
  69          <description><?php _e('Protected Comments: Please enter your password to view comments.'); ?></description>
  70          <content:encoded><![CDATA[<?php echo get_the_password_form() ?>]]></content:encoded>
  71              <?php
  72              } else {
  73              ?>
  74          <description><?php comment_text_rss() ?></description>
  75          <content:encoded><![CDATA[<?php comment_text() ?>]]></content:encoded>
  76              <?php 
  77              } // close check for password 
  78              ?>
  79      </item>
  80  <?php 
  81              } 
  82          }
  83      }
  84  endwhile; endif;
  85  ?>
  86  </channel>
  87  </rss>

Your comment here...

Name: Location:
Comments:


List: Classes | Functions | Variables | Constants | Tables

Generated: Sat Jul 15 11:57:04 2006 Courtesy of Taragana