wp/wp-includes/feed.php
changeset 5 5e2f62d02dcd
parent 0 d970ebf37754
child 7 cf61fcea0001
equal deleted inserted replaced
4:346c88efed21 5:5e2f62d02dcd
    14  *
    14  *
    15  * You can retrieve anything that you can using the get_bloginfo() function.
    15  * You can retrieve anything that you can using the get_bloginfo() function.
    16  * Everything will be stripped of tags and characters converted, when the values
    16  * Everything will be stripped of tags and characters converted, when the values
    17  * are retrieved for use in the feeds.
    17  * are retrieved for use in the feeds.
    18  *
    18  *
    19  * @package WordPress
       
    20  * @subpackage Feed
       
    21  * @since 1.5.1
    19  * @since 1.5.1
    22  * @uses apply_filters() Calls 'get_bloginfo_rss' hook with two parameters.
       
    23  * @see get_bloginfo() For the list of possible values to display.
    20  * @see get_bloginfo() For the list of possible values to display.
    24  *
    21  *
    25  * @param string $show See get_bloginfo() for possible values.
    22  * @param string $show See get_bloginfo() for possible values.
    26  * @return string
    23  * @return string
    27  */
    24  */
    28 function get_bloginfo_rss($show = '') {
    25 function get_bloginfo_rss($show = '') {
    29 	$info = strip_tags(get_bloginfo($show));
    26 	$info = strip_tags(get_bloginfo($show));
    30 	return apply_filters('get_bloginfo_rss', convert_chars($info), $show);
    27 	/**
       
    28 	 * Filter the bloginfo for use in RSS feeds.
       
    29 	 *
       
    30 	 * @since 2.2.0
       
    31 	 *
       
    32 	 * @see convert_chars()
       
    33 	 * @see get_bloginfo()
       
    34 	 *
       
    35 	 * @param string $info Converted string value of the blog information.
       
    36 	 * @param string $show The type of blog information to retrieve.
       
    37 	 */
       
    38 	return apply_filters( 'get_bloginfo_rss', convert_chars( $info ), $show );
    31 }
    39 }
    32 
    40 
    33 /**
    41 /**
    34  * Display RSS container for the bloginfo function.
    42  * Display RSS container for the bloginfo function.
    35  *
    43  *
    36  * You can retrieve anything that you can using the get_bloginfo() function.
    44  * You can retrieve anything that you can using the get_bloginfo() function.
    37  * Everything will be stripped of tags and characters converted, when the values
    45  * Everything will be stripped of tags and characters converted, when the values
    38  * are retrieved for use in the feeds.
    46  * are retrieved for use in the feeds.
    39  *
    47  *
    40  * @package WordPress
       
    41  * @subpackage Feed
       
    42  * @since 0.71
    48  * @since 0.71
    43  * @uses apply_filters() Calls 'bloginfo_rss' hook with two parameters.
       
    44  * @see get_bloginfo() For the list of possible values to display.
    49  * @see get_bloginfo() For the list of possible values to display.
    45  *
    50  *
    46  * @param string $show See get_bloginfo() for possible values.
    51  * @param string $show See get_bloginfo() for possible values.
    47  */
    52  */
    48 function bloginfo_rss($show = '') {
    53 function bloginfo_rss($show = '') {
    49 	echo apply_filters('bloginfo_rss', get_bloginfo_rss($show), $show);
    54 	/**
       
    55 	 * Filter the bloginfo for display in RSS feeds.
       
    56 	 *
       
    57 	 * @since 2.1.0
       
    58 	 *
       
    59 	 * @see get_bloginfo()
       
    60 	 *
       
    61 	 * @param string $rss_container RSS container for the blog information.
       
    62 	 * @param string $show          The type of blog information to retrieve.
       
    63 	 */
       
    64 	echo apply_filters( 'bloginfo_rss', get_bloginfo_rss( $show ), $show );
    50 }
    65 }
    51 
    66 
    52 /**
    67 /**
    53  * Retrieve the default feed.
    68  * Retrieve the default feed.
    54  *
    69  *
    55  * The default feed is 'rss2', unless a plugin changes it through the
    70  * The default feed is 'rss2', unless a plugin changes it through the
    56  * 'default_feed' filter.
    71  * 'default_feed' filter.
    57  *
    72  *
    58  * @package WordPress
    73  * @since 2.5.0
    59  * @subpackage Feed
       
    60  * @since 2.5
       
    61  * @uses apply_filters() Calls 'default_feed' hook on the default feed string.
       
    62  *
    74  *
    63  * @return string Default feed, or for example 'rss2', 'atom', etc.
    75  * @return string Default feed, or for example 'rss2', 'atom', etc.
    64  */
    76  */
    65 function get_default_feed() {
    77 function get_default_feed() {
    66 	$default_feed = apply_filters('default_feed', 'rss2');
    78 	/**
       
    79 	 * Filter the default feed type.
       
    80 	 *
       
    81 	 * @since 2.5.0
       
    82 	 *
       
    83 	 * @param string $feed_type Type of default feed. Possible values include 'rss2', 'atom'.
       
    84 	 *                          Default 'rss2'.
       
    85 	 */
       
    86 	$default_feed = apply_filters( 'default_feed', 'rss2' );
    67 	return 'rss' == $default_feed ? 'rss2' : $default_feed;
    87 	return 'rss' == $default_feed ? 'rss2' : $default_feed;
    68 }
    88 }
    69 
    89 
    70 /**
    90 /**
    71  * Retrieve the blog title for the feed title.
    91  * Retrieve the blog title for the feed title.
    72  *
    92  *
    73  * @package WordPress
       
    74  * @subpackage Feed
       
    75  * @since 2.2.0
    93  * @since 2.2.0
    76  * @uses apply_filters() Calls 'get_wp_title_rss' hook on title.
    94  *
    77  * @uses wp_title() See function for $sep parameter usage.
    95  * @param string $sep Optional. How to separate the title. See wp_title() for more info.
    78  *
       
    79  * @param string $sep Optional.How to separate the title. See wp_title() for more info.
       
    80  * @return string Error message on failure or blog title on success.
    96  * @return string Error message on failure or blog title on success.
    81  */
    97  */
    82 function get_wp_title_rss($sep = '»') {
    98 function get_wp_title_rss( $sep = '»' ) {
    83 	$title = wp_title($sep, false);
    99 	$title = wp_title( $sep, false );
    84 	if ( is_wp_error( $title ) )
   100 
       
   101 	if ( is_wp_error( $title ) ) {
    85 		return $title->get_error_message();
   102 		return $title->get_error_message();
       
   103 	}
       
   104 
       
   105 	if ( $title && $sep && ' ' !== substr( $title, 0, 1 ) ) {
       
   106 		$title = " $sep " . $title;
       
   107 	}
       
   108 
       
   109 	/**
       
   110 	 * Filter the blog title for use as the feed title.
       
   111 	 *
       
   112 	 * @since 2.2.0
       
   113 	 *
       
   114 	 * @param string $title The current blog title.
       
   115 	 * @param string $sep   Separator used by wp_title().
       
   116 	 */
    86 	$title = apply_filters( 'get_wp_title_rss', $title, $sep );
   117 	$title = apply_filters( 'get_wp_title_rss', $title, $sep );
    87 	return $title;
   118 	return $title;
    88 }
   119 }
    89 
   120 
    90 /**
   121 /**
    91  * Display the blog title for display of the feed title.
   122  * Display the blog title for display of the feed title.
    92  *
   123  *
    93  * @package WordPress
       
    94  * @subpackage Feed
       
    95  * @since 2.2.0
   124  * @since 2.2.0
    96  * @uses apply_filters() Calls 'wp_title_rss' on the blog title.
       
    97  * @see wp_title() $sep parameter usage.
   125  * @see wp_title() $sep parameter usage.
    98  *
   126  *
    99  * @param string $sep Optional.
   127  * @param string $sep Optional.
   100  */
   128  */
   101 function wp_title_rss( $sep = '»' ) {
   129 function wp_title_rss( $sep = '»' ) {
       
   130 	/**
       
   131 	 * Filter the blog title for display of the feed title.
       
   132 	 *
       
   133 	 * @since 2.2.0
       
   134 	 *
       
   135 	 * @see get_wp_title_rss()
       
   136 	 *
       
   137 	 * @param string $wp_title The current blog title.
       
   138 	 * @param string $sep      Separator used by wp_title().
       
   139 	 */
   102 	echo apply_filters( 'wp_title_rss', get_wp_title_rss( $sep ), $sep );
   140 	echo apply_filters( 'wp_title_rss', get_wp_title_rss( $sep ), $sep );
   103 }
   141 }
   104 
   142 
   105 /**
   143 /**
   106  * Retrieve the current post title for the feed.
   144  * Retrieve the current post title for the feed.
   107  *
   145  *
   108  * @package WordPress
       
   109  * @subpackage Feed
       
   110  * @since 2.0.0
   146  * @since 2.0.0
   111  * @uses apply_filters() Calls 'the_title_rss' on the post title.
       
   112  *
   147  *
   113  * @return string Current post title.
   148  * @return string Current post title.
   114  */
   149  */
   115 function get_the_title_rss() {
   150 function get_the_title_rss() {
   116 	$title = get_the_title();
   151 	$title = get_the_title();
   117 	$title = apply_filters('the_title_rss', $title);
   152 	/**
       
   153 	 * Filter the post title for use in a feed.
       
   154 	 *
       
   155 	 * @since 1.2.0
       
   156 	 *
       
   157 	 * @param string $title The current post title.
       
   158 	 */
       
   159 	$title = apply_filters( 'the_title_rss', $title );
   118 	return $title;
   160 	return $title;
   119 }
   161 }
   120 
   162 
   121 /**
   163 /**
   122  * Display the post title in the feed.
   164  * Display the post title in the feed.
   123  *
   165  *
   124  * @package WordPress
       
   125  * @subpackage Feed
       
   126  * @since 0.71
   166  * @since 0.71
   127  * @uses get_the_title_rss() Used to retrieve current post title.
       
   128  */
   167  */
   129 function the_title_rss() {
   168 function the_title_rss() {
   130 	echo get_the_title_rss();
   169 	echo get_the_title_rss();
   131 }
   170 }
   132 
   171 
   133 /**
   172 /**
   134  * Retrieve the post content for feeds.
   173  * Retrieve the post content for feeds.
   135  *
   174  *
   136  * @package WordPress
       
   137  * @subpackage Feed
       
   138  * @since 2.9.0
   175  * @since 2.9.0
   139  * @uses apply_filters() Calls 'the_content_feed' on the content before processing.
       
   140  * @see get_the_content()
   176  * @see get_the_content()
   141  *
   177  *
   142  * @param string $feed_type The type of feed. rss2 | atom | rss | rdf
   178  * @param string $feed_type The type of feed. rss2 | atom | rss | rdf
   143  * @return string The filtered content.
   179  * @return string The filtered content.
   144  */
   180  */
   145 function get_the_content_feed($feed_type = null) {
   181 function get_the_content_feed($feed_type = null) {
   146 	if ( !$feed_type )
   182 	if ( !$feed_type )
   147 		$feed_type = get_default_feed();
   183 		$feed_type = get_default_feed();
   148 
   184 
   149 	$content = apply_filters('the_content', get_the_content());
   185 	/** This filter is documented in wp-includes/post-template.php */
       
   186 	$content = apply_filters( 'the_content', get_the_content() );
   150 	$content = str_replace(']]>', ']]>', $content);
   187 	$content = str_replace(']]>', ']]>', $content);
   151 	return apply_filters('the_content_feed', $content, $feed_type);
   188 	/**
       
   189 	 * Filter the post content for use in feeds.
       
   190 	 *
       
   191 	 * @since 2.9.0
       
   192 	 *
       
   193 	 * @param string $content   The current post content.
       
   194 	 * @param string $feed_type Type of feed. Possible values include 'rss2', 'atom'.
       
   195 	 *                          Default 'rss2'.
       
   196 	 */
       
   197 	return apply_filters( 'the_content_feed', $content, $feed_type );
   152 }
   198 }
   153 
   199 
   154 /**
   200 /**
   155  * Display the post content for feeds.
   201  * Display the post content for feeds.
   156  *
   202  *
   157  * @package WordPress
       
   158  * @subpackage Feed
       
   159  * @since 2.9.0
   203  * @since 2.9.0
   160  * @uses apply_filters() Calls 'the_content_feed' on the content before processing.
       
   161  * @see get_the_content()
       
   162  *
   204  *
   163  * @param string $feed_type The type of feed. rss2 | atom | rss | rdf
   205  * @param string $feed_type The type of feed. rss2 | atom | rss | rdf
   164  */
   206  */
   165 function the_content_feed($feed_type = null) {
   207 function the_content_feed($feed_type = null) {
   166 	echo get_the_content_feed($feed_type);
   208 	echo get_the_content_feed($feed_type);
   167 }
   209 }
   168 
   210 
   169 /**
   211 /**
   170  * Display the post excerpt for the feed.
   212  * Display the post excerpt for the feed.
   171  *
   213  *
   172  * @package WordPress
       
   173  * @subpackage Feed
       
   174  * @since 0.71
   214  * @since 0.71
   175  * @uses apply_filters() Calls 'the_excerpt_rss' hook on the excerpt.
       
   176  */
   215  */
   177 function the_excerpt_rss() {
   216 function the_excerpt_rss() {
   178 	$output = get_the_excerpt();
   217 	$output = get_the_excerpt();
   179 	echo apply_filters('the_excerpt_rss', $output);
   218 	/**
       
   219 	 * Filter the post excerpt for a feed.
       
   220 	 *
       
   221 	 * @since 1.2.0
       
   222 	 *
       
   223 	 * @param string $output The current post excerpt.
       
   224 	 */
       
   225 	echo apply_filters( 'the_excerpt_rss', $output );
   180 }
   226 }
   181 
   227 
   182 /**
   228 /**
   183  * Display the permalink to the post for use in feeds.
   229  * Display the permalink to the post for use in feeds.
   184  *
   230  *
   185  * @package WordPress
       
   186  * @subpackage Feed
       
   187  * @since 2.3.0
   231  * @since 2.3.0
   188  * @uses apply_filters() Call 'the_permalink_rss' on the post permalink
       
   189  */
   232  */
   190 function the_permalink_rss() {
   233 function the_permalink_rss() {
   191 	echo esc_url( apply_filters('the_permalink_rss', get_permalink() ));
   234 	/**
       
   235 	 * Filter the permalink to the post for use in feeds.
       
   236 	 *
       
   237 	 * @since 2.3.0
       
   238 	 *
       
   239 	 * @param string $post_permalink The current post permalink.
       
   240 	 */
       
   241 	echo esc_url( apply_filters( 'the_permalink_rss', get_permalink() ) );
   192 }
   242 }
   193 
   243 
   194 /**
   244 /**
   195  * Outputs the link to the comments for the current post in an xml safe way
   245  * Outputs the link to the comments for the current post in an xml safe way
   196  *
   246  *
   197  * @since 3.0.0
   247  * @since 3.0.0
   198  * @return none
   248  * @return none
   199  */
   249  */
   200 function comments_link_feed() {
   250 function comments_link_feed() {
       
   251 	/**
       
   252 	 * Filter the comments permalink for the current post.
       
   253 	 *
       
   254 	 * @since 3.6.0
       
   255 	 *
       
   256 	 * @param string $comment_permalink The current comment permalink with
       
   257 	 *                                  '#comments' appended.
       
   258 	 */
   201 	echo esc_url( apply_filters( 'comments_link_feed', get_comments_link() ) );
   259 	echo esc_url( apply_filters( 'comments_link_feed', get_comments_link() ) );
   202 }
   260 }
   203 
   261 
   204 /**
   262 /**
   205  * Display the feed GUID for the current comment.
   263  * Display the feed GUID for the current comment.
   206  *
   264  *
   207  * @package WordPress
       
   208  * @subpackage Feed
       
   209  * @since 2.5.0
   265  * @since 2.5.0
   210  *
   266  *
   211  * @param int|object $comment_id Optional comment object or id. Defaults to global comment object.
   267  * @param int|object $comment_id Optional comment object or id. Defaults to global comment object.
   212  */
   268  */
   213 function comment_guid($comment_id = null) {
   269 function comment_guid($comment_id = null) {
   215 }
   271 }
   216 
   272 
   217 /**
   273 /**
   218  * Retrieve the feed GUID for the current comment.
   274  * Retrieve the feed GUID for the current comment.
   219  *
   275  *
   220  * @package WordPress
       
   221  * @subpackage Feed
       
   222  * @since 2.5.0
   276  * @since 2.5.0
   223  *
   277  *
   224  * @param int|object $comment_id Optional comment object or id. Defaults to global comment object.
   278  * @param int|object $comment_id Optional comment object or id. Defaults to global comment object.
   225  * @return bool|string false on failure or guid for comment on success.
   279  * @return false|string false on failure or guid for comment on success.
   226  */
   280  */
   227 function get_comment_guid($comment_id = null) {
   281 function get_comment_guid($comment_id = null) {
   228 	$comment = get_comment($comment_id);
   282 	$comment = get_comment($comment_id);
   229 
   283 
   230 	if ( !is_object($comment) )
   284 	if ( !is_object($comment) )
   237  * Display the link to the comments.
   291  * Display the link to the comments.
   238  *
   292  *
   239  * @since 1.5.0
   293  * @since 1.5.0
   240  */
   294  */
   241 function comment_link() {
   295 function comment_link() {
       
   296 	/**
       
   297 	 * Filter the current comment's permalink.
       
   298 	 *
       
   299 	 * @since 3.6.0
       
   300 	 *
       
   301 	 * @see get_comment_link()
       
   302 	 *
       
   303 	 * @param string $comment_permalink The current comment permalink.
       
   304 	 */
   242 	echo esc_url( apply_filters( 'comment_link', get_comment_link() ) );
   305 	echo esc_url( apply_filters( 'comment_link', get_comment_link() ) );
   243 }
   306 }
   244 
   307 
   245 /**
   308 /**
   246  * Retrieve the current comment author for use in the feeds.
   309  * Retrieve the current comment author for use in the feeds.
   247  *
   310  *
   248  * @package WordPress
       
   249  * @subpackage Feed
       
   250  * @since 2.0.0
   311  * @since 2.0.0
   251  * @uses apply_filters() Calls 'comment_author_rss' hook on comment author.
       
   252  * @uses get_comment_author()
       
   253  *
   312  *
   254  * @return string Comment Author
   313  * @return string Comment Author
   255  */
   314  */
   256 function get_comment_author_rss() {
   315 function get_comment_author_rss() {
   257 	return apply_filters('comment_author_rss', get_comment_author() );
   316 	/**
       
   317 	 * Filter the current comment author for use in a feed.
       
   318 	 *
       
   319 	 * @since 1.5.0
       
   320 	 *
       
   321 	 * @see get_comment_author()
       
   322 	 *
       
   323 	 * @param string $comment_author The current comment author.
       
   324 	 */
       
   325 	return apply_filters( 'comment_author_rss', get_comment_author() );
   258 }
   326 }
   259 
   327 
   260 /**
   328 /**
   261  * Display the current comment author in the feed.
   329  * Display the current comment author in the feed.
   262  *
   330  *
   263  * @package WordPress
       
   264  * @subpackage Feed
       
   265  * @since 1.0.0
   331  * @since 1.0.0
   266  */
   332  */
   267 function comment_author_rss() {
   333 function comment_author_rss() {
   268 	echo get_comment_author_rss();
   334 	echo get_comment_author_rss();
   269 }
   335 }
   270 
   336 
   271 /**
   337 /**
   272  * Display the current comment content for use in the feeds.
   338  * Display the current comment content for use in the feeds.
   273  *
   339  *
   274  * @package WordPress
       
   275  * @subpackage Feed
       
   276  * @since 1.0.0
   340  * @since 1.0.0
   277  * @uses apply_filters() Calls 'comment_text_rss' filter on comment content.
       
   278  * @uses get_comment_text()
       
   279  */
   341  */
   280 function comment_text_rss() {
   342 function comment_text_rss() {
   281 	$comment_text = get_comment_text();
   343 	$comment_text = get_comment_text();
   282 	$comment_text = apply_filters('comment_text_rss', $comment_text);
   344 	/**
       
   345 	 * Filter the current comment content for use in a feed.
       
   346 	 *
       
   347 	 * @since 1.5.0
       
   348 	 *
       
   349 	 * @param string $comment_text The content of the current comment.
       
   350 	 */
       
   351 	$comment_text = apply_filters( 'comment_text_rss', $comment_text );
   283 	echo $comment_text;
   352 	echo $comment_text;
   284 }
   353 }
   285 
   354 
   286 /**
   355 /**
   287  * Retrieve all of the post categories, formatted for use in feeds.
   356  * Retrieve all of the post categories, formatted for use in feeds.
   288  *
   357  *
   289  * All of the categories for the current post in the feed loop, will be
   358  * All of the categories for the current post in the feed loop, will be
   290  * retrieved and have feed markup added, so that they can easily be added to the
   359  * retrieved and have feed markup added, so that they can easily be added to the
   291  * RSS2, Atom, or RSS1 and RSS0.91 RDF feeds.
   360  * RSS2, Atom, or RSS1 and RSS0.91 RDF feeds.
   292  *
   361  *
   293  * @package WordPress
       
   294  * @subpackage Feed
       
   295  * @since 2.1.0
   362  * @since 2.1.0
   296  * @uses apply_filters()
       
   297  *
   363  *
   298  * @param string $type Optional, default is the type returned by get_default_feed().
   364  * @param string $type Optional, default is the type returned by get_default_feed().
   299  * @return string All of the post categories for displaying in the feed.
   365  * @return string All of the post categories for displaying in the feed.
   300  */
   366  */
   301 function get_the_category_rss($type = null) {
   367 function get_the_category_rss($type = null) {
   322 
   388 
   323 	foreach ( $cat_names as $cat_name ) {
   389 	foreach ( $cat_names as $cat_name ) {
   324 		if ( 'rdf' == $type )
   390 		if ( 'rdf' == $type )
   325 			$the_list .= "\t\t<dc:subject><![CDATA[$cat_name]]></dc:subject>\n";
   391 			$the_list .= "\t\t<dc:subject><![CDATA[$cat_name]]></dc:subject>\n";
   326 		elseif ( 'atom' == $type )
   392 		elseif ( 'atom' == $type )
   327 			$the_list .= sprintf( '<category scheme="%1$s" term="%2$s" />', esc_attr( apply_filters( 'get_bloginfo_rss', get_bloginfo( 'url' ) ) ), esc_attr( $cat_name ) );
   393 			$the_list .= sprintf( '<category scheme="%1$s" term="%2$s" />', esc_attr( get_bloginfo_rss( 'url' ) ), esc_attr( $cat_name ) );
   328 		else
   394 		else
   329 			$the_list .= "\t\t<category><![CDATA[" . @html_entity_decode( $cat_name, ENT_COMPAT, get_option('blog_charset') ) . "]]></category>\n";
   395 			$the_list .= "\t\t<category><![CDATA[" . @html_entity_decode( $cat_name, ENT_COMPAT, get_option('blog_charset') ) . "]]></category>\n";
   330 	}
   396 	}
   331 
   397 
   332 	return apply_filters('the_category_rss', $the_list, $type);
   398 	/**
       
   399 	 * Filter all of the post categories for display in a feed.
       
   400 	 *
       
   401 	 * @since 1.2.0
       
   402 	 *
       
   403 	 * @param string $the_list All of the RSS post categories.
       
   404 	 * @param string $type     Type of feed. Possible values include 'rss2', 'atom'.
       
   405 	 *                         Default 'rss2'.
       
   406 	 */
       
   407 	return apply_filters( 'the_category_rss', $the_list, $type );
   333 }
   408 }
   334 
   409 
   335 /**
   410 /**
   336  * Display the post categories in the feed.
   411  * Display the post categories in the feed.
   337  *
   412  *
   338  * @package WordPress
       
   339  * @subpackage Feed
       
   340  * @since 0.71
   413  * @since 0.71
   341  * @see get_the_category_rss() For better explanation.
   414  * @see get_the_category_rss() For better explanation.
   342  *
   415  *
   343  * @param string $type Optional, default is the type returned by get_default_feed().
   416  * @param string $type Optional, default is the type returned by get_default_feed().
   344  */
   417  */
   349 /**
   422 /**
   350  * Display the HTML type based on the blog setting.
   423  * Display the HTML type based on the blog setting.
   351  *
   424  *
   352  * The two possible values are either 'xhtml' or 'html'.
   425  * The two possible values are either 'xhtml' or 'html'.
   353  *
   426  *
   354  * @package WordPress
       
   355  * @subpackage Feed
       
   356  * @since 2.2.0
   427  * @since 2.2.0
   357  */
   428  */
   358 function html_type_rss() {
   429 function html_type_rss() {
   359 	$type = get_bloginfo('html_type');
   430 	$type = get_bloginfo('html_type');
   360 	if (strpos($type, 'xhtml') !== false)
   431 	if (strpos($type, 'xhtml') !== false)
   374  * Also uses the function get_post_custom() to get the post's 'enclosure'
   445  * Also uses the function get_post_custom() to get the post's 'enclosure'
   375  * metadata field and parses the value to display the enclosure(s). The
   446  * metadata field and parses the value to display the enclosure(s). The
   376  * enclosure(s) consist of enclosure HTML tag(s) with a URI and other
   447  * enclosure(s) consist of enclosure HTML tag(s) with a URI and other
   377  * attributes.
   448  * attributes.
   378  *
   449  *
   379  * @package WordPress
       
   380  * @subpackage Template
       
   381  * @since 1.5.0
   450  * @since 1.5.0
   382  * @uses apply_filters() Calls 'rss_enclosure' hook on rss enclosure.
       
   383  * @uses get_post_custom() To get the current post enclosure metadata.
       
   384  */
   451  */
   385 function rss_enclosure() {
   452 function rss_enclosure() {
   386 	if ( post_password_required() )
   453 	if ( post_password_required() )
   387 		return;
   454 		return;
   388 
   455 
   393 
   460 
   394 				// only get the first element, e.g. audio/mpeg from 'audio/mpeg mpga mp2 mp3'
   461 				// only get the first element, e.g. audio/mpeg from 'audio/mpeg mpga mp2 mp3'
   395 				$t = preg_split('/[ \t]/', trim($enclosure[2]) );
   462 				$t = preg_split('/[ \t]/', trim($enclosure[2]) );
   396 				$type = $t[0];
   463 				$type = $t[0];
   397 
   464 
   398 				echo apply_filters('rss_enclosure', '<enclosure url="' . trim(htmlspecialchars($enclosure[0])) . '" length="' . trim($enclosure[1]) . '" type="' . $type . '" />' . "\n");
   465 				/**
       
   466 				 * Filter the RSS enclosure HTML link tag for the current post.
       
   467 				 *
       
   468 				 * @since 2.2.0
       
   469 				 *
       
   470 				 * @param string $html_link_tag The HTML link tag with a URI and other attributes.
       
   471 				 */
       
   472 				echo apply_filters( 'rss_enclosure', '<enclosure url="' . trim( htmlspecialchars( $enclosure[0] ) ) . '" length="' . trim( $enclosure[1] ) . '" type="' . $type . '" />' . "\n" );
   399 			}
   473 			}
   400 		}
   474 		}
   401 	}
   475 	}
   402 }
   476 }
   403 
   477 
   410  *
   484  *
   411  * Also uses the function get_post_custom() to get the post's 'enclosure'
   485  * Also uses the function get_post_custom() to get the post's 'enclosure'
   412  * metadata field and parses the value to display the enclosure(s). The
   486  * metadata field and parses the value to display the enclosure(s). The
   413  * enclosure(s) consist of link HTML tag(s) with a URI and other attributes.
   487  * enclosure(s) consist of link HTML tag(s) with a URI and other attributes.
   414  *
   488  *
   415  * @package WordPress
       
   416  * @subpackage Template
       
   417  * @since 2.2.0
   489  * @since 2.2.0
   418  * @uses apply_filters() Calls 'atom_enclosure' hook on atom enclosure.
       
   419  * @uses get_post_custom() To get the current post enclosure metadata.
       
   420  */
   490  */
   421 function atom_enclosure() {
   491 function atom_enclosure() {
   422 	if ( post_password_required() )
   492 	if ( post_password_required() )
   423 		return;
   493 		return;
   424 
   494 
   425 	foreach ( (array) get_post_custom() as $key => $val ) {
   495 	foreach ( (array) get_post_custom() as $key => $val ) {
   426 		if ($key == 'enclosure') {
   496 		if ($key == 'enclosure') {
   427 			foreach ( (array) $val as $enc ) {
   497 			foreach ( (array) $val as $enc ) {
   428 				$enclosure = explode("\n", $enc);
   498 				$enclosure = explode("\n", $enc);
   429 				echo apply_filters('atom_enclosure', '<link href="' . trim(htmlspecialchars($enclosure[0])) . '" rel="enclosure" length="' . trim($enclosure[1]) . '" type="' . trim($enclosure[2]) . '" />' . "\n");
   499 				/**
       
   500 				 * Filter the atom enclosure HTML link tag for the current post.
       
   501 				 *
       
   502 				 * @since 2.2.0
       
   503 				 *
       
   504 				 * @param string $html_link_tag The HTML link tag with a URI and other attributes.
       
   505 				 */
       
   506 				echo apply_filters( 'atom_enclosure', '<link href="' . trim( htmlspecialchars( $enclosure[0] ) ) . '" rel="enclosure" length="' . trim( $enclosure[1] ) . '" type="' . trim( $enclosure[2] ) . '" />' . "\n" );
   430 			}
   507 			}
   431 		}
   508 		}
   432 	}
   509 	}
   433 }
   510 }
   434 
   511 
   442  *
   519  *
   443  * Container div tags are added to xhtml values, per section 3.1.1.3.
   520  * Container div tags are added to xhtml values, per section 3.1.1.3.
   444  *
   521  *
   445  * @link http://www.atomenabled.org/developers/syndication/atom-format-spec.php#rfc.section.3.1
   522  * @link http://www.atomenabled.org/developers/syndication/atom-format-spec.php#rfc.section.3.1
   446  *
   523  *
   447  * @package WordPress
   524  * @since 2.5.0
   448  * @subpackage Feed
       
   449  * @since 2.5
       
   450  *
   525  *
   451  * @param string $data Input string
   526  * @param string $data Input string
   452  * @return array array(type, value)
   527  * @return array array(type, value)
   453  */
   528  */
   454 function prep_atom_text_construct($data) {
   529 function prep_atom_text_construct($data) {
   480 /**
   555 /**
   481  * Display the link for the currently displayed feed in a XSS safe way.
   556  * Display the link for the currently displayed feed in a XSS safe way.
   482  *
   557  *
   483  * Generate a correct link for the atom:self element.
   558  * Generate a correct link for the atom:self element.
   484  *
   559  *
   485  * @package WordPress
   560  * @since 2.5.0
   486  * @subpackage Feed
       
   487  * @since 2.5
       
   488  */
   561  */
   489 function self_link() {
   562 function self_link() {
   490 	$host = @parse_url(home_url());
   563 	$host = @parse_url(home_url());
       
   564 	/**
       
   565 	 * Filter the current feed URL.
       
   566 	 *
       
   567 	 * @since 3.6.0
       
   568 	 *
       
   569 	 * @see set_url_scheme()
       
   570 	 * @see wp_unslash()
       
   571 	 *
       
   572 	 * @param string $feed_link The link for the feed with set URL scheme.
       
   573 	 */
   491 	echo esc_url( apply_filters( 'self_link', set_url_scheme( 'http://' . $host['host'] . wp_unslash( $_SERVER['REQUEST_URI'] ) ) ) );
   574 	echo esc_url( apply_filters( 'self_link', set_url_scheme( 'http://' . $host['host'] . wp_unslash( $_SERVER['REQUEST_URI'] ) ) ) );
   492 }
   575 }
   493 
   576 
   494 /**
   577 /**
   495  * Return the content type for specified feed type.
   578  * Return the content type for specified feed type.
   496  *
   579  *
   497  * @package WordPress
       
   498  * @subpackage Feed
       
   499  * @since 2.8.0
   580  * @since 2.8.0
   500  */
   581  */
   501 function feed_content_type( $type = '' ) {
   582 function feed_content_type( $type = '' ) {
   502 	if ( empty($type) )
   583 	if ( empty($type) )
   503 		$type = get_default_feed();
   584 		$type = get_default_feed();
   510 		'rdf'  => 'application/rdf+xml'
   591 		'rdf'  => 'application/rdf+xml'
   511 	);
   592 	);
   512 
   593 
   513 	$content_type = ( !empty($types[$type]) ) ? $types[$type] : 'application/octet-stream';
   594 	$content_type = ( !empty($types[$type]) ) ? $types[$type] : 'application/octet-stream';
   514 
   595 
       
   596 	/**
       
   597 	 * Filter the content type for a specific feed type.
       
   598 	 *
       
   599 	 * @since 2.8.0
       
   600 	 *
       
   601 	 * @param string $content_type Content type indicating the type of data that a feed contains.
       
   602 	 * @param string $type         Type of feed. Possible values include 'rss2', 'atom'.
       
   603 	 *                             Default 'rss2'.
       
   604 	 */
   515 	return apply_filters( 'feed_content_type', $content_type, $type );
   605 	return apply_filters( 'feed_content_type', $content_type, $type );
   516 }
   606 }
   517 
   607 
   518 /**
   608 /**
   519  * Build SimplePie object based on RSS or Atom feed from URL.
   609  * Build SimplePie object based on RSS or Atom feed from URL.
   520  *
   610  *
   521  * @since 2.8
   611  * @since 2.8.0
   522  *
   612  *
   523  * @param mixed $url URL of feed to retrieve. If an array of URLs, the feeds are merged
   613  * @param mixed $url URL of feed to retrieve. If an array of URLs, the feeds are merged
   524  * using SimplePie's multifeed feature.
   614  * using SimplePie's multifeed feature.
   525  * See also {@link ​http://simplepie.org/wiki/faq/typical_multifeed_gotchas}
   615  * See also {@link ​http://simplepie.org/wiki/faq/typical_multifeed_gotchas}
   526  *
   616  *
   538 
   628 
   539 	$feed->set_cache_class( 'WP_Feed_Cache' );
   629 	$feed->set_cache_class( 'WP_Feed_Cache' );
   540 	$feed->set_file_class( 'WP_SimplePie_File' );
   630 	$feed->set_file_class( 'WP_SimplePie_File' );
   541 
   631 
   542 	$feed->set_feed_url( $url );
   632 	$feed->set_feed_url( $url );
       
   633 	/** This filter is documented in wp-includes/class-feed.php */
   543 	$feed->set_cache_duration( apply_filters( 'wp_feed_cache_transient_lifetime', 12 * HOUR_IN_SECONDS, $url ) );
   634 	$feed->set_cache_duration( apply_filters( 'wp_feed_cache_transient_lifetime', 12 * HOUR_IN_SECONDS, $url ) );
       
   635 	/**
       
   636 	 * Fires just before processing the SimplePie feed object.
       
   637 	 *
       
   638 	 * @since 3.0.0
       
   639 	 *
       
   640 	 * @param object &$feed SimplePie feed object, passed by reference.
       
   641 	 * @param mixed  $url   URL of feed to retrieve. If an array of URLs, the feeds are merged.
       
   642 	 */
   544 	do_action_ref_array( 'wp_feed_options', array( &$feed, $url ) );
   643 	do_action_ref_array( 'wp_feed_options', array( &$feed, $url ) );
   545 	$feed->init();
   644 	$feed->init();
   546 	$feed->handle_content_type();
   645 	$feed->handle_content_type();
   547 
   646 
   548 	if ( $feed->error() )
   647 	if ( $feed->error() )