Make WordPress Core


Ignore:
Timestamp:
07/21/2020 04:12:49 PM (4 years ago)
Author:
swissspidy
Message:

Sitemaps: Replace wp_sitemaps_register_providers filter with more suitable wp_sitemaps_add_provider filter.

The previous filter failed the goal of allowing developers to filter all providers before they are registered, since it only filtered the built-in ones.

The more specific wp_sitemaps_add_provider filter enables exactly that, as it filters every sitemap provider right before it is added to the sitemaps registry.

Props pbiron, pfefferle, Chouby, swissspidy.
Fixes #50660.

File:
1 edited

Legend:

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

    r48536 r48543  
    111111     */
    112112    public function register_sitemaps() {
    113         /**
    114          * Filters the list of registered sitemap providers.
    115          *
    116          * @since 5.5.0
    117          *
    118          * @param array $providers {
    119          *     Array of WP_Sitemaps_Provider objects keyed by their name.
    120          *
    121          *     @type WP_Sitemaps_Posts      $posts      The WP_Sitemaps_Posts object.
    122          *     @type WP_Sitemaps_Taxonomies $taxonomies The WP_Sitemaps_Taxonomies object.
    123          *     @type WP_Sitemaps_Users      $users      The WP_Sitemaps_Users object.
    124          * }
    125          */
    126         $providers = apply_filters(
    127             'wp_sitemaps_register_providers',
    128             array(
    129                 'posts'      => new WP_Sitemaps_Posts(),
    130                 'taxonomies' => new WP_Sitemaps_Taxonomies(),
    131                 'users'      => new WP_Sitemaps_Users(),
    132             )
     113        $providers = array(
     114            'posts'      => new WP_Sitemaps_Posts(),
     115            'taxonomies' => new WP_Sitemaps_Taxonomies(),
     116            'users'      => new WP_Sitemaps_Users(),
    133117        );
    134118
    135         // Register each supported provider.
    136119        /* @var WP_Sitemaps_Provider $provider */
    137120        foreach ( $providers as $name => $provider ) {
Note: See TracChangeset for help on using the changeset viewer.