Make WordPress Core

Opened 5 months ago

#60552 new defect (bug)

Add hook to WP_Sitemaps::render_sitemaps()

Reported by: cybr's profile Cybr Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Sitemaps Keywords:
Focuses: Cc:

Description

Currently, we cannot tweak the sitemap's content parameters or headers.

To allow this without having to test whether the sitemap is outputting (there's currently no proper way, see #51543 and #56954), in WP_Sitemaps::render_sitemaps(), after the sitemaps_enabled() defense clause, add a hook wp_doing_sitemap.

For example

if ( ! $this->sitemaps_enabled() ) {
        $wp_query->set_404();
        status_header( 404 );
        return;
}

// Render stylesheet if this is stylesheet route.
if ( $stylesheet_type ) {
        ...

Becomes

if ( ! $this->sitemaps_enabled() ) {
        $wp_query->set_404();
        status_header( 404 );
        return;
}

do_action( 'wp_doing_sitemaps' );

// Render stylesheet if this is stylesheet route.
if ( $stylesheet_type ) {
        ...

Change History (0)

Note: See TracTickets for help on using tickets.