Make WordPress Core


Ignore:
Timestamp:
06/17/2020 03:22:49 PM (6 years ago)
Author:
swissspidy
Message:

Sitemaps: Add XML sitemaps functionality to WordPress.

While web crawlers are able to discover pages from links within the site and from other sites, XML sitemaps supplement this approach by allowing crawlers to quickly and comprehensively identify all URLs included in the sitemap and learn other signals about those URLs using the associated metadata.

See ​https://make.wordpress.org/core/2020/06/10/merge-announcement-extensible-core-sitemaps/ for more details.

This feature exposes the sitemap index via /wp-sitemap.xml and exposes a variety of new filters and hooks for developers to modify the behavior. Users can disable sitemaps completely by turning off search engine visibility in WordPress admin.

This change also introduces a new esc_xml() function to escape strings for output in XML, as well as XML support to wp_kses_normalize_entities().

Props Adrian McShane, afragen, adamsilverstein, casiepa, flixos90, garrett-eclipse, joemcgill, kburgoine, kraftbj, milana_cap, pacifika, pbiron, pfefferle, Ruxandra Gradina, swissspidy, szepeviktor, tangrufus, tweetythierry.
Fixes #50117.
See #3670. See #19998.

File:
1 edited

Legend:

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

    r48026 r48072  
    508508                        if ( ! empty( $addl_path ) ) {
    509509                                $redirect['path'] = trailingslashit( $redirect['path'] ) . $addl_path;
     510                        }
     511
     512                        // Remove trailing slash for sitemaps requests.
     513                        if ( ! empty( get_query_var( 'sitemap' ) ) ) {
     514                                $redirect['path'] = untrailingslashit( $redirect['path'] );
    510515                        }
    511516
    … …  
    652657        }
    653658
     659        // Remove trailing slash for sitemaps requests.
     660        if ( ! empty( get_query_var( 'sitemap' ) ) || ! empty( get_query_var( 'sitemap-stylesheet' ) ) ) {
     661                $redirect['path'] = untrailingslashit( $redirect['path'] );
     662        }
     663
    654664        // Strip multiple slashes out of the URL.
    655665        if ( strpos( $redirect['path'], '//' ) > -1 ) {
Note: See TracChangeset for help on using the changeset viewer.