Make WordPress Core


Ignore:
Timestamp:
10/14/2024 08:47:34 AM (22 months ago)
Author:
swissspidy
Message:

Sitemaps: Improve sitemap.xml redirects when using custom permalinks.

Changes the way redirects from sitemap.xml to wp-sitemap.xml happen, so that they also work when using a more complex custom rewrite structure.

Props gmariani405, swissspidy, euthelup, peterwilsoncc.
Fixes #61931.

File:
1 edited

Legend:

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

    r56549 r59228  
    12881288                $favicon_rewrite = ( empty( $home_path['path'] ) || '/' === $home_path['path'] ) ? array( 'favicon\.ico$' => $this->index . '?favicon=1' ) : array();
    12891289
     1290                // sitemap.xml -- only if installed at the root.
     1291                $sitemap_rewrite = ( empty( $home_path['path'] ) || '/' === $home_path['path'] ) ? array( 'sitemap\.xml' => $this->index . '??sitemap=index' ) : array();
     1292
    12901293                // Old feed and service files.
    12911294                $deprecated_files = array(
     
    14501453                // Put them together.
    14511454                if ( $this->use_verbose_page_rules ) {
    1452                         $this->rules = array_merge( $this->extra_rules_top, $robots_rewrite, $favicon_rewrite, $deprecated_files, $registration_pages, $root_rewrite, $comments_rewrite, $search_rewrite, $author_rewrite, $date_rewrite, $page_rewrite, $post_rewrite, $this->extra_rules );
     1455                        $this->rules = array_merge( $this->extra_rules_top, $robots_rewrite, $favicon_rewrite, $sitemap_rewrite, $deprecated_files, $registration_pages, $root_rewrite, $comments_rewrite, $search_rewrite, $author_rewrite, $date_rewrite, $page_rewrite, $post_rewrite, $this->extra_rules );
    14531456                } else {
    1454                         $this->rules = array_merge( $this->extra_rules_top, $robots_rewrite, $favicon_rewrite, $deprecated_files, $registration_pages, $root_rewrite, $comments_rewrite, $search_rewrite, $author_rewrite, $date_rewrite, $post_rewrite, $page_rewrite, $this->extra_rules );
     1457                        $this->rules = array_merge( $this->extra_rules_top, $robots_rewrite, $favicon_rewrite, $sitemap_rewrite, $deprecated_files, $registration_pages, $root_rewrite, $comments_rewrite, $search_rewrite, $author_rewrite, $date_rewrite, $post_rewrite, $page_rewrite, $this->extra_rules );
    14551458                }
    14561459
Note: See TracChangeset for help on using the changeset viewer.