wp/wp-includes/feed-rss2.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 Posts feed.
     3  * RSS2 Feed Template for displaying RSS2 Posts 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 $more = 1;
     9 $more = 1;
    10 
    10 
    11 echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>';
    11 echo '<?xml version="1.0" encoding="' . get_option( 'blog_charset' ) . '"?' . '>';
    12 
    12 
    13 /**
    13 /**
    14  * Fires between the xml and rss tags in a feed.
    14  * Fires between the xml and rss tags in a feed.
    15  *
    15  *
    16  * @since 4.0.0
    16  * @since 4.0.0
    38 >
    38 >
    39 
    39 
    40 <channel>
    40 <channel>
    41 	<title><?php wp_title_rss(); ?></title>
    41 	<title><?php wp_title_rss(); ?></title>
    42 	<atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
    42 	<atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
    43 	<link><?php bloginfo_rss('url') ?></link>
    43 	<link><?php bloginfo_rss( 'url' ); ?></link>
    44 	<description><?php bloginfo_rss("description") ?></description>
    44 	<description><?php bloginfo_rss( 'description' ); ?></description>
    45 	<lastBuildDate><?php
    45 	<lastBuildDate><?php echo get_feed_build_date( 'r' ); ?></lastBuildDate>
    46 		$date = get_lastpostmodified( 'GMT' );
       
    47 		echo $date ? mysql2date( 'r', $date, false ) : date( 'r' );
       
    48 	?></lastBuildDate>
       
    49 	<language><?php bloginfo_rss( 'language' ); ?></language>
    46 	<language><?php bloginfo_rss( 'language' ); ?></language>
    50 	<sy:updatePeriod><?php
    47 	<sy:updatePeriod>
       
    48 	<?php
    51 		$duration = 'hourly';
    49 		$duration = 'hourly';
    52 
    50 
    53 		/**
    51 		/**
    54 		 * Filters how often to update the RSS feed.
    52 		 * Filters how often to update the RSS feed.
    55 		 *
    53 		 *
    57 		 *
    55 		 *
    58 		 * @param string $duration The update period. Accepts 'hourly', 'daily', 'weekly', 'monthly',
    56 		 * @param string $duration The update period. Accepts 'hourly', 'daily', 'weekly', 'monthly',
    59 		 *                         'yearly'. Default 'hourly'.
    57 		 *                         'yearly'. Default 'hourly'.
    60 		 */
    58 		 */
    61 		echo apply_filters( 'rss_update_period', $duration );
    59 		echo apply_filters( 'rss_update_period', $duration );
    62 	?></sy:updatePeriod>
    60 	?>
    63 	<sy:updateFrequency><?php
    61 	</sy:updatePeriod>
       
    62 	<sy:updateFrequency>
       
    63 	<?php
    64 		$frequency = '1';
    64 		$frequency = '1';
    65 
    65 
    66 		/**
    66 		/**
    67 		 * Filters the RSS update frequency.
    67 		 * Filters the RSS update frequency.
    68 		 *
    68 		 *
    70 		 *
    70 		 *
    71 		 * @param string $frequency An integer passed as a string representing the frequency
    71 		 * @param string $frequency An integer passed as a string representing the frequency
    72 		 *                          of RSS updates within the update period. Default '1'.
    72 		 *                          of RSS updates within the update period. Default '1'.
    73 		 */
    73 		 */
    74 		echo apply_filters( 'rss_update_frequency', $frequency );
    74 		echo apply_filters( 'rss_update_frequency', $frequency );
    75 	?></sy:updateFrequency>
    75 	?>
       
    76 	</sy:updateFrequency>
    76 	<?php
    77 	<?php
    77 	/**
    78 	/**
    78 	 * Fires at the end of the RSS2 Feed Header.
    79 	 * Fires at the end of the RSS2 Feed Header.
    79 	 *
    80 	 *
    80 	 * @since 2.0.0
    81 	 * @since 2.0.0
    81 	 */
    82 	 */
    82 	do_action( 'rss2_head');
    83 	do_action( 'rss2_head' );
    83 
    84 
    84 	while( have_posts()) : the_post();
    85 	while ( have_posts() ) :
    85 	?>
    86 		the_post();
       
    87 		?>
    86 	<item>
    88 	<item>
    87 		<title><?php the_title_rss() ?></title>
    89 		<title><?php the_title_rss(); ?></title>
    88 		<link><?php the_permalink_rss() ?></link>
    90 		<link><?php the_permalink_rss(); ?></link>
    89 <?php if ( get_comments_number() || comments_open() ) : ?>
    91 		<?php if ( get_comments_number() || comments_open() ) : ?>
    90 		<comments><?php comments_link_feed(); ?></comments>
    92 		<comments><?php comments_link_feed(); ?></comments>
    91 <?php endif; ?>
    93 		<?php endif; ?>
    92 		<pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false); ?></pubDate>
    94 		<pubDate><?php echo mysql2date( 'D, d M Y H:i:s +0000', get_post_time( 'Y-m-d H:i:s', true ), false ); ?></pubDate>
    93 		<dc:creator><![CDATA[<?php the_author() ?>]]></dc:creator>
    95 		<dc:creator><![CDATA[<?php the_author(); ?>]]></dc:creator>
    94 		<?php the_category_rss('rss2') ?>
    96 		<?php the_category_rss( 'rss2' ); ?>
    95 
    97 
    96 		<guid isPermaLink="false"><?php the_guid(); ?></guid>
    98 		<guid isPermaLink="false"><?php the_guid(); ?></guid>
    97 <?php if (get_option('rss_use_excerpt')) : ?>
    99 		<?php if ( get_option( 'rss_use_excerpt' ) ) : ?>
    98 		<description><![CDATA[<?php the_excerpt_rss(); ?>]]></description>
   100 		<description><![CDATA[<?php the_excerpt_rss(); ?>]]></description>
    99 <?php else : ?>
   101 		<?php else : ?>
   100 		<description><![CDATA[<?php the_excerpt_rss(); ?>]]></description>
   102 		<description><![CDATA[<?php the_excerpt_rss(); ?>]]></description>
   101 	<?php $content = get_the_content_feed('rss2'); ?>
   103 			<?php $content = get_the_content_feed( 'rss2' ); ?>
   102 	<?php if ( strlen( $content ) > 0 ) : ?>
   104 			<?php if ( strlen( $content ) > 0 ) : ?>
   103 		<content:encoded><![CDATA[<?php echo $content; ?>]]></content:encoded>
   105 		<content:encoded><![CDATA[<?php echo $content; ?>]]></content:encoded>
   104 	<?php else : ?>
   106 	<?php else : ?>
   105 		<content:encoded><![CDATA[<?php the_excerpt_rss(); ?>]]></content:encoded>
   107 		<content:encoded><![CDATA[<?php the_excerpt_rss(); ?>]]></content:encoded>
   106 	<?php endif; ?>
   108 	<?php endif; ?>
   107 <?php endif; ?>
   109 		<?php endif; ?>
   108 <?php if ( get_comments_number() || comments_open() ) : ?>
   110 		<?php if ( get_comments_number() || comments_open() ) : ?>
   109 		<wfw:commentRss><?php echo esc_url( get_post_comments_feed_link(null, 'rss2') ); ?></wfw:commentRss>
   111 		<wfw:commentRss><?php echo esc_url( get_post_comments_feed_link( null, 'rss2' ) ); ?></wfw:commentRss>
   110 		<slash:comments><?php echo get_comments_number(); ?></slash:comments>
   112 		<slash:comments><?php echo get_comments_number(); ?></slash:comments>
   111 <?php endif; ?>
   113 		<?php endif; ?>
   112 <?php rss_enclosure(); ?>
   114 		<?php rss_enclosure(); ?>
   113 	<?php
   115 		<?php
   114 	/**
   116 		/**
   115 	 * Fires at the end of each RSS2 feed item.
   117 		 * Fires at the end of each RSS2 feed item.
   116 	 *
   118 		 *
   117 	 * @since 2.0.0
   119 		 * @since 2.0.0
   118 	 */
   120 		 */
   119 	do_action( 'rss2_item' );
   121 		do_action( 'rss2_item' );
   120 	?>
   122 		?>
   121 	</item>
   123 	</item>
   122 	<?php endwhile; ?>
   124 	<?php endwhile; ?>
   123 </channel>
   125 </channel>
   124 </rss>
   126 </rss>