Ticket #8994: 8994.diff
File 8994.diff, 3.6 KB (added by , 4 years ago) |
---|
-
src/wp-includes/default-filters.php
341 341 add_action( 'atom_head', 'atom_site_icon' ); 342 342 add_action( 'rss2_head', 'rss2_site_icon' ); 343 343 344 // Feed Post Thumbnail. 345 add_action( 'rss2_item', 'the_post_thumbnail_rss' ); 346 344 347 345 348 // WP Cron. 346 349 if ( ! defined( 'DOING_CRON' ) ) { -
src/wp-includes/feed-rss2.php
27 27 xmlns:atom="http://www.w3.org/2005/Atom" 28 28 xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" 29 29 xmlns:slash="http://purl.org/rss/1.0/modules/slash/" 30 xmlns:media="http://search.yahoo.com/mrss/" 30 31 <?php 31 32 /** 32 33 * Fires at the end of the RSS root to add namespaces. -
src/wp-includes/feed.php
613 613 } 614 614 615 615 /** 616 * Displays post thumbnail in RSS2. 617 * 618 * @since x.x.x 619 */ 620 function the_post_thumbnail_rss() { 621 if ( ! has_post_thumbnail() ) { 622 return; 623 } 624 625 $image = get_post( get_post_thumbnail_id() ); 626 $full = wp_get_attachment_image_src( $image->ID, 'full' ); 627 $thumbnail = wp_get_attachment_image_src( $image->ID, 'thumbnail' ); 628 ?> 629 <media:content 630 url="<?php echo esc_url( $full[0] ); ?>" 631 type="<?php echo esc_attr( $image->post_mime_type ); ?>" 632 medium="image" 633 width="<?php echo absint( $full[1] ); ?>" 634 height="<?php echo absint( $full[2] ); ?>" 635 > 636 <media:title type="plain"> 637 <![CDATA[<?php echo sanitize_text_field( $image->post_title ); ?>]]> 638 </media:title> 639 <media:thumbnail 640 url="<?php echo esc_url( $thumbnail[0] ); ?>" 641 width="<?php echo absint( $thumbnail[1] ); ?>" 642 height="<?php echo absint( $thumbnail[2] ); ?>" /> 643 <?php if ( ! empty( $image->post_content ) ) : ?> 644 <media:description type="plain"><![CDATA[<?php echo wp_kses_post( $image->post_content ); ?>]]></media:description> 645 <?php endif; ?> 646 <?php if ( ! empty( $image->post_author ) ) : ?> 647 <media:credit role="author" scheme="urn:ebu"><?php echo esc_html( get_the_author_meta( 'display_name', $image->post_author ) ); ?></media:credit> 648 <?php endif; ?> 649 </media:content> 650 <?php 651 } 652 653 /** 616 654 * Displays Site Icon in atom feeds. 617 655 * 618 656 * @since 4.3.0 -
tests/phpunit/tests/feed/rss2.php
35 35 ) 36 36 ); 37 37 38 $attachment_id = self::factory()->attachment->create_upload_object( DIR_TESTDATA . '/images/canola.jpg' ); 39 38 40 // Set a predictable time for testing date archives. 39 41 self::$post_date = strtotime( '2003-05-27 10:07:53' ); 40 42 … … 57 59 // Assign a category to those posts. 58 60 foreach ( self::$posts as $post ) { 59 61 wp_set_object_terms( $post, self::$category->slug, 'category' ); 62 set_post_thumbnail( $post, $attachment_id ); 60 63 } 61 64 } 62 65 … … 260 263 // Comment RSS. 261 264 $comment_rss = xml_find( $items[ $key ]['child'], 'wfw:commentRss' ); 262 265 $this->assertSame( html_entity_decode( get_post_comments_feed_link( $post->ID ) ), $comment_rss[0]['content'] ); 266 267 // Post Thumbnail. 268 $post_thumbnail = xml_find( $items[ $key ]['child'], 'media:content' ); 269 $this->assertSame( get_the_post_thumbnail_url( $post ), $post_thumbnail[0]['attributes']['url'] ); 263 270 } 264 271 } 265 272