Make WordPress Core


Ignore:
Timestamp:
06/25/2020 11:39:23 AM (6 years ago)
Author:
SergeyBiryukov
Message:

Canonical: Move trailing slash handling for robots.txt and sitemaps to a single condition.

Give the unit test a more descriptive name.

Follow-up to [48153], [48155].

See #48025.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/canonical.php

    r48153 r48166  
    5858        }
    5959
    60         if ( is_admin() || is_search() || is_preview() || is_trackback()
    61                 || is_favicon() || ( $is_IIS && ! iis7_supports_permalinks() )
     60        if ( is_admin() || is_search() || is_preview() || is_trackback() || is_favicon()
     61                || ( $is_IIS && ! iis7_supports_permalinks() )
    6262        ) {
    6363                return;
     
    656656        }
    657657
    658         // Remove trailing slash for sitemaps requests.
    659         if ( ! empty( get_query_var( 'sitemap' ) ) || ! empty( get_query_var( 'sitemap-stylesheet' ) ) ) {
     658        // Remove trailing slash for robots.txt or sitemap requests.
     659        if ( is_robots()
     660                || ! empty( get_query_var( 'sitemap' ) ) || ! empty( get_query_var( 'sitemap-stylesheet' ) )
     661        ) {
    660662                $redirect['path'] = untrailingslashit( $redirect['path'] );
    661663        }
     
    681683        ) {
    682684                $redirect['host'] = $original['host'];
    683         }
    684 
    685         // Even if the permalink structure ends with a slash, remove slash robots.txt.
    686         if ( is_robots() ) {
    687                 $redirect['path'] = untrailingslashit( $redirect['path'] );
    688685        }
    689686
Note: See TracChangeset for help on using the changeset viewer.