Make WordPress Core


Ignore:
Timestamp:
07/21/2020 12:55:20 AM (4 years ago)
Author:
whyisjake
Message:

Sitemaps: Ensure correct HTTP status when sitemaps are disabled

If sitemaps are disabled, previously there would be a rewrite rule for the sitemap endpoint. This endpoint would display the homepage since there was a rewrite rule. Now, Sitemaps are loaded, and the proper HTTP headers are returned.

Fixes #50643.
Props swissspidy, kraftbj, donmhico.

File:
1 edited

Legend:

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

    r48098 r48523  
    1818 * @global WP_Sitemaps $wp_sitemaps Global Core Sitemaps instance.
    1919 *
    20  * @return WP_Sitemaps|null Sitemaps instance, or null if sitemaps are disabled.
     20 * @return WP_Sitemaps Sitemaps instance.
    2121 */
    2222function wp_sitemaps_get_server() {
     
    2424
    2525    $is_enabled = (bool) get_option( 'blog_public' );
    26 
    27     /**
    28      * Filters whether XML Sitemaps are enabled or not.
    29      *
    30      * @since 5.5.0
    31      *
    32      * @param bool $is_enabled Whether XML Sitemaps are enabled or not. Defaults to true for public sites.
    33      */
    34     $is_enabled = (bool) apply_filters( 'wp_sitemaps_enabled', $is_enabled );
    35 
    36     if ( ! $is_enabled ) {
    37         return null;
    38     }
    3926
    4027    // If there isn't a global instance, set and bootstrap the sitemaps system.
Note: See TracChangeset for help on using the changeset viewer.