Make WordPress Core

Ticket #34083: 34083.3.diff

File 34083.3.diff, 2.9 KB (added by stevenkword, 6 years ago)
  • src/wp-includes/feed-rss2-comments.php

     
    4545                }
    4646        ?></title>
    4747        <atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
    48         <link><?php (is_single()) ? the_permalink_rss() : bloginfo_rss("url") ?></link>
     48        <link><?php source_link_rss(); ?></link>
    4949        <description><?php bloginfo_rss("description") ?></description>
    5050        <lastBuildDate><?php
    5151                $date = get_lastcommentmodified( 'GMT' );
  • src/wp-includes/feed-rss2.php

     
    4040<channel>
    4141        <title><?php wp_title_rss(); ?></title>
    4242        <atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
    43         <link><?php bloginfo_rss('url') ?></link>
     43        <link><?php source_link_rss(); ?></link>
    4444        <description><?php bloginfo_rss("description") ?></description>
    4545        <lastBuildDate><?php
    4646                $date = get_lastpostmodified( 'GMT' );
  • src/wp-includes/feed.php

     
    626626}
    627627
    628628/**
     629 * Display the orignal source link for the currently displayed feed.
     630 *
     631 * Generate a correct link for the <link> element.
     632 *
     633 * @since 4.8.0
     634 */
     635function source_link_rss() {
     636        // Posts, Pages and Custom Post Types
     637        if ( is_singular() ) {
     638                $source_link = the_permalink_rss();
     639        }
     640        // Taxonomy Archive Pages
     641        elseif ( ( is_category() || is_tag() || is_tax() ) && get_queried_object_id() ) {
     642                $source_link = get_term_link( get_queried_object_id() );
     643        }
     644        // Date Archive Pages
     645        elseif ( is_date() ) {
     646                if ( is_day() ) {
     647                        $source_link = get_day_link( get_query_var( 'year' ), get_query_var( 'monthnum' ), get_query_var( 'day' ) );
     648                } elseif ( is_month() ) {
     649                        $source_link = get_month_link( get_query_var( 'year' ), get_query_var( 'monthnum' ) );
     650                }
     651        }
     652        // Custom Post Type Archive Pages
     653        elseif ( is_post_type_archive() && get_query_var( 'post_type' ) ) {
     654                $source_link = get_post_type_archive_link( get_query_var( 'post_type' ) );
     655        }
     656        // Search Result Pages
     657        elseif ( is_search() && get_query_var( 's' ) ) {
     658                $source_link = get_search_link( get_query_var( 's' ) );
     659        }
     660        // Fallback
     661        else {
     662                $source_link = bloginfo_rss( 'url' );
     663        }
     664
     665        /**
     666         * Filter the original HTML source link URL for use in RSS feeds.
     667         *
     668         * @since 4.8.0
     669         *
     670         *
     671         * @param string $source_link The link to the orignal HTML source the feed represents.
     672         */
     673        echo esc_url( apply_filters( 'source_link_rss', $source_link ) );
     674}
     675
     676/**
    629677 * Return the content type for specified feed type.
    630678 *
    631679 * @since 2.8.0