wp/wp-includes/feed-atom-comments.php
author ymh <ymh.work@gmail.com>
Mon, 14 Oct 2019 17:39:30 +0200
changeset 7 cf61fcea0001
parent 5 5e2f62d02dcd
child 9 177826044cd9
permissions -rw-r--r--
resynchronize code repo with production
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
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    31
		if ( is_singular() ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    32
			/* translators: Comments feed title. 1: Post title */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    33
			printf( ent2ncr( __( 'Comments on %s' ) ), get_the_title_rss() );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    34
		} elseif ( is_search() ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    35
			/* translators: Comments feed title. 1: Site name, 2: Search query */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    36
			printf( ent2ncr( __( 'Comments for %1$s searching on %2$s' ) ), get_bloginfo_rss( 'name' ), get_search_query() );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    37
		} else {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    38
			/* translators: Comments feed title. 1: Site name */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    39
			printf( ent2ncr( __( 'Comments for %s' ) ), get_wp_title_rss() );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    40
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    41
	?></title>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    42
	<subtitle type="text"><?php bloginfo_rss('description'); ?></subtitle>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    43
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    44
	<updated><?php
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    45
		$date = get_lastcommentmodified( 'GMT' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    46
		echo $date ? mysql2date( 'Y-m-d\TH:i:s\Z', $date, false ) : date( 'Y-m-d\TH:i:s\Z' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    47
	?></updated>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    48
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    49
<?php if ( is_singular() ) { ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    50
	<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
    51
	<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
    52
	<id><?php echo esc_url( get_post_comments_feed_link('', 'atom') ); ?></id>
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    53
<?php } elseif (is_search()) { ?>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    54
	<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
    55
	<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
    56
	<id><?php echo get_search_comments_feed_link('', 'atom'); ?></id>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    57
<?php } else { ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    58
	<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
    59
	<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
    60
	<id><?php bloginfo_rss('comments_atom_url'); ?></id>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    61
<?php } ?>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    62
<?php
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    63
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    64
	 * Fires at the end of the Atom comment feed header.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    65
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    66
	 * @since 2.8.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    67
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    68
	do_action( 'comments_atom_head' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    69
?>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    70
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    71
if ( have_comments() ) : while ( have_comments() ) : the_comment();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    72
	$comment_post = $GLOBALS['post'] = get_post( $comment->comment_post_ID );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    73
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    74
	<entry>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    75
		<title><?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    76
			if ( !is_singular() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    77
				$title = get_the_title($comment_post->ID);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    78
				/** This filter is documented in wp-includes/feed.php */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    79
				$title = apply_filters( 'the_title_rss', $title );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    80
				/* translators: Individual comment title. 1: Post title, 2: Comment author name */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    81
				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
    82
			} else {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    83
				/* translators: Comment author title. 1: Comment author name */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    84
				printf(ent2ncr(__('By: %s')), get_comment_author_rss());
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    85
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    86
		?></title>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    87
		<link rel="alternate" href="<?php comment_link(); ?>" type="<?php bloginfo_rss('html_type'); ?>" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    88
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    89
		<author>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    90
			<name><?php comment_author_rss(); ?></name>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    91
			<?php if (get_comment_author_url()) echo '<uri>' . get_comment_author_url() . '</uri>'; ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    92
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    93
		</author>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    94
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    95
		<id><?php comment_guid(); ?></id>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    96
		<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
    97
		<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
    98
<?php if ( post_password_required($comment_post) ) : ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    99
		<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
   100
<?php else : // post pass ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   101
		<content type="html" xml:base="<?php comment_link(); ?>"><![CDATA[<?php comment_text(); ?>]]></content>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   102
<?php endif; // post pass
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   103
	// Return comment threading information (https://www.ietf.org/rfc/rfc4685.txt)
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   104
	if ( $comment->comment_parent == 0 ) : // This comment is top level ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   105
		<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
   106
<?php else : // This comment is in reply to another comment
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   107
	$parent_comment = get_comment($comment->comment_parent);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   108
	// 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
   109
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   110
		<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
   111
<?php endif;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   112
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   113
	 * Fires at the end of each Atom comment feed item.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   114
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   115
	 * @since 2.2.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   116
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   117
	 * @param int $comment_id      ID of the current comment.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   118
	 * @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
   119
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   120
	do_action( 'comment_atom_entry', $comment->comment_ID, $comment_post->ID );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   121
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   122
	</entry>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   123
<?php endwhile; endif; ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   124
</feed>