Skip to content
This repository was archived by the owner on Sep 14, 2021. It is now read-only.
This repository was archived by the owner on Sep 14, 2021. It is now read-only.

extension elements in sitemaps #151

@pbiron

Description

@pbiron

extension elements in sitemaps

Describe the bug

#88 added filters that allow extension elements to be added to sitemaps (e.g., core_sitemaps_posts_url_list).

However, there are a couple of problems with the solution:

  1. Core_Sitemaps_Renderer::get_sitemap_xml() outputs all elements in the sitemaps namespace (i.e., http://www.sitemaps.org/schemas/sitemap/0.9) and the sitemaps XML Schema specifies that any element children of sitemap:url other than sitemap:loc, sitemap:lastmod, sitemap:changefreq and sitemap:priority must be in another namespace (where sitemap:xyz is a QName for an element whose local-name() is xyz and whose namespace-uri() is the sitemaps namespace URI). Therefore, if a plugin hooks into core_sitemaps_posts_url_list and adds a foo property to each URL in the list, the generated sitemap XML will be invalid against the XML Schema. There is currently no way for a plugin to tell the renderer what namespace to use for these extension elements.
  2. The sitemaps XML Schema also specifies that the child elements of sitemap:url must be in the order above, with all elements in a foreign namespace coming at the end. So, if a plugin hooks into core_sitemaps_posts_url_list and does something like foreach ( $url_list as $url ) { $url = array_merge( array( 'priority' => 0.9 ), $url ); } then Core_Sitemaps_Renderer::get_sitemap_xml() will output a sitemap that is invalid against the XML Schema.

I do not know whether sitemap consumers (e.g., Google, Bing, Yandex, etc) would fail to process a sitemap that was invalid against the XML Schema, but do we want to try our best to ensure that generated sitemaps are valid?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: BugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions