Skip to content

Core-65593: Remove sitemap stylesheets - #12448

Closed
masteradhoc wants to merge 27 commits into
WordPress:trunkfrom
masteradhoc:xsl-stylesheet
Closed

masteradhoc wants to merge 27 commits into
WordPress:trunkfrom
masteradhoc:xsl-stylesheet

Conversation

@masteradhoc

@masteradhoc masteradhoc commented Jul 8, 2026 •

Copy link
Copy Markdown

Removes the sitemap XSL stylesheet feature from core. Chrome and other browsers are deprecating and removing XSLT support (https://developer.chrome.com/docs/web-platform/deprecating-xslt), so the <?xml-stylesheet?> processing instruction pointing at /wp-sitemap.xsl / /wp-sitemap-index.xsl will stop working for site visitors and no longer serves its purpose.

After this change, generated sitemap XML no longer includes a stylesheet processing instruction, and the /wp-sitemap.xsl and /wp-sitemap-index.xsl rewrite rules and the sitemap-stylesheet query var are removed.

Backward compatibility

  • WP_Sitemaps_Stylesheet is retained but deprecated. Each of its methods triggers a deprecation notice: render_stylesheet() sends a 410 Gone status and exits, and the others return an empty string.
  • WP_Sitemaps_Renderer::get_sitemap_stylesheet_url() and WP_Sitemaps_Renderer::get_sitemap_index_stylesheet_url() are deprecated and return an empty string.
  • The wp_sitemaps_stylesheet_url, wp_sitemaps_stylesheet_index_url, wp_sitemaps_stylesheet_content, wp_sitemaps_stylesheet_index_content and wp_sitemaps_stylesheet_css filters are deprecated and no longer have any effect. They are still applied when sitemap XML is generated, so a plugin that hooks one gets a deprecation notice rather than being silently ignored.

Trac ticket: https://core.trac.wordpress.org/ticket/65593

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Sonnet 5
Used for: Implementing the removal across WP_Sitemaps, WP_Sitemaps_Renderer, canonical.php, and wp-settings.php, deleting the obsolete WP_Sitemaps_Stylesheet class, and updating/removing the associated PHPUnit tests. All changes were reviewed and tested by me.

Follow-up commits by @westonruter also used Claude Code (Claude Opus 5.5) for the deprecation notices on the removed stylesheet filters and renderer URL methods, docblock fixes, and the accompanying tests. These were reviewed and directed by @westonruter.


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@masteradhoc masteradhoc changed the title remove sitemap stylesheets #65593: remove sitemap stylesheets Jul 8, 2026
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@masteradhoc
masteradhoc marked this pull request as ready for review July 8, 2026 08:36
@github-actions

github-actions Bot commented Jul 8, 2026 •

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props masteradhoc, peterwilsoncc, westonruter, pbiron.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@masteradhoc

Copy link
Copy Markdown
Author

@westonruter

This PR removes the XSLT-based sitemap stylesheet entirely. That aligns with Chrome's XSLT deprecation (https://developer.chrome.com/docs/web-platform/deprecating-xslt).

But: per Chrome's own docs, type="text/css" continues to be supported (see "XML + CSS is not being removed"). So there's an open question for core: do we want to keep some human-readable sitemap styling via a CSS-based , or is dropping styling altogether the intended outcome here?

@westonruter

Copy link
Copy Markdown
Member

Good question. Is CSS able to style the XML sufficiently?

@masteradhoc

Copy link
Copy Markdown
Author

@westonruter worth a try IMO. I'd though suggest we'll split it so we can first get rid of the existing implementation and then see if and what we want to style it moving forward.

@pbiron

pbiron commented Jul 15, 2026 •

Copy link
Copy Markdown

Good question. Is CSS able to style the XML sufficiently?

It's possible to style the XML with CSS, but it's not possible to make the "links" actually work. However, Chrome & Firefox (and other browsers, AFAIK) don't support XLink in generic XML documents (they do in SVG and MathML)...so it wouldn't be possible for a user to click on a link in the sitemap index to load a specific sitemap, nor to click on a link in a specific sitemap to get to that URL on the site.

@masteradhoc

Copy link
Copy Markdown
Author

@westonruter are we ready to move forward for now without styling?

@pbiron

pbiron commented Sep 10, 2026

Copy link
Copy Markdown

@masteradhoc @westonruter Have you seen the alternate PR I did that removes the need for browser-support of XSLT but still renders a human-readable version of the sitemaps by doing the XSLT server-side?

#12584

Comment thread src/wp-includes/sitemaps/class-wp-sitemaps-renderer.php
Comment thread src/wp-includes/sitemaps/class-wp-sitemaps-stylesheet.php
Comment thread src/wp-settings.php
Comment thread src/wp-includes/sitemaps/class-wp-sitemaps-stylesheet.php Outdated
Comment thread src/wp-includes/sitemaps/class-wp-sitemaps-renderer.php
Comment thread src/wp-includes/sitemaps/class-wp-sitemaps-renderer.php
Comment thread src/wp-includes/sitemaps/class-wp-sitemaps-stylesheet.php
masteradhoc and others added 3 commits September 12, 2026 21:42
Co-authored-by: Weston Ruter <westonruter@gmail.com>
Co-authored-by: Weston Ruter <westonruter@gmail.com>
@westonruter

Copy link
Copy Markdown
Member

There is a test failure:

1) Tests_Query_Vars::testPublicQueryVarsAreAsExpected
Care should be taken when introducing new public query vars. See https://core.trac.wordpress.org/ticket/35115
Failed asserting that two arrays are identical.
--- Expected
+++ Actual
@@ @@
     47 => 'rest_route'
     48 => 'sitemap'
     49 => 'sitemap-subtype'
