web/wp-includes/feed.php
branchwordpress
changeset 132 4d4862461b8d
parent 109 03b0d1493584
equal deleted inserted replaced
131:a4642baaf829 132:4d4862461b8d
   128 function the_title_rss() {
   128 function the_title_rss() {
   129 	echo get_the_title_rss();
   129 	echo get_the_title_rss();
   130 }
   130 }
   131 
   131 
   132 /**
   132 /**
   133  * Display the post content for the feed.
   133  * Retrieve the post content for feeds.
   134  *
   134  *
   135  * For encoding the html or the $encode_html parameter, there are three possible
   135  * @package WordPress
   136  * values. '0' will make urls footnotes and use make_url_footnote(). '1' will
   136  * @subpackage Feed
   137  * encode special characters and automatically display all of the content. The
   137  * @since 2.9.0
   138  * value of '2' will strip all HTML tags from the content.
   138  * @uses apply_filters() Calls 'the_content_feed' on the content before processing.
   139  *
   139  * @see get_the_content()
   140  * Also note that you cannot set the amount of words and not set the html
   140  *
   141  * encoding. If that is the case, then the html encoding will default to 2,
   141  * @param string $feed_type The type of feed. rss2 | atom | rss | rdf
   142  * which will strip all HTML tags.
   142  */
   143  *
   143 function get_the_content_feed($feed_type = null) {
   144  * To restrict the amount of words of the content, you can use the cut
   144 	if ( !$feed_type )
   145  * parameter. If the content is less than the amount, then there won't be any
   145 		$feed_type = get_default_feed();
   146  * dots added to the end. If there is content left over, then dots will be added
   146 
   147  * and the rest of the content will be removed.
   147 	$content = apply_filters('the_content', get_the_content());
   148  *
       
   149  * @package WordPress
       
   150  * @subpackage Feed
       
   151  * @since 0.71
       
   152  * @uses apply_filters() Calls 'the_content_rss' on the content before processing.
       
   153  * @see get_the_content() For the $more_link_text, $stripteaser, and $more_file
       
   154  *		parameters.
       
   155  *
       
   156  * @param string $more_link_text Optional. Text to display when more content is available but not displayed.
       
   157  * @param int|bool $stripteaser Optional. Default is 0.
       
   158  * @param string $more_file Optional.
       
   159  * @param int $cut Optional. Amount of words to keep for the content.
       
   160  * @param int $encode_html Optional. How to encode the content.
       
   161  */
       
   162 function the_content_rss($more_link_text='(more...)', $stripteaser=0, $more_file='', $cut = 0, $encode_html = 0) {
       
   163 	$content = get_the_content($more_link_text, $stripteaser, $more_file);
       
   164 	$content = apply_filters('the_content_rss', $content);
       
   165 	if ( $cut && !$encode_html )
       
   166 		$encode_html = 2;
       
   167 	if ( 1== $encode_html ) {
       
   168 		$content = esc_html($content);
       
   169 		$cut = 0;
       
   170 	} elseif ( 0 == $encode_html ) {
       
   171 		$content = make_url_footnote($content);
       
   172 	} elseif ( 2 == $encode_html ) {
       
   173 		$content = strip_tags($content);
       
   174 	}
       
   175 	if ( $cut ) {
       
   176 		$blah = explode(' ', $content);
       
   177 		if ( count($blah) > $cut ) {
       
   178 			$k = $cut;
       
   179 			$use_dotdotdot = 1;
       
   180 		} else {
       
   181 			$k = count($blah);
       
   182 			$use_dotdotdot = 0;
       
   183 		}
       
   184 
       
   185 		/** @todo Check performance, might be faster to use array slice instead. */
       
   186 		for ( $i=0; $i<$k; $i++ )
       
   187 			$excerpt .= $blah[$i].' ';
       
   188 		$excerpt .= ($use_dotdotdot) ? '...' : '';
       
   189 		$content = $excerpt;
       
   190 	}
       
   191 	$content = str_replace(']]>', ']]&gt;', $content);
   148 	$content = str_replace(']]>', ']]&gt;', $content);
   192 	echo $content;
   149 	return apply_filters('the_content_feed', $content, $feed_type);
       
   150 }
       
   151 
       
   152 /**
       
   153  * Display the post content for feeds.
       
   154  *
       
   155  * @package WordPress
       
   156  * @subpackage Feed
       
   157  * @since 2.9.0
       
   158  * @uses apply_filters() Calls 'the_content_feed' on the content before processing.
       
   159  * @see get_the_content()
       
   160  *
       
   161  * @param string $feed_type The type of feed. rss2 | atom | rss | rdf
       
   162  */
       
   163 function the_content_feed($feed_type = null) {
       
   164 	echo get_the_content_feed();
   193 }
   165 }
   194 
   166 
   195 /**
   167 /**
   196  * Display the post excerpt for the feed.
   168  * Display the post excerpt for the feed.
   197  *
   169  *
   309  * @package WordPress
   281  * @package WordPress
   310  * @subpackage Feed
   282  * @subpackage Feed
   311  * @since 2.1.0
   283  * @since 2.1.0
   312  * @uses apply_filters()
   284  * @uses apply_filters()
   313  *
   285  *
   314  * @param string $type Optional, default is 'rss'. Either 'rss', 'atom', or 'rdf'.
   286  * @param string $type Optional, default is the type returned by get_default_feed().
   315  * @return string All of the post categories for displaying in the feed.
   287  * @return string All of the post categories for displaying in the feed.
   316  */
   288  */
   317 function get_the_category_rss($type = 'rss') {
   289 function get_the_category_rss($type = null) {
       
   290 	if ( empty($type) )
       
   291 		$type = get_default_feed();
   318 	$categories = get_the_category();
   292 	$categories = get_the_category();
   319 	$tags = get_the_tags();
   293 	$tags = get_the_tags();
   320 	$the_list = '';
   294 	$the_list = '';
   321 	$cat_names = array();
   295 	$cat_names = array();
   322 
   296 
   352  * @package WordPress
   326  * @package WordPress
   353  * @subpackage Feed
   327  * @subpackage Feed
   354  * @since 0.71
   328  * @since 0.71
   355  * @see get_the_category_rss() For better explanation.
   329  * @see get_the_category_rss() For better explanation.
   356  *
   330  *
   357  * @param string $type Optional, default is 'rss'. Either 'rss', 'atom', or 'rdf'.
   331  * @param string $type Optional, default is the type returned by get_default_feed().
   358  */
   332  */
   359 function the_category_rss($type = 'rss') {
   333 function the_category_rss($type = null) {
   360 	echo get_the_category_rss($type);
   334 	echo get_the_category_rss($type);
   361 }
   335 }
   362 
   336 
   363 /**
   337 /**
   364  * Display the HTML type based on the blog setting.
   338  * Display the HTML type based on the blog setting.