wp/wp-includes/feed-atom-comments.php
changeset 16 a86126ab1dd4
parent 9 177826044cd9
child 21 48c4eec2b7e6
equal deleted inserted replaced
15:3d4e9c994f10 16:a86126ab1dd4
    28 	?>
    28 	?>
    29 >
    29 >
    30 	<title type="text">
    30 	<title type="text">
    31 	<?php
    31 	<?php
    32 	if ( is_singular() ) {
    32 	if ( is_singular() ) {
    33 		/* translators: Comments feed title. %s: Post title */
    33 		/* translators: Comments feed title. %s: Post title. */
    34 		printf( ent2ncr( __( 'Comments on %s' ) ), get_the_title_rss() );
    34 		printf( ent2ncr( __( 'Comments on %s' ) ), get_the_title_rss() );
    35 	} elseif ( is_search() ) {
    35 	} elseif ( is_search() ) {
    36 		/* translators: Comments feed title. 1: Site name, 2: Search query */
    36 		/* translators: Comments feed title. 1: Site title, 2: Search query. */
    37 		printf( ent2ncr( __( 'Comments for %1$s searching on %2$s' ) ), get_bloginfo_rss( 'name' ), get_search_query() );
    37 		printf( ent2ncr( __( 'Comments for %1$s searching on %2$s' ) ), get_bloginfo_rss( 'name' ), get_search_query() );
    38 	} else {
    38 	} else {
    39 		/* translators: Comments feed title. %s: Site name */
    39 		/* translators: Comments feed title. %s: Site title. */
    40 		printf( ent2ncr( __( 'Comments for %s' ) ), get_wp_title_rss() );
    40 		printf( ent2ncr( __( 'Comments for %s' ) ), get_wp_title_rss() );
    41 	}
    41 	}
    42 	?>
    42 	?>
    43 	</title>
    43 	</title>
    44 	<subtitle type="text"><?php bloginfo_rss( 'description' ); ?></subtitle>
    44 	<subtitle type="text"><?php bloginfo_rss( 'description' ); ?></subtitle>
    45 
    45 
    46 	<updated><?php echo get_feed_build_date( 'Y-m-d\TH:i:s\Z' ); ?></updated>
    46 	<updated><?php echo get_feed_build_date( 'Y-m-d\TH:i:s\Z' ); ?></updated>
    47 
    47 
    48 <?php if ( is_singular() ) { ?>
    48 <?php if ( is_singular() ) : ?>
    49 	<link rel="alternate" type="<?php bloginfo_rss( 'html_type' ); ?>" href="<?php comments_link_feed(); ?>" />
    49 	<link rel="alternate" type="<?php bloginfo_rss( 'html_type' ); ?>" href="<?php comments_link_feed(); ?>" />
    50 	<link rel="self" type="application/atom+xml" href="<?php echo esc_url( get_post_comments_feed_link( '', 'atom' ) ); ?>" />
    50 	<link rel="self" type="application/atom+xml" href="<?php echo esc_url( get_post_comments_feed_link( '', 'atom' ) ); ?>" />
    51 	<id><?php echo esc_url( get_post_comments_feed_link( '', 'atom' ) ); ?></id>
    51 	<id><?php echo esc_url( get_post_comments_feed_link( '', 'atom' ) ); ?></id>
    52 <?php } elseif ( is_search() ) { ?>
    52 <?php elseif ( is_search() ) : ?>
    53 	<link rel="alternate" type="<?php bloginfo_rss( 'html_type' ); ?>" href="<?php echo home_url() . '?s=' . get_search_query(); ?>" />
    53 	<link rel="alternate" type="<?php bloginfo_rss( 'html_type' ); ?>" href="<?php echo home_url() . '?s=' . get_search_query(); ?>" />
    54 	<link rel="self" type="application/atom+xml" href="<?php echo get_search_comments_feed_link( '', 'atom' ); ?>" />
    54 	<link rel="self" type="application/atom+xml" href="<?php echo get_search_comments_feed_link( '', 'atom' ); ?>" />
    55 	<id><?php echo get_search_comments_feed_link( '', 'atom' ); ?></id>
    55 	<id><?php echo get_search_comments_feed_link( '', 'atom' ); ?></id>
    56 <?php } else { ?>
    56 <?php else : ?>
    57 	<link rel="alternate" type="<?php bloginfo_rss( 'html_type' ); ?>" href="<?php bloginfo_rss( 'url' ); ?>" />
    57 	<link rel="alternate" type="<?php bloginfo_rss( 'html_type' ); ?>" href="<?php bloginfo_rss( 'url' ); ?>" />
    58 	<link rel="self" type="application/atom+xml" href="<?php bloginfo_rss( 'comments_atom_url' ); ?>" />
    58 	<link rel="self" type="application/atom+xml" href="<?php bloginfo_rss( 'comments_atom_url' ); ?>" />
    59 	<id><?php bloginfo_rss( 'comments_atom_url' ); ?></id>
    59 	<id><?php bloginfo_rss( 'comments_atom_url' ); ?></id>
    60 <?php } ?>
    60 <?php endif; ?>
    61 <?php
    61 <?php
    62 	/**
    62 	/**
    63 	 * Fires at the end of the Atom comment feed header.
    63 	 * Fires at the end of the Atom comment feed header.
    64 	 *
    64 	 *
    65 	 * @since 2.8.0
    65 	 * @since 2.8.0
    66 	 */
    66 	 */
    67 	do_action( 'comments_atom_head' );
    67 	do_action( 'comments_atom_head' );
    68 ?>
    68 ?>
    69 <?php
    69 <?php
    70 if ( have_comments() ) :
    70 while ( have_comments() ) :
    71 	while ( have_comments() ) :
    71 	the_comment();
    72 		the_comment();
    72 	$comment_post    = get_post( $comment->comment_post_ID );
    73 		$comment_post = $GLOBALS['post'] = get_post( $comment->comment_post_ID );
    73 	$GLOBALS['post'] = $comment_post;
    74 		?>
    74 	?>
    75 	<entry>
    75 	<entry>
    76 		<title>
    76 		<title>
    77 		<?php
    77 		<?php
    78 		if ( ! is_singular() ) {
    78 		if ( ! is_singular() ) {
    79 			$title = get_the_title( $comment_post->ID );
    79 			$title = get_the_title( $comment_post->ID );
    80 			/** This filter is documented in wp-includes/feed.php */
    80 			/** This filter is documented in wp-includes/feed.php */
    81 			$title = apply_filters( 'the_title_rss', $title );
    81 			$title = apply_filters( 'the_title_rss', $title );
    82 			/* translators: Individual comment title. 1: Post title, 2: Comment author name */
    82 			/* translators: Individual comment title. 1: Post title, 2: Comment author name. */
    83 			printf( ent2ncr( __( 'Comment on %1$s by %2$s' ) ), $title, get_comment_author_rss() );
    83 			printf( ent2ncr( __( 'Comment on %1$s by %2$s' ) ), $title, get_comment_author_rss() );
    84 		} else {
    84 		} else {
    85 			/* translators: Comment author title. %s: Comment author name */
    85 			/* translators: Comment author title. %s: Comment author name. */
    86 			printf( ent2ncr( __( 'By: %s' ) ), get_comment_author_rss() );
    86 			printf( ent2ncr( __( 'By: %s' ) ), get_comment_author_rss() );
    87 		}
    87 		}
    88 		?>
    88 		?>
    89 			</title>
    89 		</title>
    90 			<link rel="alternate" href="<?php comment_link(); ?>" type="<?php bloginfo_rss( 'html_type' ); ?>" />
    90 		<link rel="alternate" href="<?php comment_link(); ?>" type="<?php bloginfo_rss( 'html_type' ); ?>" />
    91 
    91 
    92 		<author>
    92 		<author>
    93 			<name><?php comment_author_rss(); ?></name>
    93 			<name><?php comment_author_rss(); ?></name>
    94 			<?php
    94 			<?php
    95 			if ( get_comment_author_url() ) {
    95 			if ( get_comment_author_url() ) {
    99 		</author>
    99 		</author>
   100 
   100 
   101 		<id><?php comment_guid(); ?></id>
   101 		<id><?php comment_guid(); ?></id>
   102 		<updated><?php echo mysql2date( 'Y-m-d\TH:i:s\Z', get_comment_time( 'Y-m-d H:i:s', true, false ), false ); ?></updated>
   102 		<updated><?php echo mysql2date( 'Y-m-d\TH:i:s\Z', get_comment_time( 'Y-m-d H:i:s', true, false ), false ); ?></updated>
   103 		<published><?php echo mysql2date( 'Y-m-d\TH:i:s\Z', get_comment_time( 'Y-m-d H:i:s', true, false ), false ); ?></published>
   103 		<published><?php echo mysql2date( 'Y-m-d\TH:i:s\Z', get_comment_time( 'Y-m-d H:i:s', true, false ), false ); ?></published>
       
   104 
   104 		<?php if ( post_password_required( $comment_post ) ) : ?>
   105 		<?php if ( post_password_required( $comment_post ) ) : ?>
   105 		<content type="html" xml:base="<?php comment_link(); ?>"><![CDATA[<?php echo get_the_password_form(); ?>]]></content>
   106 			<content type="html" xml:base="<?php comment_link(); ?>"><![CDATA[<?php echo get_the_password_form(); ?>]]></content>
   106 	<?php else : // post pass ?>
   107 		<?php else : ?>
   107 		<content type="html" xml:base="<?php comment_link(); ?>"><![CDATA[<?php comment_text(); ?>]]></content>
   108 			<content type="html" xml:base="<?php comment_link(); ?>"><![CDATA[<?php comment_text(); ?>]]></content>
       
   109 		<?php endif; // End if post_password_required(). ?>
       
   110 
   108 		<?php
   111 		<?php
   109 	endif; // post pass
   112 		// Return comment threading information (https://www.ietf.org/rfc/rfc4685.txt).
   110 	// Return comment threading information (https://www.ietf.org/rfc/rfc4685.txt)
   113 		if ( 0 == $comment->comment_parent ) : // This comment is top-level.
   111 	if ( $comment->comment_parent == 0 ) : // This comment is top level
   114 			?>
       
   115 			<thr:in-reply-to ref="<?php the_guid(); ?>" href="<?php the_permalink_rss(); ?>" type="<?php bloginfo_rss( 'html_type' ); ?>" />
       
   116 			<?php
       
   117 		else : // This comment is in reply to another comment.
       
   118 			$parent_comment = get_comment( $comment->comment_parent );
       
   119 			/*
       
   120 			 * The rel attribute below and the id tag above should be GUIDs,
       
   121 			 * but WP doesn't create them for comments (unlike posts).
       
   122 			 * Either way, it's more important that they both use the same system.
       
   123 			 */
       
   124 			?>
       
   125 			<thr:in-reply-to ref="<?php comment_guid( $parent_comment ); ?>" href="<?php echo get_comment_link( $parent_comment ); ?>" type="<?php bloginfo_rss( 'html_type' ); ?>" />
       
   126 			<?php
       
   127 		endif;
       
   128 
       
   129 		/**
       
   130 		 * Fires at the end of each Atom comment feed item.
       
   131 		 *
       
   132 		 * @since 2.2.0
       
   133 		 *
       
   134 		 * @param int $comment_id      ID of the current comment.
       
   135 		 * @param int $comment_post_id ID of the post the current comment is connected to.
       
   136 		 */
       
   137 		do_action( 'comment_atom_entry', $comment->comment_ID, $comment_post->ID );
   112 		?>
   138 		?>
   113 	<thr:in-reply-to ref="<?php the_guid(); ?>" href="<?php the_permalink_rss(); ?>" type="<?php bloginfo_rss( 'html_type' ); ?>" />
       
   114 		<?php
       
   115 	else : // This comment is in reply to another comment
       
   116 		$parent_comment = get_comment( $comment->comment_parent );
       
   117 		// 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
       
   118 		?>
       
   119 		<thr:in-reply-to ref="<?php comment_guid( $parent_comment ); ?>" href="<?php echo get_comment_link( $parent_comment ); ?>" type="<?php bloginfo_rss( 'html_type' ); ?>" />
       
   120 		<?php
       
   121 endif;
       
   122 	/**
       
   123 	 * Fires at the end of each Atom comment feed item.
       
   124 	 *
       
   125 	 * @since 2.2.0
       
   126 	 *
       
   127 	 * @param int $comment_id      ID of the current comment.
       
   128 	 * @param int $comment_post_id ID of the post the current comment is connected to.
       
   129 	 */
       
   130 	do_action( 'comment_atom_entry', $comment->comment_ID, $comment_post->ID );
       
   131 	?>
       
   132 	</entry>
   139 	</entry>
   133 		<?php
   140 	<?php
   134 	endwhile;
   141 endwhile;
   135 endif;
       
   136 ?>
   142 ?>
   137 </feed>
   143 </feed>