wp/wp-includes/feed-atom-comments.php
author ymh <ymh.work@gmail.com>
Tue, 09 Jun 2015 03:35:32 +0200
changeset 5 5e2f62d02dcd
parent 0 d970ebf37754
child 7 cf61fcea0001
permissions -rw-r--r--
upgrade wordpress + plugins
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
 * Atom Feed Template for displaying Atom Comments feed.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
 * @package WordPress
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
header('Content-Type: ' . feed_content_type('atom') . '; charset=' . get_option('blog_charset'), true);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
echo '<?xml version="1.0" encoding="' . get_option('blog_charset') . '" ?' . '>';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    10
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    11
/** This action is documented in wp-includes/feed-rss2.php */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    12
do_action( 'rss_tag_pre', 'atom-comments' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
<feed
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
	xmlns="http://www.w3.org/2005/Atom"
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
	xml:lang="<?php bloginfo_rss( 'language' ); ?>"
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    17
	xmlns:thr="http://purl.org/syndication/thread/1.0"
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    18
	<?php
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    19
		/** This action is documented in wp-includes/feed-atom.php */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    20
		do_action( 'atom_ns' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    21
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    22
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    23
		 * Fires inside the feed tag in the Atom comment feed.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    24
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    25
		 * @since 2.8.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    26
		 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    27
		do_action( 'atom_comments_ns' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    28
	?>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    29
>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    30
	<title type="text"><?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    31
		if ( is_singular() )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    32
			printf( ent2ncr( __( 'Comments on %s' ) ), get_the_title_rss() );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    33
		elseif ( is_search() )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    34
			printf( ent2ncr( __( 'Comments for %1$s searching on %2$s' ) ), get_bloginfo_rss( 'name' ), get_search_query() );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    35
		else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    36
			printf( ent2ncr( __( 'Comments for %s' ) ), get_bloginfo_rss( 'name' ) . get_wp_title_rss() );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    37
	?></title>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    38
	<subtitle type="text"><?php bloginfo_rss('description'); ?></subtitle>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    39
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    40
	<updated><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastcommentmodified('GMT'), false); ?></updated>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    41
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    42
<?php if ( is_singular() ) { ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    43
	<link rel="alternate" type="<?php bloginfo_rss('html_type'); ?>" href="<?php comments_link_feed(); ?>" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    44
	<link rel="self" type="application/atom+xml" href="<?php echo esc_url( get_post_comments_feed_link('', 'atom') ); ?>" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    45
	<id><?php echo esc_url( get_post_comments_feed_link('', 'atom') ); ?></id>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    46
<?php } elseif(is_search()) { ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    47
	<link rel="alternate" type="<?php bloginfo_rss('html_type'); ?>" href="<?php echo home_url() . '?s=' . get_search_query(); ?>" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    48
	<link rel="self" type="application/atom+xml" href="<?php echo get_search_comments_feed_link('', 'atom'); ?>" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    49
	<id><?php echo get_search_comments_feed_link('', 'atom'); ?></id>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    50
<?php } else { ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    51
	<link rel="alternate" type="<?php bloginfo_rss('html_type'); ?>" href="<?php bloginfo_rss('url'); ?>" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    52
	<link rel="self" type="application/atom+xml" href="<?php bloginfo_rss('comments_atom_url'); ?>" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    53
	<id><?php bloginfo_rss('comments_atom_url'); ?></id>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    54
<?php } ?>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    55
<?php
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    56
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    57
	 * Fires at the end of the Atom comment feed header.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    58
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    59
	 * @since 2.8.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    60
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    61
	do_action( 'comments_atom_head' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    62
?>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    63
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    64
if ( have_comments() ) : while ( have_comments() ) : the_comment();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    65
	$comment_post = $GLOBALS['post'] = get_post( $comment->comment_post_ID );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    66
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    67
	<entry>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    68
		<title><?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    69
			if ( !is_singular() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    70
				$title = get_the_title($comment_post->ID);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    71
				/** This filter is documented in wp-includes/feed.php */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    72
				$title = apply_filters( 'the_title_rss', $title );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    73
				printf(ent2ncr(__('Comment on %1$s by %2$s')), $title, get_comment_author_rss());
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    74
			} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    75
				printf(ent2ncr(__('By: %s')), get_comment_author_rss());
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    76
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    77
		?></title>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    78
		<link rel="alternate" href="<?php comment_link(); ?>" type="<?php bloginfo_rss('html_type'); ?>" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    79
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    80
		<author>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    81
			<name><?php comment_author_rss(); ?></name>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    82
			<?php if (get_comment_author_url()) echo '<uri>' . get_comment_author_url() . '</uri>'; ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    83
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    84
		</author>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    85
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    86
		<id><?php comment_guid(); ?></id>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    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>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    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>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    89
<?php if ( post_password_required($comment_post) ) : ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    90
		<content type="html" xml:base="<?php comment_link(); ?>"><![CDATA[<?php echo get_the_password_form(); ?>]]></content>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    91
<?php else : // post pass ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    92
		<content type="html" xml:base="<?php comment_link(); ?>"><![CDATA[<?php comment_text(); ?>]]></content>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    93
<?php endif; // post pass
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    94
	// Return comment threading information (http://www.ietf.org/rfc/rfc4685.txt)
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    95
	if ( $comment->comment_parent == 0 ) : // This comment is top level ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    96
		<thr:in-reply-to ref="<?php the_guid(); ?>" href="<?php the_permalink_rss() ?>" type="<?php bloginfo_rss('html_type'); ?>" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    97
<?php else : // This comment is in reply to another comment
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    98
	$parent_comment = get_comment($comment->comment_parent);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    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
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   100
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   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'); ?>" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   102
<?php endif;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   103
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   104
	 * Fires at the end of each Atom comment feed item.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   105
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   106
	 * @since 2.2.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   107
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   108
	 * @param int $comment_id      ID of the current comment.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   109
	 * @param int $comment_post_id ID of the post the current comment is connected to.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   110
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   111
	do_action( 'comment_atom_entry', $comment->comment_ID, $comment_post->ID );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   112
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   113
	</entry>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   114
<?php endwhile; endif; ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   115
</feed>