]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-includes/feed-atom-comments.php
Wordpress 4.5.3-scripts
[autoinstalls/wordpress.git] / 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 >
30         <title type="text"><?php
31                 if ( is_singular() )
32                         printf( ent2ncr( __( 'Comments on %s' ) ), get_the_title_rss() );
33                 elseif ( is_search() )
34                         printf( ent2ncr( __( 'Comments for %1$s searching on %2$s' ) ), get_bloginfo_rss( 'name' ), get_search_query() );
35                 else
36                         printf( ent2ncr( __( 'Comments for %s' ) ), get_wp_title_rss() );
37         ?></title>
38         <subtitle type="text"><?php bloginfo_rss('description'); ?></subtitle>
39
40         <updated><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastcommentmodified('GMT'), false); ?></updated>
41
42 <?php if ( is_singular() ) { ?>
43         <link rel="alternate" type="<?php bloginfo_rss('html_type'); ?>" href="<?php comments_link_feed(); ?>" />
44         <link rel="self" type="application/atom+xml" href="<?php echo esc_url( get_post_comments_feed_link('', 'atom') ); ?>" />
45         <id><?php echo esc_url( get_post_comments_feed_link('', 'atom') ); ?></id>
46 <?php } elseif (is_search()) { ?>
47         <link rel="alternate" type="<?php bloginfo_rss('html_type'); ?>" href="<?php echo home_url() . '?s=' . get_search_query(); ?>" />
48         <link rel="self" type="application/atom+xml" href="<?php echo get_search_comments_feed_link('', 'atom'); ?>" />
49         <id><?php echo get_search_comments_feed_link('', 'atom'); ?></id>
50 <?php } else { ?>
51         <link rel="alternate" type="<?php bloginfo_rss('html_type'); ?>" href="<?php bloginfo_rss('url'); ?>" />
52         <link rel="self" type="application/atom+xml" href="<?php bloginfo_rss('comments_atom_url'); ?>" />
53         <id><?php bloginfo_rss('comments_atom_url'); ?></id>
54 <?php } ?>
55 <?php
56         /**
57          * Fires at the end of the Atom comment feed header.
58          *
59          * @since 2.8.0
60          */
61         do_action( 'comments_atom_head' );
62 ?>
63 <?php
64 if ( have_comments() ) : while ( have_comments() ) : the_comment();
65         $comment_post = $GLOBALS['post'] = get_post( $comment->comment_post_ID );
66 ?>
67         <entry>
68                 <title><?php
69                         if ( !is_singular() ) {
70                                 $title = get_the_title($comment_post->ID);
71                                 /** This filter is documented in wp-includes/feed.php */
72                                 $title = apply_filters( 'the_title_rss', $title );
73                                 printf(ent2ncr(__('Comment on %1$s by %2$s')), $title, get_comment_author_rss());
74                         } else {
75                                 printf(ent2ncr(__('By: %s')), get_comment_author_rss());
76                         }
77                 ?></title>
78                 <link rel="alternate" href="<?php comment_link(); ?>" type="<?php bloginfo_rss('html_type'); ?>" />
79
80                 <author>
81                         <name><?php comment_author_rss(); ?></name>
82                         <?php if (get_comment_author_url()) echo '<uri>' . get_comment_author_url() . '</uri>'; ?>
83
84                 </author>
85
86                 <id><?php comment_guid(); ?></id>
87                 <updated><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_comment_time('Y-m-d H:i:s', true, false), false); ?></updated>
88                 <published><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_comment_time('Y-m-d H:i:s', true, false), false); ?></published>
89 <?php if ( post_password_required($comment_post) ) : ?>
90                 <content type="html" xml:base="<?php comment_link(); ?>"><![CDATA[<?php echo get_the_password_form(); ?>]]></content>
91 <?php else : // post pass ?>
92                 <content type="html" xml:base="<?php comment_link(); ?>"><![CDATA[<?php comment_text(); ?>]]></content>
93 <?php endif; // post pass
94         // Return comment threading information (http://www.ietf.org/rfc/rfc4685.txt)
95         if ( $comment->comment_parent == 0 ) : // This comment is top level ?>
96                 <thr:in-reply-to ref="<?php the_guid(); ?>" href="<?php the_permalink_rss() ?>" type="<?php bloginfo_rss('html_type'); ?>" />
97 <?php else : // This comment is in reply to another comment
98         $parent_comment = get_comment($comment->comment_parent);
99         // 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
100 ?>
101                 <thr:in-reply-to ref="<?php comment_guid($parent_comment) ?>" href="<?php echo get_comment_link($parent_comment) ?>" type="<?php bloginfo_rss('html_type'); ?>" />
102 <?php endif;
103         /**
104          * Fires at the end of each Atom comment feed item.
105          *
106          * @since 2.2.0
107          *
108          * @param int $comment_id      ID of the current comment.
109          * @param int $comment_post_id ID of the post the current comment is connected to.
110          */
111         do_action( 'comment_atom_entry', $comment->comment_ID, $comment_post->ID );
112 ?>
113         </entry>
114 <?php endwhile; endif; ?>
115 </feed>