Changeset 42343 for trunk/src/wp-includes/feed.php
- Timestamp:
- 11/30/2017 11:09:33 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/feed.php
r42260 r42343 24 24 * @return string 25 25 */ 26 function get_bloginfo_rss( $show = '') {27 $info = strip_tags( get_bloginfo($show));26 function get_bloginfo_rss( $show = '' ) { 27 $info = strip_tags( get_bloginfo( $show ) ); 28 28 /** 29 29 * Filters the bloginfo for use in RSS feeds. … … 52 52 * @param string $show See get_bloginfo() for possible values. 53 53 */ 54 function bloginfo_rss( $show = '') {54 function bloginfo_rss( $show = '' ) { 55 55 /** 56 56 * Filters the bloginfo for display in RSS feeds. … … 183 183 * @return string The filtered content. 184 184 */ 185 function get_the_content_feed( $feed_type = null) {186 if ( ! $feed_type )185 function get_the_content_feed( $feed_type = null ) { 186 if ( ! $feed_type ) { 187 187 $feed_type = get_default_feed(); 188 } 188 189 189 190 /** This filter is documented in wp-includes/post-template.php */ 190 191 $content = apply_filters( 'the_content', get_the_content() ); 191 $content = str_replace( ']]>', ']]>', $content);192 $content = str_replace( ']]>', ']]>', $content ); 192 193 /** 193 194 * Filters the post content for use in feeds. … … 209 210 * @param string $feed_type The type of feed. rss2 | atom | rss | rdf 210 211 */ 211 function the_content_feed( $feed_type = null) {212 echo get_the_content_feed( $feed_type);212 function the_content_feed( $feed_type = null ) { 213 echo get_the_content_feed( $feed_type ); 213 214 } 214 215 … … 271 272 * @param int|WP_Comment $comment_id Optional comment object or id. Defaults to global comment object. 272 273 */ 273 function comment_guid( $comment_id = null) {274 echo esc_url( get_comment_guid( $comment_id) );274 function comment_guid( $comment_id = null ) { 275 echo esc_url( get_comment_guid( $comment_id ) ); 275 276 } 276 277 … … 283 284 * @return false|string false on failure or guid for comment on success. 284 285 */ 285 function get_comment_guid( $comment_id = null) {286 $comment = get_comment( $comment_id);287 288 if ( ! is_object($comment) )286 function get_comment_guid( $comment_id = null ) { 287 $comment = get_comment( $comment_id ); 288 289 if ( ! is_object( $comment ) ) { 289 290 return false; 290 291 return get_the_guid($comment->comment_post_ID) . '#comment-' . $comment->comment_ID; 291 } 292 293 return get_the_guid( $comment->comment_post_ID ) . '#comment-' . $comment->comment_ID; 292 294 } 293 295 … … 372 374 * @return string All of the post categories for displaying in the feed. 373 375 */ 374 function get_the_category_rss( $type = null) {375 if ( empty( $type) )376 function get_the_category_rss( $type = null ) { 377 if ( empty( $type ) ) { 376 378 $type = get_default_feed(); 379 } 377 380 $categories = get_the_category(); 378 $tags = get_the_tags();379 $the_list = '';380 $cat_names = array();381 $tags = get_the_tags(); 382 $the_list = ''; 383 $cat_names = array(); 381 384 382 385 $filter = 'rss'; 383 if ( 'atom' == $type ) 386 if ( 'atom' == $type ) { 384 387 $filter = 'raw'; 385 386 if ( !empty($categories) ) foreach ( (array) $categories as $category ) { 387 $cat_names[] = sanitize_term_field('name', $category->name, $category->term_id, 'category', $filter); 388 } 389 390 if ( !empty($tags) ) foreach ( (array) $tags as $tag ) { 391 $cat_names[] = sanitize_term_field('name', $tag->name, $tag->term_id, 'post_tag', $filter); 392 } 393 394 $cat_names = array_unique($cat_names); 388 } 389 390 if ( ! empty( $categories ) ) { 391 foreach ( (array) $categories as $category ) { 392 $cat_names[] = sanitize_term_field( 'name', $category->name, $category->term_id, 'category', $filter ); 393 } 394 } 395 396 if ( ! empty( $tags ) ) { 397 foreach ( (array) $tags as $tag ) { 398 $cat_names[] = sanitize_term_field( 'name', $tag->name, $tag->term_id, 'post_tag', $filter ); 399 } 400 } 401 402 $cat_names = array_unique( $cat_names ); 395 403 396 404 foreach ( $cat_names as $cat_name ) { 397 if ( 'rdf' == $type ) 405 if ( 'rdf' == $type ) { 398 406 $the_list .= "\t\t<dc:subject><![CDATA[$cat_name]]></dc:subject>\n"; 399 elseif ( 'atom' == $type )407 } elseif ( 'atom' == $type ) { 400 408 $the_list .= sprintf( '<category scheme="%1$s" term="%2$s" />', esc_attr( get_bloginfo_rss( 'url' ) ), esc_attr( $cat_name ) ); 401 else 402 $the_list .= "\t\t<category><![CDATA[" . @html_entity_decode( $cat_name, ENT_COMPAT, get_option('blog_charset') ) . "]]></category>\n"; 409 } else { 410 $the_list .= "\t\t<category><![CDATA[" . @html_entity_decode( $cat_name, ENT_COMPAT, get_option( 'blog_charset' ) ) . "]]></category>\n"; 411 } 403 412 } 404 413 … … 423 432 * @param string $type Optional, default is the type returned by get_default_feed(). 424 433 */ 425 function the_category_rss( $type = null) {426 echo get_the_category_rss( $type);434 function the_category_rss( $type = null ) { 435 echo get_the_category_rss( $type ); 427 436 } 428 437 … … 435 444 */ 436 445 function html_type_rss() { 437 $type = get_bloginfo( 'html_type');438 if ( strpos($type, 'xhtml') !== false)446 $type = get_bloginfo( 'html_type' ); 447 if ( strpos( $type, 'xhtml' ) !== false ) { 439 448 $type = 'xhtml'; 440 else449 } else { 441 450 $type = 'html'; 451 } 442 452 echo $type; 443 453 } … … 458 468 */ 459 469 function rss_enclosure() { 460 if ( post_password_required() ) 470 if ( post_password_required() ) { 461 471 return; 462 463 foreach ( (array) get_post_custom() as $key => $val) { 464 if ($key == 'enclosure') { 472 } 473 474 foreach ( (array) get_post_custom() as $key => $val ) { 475 if ( $key == 'enclosure' ) { 465 476 foreach ( (array) $val as $enc ) { 466 $enclosure = explode( "\n", $enc);477 $enclosure = explode( "\n", $enc ); 467 478 468 479 // only get the first element, e.g. audio/mpeg from 'audio/mpeg mpga mp2 mp3' 469 $t = preg_split('/[ \t]/', trim($enclosure[2]) );480 $t = preg_split( '/[ \t]/', trim( $enclosure[2] ) ); 470 481 $type = $t[0]; 471 482 … … 497 508 */ 498 509 function atom_enclosure() { 499 if ( post_password_required() ) 510 if ( post_password_required() ) { 500 511 return; 512 } 501 513 502 514 foreach ( (array) get_post_custom() as $key => $val ) { 503 if ( $key == 'enclosure') {515 if ( $key == 'enclosure' ) { 504 516 foreach ( (array) $val as $enc ) { 505 $enclosure = explode( "\n", $enc);517 $enclosure = explode( "\n", $enc ); 506 518 /** 507 519 * Filters the atom enclosure HTML link tag for the current post. … … 534 546 * @return array array(type, value) 535 547 */ 536 function prep_atom_text_construct( $data) {537 if ( strpos($data, '<') === false && strpos($data, '&') === false) {538 return array( 'text', $data);548 function prep_atom_text_construct( $data ) { 549 if ( strpos( $data, '<' ) === false && strpos( $data, '&' ) === false ) { 550 return array( 'text', $data ); 539 551 } 540 552 … … 546 558 547 559 $parser = xml_parser_create(); 548 xml_parse( $parser, '<div>' . $data . '</div>', true);549 $code = xml_get_error_code( $parser);550 xml_parser_free( $parser);551 552 if ( !$code) {553 if ( strpos($data, '<') === false) {554 return array( 'text', $data);560 xml_parse( $parser, '<div>' . $data . '</div>', true ); 561 $code = xml_get_error_code( $parser ); 562 xml_parser_free( $parser ); 563 564 if ( ! $code ) { 565 if ( strpos( $data, '<' ) === false ) { 566 return array( 'text', $data ); 555 567 } else { 556 568 $data = "<div xmlns='http://www.w3.org/1999/xhtml'>$data</div>"; 557 return array( 'xhtml', $data);569 return array( 'xhtml', $data ); 558 570 } 559 571 } 560 572 561 if ( strpos($data, ']]>') === false) {562 return array( 'html', "<![CDATA[$data]]>");573 if ( strpos( $data, ']]>' ) === false ) { 574 return array( 'html', "<![CDATA[$data]]>" ); 563 575 } else { 564 return array( 'html', htmlspecialchars($data));576 return array( 'html', htmlspecialchars( $data ) ); 565 577 } 566 578 } … … 612 624 */ 613 625 function self_link() { 614 $host = @parse_url( home_url());626 $host = @parse_url( home_url() ); 615 627 /** 616 628 * Filters the current feed URL. … … 634 646 */ 635 647 function feed_content_type( $type = '' ) { 636 if ( empty( $type) )648 if ( empty( $type ) ) { 637 649 $type = get_default_feed(); 650 } 638 651 639 652 $types = array( … … 642 655 'rss-http' => 'text/xml', 643 656 'atom' => 'application/atom+xml', 644 'rdf' => 'application/rdf+xml' 657 'rdf' => 'application/rdf+xml', 645 658 ); 646 659 647 $content_type = ( ! empty($types[$type]) ) ? $types[$type] : 'application/octet-stream';660 $content_type = ( ! empty( $types[ $type ] ) ) ? $types[ $type ] : 'application/octet-stream'; 648 661 649 662 /** … … 704 717 $feed->set_output_encoding( get_option( 'blog_charset' ) ); 705 718 706 if ( $feed->error() ) 719 if ( $feed->error() ) { 707 720 return new WP_Error( 'simplepie-error', $feed->error() ); 721 } 708 722 709 723 return $feed;
Note: See TracChangeset
for help on using the changeset viewer.