[wp-trac] [WordPress Trac] #60552: Add hook to WP_Sitemaps::render_sitemaps()
WordPress Trac
noreply at wordpress.org
Thu Feb 15 18:53:14 UTC 2024
#60552: Add hook to WP_Sitemaps::render_sitemaps()
--------------------------+-----------------------------
Reporter: Cybr | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Sitemaps | Version:
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
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
{{{#!php
if ( ! $this->sitemaps_enabled() ) {
$wp_query->set_404();
status_header( 404 );
return;
}
// Render stylesheet if this is stylesheet route.
if ( $stylesheet_type ) {
...
}}}
Becomes
{{{#!php
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 ) {
...
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/60552>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list