PageRenderTime 49ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/blog/wp-content/plugins/podpress/optional_files/wp1.5_2.0/wp-commentsrss2.php

https://bitbucket.org/sergiohzlz/reportaprod
PHP | 87 lines | 80 code | 4 blank | 3 comment | 18 complexity | 1e734faa350166e168235c41907edec3 MD5 | raw file
Possible License(s): GPL-2.0, GPL-3.0, AGPL-1.0, LGPL-2.1
  1. <?php
  2. if (empty($wp)) {
  3. require_once('wp-config.php');
  4. wp('feed=rss2&withcomments=1');
  5. }
  6. header('Content-type: text/xml;charset=' . get_settings('blog_charset'), true);
  7. echo '<?xml version="1.0" encoding="'.get_settings('blog_charset').'"?'.'>';
  8. ?>
  9. <!-- generator="wordpress/<?php echo $wp_version ?>" -->
  10. <rss version="2.0"
  11. xmlns:content="http://purl.org/rss/1.0/modules/content/">
  12. <channel>
  13. <?php
  14. $i = 0;
  15. if (have_posts()) :
  16. while (have_posts()) : the_post();
  17. if ($i < 1) {
  18. $i++;
  19. ?>
  20. <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>
  21. <link><?php (is_single()) ? permalink_single_rss() : bloginfo_rss("url") ?></link>
  22. <description><?php bloginfo_rss("description") ?></description>
  23. <pubDate><?php echo gmdate('r'); ?></pubDate>
  24. <generator>http://wordpress.org/?v=<?php echo $wp_version ?></generator>
  25. <?php
  26. if (is_single() || is_page()) {
  27. $comments = $wpdb->get_results("SELECT comment_ID, comment_author, comment_author_email,
  28. comment_author_url, comment_date, comment_date_gmt, comment_content, comment_post_ID,
  29. $wpdb->posts.ID, $wpdb->posts.post_password FROM $wpdb->comments
  30. LEFT JOIN $wpdb->posts ON comment_post_id = id WHERE comment_post_ID = '$id'
  31. AND $wpdb->comments.comment_approved = '1' AND $wpdb->posts.post_status IN ('publish', 'static', 'object')
  32. AND post_date_gmt < '" . gmdate("Y-m-d H:i:59") . "'
  33. ORDER BY comment_date_gmt DESC LIMIT " . get_settings('posts_per_rss') );
  34. } else { // if no post id passed in, we'll just ue the last 10 comments.
  35. $comments = $wpdb->get_results("SELECT comment_ID, comment_author, comment_author_email,
  36. comment_author_url, comment_date, comment_date_gmt, comment_content, comment_post_ID,
  37. $wpdb->posts.ID, $wpdb->posts.post_password FROM $wpdb->comments
  38. LEFT JOIN $wpdb->posts ON comment_post_id = id WHERE $wpdb->posts.post_status IN ('publish', 'static', 'object')
  39. AND $wpdb->comments.comment_approved = '1' AND post_date_gmt < '" . gmdate("Y-m-d H:i:s") . "'
  40. ORDER BY comment_date_gmt DESC LIMIT " . get_settings('posts_per_rss') );
  41. }
  42. // this line is WordPress' motor, do not delete it.
  43. if ($comments) {
  44. foreach ($comments as $comment) {
  45. // Some plugins may need to know the metadata
  46. // associated with this comment's post:
  47. get_post_custom($comment->comment_post_ID);
  48. ?>
  49. <item>
  50. <title><?php if ( ! (is_single() || is_page()) ) {
  51. $title = get_the_title($comment->comment_post_ID);
  52. $title = apply_filters('the_title', $title);
  53. $title = apply_filters('the_title_rss', $title);
  54. printf(__('Comment on %1$s by %2$s'), $title, get_comment_author_rss());
  55. } else {
  56. printf(__('by: %s'), get_comment_author_rss());
  57. } ?></title>
  58. <link><?php comment_link() ?></link>
  59. <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_comment_time('Y-m-d H:i:s', true), false); ?></pubDate>
  60. <guid><?php comment_link() ?></guid>
  61. <?php
  62. if (!empty($comment->post_password) && $_COOKIE['wp-postpass'] != $comment->post_password) {
  63. ?>
  64. <description><?php _e('Protected Comments: Please enter your password to view comments.'); ?></description>
  65. <content:encoded><![CDATA[<?php echo get_the_password_form() ?>]]></content:encoded>
  66. <?php
  67. } else {
  68. ?>
  69. <description><?php comment_text_rss() ?></description>
  70. <content:encoded><![CDATA[<?php comment_text() ?>]]></content:encoded>
  71. <?php
  72. } // close check for password
  73. ?>
  74. <?php do_action('commentsrss2_item'); ?>
  75. </item>
  76. <?php
  77. }
  78. }
  79. }
  80. endwhile; endif;
  81. ?>
  82. </channel>
  83. </rss>