| 1 | <?php |
|---|
| 2 | if ( empty($feed) ) { |
|---|
| 3 | $feed = 'atom'; |
|---|
| 4 | $withcomments = 1; |
|---|
| 5 | $doing_rss = 1; |
|---|
| 6 | require('wp-blog-header.php'); |
|---|
| 7 | } |
|---|
| 8 | header('Content-type: application/atom+xml;charset=' . get_settings('blog_charset'), true); |
|---|
| 9 | echo '<?xml version="1.0" encoding="'.get_settings('blog_charset').'"?'.'>'; |
|---|
| 10 | ?> |
|---|
| 11 | |
|---|
| 12 | <?php echo '<?xml-stylesheet href="'; ?><?php bloginfo('stylesheet_directory'); ?><?php echo '/atom.css" type="text/css"'.'?>'; ?> |
|---|
| 13 | |
|---|
| 14 | <?php |
|---|
| 15 | $i = 0; |
|---|
| 16 | if (have_posts()) : |
|---|
| 17 | while (have_posts()) : the_post(); |
|---|
| 18 | if ($i < 1) { |
|---|
| 19 | $i++; |
|---|
| 20 | ?> |
|---|
| 21 | |
|---|
| 22 | <feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"> |
|---|
| 23 | <title> |
|---|
| 24 | <?php if (is_single() || is_page()) { |
|---|
| 25 | echo "Comments on: "; the_title_rss(); |
|---|
| 26 | } else { |
|---|
| 27 | bloginfo_rss("name"); echo " Comments"; |
|---|
| 28 | } ?> |
|---|
| 29 | </title> |
|---|
| 30 | <?php if (bloginfo_rss("description")) { ?> |
|---|
| 31 | <subtitle><?php bloginfo_rss("description") ?></subtitle> |
|---|
| 32 | <?php } ?> |
|---|
| 33 | <id><?php bloginfo('url') ?>/comments/</id> |
|---|
| 34 | <link href="<?php (is_single()) ? permalink_single_rss() : bloginfo_rss("url") ?>" rel="alternate" type="<?php bloginfo('html_type'); ?>"/> |
|---|
| 35 | <link href="<?php bloginfo_rss("comments_rss2_url") ?>" rel="self" type="application/atom+xml"/> |
|---|
| 36 | <updated><?php echo gmdate('Y-m-d\TH:i:s\Z'); ?></updated> |
|---|
| 37 | <rights>Copyright <?php echo mysql2date('Y', get_lastpostdate('blog')); ?></rights> |
|---|
| 38 | <author> |
|---|
| 39 | <name>Various authors</name> |
|---|
| 40 | </author> |
|---|
| 41 | <generator version="<?php echo $wp_version ?>" uri="http://wordpress.org/">Wordpress</generator> |
|---|
| 42 | |
|---|
| 43 | <?php |
|---|
| 44 | if (is_single() || is_page()) { |
|---|
| 45 | $comments = $wpdb->get_results("SELECT comment_ID, comment_author, comment_author_email, |
|---|
| 46 | comment_author_url, comment_date, comment_date_gmt, comment_content, comment_post_ID, |
|---|
| 47 | $wpdb->posts.ID, $wpdb->posts.post_password FROM $wpdb->comments |
|---|
| 48 | LEFT JOIN $wpdb->posts ON comment_post_id = id WHERE comment_post_ID = '$id' |
|---|
| 49 | AND $wpdb->comments.comment_approved = '1' AND ($wpdb->posts.post_status = 'publish' OR $wpdb->posts.post_status = 'page') |
|---|
| 50 | AND post_date < '".date("Y-m-d H:i:59")."' |
|---|
| 51 | ORDER BY comment_date LIMIT " . get_settings('posts_per_rss') ); |
|---|
| 52 | } else { // if no post id passed in, we'll just use the last 10 comments. |
|---|
| 53 | $comments = $wpdb->get_results("SELECT comment_ID, comment_author, comment_author_email, |
|---|
| 54 | comment_author_url, comment_date, comment_date_gmt, comment_content, comment_post_ID, |
|---|
| 55 | $wpdb->posts.ID, $wpdb->posts.post_title, $wpdb->posts.post_name, $wpdb->posts.post_password FROM $wpdb->comments |
|---|
| 56 | LEFT JOIN $wpdb->posts ON comment_post_id = id WHERE $wpdb->posts.post_status = 'publish' |
|---|
| 57 | AND $wpdb->comments.comment_approved = '1' AND post_date < '".date("Y-m-d H:i:s")."' |
|---|
| 58 | ORDER BY comment_date DESC LIMIT " . get_settings('posts_per_rss') ); |
|---|
| 59 | } |
|---|
| 60 | // this line is WordPress' motor, do not delete it. |
|---|
| 61 | if ($comments) { |
|---|
| 62 | foreach ($comments as $comment) { |
|---|
| 63 | ?> |
|---|
| 64 | |
|---|
| 65 | <entry> |
|---|
| 66 | <title>Re: <?php echo $comment->post_title; ?></title> |
|---|
| 67 | <link href="<?php comment_link() ?>" rel="alternate" type="text/html" /> |
|---|
| 68 | <author> |
|---|
| 69 | <name><?php comment_author_rss() ?></name> |
|---|
| 70 | <?php if (get_comment_author_url()) { |
|---|
| 71 | echo '<uri>'.get_comment_author_url().'</uri>'; |
|---|
| 72 | } ?> |
|---|
| 73 | </author> |
|---|
| 74 | <id><?php echo get_permalink($comment->ID) . "#comment-" . get_comment_ID(); ?></id> |
|---|
| 75 | <updated><?php echo get_comment_time('Y-m-d\TH:i:s\Z', true); ?></updated> |
|---|
| 76 | <published><?php echo get_comment_time('Y-m-d\TH:i:s\Z', true); ?></published> |
|---|
| 77 | |
|---|
| 78 | <?php if (!empty($comment->post_password) && $_COOKIE['wp-postpass'] != $comment->post_password) { ?> |
|---|
| 79 | <content |
|---|
| 80 | type="html" |
|---|
| 81 | xml:base="<?php echo get_permalink($comment->ID); ?>"> |
|---|
| 82 | <![CDATA[<?php echo get_the_password_form($comment->post_name) ?>]]> |
|---|
| 83 | </content> |
|---|
| 84 | <?php } else { ?> |
|---|
| 85 | <content |
|---|
| 86 | type="html" |
|---|
| 87 | xml:base="<?php echo get_permalink($comment->ID); ?>"> |
|---|
| 88 | <![CDATA[<?php comment_text() ?>]]> |
|---|
| 89 | </content> |
|---|
| 90 | <?php } // close check for password ?> |
|---|
| 91 | </entry> |
|---|
| 92 | |
|---|
| 93 | <?php } } } endwhile; endif; ?> |
|---|
| 94 | |
|---|
| 95 | </feed> |
|---|