Opened 5 years ago
Closed 5 years ago
#50660 closed defect (bug) (fixed)
Not all sitemaps providers can be filtered
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 5.5 | Priority: | normal |
| Severity: | normal | Version: | 5.5 |
| Component: | Sitemaps | Keywords: | has-patch commit |
| Focuses: | Cc: |
Description
For the context: to allow multilingual sitemaps with Polylang, and after
this comment, I implemented a sitemaps provider decorator replacing the existing providers with the filter wp_sitemaps_register_providers. See https://github.com/polylang/polylang/blob/2.8-beta1/modules/sitemaps/sitemaps.php#L152-L163
However I realized that if another provider is added directly, for example with wp_register_sitemap(), it is not seen by the filter wp_sitemaps_register_providers and it looks like there is no alternative to filter it.
So I suggest to add a filter allowing to filter all registered sitemap providers.
Attachments (2)
Change History (11)
#1
@
5 years ago
- Keywords needs-patch added
- Milestone changed from Awaiting Review to 5.5
- Type changed from enhancement to defect (bug)
This ticket was mentioned in Slack in #core-sitemaps by swissspidy. View the logs.
5 years ago
This ticket was mentioned in Slack in #core-sitemaps by swissspidy. View the logs.
5 years ago
#6
@
5 years ago
50660.2.diff looks good to me
Thanks for your report! Very useful feedback as always.
You're right that folks can (and should) use
wp_register_sitemap()to register sitemaps, and that will not pass through thewp_sitemaps_register_providersfilter.The filter doc block is a bit misleading: "Filters the list of registered sitemap providers."
It would be more accurate to say "Filters the list of built-in sitemap providers before they are registered.". Not to mention the doc block for the class method which could be improved...
Anyway, I'd consider not being able to unregister/filter sitemaps added via
wp_register_sitemapa bug, and we should fix it.