Make WordPress Core

Opened 5 weeks ago

#64458 new enhancement

Add ability to set different renders based on sitemap type

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

Description

I'm working on a plugin that extends the core sitemaps functionality to add a News Sitemap. One area that got a little hacky was overriding the core Renderer. Ideally, this would work exactly like how the Providers work, extending WP_Sitemaps_Registry to also manage renderers. They could similarly be keyed by a name, and if WP_Sitemaps::render_sitemaps() has no renderer for the sitemap type, the current renderer could be used as a fallback.

This would facilitate adding other sitemap types as discussed in #51016 and offers an alternative approach to what was discussed in GitHub.

Adding a new Renderer would then look something like:

add_action(
    'wp_sitemaps_init',
    function ( $wp_sitemaps ) {
        $wp_sitemaps->registry->add_renderer( 'video', new My_Video_Sitemap_Renderer() );
    }
);

Change History (0)

Note: See TracTickets for help on using tickets.