Changeset 8246
- Timestamp:
- 07/03/2008 03:23:22 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/feed.php
r7244 r8246 1 1 <?php 2 2 /** 3 * WordPress Feed API 4 * 5 * Many of the functions used in here belong in The Loop, or The Loop for the 6 * Feeds. 7 * 8 * @package WordPress 9 * @subpackage Feed 10 */ 11 12 /** 13 * RSS container for the bloginfo function. 14 * 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 17 * are retrieved for use in the feeds. 18 * 19 * @package WordPress 20 * @subpackage Feed 21 * @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. 24 * 25 * @param string $show See get_bloginfo() for possible values. 26 * @return string 27 */ 3 28 function get_bloginfo_rss($show = '') { 4 29 $info = strip_tags(get_bloginfo($show)); … … 6 31 } 7 32 33 /** 34 * Display RSS container for the bloginfo function. 35 * 36 * 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 38 * are retrieved for use in the feeds. 39 * 40 * @package WordPress 41 * @subpackage Feed 42 * @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. 45 * 46 * @param string $show See get_bloginfo() for possible values. 47 */ 8 48 function bloginfo_rss($show = '') { 9 49 echo apply_filters('bloginfo_rss', get_bloginfo_rss($show), $show); 10 50 } 11 51 52 /** 53 * Retrieve the default feed. 54 * 55 * The default feed is 'rss2', unless a plugin changes it through the 56 * 'default_feed' filter. 57 * 58 * @package WordPress 59 * @subpackage Feed 60 * @since 2.5 61 * @uses apply_filters() Calls 'default_feed' hook on the default feed string. 62 * 63 * @return string Default feed, or for example 'rss2', 'atom', etc. 64 */ 12 65 function get_default_feed() { 13 66 return apply_filters('default_feed', 'rss2'); 14 67 } 15 68 69 /** 70 * Retrieve the blog title for the feed title. 71 * 72 * @package WordPress 73 * @subpackage Feed 74 * @since 2.2.0 75 * @uses apply_filters() Calls 'get_wp_title_rss' hook on title. 76 * @uses wp_title() See function for $sep parameter usage. 77 * 78 * @param string $sep Optional.How to separate the title. See wp_title() for more info. 79 * @return string Error message on failure or blog title on success. 80 */ 16 81 function get_wp_title_rss($sep = '»') { 17 82 $title = wp_title($sep, false); … … 22 87 } 23 88 89 /** 90 * Display the blog title for display of the feed title. 91 * 92 * @package WordPress 93 * @subpackage Feed 94 * @since 2.2.0 95 * @uses apply_filters() Calls 'wp_title_rss' on the blog title. 96 * @see wp_title() $sep parameter usage. 97 * 98 * @param string $sep Optional. 99 */ 24 100 function wp_title_rss($sep = '»') { 25 101 echo apply_filters('wp_title_rss', get_wp_title_rss($sep)); 26 102 } 27 103 104 /** 105 * Retrieve the current post title for the feed. 106 * 107 * @package WordPress 108 * @subpackage Feed 109 * @since 2.0.0 110 * @uses apply_filters() Calls 'the_title_rss' on the post title. 111 * 112 * @return string Current post title. 113 */ 28 114 function get_the_title_rss() { 29 115 $title = get_the_title(); … … 32 118 } 33 119 34 120 /** 121 * Display the post title in the feed. 122 * 123 * @package WordPress 124 * @subpackage Feed 125 * @since 0.71 126 * @uses get_the_title_rss() Used to retrieve current post title. 127 */ 35 128 function the_title_rss() { 36 129 echo get_the_title_rss(); 37 130 } 38 131 39 132 /** 133 * Display the post content for the feed. 134 * 135 * For encoding the html or the $encode_html parameter, there are three possible 136 * values. '0' will make urls footnotes and use make_url_footnote(). '1' will 137 * encode special characters and automatically display all of the content. The 138 * value of '2' will strip all HTML tags from the content. 139 * 140 * Also note that you cannot set the amount of words and not set the html 141 * encoding. If that is the case, then the html encoding will default to 2, 142 * which will strip all HTML tags. 143 * 144 * To restrict the amount of words of the content, you can use the cut 145 * parameter. If the content is less than the amount, then there won't be any 146 * dots added to the end. If there is content left over, then dots will be added 147 * and the rest of the content will be removed. 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 */ 40 162 function the_content_rss($more_link_text='(more...)', $stripteaser=0, $more_file='', $cut = 0, $encode_html = 0) { 41 163 $content = get_the_content($more_link_text, $stripteaser, $more_file); … … 60 182 $use_dotdotdot = 0; 61 183 } 184 185 /** @todo Check performance, might be faster to use array slice instead. */ 62 186 for ( $i=0; $i<$k; $i++ ) 63 187 $excerpt .= $blah[$i].' '; … … 69 193 } 70 194 71 195 /** 196 * Display the post excerpt for the feed. 197 * 198 * @package WordPress 199 * @subpackage Feed 200 * @since 0.71 201 * @uses apply_filters() Calls 'the_excerpt_rss' hook on the excerpt. 202 */ 72 203 function the_excerpt_rss() { 73 204 $output = get_the_excerpt(); … … 75 206 } 76 207 208 /** 209 * Display the permalink to the post for use in feeds. 210 * 211 * @package WordPress 212 * @subpackage Feed 213 * @since 2.3.0 214 * @uses apply_filters() Call 'the_permalink_rss' on the post permalink 215 */ 77 216 function the_permalink_rss() { 78 217 echo apply_filters('the_permalink_rss', get_permalink()); 79 80 } 81 218 } 219 220 /** 221 * Display the feed GUID for the current comment. 222 * 223 * @package WordPress 224 * @subpackage Feed 225 * @since unknown 226 */ 82 227 function comment_guid() { 83 228 echo get_comment_guid(); 84 229 } 85 230 231 /** 232 * Retrieve the feed GUID for the current comment. 233 * 234 * @package WordPress 235 * @subpackage Feed 236 * @since unknown 237 * 238 * @return bool|string false on failure or guid for comment on success. 239 */ 86 240 function get_comment_guid() { 87 241 global $comment; … … 93 247 } 94 248 249 /** 250 * Display the link to the comments. 251 * 252 * @since 1.5.0 253 */ 95 254 function comment_link() { 96 255 echo get_comment_link(); 97 256 } 98 257 258 /** 259 * Retrieve the current comment author for use in the feeds. 260 * 261 * @package WordPress 262 * @subpackage Feed 263 * @since 2.0.0 264 * @uses apply_filters() Calls 'comment_author_rss' hook on comment author. 265 * @uses get_comment_author() 266 * 267 * @return string Comment Author 268 */ 99 269 function get_comment_author_rss() { 100 270 return apply_filters('comment_author_rss', get_comment_author() ); 101 271 } 102 272 273 /** 274 * Display the current comment author in the feed. 275 * 276 * @package WordPress 277 * @subpackage Feed 278 * @since 1.0.0 279 */ 103 280 function comment_author_rss() { 104 281 echo get_comment_author_rss(); 105 282 } 106 283 284 /** 285 * Display the current comment content for use in the feeds. 286 * 287 * @package WordPress 288 * @subpackage Feed 289 * @since 1.0.0 290 * @uses apply_filters() Calls 'comment_text_rss' filter on comment content. 291 * @uses get_comment_text() 292 */ 107 293 function comment_text_rss() { 108 294 $comment_text = get_comment_text(); … … 111 297 } 112 298 299 /** 300 * Retrieve all of the post categories, formatted for use in feeds. 301 * 302 * All of the categories for the current post in the feed loop, will be 303 * retrieved and have feed markup added, so that they can easily be added to the 304 * RSS2, Atom, or RSS1 and RSS0.91 RDF feeds. 305 * 306 * @package WordPress 307 * @subpackage Feed 308 * @since 2.1.0 309 * @uses apply_filters() 310 * 311 * @param string $type Optional, default is 'rss'. Either 'rss', 'atom', or 'rdf'. 312 * @return string All of the post categories for displaying in the feed. 313 */ 113 314 function get_the_category_rss($type = 'rss') { 114 315 $categories = get_the_category(); … … 143 344 } 144 345 346 /** 347 * Display the post categories in the feed. 348 * 349 * @package WordPress 350 * @subpackage Feed 351 * @since 0.71 352 * @see get_the_category_rss() For better explanation. 353 * 354 * @param string $type Optional, default is 'rss'. Either 'rss', 'atom', or 'rdf'. 355 */ 145 356 function the_category_rss($type = 'rss') { 146 357 echo get_the_category_rss($type); 147 358 } 148 359 360 /** 361 * Display the HTML type based on the blog setting. 362 * 363 * The two possible values are either 'xhtml' or 'html'. 364 * 365 * @package WordPress 366 * @subpackage Feed 367 * @since 2.2.0 368 */ 149 369 function html_type_rss() { 150 370 $type = get_bloginfo('html_type'); … … 156 376 } 157 377 158 378 /** 379 * Display the rss enclosure for the current post. 380 * 381 * Uses the global $post to check whether the post requires a password and if 382 * the user has the password for the post. If not then it will return before 383 * displaying. 384 * 385 * Also uses the function get_post_custom() to get the post's 'enclosure' 386 * metadata field and parses the value to display the enclosure(s). The 387 * enclosure(s) consist of enclosure HTML tag(s) with a URI and other 388 * attributes. 389 * 390 * @package WordPress 391 * @subpackage Template 392 * @since 1.5.0 393 * @uses apply_filters() Calls 'rss_enclosure' hook on rss enclosure. 394 * @uses get_post_custom() To get the current post enclosure metadata. 395 */ 159 396 function rss_enclosure() { 160 397 global $post; … … 172 409 } 173 410 411 /** 412 * Display the atom enclosure for the current post. 413 * 414 * Uses the global $post to check whether the post requires a password and if 415 * the user has the password for the post. If not then it will return before 416 * displaying. 417 * 418 * Also uses the function get_post_custom() to get the post's 'enclosure' 419 * metadata field and parses the value to display the enclosure(s). The 420 * enclosure(s) consist of link HTML tag(s) with a URI and other attributes. 421 * 422 * @package WordPress 423 * @subpackage Template 424 * @since 2.2.0 425 * @uses apply_filters() Calls 'atom_enclosure' hook on atom enclosure. 426 * @uses get_post_custom() To get the current post enclosure metadata. 427 */ 174 428 function atom_enclosure() { 175 429 global $post; … … 188 442 189 443 /** 190 * prep_atom_text_construct() - Determine the type of a given string of data444 * Determine the type of a string of data with the data formatted. 191 445 * 192 446 * Tell whether the type is text, html, or xhtml, per RFC 4287 section 3.1. … … 203 457 * @since 2.5 204 458 * 205 * @param string $data input string206 * @return array $resultarray(type, value)459 * @param string $data Input string 460 * @return array array(type, value) 207 461 */ 208 462 function prep_atom_text_construct($data) { … … 233 487 234 488 /** 235 * self_link() - Generate a correct link for the atom:self elemet236 * 237 * Echo the link for the currently displayed feed in a XSS safe way.489 * Display the link for the currently displayed feed in a XSS safe way. 490 * 491 * Generate a correct link for the atom:self element. 238 492 * 239 493 * @package WordPress 240 494 * @subpackage Feed 241 495 * @since 2.5 242 *243 496 */ 244 497 function self_link() {
Note: See TracChangeset
for help on using the changeset viewer.