Make WordPress Core

Ticket #34083: 34083.2.patch

File 34083.2.patch, 3.6 KB (added by stevenkword, 8 years ago)

Adds check for populated query object keys

  • src/wp-includes/feed-rss2-comments.php

     
    4141                        printf( ent2ncr( __( 'Comments for %s' ) ), get_wp_title_rss() );
    4242        ?></title>
    4343        <atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
    44         <link><?php (is_single()) ? the_permalink_rss() : bloginfo_rss("url") ?></link>
     44        <link><?php source_link_rss(); ?></link>
    4545        <description><?php bloginfo_rss("description") ?></description>
    4646        <lastBuildDate><?php echo mysql2date('r', get_lastcommentmodified('GMT')); ?></lastBuildDate>
    4747        <sy:updatePeriod><?php
  • 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 echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false); ?></lastBuildDate>
    4646        <language><?php bloginfo_rss( 'language' ); ?></language>
  • src/wp-includes/feed.php

     
    619619}
    620620
    621621/**
     622 * Display the orignal source link for the currently displayed feed.
     623 *
     624 * Generate a correct link for the <link> element.
     625 *
     626 * @since 4.4.0
     627 */
     628function source_link_rss() {
     629        global $wp_query;
     630        $queried_object = get_queried_object();
     631
     632        // Posts and Custom Post Types
     633        if( $wp_query->is_singular() ) {
     634                $source_link = the_permalink_rss();
     635        }
     636        // Pages
     637        else if( $wp_query->is_page() && isset( $wp_query->query['pagename'] ) ) {
     638                $page = get_page_by_path( $wp_query->query['pagename'] );
     639                $source_link = get_page_link( $page->ID );
     640        }
     641        // Taxonomy Archive Pages
     642        else if( ( $wp_query->is_category() || $wp_query->is_tag() || $wp_query->is_taxonomy() ) && isset( $queried_object->term_id ) && ! empty( $queried_object->term_id ) ) {
     643                $source_link = get_term_link( $queried_object->term_id );
     644        }
     645        // Date Archive Pages
     646        else if( $wp_query->is_date() ) {
     647                if( $wp_query->is_day() ) {
     648                        $source_link = get_day_link( $wp_query->query_vars['year'], $wp_query->query_vars['monthnum'], $wp_query->query_vars['day'] );
     649                } else if( $wp_query->is_month() ) {
     650                        $source_link = get_month_link( $wp_query->query['year'], $wp_query->query['monthnum'] );
     651                }
     652        }
     653        // Custom Post Type Archive Pages
     654        else if( $wp_query->is_post_type_archive() && isset( $wp_query->query['post_type'] ) && ! empty( $wp_query->query['post_type'] ) ) {
     655                $post_type = $wp_query->query['post_type'];
     656                $source_link = get_post_type_archive_link( $post_type );
     657        }
     658        // Search Result Pages
     659        else if( $wp_query->is_search() && isset( $wp_query->query['s'] ) && ! empty( $wp_query->query['s'] ) ) {
     660                $source_link = get_search_link( $wp_query->query['s'] );
     661        }
     662        // Fallback
     663        else {
     664                $source_link = bloginfo_rss('url');
     665        }
     666
     667        /**
     668         * Filter the original HTML source link URL for use in RSS feeds.
     669         *
     670         * @since 4.4.0
     671         *
     672         *
     673         * @param string $source_link The link to the orignal HTML source the feed represents.
     674         */
     675        echo esc_url( apply_filters( 'source_link_rss', $source_link ) );
     676}
     677
     678/**
    622679 * Return the content type for specified feed type.
    623680 *
    624681 * @since 2.8.0