Make WordPress Core


Ignore:
Timestamp:
02/24/2007 07:33:29 AM (18 years ago)
Author:
ryan
Message:

Comment feeds everywhere. Props mdawaffe and rob1n. fixes #2485

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/feed-rss2-comments.php

    r4927 r4934  
    88    xmlns:content="http://purl.org/rss/1.0/modules/content/">
    99<channel>
    10 <?php
    11 $i = 0;
    12 if (have_posts()) :
    13   while (have_posts()) : the_post();
    14     if ($i < 1) {
    15         $i++;
    16 ?>
    17     <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>
     10    <title><?php
     11        if ( is_singular() )
     12            printf(__('Comments on: %s'), get_the_title_rss());
     13        elseif ( is_search() )
     14            printf(__('Comments for %s searching on %s'), get_bloginfo_rss( 'name' ), attribute_escape($wp_query->query_vars['s']));
     15        else
     16            printf(__('Comments for %s'), get_bloginfo_rss( 'name' ) . get_wp_title_rss());
     17    ?></title>
    1818    <link><?php (is_single()) ? permalink_single_rss() : bloginfo_rss("url") ?></link>
    1919    <description><?php bloginfo_rss("description") ?></description>
     
    2222
    2323<?php
    24         if (is_single() || is_page()) {
    25             $comments = $wpdb->get_results("SELECT comment_ID, comment_author, comment_author_email,
    26             comment_author_url, comment_date, comment_date_gmt, comment_content, comment_post_ID,
    27             $wpdb->posts.ID, $wpdb->posts.post_password FROM $wpdb->comments
    28             LEFT JOIN $wpdb->posts ON comment_post_id = id WHERE comment_post_ID = '" . get_the_ID() . "'
    29             AND $wpdb->comments.comment_approved = '1' AND $wpdb->posts.post_status = 'publish'
    30             AND post_date_gmt < '" . gmdate("Y-m-d H:i:59") . "'
    31             ORDER BY comment_date_gmt ASC" );
    32         } else { // if no post id passed in, we'll just ue the last 10 comments.
    33             $comments = $wpdb->get_results("SELECT comment_ID, comment_author, comment_author_email,
    34             comment_author_url, comment_date, comment_date_gmt, comment_content, comment_post_ID,
    35             $wpdb->posts.ID, $wpdb->posts.post_password FROM $wpdb->comments
    36             LEFT JOIN $wpdb->posts ON comment_post_id = id WHERE $wpdb->posts.post_status = 'publish'
    37             AND $wpdb->comments.comment_approved = '1' AND post_date_gmt < '" . gmdate("Y-m-d H:i:s") . "' 
    38             ORDER BY comment_date_gmt DESC LIMIT " . get_option('posts_per_rss') );
    39         }
    40     // this line is WordPress' motor, do not delete it.
    41         if ($comments) {
    42             foreach ($comments as $comment) {
    43                 $GLOBALS['comment'] =& $comment;
    44                 // Some plugins may need to know the metadata
    45                 // associated with this comment's post:
    46                 get_post_custom($comment->comment_post_ID);
     24if ( have_comments() ) : while ( have_comments() ) : the_comment();
     25    $comment_post = get_post($comment->comment_post_ID);
     26    get_post_custom($comment_post->ID);
    4727?>
    4828    <item>
    49         <title><?php if ( ! (is_single() || is_page()) ) {
    50             $title = get_the_title($comment->comment_post_ID);
    51             $title = apply_filters('the_title', $title);
    52             $title = apply_filters('the_title_rss', $title);
    53             printf(__('Comment on %1$s by %2$s'), $title, get_comment_author_rss());
    54         } else {
    55             printf(__('By: %s'), get_comment_author_rss());
    56         } ?></title>
     29        <title><?php
     30            if ( !is_singular() ) {
     31                $title = get_the_title($comment_post->ID);
     32                $title = apply_filters('the_title', $title);
     33                $title = apply_filters('the_title_rss', $title);
     34                printf(__('Comment on %1$s by %2$s'), $title, get_comment_author_rss());
     35            } else {
     36                printf(__('By: %s'), get_comment_author_rss());
     37            }
     38        ?></title>
    5739        <link><?php comment_link() ?></link>
    5840        <author><?php echo get_comment_author_rss() ?></author>
    5941        <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_comment_time('Y-m-d H:i:s', true), false); ?></pubDate>
    6042        <guid><?php comment_link() ?></guid>
    61             <?php
    62             if (!empty($comment->post_password) && $_COOKIE['wp-postpass'] != $comment->post_password) {
    63             ?>
     43<?php if (!empty($comment_post->post_password) && $_COOKIE['wp-postpass'] != $comment_post->post_password) : ?>
    6444        <description><?php _e('Protected Comments: Please enter your password to view comments.'); ?></description>
    6545        <content:encoded><![CDATA[<?php echo get_the_password_form() ?>]]></content:encoded>
    66             <?php
    67             } else {
    68             ?>
     46<?php else : // post pass ?>
    6947        <description><?php comment_text_rss() ?></description>
    7048        <content:encoded><![CDATA[<?php comment_text() ?>]]></content:encoded>
    71             <?php
    72             } // close check for password
    73             do_action('commentrss2_item', $comment->comment_ID, $comment->comment_post_ID);
    74             ?>
     49<?php endif; // post pass
     50    do_action('commentrss2_item', $comment->comment_ID, $comment_post->ID);
     51?>
    7552    </item>
    76 <?php
    77             }
    78         }
    79     }
    80 endwhile; endif;
    81 ?>
     53<?php endwhile; endif; ?>
    8254</channel>
    8355</rss>
Note: See TracChangeset for help on using the changeset viewer.