Opened 4 years ago
Last modified 17 months ago
#51280 assigned defect (bug)
wp_register_sitemap_provider() breaks sitemap functionality if provider name contains a dash (-)
Reported by: | MadtownLems | Owned by: | pbiron |
---|---|---|---|
Milestone: | Future Release | Priority: | normal |
Severity: | minor | Version: | 5.5 |
Component: | Sitemaps | Keywords: | needs-patch |
Focuses: | Cc: |
Description
The announcement post for the functionality (https://make.wordpress.org/core/2020/07/22/new-xml-sitemaps-functionality-in-wordpress-5-5/) includes the following snippet:
wp_register_sitemap_provider( 'awesome-plugin', $provider );
However, I believe that the name doesn't work in practice. From my experiences, using a dash in the sitemap provider name causes the following:
The map is listed on the index, but when trying to view it, you just view your site's home page (not a 404, and not anything sitemappy).
If you register the provider with the name 'awesome-plugin', render_sitemaps() sees the following data:
$sitemap => 'awesome' (Expected: 'awesome-plugin' )
$object_subtype => 'plugin' (Expected: null )
and then it returns early due to if ( ! $provider )
As another test, I tried simply changing the name of Core's User Sitemap from 'users' to 'foo-users' and got the same result. The map was listed on the index, but when trying to browse it, you just see your site's home page (not a 404).
Doing some debugging, render_sitemaps sees the following data:
$sitemap => 'foo'
$object_subtype => 'users'
and then it returns early due to if ( ! $provider )
Thank you for the report.
I can confirm the described behavior. It's not just dash (
-
): any character not in the range[a-z]
causes the same results.Additionally, the
$name
parameter ofwp_register_sitemap_provider()
must be the same as the$name
property of theWP_Sitemaps_Provider
subclass instance passed in the$provider
param...and that is not currently documented anywhere.