+    50 => 'sitemap-stylesheet'
 )

Comment thread src/wp-includes/sitemaps/class-wp-sitemaps-renderer.php
Comment thread src/wp-includes/sitemaps/class-wp-sitemaps-stylesheet.php
@westonruter

Copy link
Copy Markdown
Member

All of the methods that now no-op should probably also get @since tags to document that they don't do anything anymore. It's one thing for functions to be deprecated, but often they still retain the old behavior. Here, however, the functionality is removed entirely. This should be made more clear in the docs.

@peterwilsoncc peterwilsoncc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a few notes inline but was repeating myself.

Each of the deprecated methods will need to call _deprecated_function( __METHOD__, '7.2.0' );

Comment thread src/wp-includes/sitemaps/class-wp-sitemaps-stylesheet.php Outdated
Comment thread src/wp-includes/sitemaps/class-wp-sitemaps-stylesheet.php
Comment thread src/wp-includes/sitemaps/class-wp-sitemaps-stylesheet.php
Comment thread src/wp-includes/sitemaps/class-wp-sitemaps-stylesheet.php
Comment thread src/wp-includes/sitemaps/class-wp-sitemaps-renderer.php
@masteradhoc

Copy link
Copy Markdown
Author

@westonruter @peterwilsoncc just saw this message displayed from chrome now by default if you still use XSLT

image

masteradhoc and others added 15 commits October 2, 2026 10:29
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The stylesheet filters were only applied in methods that core no longer
calls, and the two stylesheet content filters were not applied at all, so a
plugin's callback on any of them was silently ignored. Apply all five where
the sitemap and sitemap index XML is generated, so that a callback triggers a
deprecation notice. A filter with no callbacks triggers nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Call _deprecated_function() in WP_Sitemaps_Renderer::get_sitemap_stylesheet_url()
and get_sitemap_index_stylesheet_url(), matching the deprecated methods of
WP_Sitemaps_Stylesheet. Previously a direct call only triggered a notice if
a callback was added to the method's filter.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The $stylesheet and $stylesheet_index properties and the constructor of
WP_Sitemaps_Renderer had their original @SInCE 5.5.0 tags replaced by
@deprecated. Keep both, as is done for the deprecated methods.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Only the constructor's body was removed, not the class, and core still
instantiates WP_Sitemaps_Renderer. Tagging the constructor as deprecated
would cause IDEs and static analysis to flag every instantiation. Document
the change with a @SInCE 7.2.0 note instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Cover get_sitemap_stylesheet(), get_sitemap_index_stylesheet() and
get_stylesheet_css(), each of which must return an empty string and trigger
a deprecation notice. The previous tests for this class were removed along
with the stylesheet content filters they exercised.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The $stylesheet and $stylesheet_index properties are deprecated, not
repurposed, so keep their original descriptions and only add @deprecated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The methods of WP_Sitemaps_Stylesheet are deprecated, not repurposed, so
keep their original descriptions alongside the @deprecated tags.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread src/wp-includes/sitemaps/class-wp-sitemaps-renderer.php
@westonruter

Copy link
Copy Markdown
Member

Note: If it so happens that a cached XML Sitemap is served with the <?xml-stylesheet?> PI included, but an the XSL stylesheet itself is not cached, then Firefox shows an error because it fails to parse the XSL (since it is HTML, being the homepage response):

Screenshot 2026-10-02 at 16 38 27

I think this is an exceeding edge case, and it isn't much different from serving back a white screen as it would otherwise be doing now in the normal case.

