raw
mp-wp_genesis           1 <?php
mp-wp_genesis 2 /**
mp-wp_genesis 3 * WordPress Feed API
mp-wp_genesis 4 *
mp-wp_genesis 5 * Many of the functions used in here belong in The Loop, or The Loop for the
mp-wp_genesis 6 * Feeds.
mp-wp_genesis 7 *
mp-wp_genesis 8 * @package WordPress
mp-wp_genesis 9 * @subpackage Feed
mp-wp_genesis 10 */
mp-wp_genesis 11
mp-wp_genesis 12 /**
mp-wp_genesis 13 * RSS container for the bloginfo function.
mp-wp_genesis 14 *
mp-wp_genesis 15 * You can retrieve anything that you can using the get_bloginfo() function.
mp-wp_genesis 16 * Everything will be stripped of tags and characters converted, when the values
mp-wp_genesis 17 * are retrieved for use in the feeds.
mp-wp_genesis 18 *
mp-wp_genesis 19 * @package WordPress
mp-wp_genesis 20 * @subpackage Feed
mp-wp_genesis 21 * @since 1.5.1
mp-wp_genesis 22 * @uses apply_filters() Calls 'get_bloginfo_rss' hook with two parameters.
mp-wp_genesis 23 * @see get_bloginfo() For the list of possible values to display.
mp-wp_genesis 24 *
mp-wp_genesis 25 * @param string $show See get_bloginfo() for possible values.
mp-wp_genesis 26 * @return string
mp-wp_genesis 27 */
mp-wp_genesis 28 function get_bloginfo_rss($show = '') {
mp-wp_genesis 29 $info = strip_tags(get_bloginfo($show));
mp-wp_genesis 30 return apply_filters('get_bloginfo_rss', convert_chars($info), $show);
mp-wp_genesis 31 }
mp-wp_genesis 32
mp-wp_genesis 33 /**
mp-wp_genesis 34 * Display RSS container for the bloginfo function.
mp-wp_genesis 35 *
mp-wp_genesis 36 * You can retrieve anything that you can using the get_bloginfo() function.
mp-wp_genesis 37 * Everything will be stripped of tags and characters converted, when the values
mp-wp_genesis 38 * are retrieved for use in the feeds.
mp-wp_genesis 39 *
mp-wp_genesis 40 * @package WordPress
mp-wp_genesis 41 * @subpackage Feed
mp-wp_genesis 42 * @since 0.71
mp-wp_genesis 43 * @uses apply_filters() Calls 'bloginfo_rss' hook with two parameters.
mp-wp_genesis 44 * @see get_bloginfo() For the list of possible values to display.
mp-wp_genesis 45 *
mp-wp_genesis 46 * @param string $show See get_bloginfo() for possible values.
mp-wp_genesis 47 */
mp-wp_genesis 48 function bloginfo_rss($show = '') {
mp-wp_genesis 49 echo apply_filters('bloginfo_rss', get_bloginfo_rss($show), $show);
mp-wp_genesis 50 }
mp-wp_genesis 51
mp-wp_genesis 52 /**
mp-wp_genesis 53 * Retrieve the default feed.
mp-wp_genesis 54 *
mp-wp_genesis 55 * The default feed is 'rss2', unless a plugin changes it through the
mp-wp_genesis 56 * 'default_feed' filter.
mp-wp_genesis 57 *
mp-wp_genesis 58 * @package WordPress
mp-wp_genesis 59 * @subpackage Feed
mp-wp_genesis 60 * @since 2.5
mp-wp_genesis 61 * @uses apply_filters() Calls 'default_feed' hook on the default feed string.
mp-wp_genesis 62 *
mp-wp_genesis 63 * @return string Default feed, or for example 'rss2', 'atom', etc.
mp-wp_genesis 64 */
mp-wp_genesis 65 function get_default_feed() {
mp-wp_genesis 66 return apply_filters('default_feed', 'rss2');
mp-wp_genesis 67 }
mp-wp_genesis 68
mp-wp_genesis 69 /**
mp-wp_genesis 70 * Retrieve the blog title for the feed title.
mp-wp_genesis 71 *
mp-wp_genesis 72 * @package WordPress
mp-wp_genesis 73 * @subpackage Feed
mp-wp_genesis 74 * @since 2.2.0
mp-wp_genesis 75 * @uses apply_filters() Calls 'get_wp_title_rss' hook on title.
mp-wp_genesis 76 * @uses wp_title() See function for $sep parameter usage.
mp-wp_genesis 77 *
mp-wp_genesis 78 * @param string $sep Optional.How to separate the title. See wp_title() for more info.
mp-wp_genesis 79 * @return string Error message on failure or blog title on success.
mp-wp_genesis 80 */
mp-wp_genesis 81 function get_wp_title_rss($sep = '&#187;') {
mp-wp_genesis 82 $title = wp_title($sep, false);
mp-wp_genesis 83 if ( is_wp_error( $title ) )
mp-wp_genesis 84 return $title->get_error_message();
mp-wp_genesis 85 $title = apply_filters('get_wp_title_rss', $title);
mp-wp_genesis 86 return $title;
mp-wp_genesis 87 }
mp-wp_genesis 88
mp-wp_genesis 89 /**
mp-wp_genesis 90 * Display the blog title for display of the feed title.
mp-wp_genesis 91 *
mp-wp_genesis 92 * @package WordPress
mp-wp_genesis 93 * @subpackage Feed
mp-wp_genesis 94 * @since 2.2.0
mp-wp_genesis 95 * @uses apply_filters() Calls 'wp_title_rss' on the blog title.
mp-wp_genesis 96 * @see wp_title() $sep parameter usage.
mp-wp_genesis 97 *
mp-wp_genesis 98 * @param string $sep Optional.
mp-wp_genesis 99 */
mp-wp_genesis 100 function wp_title_rss($sep = '&#187;') {
mp-wp_genesis 101 echo apply_filters('wp_title_rss', get_wp_title_rss($sep));
mp-wp_genesis 102 }
mp-wp_genesis 103
mp-wp_genesis 104 /**
mp-wp_genesis 105 * Retrieve the current post title for the feed.
mp-wp_genesis 106 *
mp-wp_genesis 107 * @package WordPress
mp-wp_genesis 108 * @subpackage Feed
mp-wp_genesis 109 * @since 2.0.0
mp-wp_genesis 110 * @uses apply_filters() Calls 'the_title_rss' on the post title.
mp-wp_genesis 111 *
mp-wp_genesis 112 * @return string Current post title.
mp-wp_genesis 113 */
mp-wp_genesis 114 function get_the_title_rss() {
mp-wp_genesis 115 $title = get_the_title();
mp-wp_genesis 116 $title = apply_filters('the_title_rss', $title);
mp-wp_genesis 117 return $title;
mp-wp_genesis 118 }
mp-wp_genesis 119
mp-wp_genesis 120 /**
mp-wp_genesis 121 * Display the post title in the feed.
mp-wp_genesis 122 *
mp-wp_genesis 123 * @package WordPress
mp-wp_genesis 124 * @subpackage Feed
mp-wp_genesis 125 * @since 0.71
mp-wp_genesis 126 * @uses get_the_title_rss() Used to retrieve current post title.
mp-wp_genesis 127 */
mp-wp_genesis 128 function the_title_rss() {
mp-wp_genesis 129 echo get_the_title_rss();
mp-wp_genesis 130 }
mp-wp_genesis 131
mp-wp_genesis 132 /**
mp-wp_genesis 133 * Display the post content for the feed.
mp-wp_genesis 134 *
mp-wp_genesis 135 * For encoding the html or the $encode_html parameter, there are three possible
mp-wp_genesis 136 * values. '0' will make urls footnotes and use make_url_footnote(). '1' will
mp-wp_genesis 137 * encode special characters and automatically display all of the content. The
mp-wp_genesis 138 * value of '2' will strip all HTML tags from the content.
mp-wp_genesis 139 *
mp-wp_genesis 140 * Also note that you cannot set the amount of words and not set the html
mp-wp_genesis 141 * encoding. If that is the case, then the html encoding will default to 2,
mp-wp_genesis 142 * which will strip all HTML tags.
mp-wp_genesis 143 *
mp-wp_genesis 144 * To restrict the amount of words of the content, you can use the cut
mp-wp_genesis 145 * parameter. If the content is less than the amount, then there won't be any
mp-wp_genesis 146 * dots added to the end. If there is content left over, then dots will be added
mp-wp_genesis 147 * and the rest of the content will be removed.
mp-wp_genesis 148 *
mp-wp_genesis 149 * @package WordPress
mp-wp_genesis 150 * @subpackage Feed
mp-wp_genesis 151 * @since 0.71
mp-wp_genesis 152 * @uses apply_filters() Calls 'the_content_rss' on the content before processing.
mp-wp_genesis 153 * @see get_the_content() For the $more_link_text, $stripteaser, and $more_file
mp-wp_genesis 154 * parameters.
mp-wp_genesis 155 *
mp-wp_genesis 156 * @param string $more_link_text Optional. Text to display when more content is available but not displayed.
mp-wp_genesis 157 * @param int|bool $stripteaser Optional. Default is 0.
mp-wp_genesis 158 * @param string $more_file Optional.
mp-wp_genesis 159 * @param int $cut Optional. Amount of words to keep for the content.
mp-wp_genesis 160 * @param int $encode_html Optional. How to encode the content.
mp-wp_genesis 161 */
mp-wp_genesis 162 function the_content_rss($more_link_text='(more...)', $stripteaser=0, $more_file='', $cut = 0, $encode_html = 0) {
mp-wp_genesis 163 $content = get_the_content($more_link_text, $stripteaser, $more_file);
mp-wp_genesis 164 $content = apply_filters('the_content_rss', $content);
mp-wp_genesis 165 if ( $cut && !$encode_html )
mp-wp_genesis 166 $encode_html = 2;
mp-wp_genesis 167 if ( 1== $encode_html ) {
mp-wp_genesis 168 $content = wp_specialchars($content);
mp-wp_genesis 169 $cut = 0;
mp-wp_genesis 170 } elseif ( 0 == $encode_html ) {
mp-wp_genesis 171 $content = make_url_footnote($content);
mp-wp_genesis 172 } elseif ( 2 == $encode_html ) {
mp-wp_genesis 173 $content = strip_tags($content);
mp-wp_genesis 174 }
mp-wp_genesis 175 if ( $cut ) {
mp-wp_genesis 176 $blah = explode(' ', $content);
mp-wp_genesis 177 if ( count($blah) > $cut ) {
mp-wp_genesis 178 $k = $cut;
mp-wp_genesis 179 $use_dotdotdot = 1;
mp-wp_genesis 180 } else {
mp-wp_genesis 181 $k = count($blah);
mp-wp_genesis 182 $use_dotdotdot = 0;
mp-wp_genesis 183 }
mp-wp_genesis 184
mp-wp_genesis 185 /** @todo Check performance, might be faster to use array slice instead. */
mp-wp_genesis 186 for ( $i=0; $i<$k; $i++ )
mp-wp_genesis 187 $excerpt .= $blah[$i].' ';
mp-wp_genesis 188 $excerpt .= ($use_dotdotdot) ? '...' : '';
mp-wp_genesis 189 $content = $excerpt;
mp-wp_genesis 190 }
mp-wp_genesis 191 $content = str_replace(']]>', ']]&gt;', $content);
mp-wp_genesis 192 echo $content;
mp-wp_genesis 193 }
mp-wp_genesis 194
mp-wp_genesis 195 /**
mp-wp_genesis 196 * Display the post excerpt for the feed.
mp-wp_genesis 197 *
mp-wp_genesis 198 * @package WordPress
mp-wp_genesis 199 * @subpackage Feed
mp-wp_genesis 200 * @since 0.71
mp-wp_genesis 201 * @uses apply_filters() Calls 'the_excerpt_rss' hook on the excerpt.
mp-wp_genesis 202 */
mp-wp_genesis 203 function the_excerpt_rss() {
mp-wp_genesis 204 $output = get_the_excerpt();
mp-wp_genesis 205 echo apply_filters('the_excerpt_rss', $output);
mp-wp_genesis 206 }
mp-wp_genesis 207
mp-wp_genesis 208 /**
mp-wp_genesis 209 * Display the permalink to the post for use in feeds.
mp-wp_genesis 210 *
mp-wp_genesis 211 * @package WordPress
mp-wp_genesis 212 * @subpackage Feed
mp-wp_genesis 213 * @since 2.3.0
mp-wp_genesis 214 * @uses apply_filters() Call 'the_permalink_rss' on the post permalink
mp-wp_genesis 215 */
mp-wp_genesis 216 function the_permalink_rss() {
mp-wp_genesis 217 echo apply_filters('the_permalink_rss', get_permalink());
mp-wp_genesis 218 }
mp-wp_genesis 219
mp-wp_genesis 220 /**
mp-wp_genesis 221 * Display the feed GUID for the current comment.
mp-wp_genesis 222 *
mp-wp_genesis 223 * @package WordPress
mp-wp_genesis 224 * @subpackage Feed
mp-wp_genesis 225 * @since unknown
mp-wp_genesis 226 */
mp-wp_genesis 227 function comment_guid() {
mp-wp_genesis 228 echo get_comment_guid();
mp-wp_genesis 229 }
mp-wp_genesis 230
mp-wp_genesis 231 /**
mp-wp_genesis 232 * Retrieve the feed GUID for the current comment.
mp-wp_genesis 233 *
mp-wp_genesis 234 * @package WordPress
mp-wp_genesis 235 * @subpackage Feed
mp-wp_genesis 236 * @since unknown
mp-wp_genesis 237 *
mp-wp_genesis 238 * @return bool|string false on failure or guid for comment on success.
mp-wp_genesis 239 */
mp-wp_genesis 240 function get_comment_guid() {
mp-wp_genesis 241 global $comment;
mp-wp_genesis 242
mp-wp_genesis 243 if ( !is_object($comment) )
mp-wp_genesis 244 return false;
mp-wp_genesis 245
mp-wp_genesis 246 return get_the_guid($comment->comment_post_ID) . '#comment-' . $comment->comment_ID;
mp-wp_genesis 247 }
mp-wp_genesis 248
mp-wp_genesis 249 /**
mp-wp_genesis 250 * Display the link to the comments.
mp-wp_genesis 251 *
mp-wp_genesis 252 * @since 1.5.0
mp-wp_genesis 253 */
mp-wp_genesis 254 function comment_link() {
mp-wp_genesis 255 echo get_comment_link();
mp-wp_genesis 256 }
mp-wp_genesis 257
mp-wp_genesis 258 /**
mp-wp_genesis 259 * Retrieve the current comment author for use in the feeds.
mp-wp_genesis 260 *
mp-wp_genesis 261 * @package WordPress
mp-wp_genesis 262 * @subpackage Feed
mp-wp_genesis 263 * @since 2.0.0
mp-wp_genesis 264 * @uses apply_filters() Calls 'comment_author_rss' hook on comment author.
mp-wp_genesis 265 * @uses get_comment_author()
mp-wp_genesis 266 *
mp-wp_genesis 267 * @return string Comment Author
mp-wp_genesis 268 */
mp-wp_genesis 269 function get_comment_author_rss() {
mp-wp_genesis 270 return apply_filters('comment_author_rss', get_comment_author() );
mp-wp_genesis 271 }
mp-wp_genesis 272
mp-wp_genesis 273 /**
mp-wp_genesis 274 * Display the current comment author in the feed.
mp-wp_genesis 275 *
mp-wp_genesis 276 * @package WordPress
mp-wp_genesis 277 * @subpackage Feed
mp-wp_genesis 278 * @since 1.0.0
mp-wp_genesis 279 */
mp-wp_genesis 280 function comment_author_rss() {
mp-wp_genesis 281 echo get_comment_author_rss();
mp-wp_genesis 282 }
mp-wp_genesis 283
mp-wp_genesis 284 /**
mp-wp_genesis 285 * Display the current comment content for use in the feeds.
mp-wp_genesis 286 *
mp-wp_genesis 287 * @package WordPress
mp-wp_genesis 288 * @subpackage Feed
mp-wp_genesis 289 * @since 1.0.0
mp-wp_genesis 290 * @uses apply_filters() Calls 'comment_text_rss' filter on comment content.
mp-wp_genesis 291 * @uses get_comment_text()
mp-wp_genesis 292 */
mp-wp_genesis 293 function comment_text_rss() {
mp-wp_genesis 294 $comment_text = get_comment_text();
mp-wp_genesis 295 $comment_text = apply_filters('comment_text_rss', $comment_text);
mp-wp_genesis 296 echo $comment_text;
mp-wp_genesis 297 }
mp-wp_genesis 298
mp-wp_genesis 299 /**
mp-wp_genesis 300 * Retrieve all of the post categories, formatted for use in feeds.
mp-wp_genesis 301 *
mp-wp_genesis 302 * All of the categories for the current post in the feed loop, will be
mp-wp_genesis 303 * retrieved and have feed markup added, so that they can easily be added to the
mp-wp_genesis 304 * RSS2, Atom, or RSS1 and RSS0.91 RDF feeds.
mp-wp_genesis 305 *
mp-wp_genesis 306 * @package WordPress
mp-wp_genesis 307 * @subpackage Feed
mp-wp_genesis 308 * @since 2.1.0
mp-wp_genesis 309 * @uses apply_filters()
mp-wp_genesis 310 *
mp-wp_genesis 311 * @param string $type Optional, default is 'rss'. Either 'rss', 'atom', or 'rdf'.
mp-wp_genesis 312 * @return string All of the post categories for displaying in the feed.
mp-wp_genesis 313 */
mp-wp_genesis 314 function get_the_category_rss($type = 'rss') {
mp-wp_genesis 315 $categories = get_the_category();
mp-wp_genesis 316 $tags = get_the_tags();
mp-wp_genesis 317 $the_list = '';
mp-wp_genesis 318 $cat_names = array();
mp-wp_genesis 319
mp-wp_genesis 320 $filter = 'rss';
mp-wp_genesis 321 if ( 'atom' == $type )
mp-wp_genesis 322 $filter = 'raw';
mp-wp_genesis 323
mp-wp_genesis 324 if ( !empty($categories) ) foreach ( (array) $categories as $category ) {
mp-wp_genesis 325 $cat_names[] = sanitize_term_field('name', $category->name, $category->term_id, 'category', $filter);
mp-wp_genesis 326 }
mp-wp_genesis 327
mp-wp_genesis 328 if ( !empty($tags) ) foreach ( (array) $tags as $tag ) {
mp-wp_genesis 329 $cat_names[] = sanitize_term_field('name', $tag->name, $tag->term_id, 'post_tag', $filter);
mp-wp_genesis 330 }
mp-wp_genesis 331
mp-wp_genesis 332 $cat_names = array_unique($cat_names);
mp-wp_genesis 333
mp-wp_genesis 334 foreach ( $cat_names as $cat_name ) {
mp-wp_genesis 335 if ( 'rdf' == $type )
mp-wp_genesis 336 $the_list .= "\n\t\t<dc:subject><![CDATA[$cat_name]]></dc:subject>\n";
mp-wp_genesis 337 elseif ( 'atom' == $type )
mp-wp_genesis 338 $the_list .= sprintf( '<category scheme="%1$s" term="%2$s" />', attribute_escape( apply_filters( 'get_bloginfo_rss', get_bloginfo( 'url' ) ) ), attribute_escape( $cat_name ) );
mp-wp_genesis 339 else
mp-wp_genesis 340 $the_list .= "\n\t\t<category><![CDATA[" . html_entity_decode( $cat_name ) . "]]></category>\n";
mp-wp_genesis 341 }
mp-wp_genesis 342
mp-wp_genesis 343 return apply_filters('the_category_rss', $the_list, $type);
mp-wp_genesis 344 }
mp-wp_genesis 345
mp-wp_genesis 346 /**
mp-wp_genesis 347 * Display the post categories in the feed.
mp-wp_genesis 348 *
mp-wp_genesis 349 * @package WordPress
mp-wp_genesis 350 * @subpackage Feed
mp-wp_genesis 351 * @since 0.71
mp-wp_genesis 352 * @see get_the_category_rss() For better explanation.
mp-wp_genesis 353 *
mp-wp_genesis 354 * @param string $type Optional, default is 'rss'. Either 'rss', 'atom', or 'rdf'.
mp-wp_genesis 355 */
mp-wp_genesis 356 function the_category_rss($type = 'rss') {
mp-wp_genesis 357 echo get_the_category_rss($type);
mp-wp_genesis 358 }
mp-wp_genesis 359
mp-wp_genesis 360 /**
mp-wp_genesis 361 * Display the HTML type based on the blog setting.
mp-wp_genesis 362 *
mp-wp_genesis 363 * The two possible values are either 'xhtml' or 'html'.
mp-wp_genesis 364 *
mp-wp_genesis 365 * @package WordPress
mp-wp_genesis 366 * @subpackage Feed
mp-wp_genesis 367 * @since 2.2.0
mp-wp_genesis 368 */
mp-wp_genesis 369 function html_type_rss() {
mp-wp_genesis 370 $type = get_bloginfo('html_type');
mp-wp_genesis 371 if (strpos($type, 'xhtml') !== false)
mp-wp_genesis 372 $type = 'xhtml';
mp-wp_genesis 373 else
mp-wp_genesis 374 $type = 'html';
mp-wp_genesis 375 echo $type;
mp-wp_genesis 376 }
mp-wp_genesis 377
mp-wp_genesis 378 /**
mp-wp_genesis 379 * Display the rss enclosure for the current post.
mp-wp_genesis 380 *
mp-wp_genesis 381 * Uses the global $post to check whether the post requires a password and if
mp-wp_genesis 382 * the user has the password for the post. If not then it will return before
mp-wp_genesis 383 * displaying.
mp-wp_genesis 384 *
mp-wp_genesis 385 * Also uses the function get_post_custom() to get the post's 'enclosure'
mp-wp_genesis 386 * metadata field and parses the value to display the enclosure(s). The
mp-wp_genesis 387 * enclosure(s) consist of enclosure HTML tag(s) with a URI and other
mp-wp_genesis 388 * attributes.
mp-wp_genesis 389 *
mp-wp_genesis 390 * @package WordPress
mp-wp_genesis 391 * @subpackage Template
mp-wp_genesis 392 * @since 1.5.0
mp-wp_genesis 393 * @uses apply_filters() Calls 'rss_enclosure' hook on rss enclosure.
mp-wp_genesis 394 * @uses get_post_custom() To get the current post enclosure metadata.
mp-wp_genesis 395 */
mp-wp_genesis 396 function rss_enclosure() {
mp-wp_genesis 397 if ( post_password_required() )
mp-wp_genesis 398 return;
mp-wp_genesis 399
mp-wp_genesis 400 foreach ( (array) get_post_custom() as $key => $val) {
mp-wp_genesis 401 if ($key == 'enclosure') {
mp-wp_genesis 402 foreach ( (array) $val as $enc ) {
mp-wp_genesis 403 $enclosure = split("\n", $enc);
mp-wp_genesis 404
mp-wp_genesis 405 //only get the the first element eg, audio/mpeg from 'audio/mpeg mpga mp2 mp3'
mp-wp_genesis 406 $t = split('[ \t]', trim($enclosure[2]) );
mp-wp_genesis 407 $type = $t[0];
mp-wp_genesis 408
mp-wp_genesis 409 echo apply_filters('rss_enclosure', '<enclosure url="' . trim(htmlspecialchars($enclosure[0])) . '" length="' . trim($enclosure[1]) . '" type="' . $type . '" />' . "\n");
mp-wp_genesis 410 }
mp-wp_genesis 411 }
mp-wp_genesis 412 }
mp-wp_genesis 413 }
mp-wp_genesis 414
mp-wp_genesis 415 /**
mp-wp_genesis 416 * Display the atom enclosure for the current post.
mp-wp_genesis 417 *
mp-wp_genesis 418 * Uses the global $post to check whether the post requires a password and if
mp-wp_genesis 419 * the user has the password for the post. If not then it will return before
mp-wp_genesis 420 * displaying.
mp-wp_genesis 421 *
mp-wp_genesis 422 * Also uses the function get_post_custom() to get the post's 'enclosure'
mp-wp_genesis 423 * metadata field and parses the value to display the enclosure(s). The
mp-wp_genesis 424 * enclosure(s) consist of link HTML tag(s) with a URI and other attributes.
mp-wp_genesis 425 *
mp-wp_genesis 426 * @package WordPress
mp-wp_genesis 427 * @subpackage Template
mp-wp_genesis 428 * @since 2.2.0
mp-wp_genesis 429 * @uses apply_filters() Calls 'atom_enclosure' hook on atom enclosure.
mp-wp_genesis 430 * @uses get_post_custom() To get the current post enclosure metadata.
mp-wp_genesis 431 */
mp-wp_genesis 432 function atom_enclosure() {
mp-wp_genesis 433 if ( post_password_required() )
mp-wp_genesis 434 return;
mp-wp_genesis 435
mp-wp_genesis 436 foreach ( (array) get_post_custom() as $key => $val ) {
mp-wp_genesis 437 if ($key == 'enclosure') {
mp-wp_genesis 438 foreach ( (array) $val as $enc ) {
mp-wp_genesis 439 $enclosure = split("\n", $enc);
mp-wp_genesis 440 echo apply_filters('atom_enclosure', '<link href="' . trim(htmlspecialchars($enclosure[0])) . '" rel="enclosure" length="' . trim($enclosure[1]) . '" type="' . trim($enclosure[2]) . '" />' . "\n");
mp-wp_genesis 441 }
mp-wp_genesis 442 }
mp-wp_genesis 443 }
mp-wp_genesis 444 }
mp-wp_genesis 445
mp-wp_genesis 446 /**
mp-wp_genesis 447 * Determine the type of a string of data with the data formatted.
mp-wp_genesis 448 *
mp-wp_genesis 449 * Tell whether the type is text, html, or xhtml, per RFC 4287 section 3.1.
mp-wp_genesis 450 *
mp-wp_genesis 451 * In the case of WordPress, text is defined as containing no markup,
mp-wp_genesis 452 * xhtml is defined as "well formed", and html as tag soup (i.e., the rest).
mp-wp_genesis 453 *
mp-wp_genesis 454 * Container div tags are added to xhtml values, per section 3.1.1.3.
mp-wp_genesis 455 *
mp-wp_genesis 456 * @link http://www.atomenabled.org/developers/syndication/atom-format-spec.php#rfc.section.3.1
mp-wp_genesis 457 *
mp-wp_genesis 458 * @package WordPress
mp-wp_genesis 459 * @subpackage Feed
mp-wp_genesis 460 * @since 2.5
mp-wp_genesis 461 *
mp-wp_genesis 462 * @param string $data Input string
mp-wp_genesis 463 * @return array array(type, value)
mp-wp_genesis 464 */
mp-wp_genesis 465 function prep_atom_text_construct($data) {
mp-wp_genesis 466 if (strpos($data, '<') === false && strpos($data, '&') === false) {
mp-wp_genesis 467 return array('text', $data);
mp-wp_genesis 468 }
mp-wp_genesis 469
mp-wp_genesis 470 $parser = xml_parser_create();
mp-wp_genesis 471 xml_parse($parser, '<div>' . $data . '</div>', true);
mp-wp_genesis 472 $code = xml_get_error_code($parser);
mp-wp_genesis 473 xml_parser_free($parser);
mp-wp_genesis 474
mp-wp_genesis 475 if (!$code) {
mp-wp_genesis 476 if (strpos($data, '<') === false) {
mp-wp_genesis 477 return array('text', $data);
mp-wp_genesis 478 } else {
mp-wp_genesis 479 $data = "<div xmlns='http://www.w3.org/1999/xhtml'>$data</div>";
mp-wp_genesis 480 return array('xhtml', $data);
mp-wp_genesis 481 }
mp-wp_genesis 482 }
mp-wp_genesis 483
mp-wp_genesis 484 if (strpos($data, ']]>') == false) {
mp-wp_genesis 485 return array('html', "<![CDATA[$data]]>");
mp-wp_genesis 486 } else {
mp-wp_genesis 487 return array('html', htmlspecialchars($data));
mp-wp_genesis 488 }
mp-wp_genesis 489 }
mp-wp_genesis 490
mp-wp_genesis 491 /**
mp-wp_genesis 492 * Display the link for the currently displayed feed in a XSS safe way.
mp-wp_genesis 493 *
mp-wp_genesis 494 * Generate a correct link for the atom:self element.
mp-wp_genesis 495 *
mp-wp_genesis 496 * @package WordPress
mp-wp_genesis 497 * @subpackage Feed
mp-wp_genesis 498 * @since 2.5
mp-wp_genesis 499 */
mp-wp_genesis 500 function self_link() {
mp-wp_genesis 501 $host = @parse_url(get_option('home'));
mp-wp_genesis 502 $host = $host['host'];
mp-wp_genesis 503 echo clean_url(
mp-wp_genesis 504 'http'
mp-wp_genesis 505 . ( (isset($_SERVER['https']) && $_SERVER['https'] == 'on') ? 's' : '' ) . '://'
mp-wp_genesis 506 . $host
mp-wp_genesis 507 . stripslashes($_SERVER['REQUEST_URI'])
mp-wp_genesis 508 );
mp-wp_genesis 509 }
mp-wp_genesis 510
mp-wp_genesis 511 ?>