/wp-includes/feed-atom-comments.php

  1. <?php 
  2. /** 
  3. * Atom Feed Template for displaying Atom Comments feed. 
  4. * 
  5. * @package WordPress 
  6. */ 
  7.  
  8. header('Content-Type: ' . feed_content_type('atom') . '; charset=' . get_option('blog_charset'), true); 
  9. echo '<?xml version="1.0" encoding="' . get_option('blog_charset') . '" ?' . '>'; 
  10.  
  11. /** This action is documented in wp-includes/feed-rss2.php */ 
  12. do_action( 'rss_tag_pre', 'atom-comments' ); 
  13. ?> 
  14. <feed 
  15. xmlns="http://www.w3.org/2005/Atom" 
  16. xml:lang="<?php bloginfo_rss( 'language' ); ?>" 
  17. xmlns:thr="http://purl.org/syndication/thread/1.0" 
  18. <?php 
  19. /** This action is documented in wp-includes/feed-atom.php */ 
  20. do_action( 'atom_ns' ); 
  21.  
  22. /** 
  23. * Fires inside the feed tag in the Atom comment feed. 
  24. * 
  25. * @since 2.8.0 
  26. */ 
  27. do_action( 'atom_comments_ns' ); 
  28. ?> 
  29. <title type="text"><?php 
  30. if ( is_singular() ) { 
  31. /** translators: Comments feed title. 1: Post title */ 
  32. printf( ent2ncr( __( 'Comments on %s' ) ), get_the_title_rss() ); 
  33. } elseif ( is_search() ) { 
  34. /** translators: Comments feed title. 1: Site name, 2: Search query */ 
  35. printf( ent2ncr( __( 'Comments for %1$s searching on %2$s' ) ), get_bloginfo_rss( 'name' ), get_search_query() ); 
  36. } else { 
  37. /** translators: Comments feed title. 1: Site name */ 
  38. printf( ent2ncr( __( 'Comments for %s' ) ), get_wp_title_rss() ); 
  39. ?></title> 
  40. <subtitle type="text"><?php bloginfo_rss('description'); ?></subtitle> 
  41.  
  42. <updated><?php 
  43. $date = get_lastcommentmodified( 'GMT' ); 
  44. echo $date ? mysql2date( 'Y-m-d\TH:i:s\Z', $date ) : date( 'Y-m-d\TH:i:s\Z' ); 
  45. ?></updated> 
  46.  
  47. <?php if ( is_singular() ) { ?> 
  48. <link rel="alternate" type="<?php bloginfo_rss('html_type'); ?>" href="<?php comments_link_feed(); ?>" /> 
  49. <link rel="self" type="application/atom+xml" href="<?php echo esc_url( get_post_comments_feed_link('', 'atom') ); ?>" /> 
  50. <id><?php echo esc_url( get_post_comments_feed_link('', 'atom') ); ?></id> 
  51. <?php } elseif (is_search()) { ?> 
  52. <link rel="alternate" type="<?php bloginfo_rss('html_type'); ?>" href="<?php echo home_url() . '?s=' . get_search_query(); ?>" /> 
  53. <link rel="self" type="application/atom+xml" href="<?php echo get_search_comments_feed_link('', 'atom'); ?>" /> 
  54. <id><?php echo get_search_comments_feed_link('', 'atom'); ?></id> 
  55. <?php } else { ?> 
  56. <link rel="alternate" type="<?php bloginfo_rss('html_type'); ?>" href="<?php bloginfo_rss('url'); ?>" /> 
  57. <link rel="self" type="application/atom+xml" href="<?php bloginfo_rss('comments_atom_url'); ?>" /> 
  58. <id><?php bloginfo_rss('comments_atom_url'); ?></id> 
  59. <?php } ?> 
  60. <?php 
  61. /** 
  62. * Fires at the end of the Atom comment feed header. 
  63. * 
  64. * @since 2.8.0 
  65. */ 
  66. do_action( 'comments_atom_head' ); 
  67. ?> 
  68. <?php 
  69. if ( have_comments() ) : while ( have_comments() ) : the_comment(); 
  70. $comment_post = $GLOBALS['post'] = get_post( $comment->comment_post_ID ); 
  71. ?> 
  72. <entry> 
  73. <title><?php 
  74. if ( !is_singular() ) { 
  75. $title = get_the_title($comment_post->ID); 
  76. /** This filter is documented in wp-includes/feed.php */ 
  77. $title = apply_filters( 'the_title_rss', $title ); 
  78. /** translators: Individual comment title. 1: Post title, 2: Comment author name */ 
  79. printf(ent2ncr(__('Comment on %1$s by %2$s')), $title, get_comment_author_rss()); 
  80. } else { 
  81. /** translators: Comment author title. 1: Comment author name */ 
  82. printf(ent2ncr(__('By: %s')), get_comment_author_rss()); 
  83. ?></title> 
  84. <link rel="alternate" href="<?php comment_link(); ?>" type="<?php bloginfo_rss('html_type'); ?>" /> 
  85.  
  86. <author> 
  87. <name><?php comment_author_rss(); ?></name> 
  88. <?php if (get_comment_author_url()) echo '<uri>' . get_comment_author_url() . '</uri>'; ?> 
  89.  
  90. </author> 
  91.  
  92. <id><?php comment_guid(); ?></id> 
  93. <updated><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_comment_time('Y-m-d H:i:s', true, false), false); ?></updated> 
  94. <published><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_comment_time('Y-m-d H:i:s', true, false), false); ?></published> 
  95. <?php if ( post_password_required($comment_post) ) : ?> 
  96. <content type="html" xml:base="<?php comment_link(); ?>"><![CDATA[<?php echo get_the_password_form(); ?>]]></content> 
  97. <?php else : // post pass ?> 
  98. <content type="html" xml:base="<?php comment_link(); ?>"><![CDATA[<?php comment_text(); ?>]]></content> 
  99. <?php endif; // post pass 
  100. // Return comment threading information (https://www.ietf.org/rfc/rfc4685.txt) 
  101. if ( $comment->comment_parent == 0 ) : // This comment is top level ?> 
  102. <thr:in-reply-to ref="<?php the_guid(); ?>" href="<?php the_permalink_rss() ?>" type="<?php bloginfo_rss('html_type'); ?>" /> 
  103. <?php else : // This comment is in reply to another comment 
  104. $parent_comment = get_comment($comment->comment_parent); 
  105. // The rel attribute below and the id tag above should be GUIDs, but WP doesn't create them for comments (unlike posts). Either way, it's more important that they both use the same system 
  106. ?> 
  107. <thr:in-reply-to ref="<?php comment_guid($parent_comment) ?>" href="<?php echo get_comment_link($parent_comment) ?>" type="<?php bloginfo_rss('html_type'); ?>" /> 
  108. <?php endif; 
  109. /** 
  110. * Fires at the end of each Atom comment feed item. 
  111. * 
  112. * @since 2.2.0 
  113. * 
  114. * @param int $comment_id ID of the current comment. 
  115. * @param int $comment_post_id ID of the post the current comment is connected to. 
  116. */ 
  117. do_action( 'comment_atom_entry', $comment->comment_ID, $comment_post->ID ); 
  118. ?> 
  119. </entry> 
  120. <?php endwhile; endif; ?> 
  121. </feed> 
.