[wp-trac] [WordPress Trac] #51280: wp_register_sitemap_provider() breaks sitemap functionality if provider name contains a dash (-)

WordPress Trac noreply at wordpress.org
Wed Sep 9 16:32:32 UTC 2020


#51280: wp_register_sitemap_provider() breaks sitemap functionality if provider
name contains a dash (-)
--------------------------+-----------------------------
 Reporter:  MadtownLems   |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Sitemaps      |    Version:
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 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 )

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/51280>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list