@westonruter westonruter changed the title #65593: remove sitemap stylesheets Core-65593: Remove sitemap stylesheets Oct 3, 2026

@peterwilsoncc peterwilsoncc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a few notes inline, mainly the clarify that the filters don't do anything any more and possible test improvements.

Comment thread src/wp-includes/sitemaps/class-wp-sitemaps-renderer.php Outdated
Comment thread src/wp-includes/sitemaps/class-wp-sitemaps-renderer.php Outdated
Comment thread src/wp-includes/sitemaps/class-wp-sitemaps-renderer.php
Comment thread src/wp-includes/sitemaps/class-wp-sitemaps-renderer.php
Comment thread src/wp-includes/sitemaps/class-wp-sitemaps-stylesheet.php
Comment thread tests/phpunit/tests/sitemaps/wpSitemapsRenderer.php
Co-authored-by: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com>

@peterwilsoncc peterwilsoncc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've pushed my docblock suggestions and this is now ready for commit.

@peterwilsoncc peterwilsoncc added the props-bot Adding this label triggers the Props Bot workflow for a PR. label Oct 3, 2026
@github-actions github-actions Bot removed the props-bot Adding this label triggers the Props Bot workflow for a PR. label Oct 3, 2026
wporg-sync pushed a commit that referenced this pull request Oct 3, 2026
Browser support for client-side XSLT is being deprecated and removed. For sites including an XSL stylesheet, the display of the XML sitemaps may fail.

This removes the stylesheets in favour of allowing browsers to render them as they will.

This change deprecates:

* `WP_Sitemaps_Renderer::$stylesheet`
* `WP_Sitemaps_Renderer::$stylesheet_index`
* `WP_Sitemaps_Renderer::get_sitemap_stylesheet_url()`
* `WP_Sitemaps_Renderer::get_sitemap_index_stylesheet_url()`
* `WP_Sitemaps_Stylesheet` in its entirety
* the `sitemap-stylesheet` rewrite tag
* the `sitemap-stylesheet` query variable
* the `*.xls` rewrite rules
* the `wp_sitemaps_stylesheet_url` filter
* the `wp_sitemaps_stylesheet_index_url` filter
* the `wp_sitemaps_stylesheet_index_content` filter
* the `wp_sitemaps_stylesheet_content` filter
* the `wp_sitemaps_stylesheet_css` filter

The outcome of the deprecated filters is ignored, the filters are now only fired in order to provide deprecation notices to developers.

Developed in #12448

Props masteradhoc, pbiron, westonruter, peterwilsoncc.
Fixes #65593.


git-svn-id: https://develop.svn.wordpress.org/trunk@64073 602fd350-edb4-49c9-b593-d223f7449a82
@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown

A commit was made that fixes the Trac ticket referenced in the description of this pull request.

SVN changeset: 64073
GitHub commit: f4350cd

This PR will be closed, but please confirm the accuracy of this and reopen if there is more work to be done.

@github-actions github-actions Bot closed this Oct 3, 2026
wporg-sync pushed a commit to WordPress/WordPress that referenced this pull request Oct 3, 2026
Browser support for client-side XSLT is being deprecated and removed. For sites including an XSL stylesheet, the display of the XML sitemaps may fail.

This removes the stylesheets in favour of allowing browsers to render them as they will.

This change deprecates:

* `WP_Sitemaps_Renderer::$stylesheet`
* `WP_Sitemaps_Renderer::$stylesheet_index`
* `WP_Sitemaps_Renderer::get_sitemap_stylesheet_url()`
* `WP_Sitemaps_Renderer::get_sitemap_index_stylesheet_url()`
* `WP_Sitemaps_Stylesheet` in its entirety
* the `sitemap-stylesheet` rewrite tag
* the `sitemap-stylesheet` query variable
* the `*.xls` rewrite rules
* the `wp_sitemaps_stylesheet_url` filter
* the `wp_sitemaps_stylesheet_index_url` filter
* the `wp_sitemaps_stylesheet_index_content` filter
* the `wp_sitemaps_stylesheet_content` filter
* the `wp_sitemaps_stylesheet_css` filter

The outcome of the deprecated filters is ignored, the filters are now only fired in order to provide deprecation notices to developers.

Developed in WordPress/wordpress-develop#12448

Props masteradhoc, pbiron, westonruter, peterwilsoncc.
Fixes #65593.

Built from https://develop.svn.wordpress.org/trunk@64073


git-svn-id: http://core.svn.wordpress.org/trunk@63232 1a063a9b-81f0-0310-95a4-ce76da25c4cd
@masteradhoc
masteradhoc deleted the xsl-stylesheet branch October 3, 2026 06:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants