wp/wp-includes/feed-rss2-comments.php
changeset 9 177826044cd9
parent 7 cf61fcea0001
child 16 a86126ab1dd4
equal deleted inserted replaced
8:c7c34916027a 9:177826044cd9
     3  * RSS2 Feed Template for displaying RSS2 Comments feed.
     3  * RSS2 Feed Template for displaying RSS2 Comments feed.
     4  *
     4  *
     5  * @package WordPress
     5  * @package WordPress
     6  */
     6  */
     7 
     7 
     8 header('Content-Type: ' . feed_content_type('rss2') . '; charset=' . get_option('blog_charset'), true);
     8 header( 'Content-Type: ' . feed_content_type( 'rss2' ) . '; charset=' . get_option( 'blog_charset' ), true );
     9 
     9 
    10 echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>';
    10 echo '<?xml version="1.0" encoding="' . get_option( 'blog_charset' ) . '"?' . '>';
    11 
    11 
    12 /** This action is documented in wp-includes/feed-rss2.php */
    12 /** This action is documented in wp-includes/feed-rss2.php */
    13 do_action( 'rss_tag_pre', 'rss2-comments' );
    13 do_action( 'rss_tag_pre', 'rss2-comments' );
    14 ?>
    14 ?>
    15 <rss version="2.0"
    15 <rss version="2.0"
    30 	 */
    30 	 */
    31 	do_action( 'rss2_comments_ns' );
    31 	do_action( 'rss2_comments_ns' );
    32 	?>
    32 	?>
    33 >
    33 >
    34 <channel>
    34 <channel>
    35 	<title><?php
    35 	<title>
    36 		if ( is_singular() ) {
    36 	<?php
    37 			/* translators: Comments feed title. 1: Post title */
    37 	if ( is_singular() ) {
    38 			printf( ent2ncr( __( 'Comments on: %s' ) ), get_the_title_rss() );
    38 		/* translators: Comments feed title. %s: Post title */
    39 		} elseif ( is_search() ) {
    39 		printf( ent2ncr( __( 'Comments on: %s' ) ), get_the_title_rss() );
    40 			/* translators: Comments feed title. 1: Site name, 2: Search query */
    40 	} elseif ( is_search() ) {
    41 			printf( ent2ncr( __( 'Comments for %1$s searching on %2$s' ) ), get_bloginfo_rss( 'name' ), get_search_query() );
    41 		/* translators: Comments feed title. 1: Site name, 2: Search query */
    42 		} else {
    42 		printf( ent2ncr( __( 'Comments for %1$s searching on %2$s' ) ), get_bloginfo_rss( 'name' ), get_search_query() );
    43 			/* translators: Comments feed title. 1: Site name */
    43 	} else {
    44 			printf( ent2ncr( __( 'Comments for %s' ) ), get_wp_title_rss() );
    44 		/* translators: Comments feed title. %s: Site name */
    45 		}
    45 		printf( ent2ncr( __( 'Comments for %s' ) ), get_wp_title_rss() );
    46 	?></title>
    46 	}
       
    47 	?>
       
    48 	</title>
    47 	<atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
    49 	<atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
    48 	<link><?php (is_single()) ? the_permalink_rss() : bloginfo_rss("url") ?></link>
    50 	<link><?php ( is_single() ) ? the_permalink_rss() : bloginfo_rss( 'url' ); ?></link>
    49 	<description><?php bloginfo_rss("description") ?></description>
    51 	<description><?php bloginfo_rss( 'description' ); ?></description>
    50 	<lastBuildDate><?php
    52 	<lastBuildDate><?php echo get_feed_build_date( 'r' ); ?></lastBuildDate>
    51 		$date = get_lastcommentmodified( 'GMT' );
    53 	<sy:updatePeriod>
    52 		echo $date ? mysql2date( 'r', $date, false ) : date( 'r' );
    54 	<?php
    53 	?></lastBuildDate>
       
    54 	<sy:updatePeriod><?php
       
    55 		/** This filter is documented in wp-includes/feed-rss2.php */
    55 		/** This filter is documented in wp-includes/feed-rss2.php */
    56 		echo apply_filters( 'rss_update_period', 'hourly' );
    56 		echo apply_filters( 'rss_update_period', 'hourly' );
    57 	?></sy:updatePeriod>
    57 	?>
    58 	<sy:updateFrequency><?php
    58 	</sy:updatePeriod>
       
    59 	<sy:updateFrequency>
       
    60 	<?php
    59 		/** This filter is documented in wp-includes/feed-rss2.php */
    61 		/** This filter is documented in wp-includes/feed-rss2.php */
    60 		echo apply_filters( 'rss_update_frequency', '1' );
    62 		echo apply_filters( 'rss_update_frequency', '1' );
    61 	?></sy:updateFrequency>
    63 	?>
       
    64 	</sy:updateFrequency>
    62 	<?php
    65 	<?php
    63 	/**
    66 	/**
    64 	 * Fires at the end of the RSS2 comment feed header.
    67 	 * Fires at the end of the RSS2 comment feed header.
    65 	 *
    68 	 *
    66 	 * @since 2.3.0
    69 	 * @since 2.3.0
    67 	 */
    70 	 */
    68 	do_action( 'commentsrss2_head' );
    71 	do_action( 'commentsrss2_head' );
    69 
    72 
    70 	if ( have_comments() ) : while ( have_comments() ) : the_comment();
    73 	if ( have_comments() ) :
    71 		$comment_post = $GLOBALS['post'] = get_post( $comment->comment_post_ID );
    74 		while ( have_comments() ) :
       
    75 			the_comment();
       
    76 			$comment_post = $GLOBALS['post'] = get_post( $comment->comment_post_ID );
       
    77 			?>
       
    78 			<item>
       
    79 				<title>
       
    80 				<?php
       
    81 				if ( ! is_singular() ) {
       
    82 					$title = get_the_title( $comment_post->ID );
       
    83 					/** This filter is documented in wp-includes/feed.php */
       
    84 					$title = apply_filters( 'the_title_rss', $title );
       
    85 					/* translators: Individual comment title. 1: Post title, 2: Comment author name */
       
    86 					printf( ent2ncr( __( 'Comment on %1$s by %2$s' ) ), $title, get_comment_author_rss() );
       
    87 				} else {
       
    88 					/* translators: Comment author title. %s: Comment author name */
       
    89 					printf( ent2ncr( __( 'By: %s' ) ), get_comment_author_rss() );
       
    90 				}
       
    91 				?>
       
    92 				</title>
       
    93 				<link><?php comment_link(); ?></link>
       
    94 		<dc:creator><![CDATA[<?php echo get_comment_author_rss(); ?>]]></dc:creator>
       
    95 		<pubDate><?php echo mysql2date( 'D, d M Y H:i:s +0000', get_comment_time( 'Y-m-d H:i:s', true, false ), false ); ?></pubDate>
       
    96 		<guid isPermaLink="false"><?php comment_guid(); ?></guid>
       
    97 			<?php if ( post_password_required( $comment_post ) ) : ?>
       
    98 		<description><?php echo ent2ncr( __( 'Protected Comments: Please enter your password to view comments.' ) ); ?></description>
       
    99 		<content:encoded><![CDATA[<?php echo get_the_password_form(); ?>]]></content:encoded>
       
   100 		<?php else : // post pass ?>
       
   101 		<description><![CDATA[<?php comment_text_rss(); ?>]]></description>
       
   102 		<content:encoded><![CDATA[<?php comment_text(); ?>]]></content:encoded>
       
   103 			<?php
       
   104 		endif; // post pass
       
   105 			/**
       
   106 			 * Fires at the end of each RSS2 comment feed item.
       
   107 			 *
       
   108 			 * @since 2.1.0
       
   109 			 *
       
   110 			 * @param int $comment->comment_ID The ID of the comment being displayed.
       
   111 			 * @param int $comment_post->ID    The ID of the post the comment is connected to.
       
   112 			 */
       
   113 			do_action( 'commentrss2_item', $comment->comment_ID, $comment_post->ID );
       
   114 		?>
       
   115 			</item>
       
   116 			<?php
       
   117 		endwhile;
       
   118 endif;
    72 	?>
   119 	?>
    73 	<item>
       
    74 		<title><?php
       
    75 			if ( !is_singular() ) {
       
    76 				$title = get_the_title($comment_post->ID);
       
    77 				/** This filter is documented in wp-includes/feed.php */
       
    78 				$title = apply_filters( 'the_title_rss', $title );
       
    79 				/* translators: Individual comment title. 1: Post title, 2: Comment author name */
       
    80 				printf(ent2ncr(__('Comment on %1$s by %2$s')), $title, get_comment_author_rss());
       
    81 			} else {
       
    82 				/* translators: Comment author title. 1: Comment author name */
       
    83 				printf(ent2ncr(__('By: %s')), get_comment_author_rss());
       
    84 			}
       
    85 		?></title>
       
    86 		<link><?php comment_link() ?></link>
       
    87 		<dc:creator><![CDATA[<?php echo get_comment_author_rss() ?>]]></dc:creator>
       
    88 		<pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_comment_time('Y-m-d H:i:s', true, false), false); ?></pubDate>
       
    89 		<guid isPermaLink="false"><?php comment_guid() ?></guid>
       
    90 <?php if ( post_password_required($comment_post) ) : ?>
       
    91 		<description><?php echo ent2ncr(__('Protected Comments: Please enter your password to view comments.')); ?></description>
       
    92 		<content:encoded><![CDATA[<?php echo get_the_password_form() ?>]]></content:encoded>
       
    93 <?php else : // post pass ?>
       
    94 		<description><![CDATA[<?php comment_text_rss() ?>]]></description>
       
    95 		<content:encoded><![CDATA[<?php comment_text() ?>]]></content:encoded>
       
    96 <?php endif; // post pass
       
    97 	/**
       
    98 	 * Fires at the end of each RSS2 comment feed item.
       
    99 	 *
       
   100 	 * @since 2.1.0
       
   101 	 *
       
   102 	 * @param int $comment->comment_ID The ID of the comment being displayed.
       
   103 	 * @param int $comment_post->ID    The ID of the post the comment is connected to.
       
   104 	 */
       
   105 	do_action( 'commentrss2_item', $comment->comment_ID, $comment_post->ID );
       
   106 ?>
       
   107 	</item>
       
   108 <?php endwhile; endif; ?>
       
   109 </channel>
   120 </channel>
   110 </rss>
   121 </rss>