Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
1ddd28f
remove sitemap stylesheets
masteradhoc Jul 8, 2026
b4906d4
adjust peters comments
masteradhoc Sep 12, 2026
70e80b9
resolve conflict for class-wp-sitemaps.php
masteradhoc Sep 12, 2026
15d8b63
Merge branch 'trunk' into xsl-stylesheet
masteradhoc Sep 12, 2026
99baabe
fix phpstan error
masteradhoc Sep 12, 2026
6018a1f
restore filter
masteradhoc Sep 12, 2026
78a50fb
add deprecated filter
masteradhoc Sep 12, 2026
8a028f2
Merge branch 'trunk' into xsl-stylesheet
masteradhoc Sep 17, 2026
2fe9900
Restore deprecation notices and docblocks for stylesheet no-op methods.
masteradhoc Sep 17, 2026
addf922
Merge branch 'trunk' into xsl-stylesheet
peterwilsoncc Oct 1, 2026
5f563fd
Merge branch 'trunk' into xsl-stylesheet
masteradhoc Oct 2, 2026
f2cf82d
update patch and stylesheet routes
masteradhoc Oct 2, 2026
bb3fd50
rework tests
masteradhoc Oct 2, 2026
ee2d87e
Regenerate PHPStan baselines
westonruter Oct 2, 2026
32e72e3
Send 410 Gone status code when calling render_stylesheet()
westonruter Oct 2, 2026
4455d16
Unset unused param
westonruter Oct 2, 2026
3c49b02
Remove duplicate @since tag from render_stylesheet() docblock
westonruter Oct 2, 2026
8fee4be
Trigger deprecation notices for removed sitemap stylesheet filters
westonruter Oct 2, 2026
69a1332
Mark sitemap stylesheet URL methods as deprecated at runtime
westonruter Oct 2, 2026
4c3ac9e
Restore @since tags on deprecated sitemap renderer members
westonruter Oct 2, 2026
43f62af
Remove @deprecated tag from WP_Sitemaps_Renderer constructor
westonruter Oct 2, 2026
33a9334
Add tests for deprecated WP_Sitemaps_Stylesheet methods
westonruter Oct 2, 2026
e691347
Restore original descriptions of deprecated sitemap renderer properties
westonruter Oct 3, 2026
6839dd5
Use string literal enum for sitemap type
westonruter Oct 3, 2026
82cba66
Restore original descriptions of deprecated sitemap stylesheet methods
westonruter Oct 3, 2026
5252775
Note filter outcomes ignored.
peterwilsoncc Oct 3, 2026
d59474d
Merge branch 'trunk' into xsl-stylesheet
peterwilsoncc Oct 3, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/wp-includes/canonical.php
Original file line number Diff line number Diff line change
Expand Up @@ -707,9 +707,7 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) {
}

// Remove trailing slash for robots.txt or sitemap requests.
if ( is_robots()
|| ! empty( get_query_var( 'sitemap' ) ) || ! empty( get_query_var( 'sitemap-stylesheet' ) )
) {
if ( is_robots() || ! empty( get_query_var( 'sitemap' ) ) ) {
$redirect['path'] = untrailingslashit( $redirect['path'] );
}

Expand Down
2 changes: 1 addition & 1 deletion src/wp-includes/class-wp.php
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@ public function handle_404() {

// Never 404 here for the admin, robots, favicon, or sitemaps.
// Sitemap routes send their own status in WP_Sitemaps::render_sitemaps().
if ( is_admin() || is_robots() || is_favicon() || is_sitemap() || get_query_var( 'sitemap-stylesheet' ) ) {
if ( is_admin() || is_robots() || is_favicon() || is_sitemap() ) {
$set_404 = false;

// If posts were found, check for paged content.
Expand Down
119 changes: 78 additions & 41 deletions src/wp-includes/sitemaps/class-wp-sitemaps-renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class WP_Sitemaps_Renderer {
* XSL stylesheet for styling a sitemap for web browsers.
*
* @since 5.5.0
* @deprecated 7.2.0 Stylesheets are no longer supported.
*
* @var string
*/
Expand All @@ -29,6 +30,7 @@ class WP_Sitemaps_Renderer {
* XSL stylesheet for styling a sitemap for web browsers.
*
* @since 5.5.0
* @deprecated 7.2.0 Stylesheets are no longer supported.
*
* @var string
*/
Expand All @@ -38,81 +40,64 @@ class WP_Sitemaps_Renderer {
* WP_Sitemaps_Renderer constructor.
*
* @since 5.5.0
* @since 7.2.0 No longer sets up the stylesheets, which are no longer supported.
*/
public function __construct() {
$stylesheet_url = $this->get_sitemap_stylesheet_url();

if ( $stylesheet_url ) {
$this->stylesheet = '<?xml-stylesheet type="text/xsl" href="' . esc_url( $stylesheet_url ) . '" ?>';
}

$stylesheet_index_url = $this->get_sitemap_index_stylesheet_url();

if ( $stylesheet_index_url ) {
$this->stylesheet_index = '<?xml-stylesheet type="text/xsl" href="' . esc_url( $stylesheet_index_url ) . '" ?>';
}
}
public function __construct() {}

/**
* Gets the URL for the sitemap stylesheet.
*
* @since 5.5.0
* @deprecated 7.2.0 Stylesheets are no longer supported.
*
* @global WP_Rewrite $wp_rewrite WordPress rewrite component.
*
* @return string The sitemap stylesheet URL.
* @return string Empty string.
*/
public function get_sitemap_stylesheet_url() {
Comment thread
masteradhoc marked this conversation as resolved.
global $wp_rewrite;

$sitemap_url = home_url( '/wp-sitemap.xsl' );

if ( ! $wp_rewrite->using_permalinks() ) {
$sitemap_url = home_url( '/?sitemap-stylesheet=sitemap' );
}
_deprecated_function( __METHOD__, '7.2.0' );

/**
* Filters the URL for the sitemap stylesheet.
*
* If a falsey value is returned, no stylesheet will be used and
* the "raw" XML of the sitemap will be displayed.
* Following the deprecation of XSLT by browser manufacturers the
* outcome of this filter is ignored.
*
* @since 5.5.0
* @deprecated 7.2.0 Stylesheets are no longer supported.
*
* @param string $sitemap_url Full URL for the sitemaps XSL file.
*/
return apply_filters( 'wp_sitemaps_stylesheet_url', $sitemap_url );
apply_filters_deprecated( 'wp_sitemaps_stylesheet_url', array( '' ), '7.2.0' );

return '';
Comment thread
masteradhoc marked this conversation as resolved.
}

/**
* Gets the URL for the sitemap index stylesheet.
*
* @since 5.5.0
* @deprecated 7.2.0 Stylesheets are no longer supported.
*
* @global WP_Rewrite $wp_rewrite WordPress rewrite component.
*
* @return string The sitemap index stylesheet URL.
* @return string Empty string.
*/
public function get_sitemap_index_stylesheet_url() {
global $wp_rewrite;

$sitemap_url = home_url( '/wp-sitemap-index.xsl' );

if ( ! $wp_rewrite->using_permalinks() ) {
$sitemap_url = home_url( '/?sitemap-stylesheet=index' );
}
_deprecated_function( __METHOD__, '7.2.0' );

/**
* Filters the URL for the sitemap index stylesheet.
*
* If a falsey value is returned, no stylesheet will be used and
* the "raw" XML of the sitemap index will be displayed.
* Following the deprecation of XSLT by browser manufacturers the
* outcome of this filter is ignored.
*
* @since 5.5.0
* @deprecated 7.2.0 Stylesheets are no longer supported.
*
* @param string $sitemap_url Full URL for the sitemaps index XSL file.
*/
return apply_filters( 'wp_sitemaps_stylesheet_index_url', $sitemap_url );
apply_filters_deprecated( 'wp_sitemaps_stylesheet_index_url', array( '' ), '7.2.0' );
Comment thread
masteradhoc marked this conversation as resolved.
Comment thread
masteradhoc marked this conversation as resolved.

return '';
}

/**
Expand Down Expand Up @@ -144,11 +129,12 @@ public function render_index( $sitemaps ) {
* @return string|false A well-formed XML string for a sitemap index. False on error.
*/
public function get_sitemap_index_xml( $sitemaps ) {
$this->apply_deprecated_stylesheet_filters( 'index' );

$sitemap_index = new SimpleXMLElement(
sprintf(
'%1$s%2$s%3$s',
'%1$s%2$s',
'<?xml version="1.0" encoding="UTF-8" ?>',
$this->stylesheet_index,
'<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" />'
)
);
Expand Down Expand Up @@ -208,11 +194,12 @@ public function render_sitemap( $url_list ) {
* @return string|false A well-formed XML string for a sitemap index. False on error.
*/
public function get_sitemap_xml( $url_list ) {
$this->apply_deprecated_stylesheet_filters( 'sitemap' );

$urlset = new SimpleXMLElement(
sprintf(
'%1$s%2$s%3$s',
'%1$s%2$s',
'<?xml version="1.0" encoding="UTF-8" ?>',
$this->stylesheet,
'<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" />'
)
);
Expand Down Expand Up @@ -243,6 +230,56 @@ public function get_sitemap_xml( $url_list ) {
return $urlset->asXML();
}

/**
* Applies the removed stylesheet filters so that their callbacks trigger deprecation notices.
*
* The stylesheet filters no longer have any effect. Applying them where a sitemap is
* generated ensures a callback still added to one is reported rather than silently ignored.
* No notice is triggered for a filter that has no callbacks.
*
* @since 7.2.0
*
* @param 'sitemap'|'index' $type Sitemap type.
*/
private function apply_deprecated_stylesheet_filters( string $type ): void {
if ( 'index' === $type ) {
/** This filter is documented in wp-includes/sitemaps/class-wp-sitemaps-renderer.php */
apply_filters_deprecated( 'wp_sitemaps_stylesheet_index_url', array( '' ), '7.2.0' );

/**
* Filters the content of the sitemap index stylesheet.
*
* Following the deprecation of XSLT by browser manufacturers the
* outcome of this filter is ignored.
*
* @since 5.5.0
Comment thread
peterwilsoncc marked this conversation as resolved.
* @deprecated 7.2.0 Stylesheets are no longer supported.
*
* @param string $xsl_content Full content for the XML stylesheet.
*/
apply_filters_deprecated( 'wp_sitemaps_stylesheet_index_content', array( '' ), '7.2.0' );
} else {
/** This filter is documented in wp-includes/sitemaps/class-wp-sitemaps-renderer.php */
apply_filters_deprecated( 'wp_sitemaps_stylesheet_url', array( '' ), '7.2.0' );

/**
* Filters the content of the sitemap stylesheet.
*
* Following the deprecation of XSLT by browser manufacturers the
* outcome of this filter is ignored.
*
* @since 5.5.0
Comment thread
peterwilsoncc marked this conversation as resolved.
* @deprecated 7.2.0 Stylesheets are no longer supported.
*
* @param string $xsl_content Full content for the XML stylesheet.
*/
apply_filters_deprecated( 'wp_sitemaps_stylesheet_content', array( '' ), '7.2.0' );
}

/** This filter is documented in wp-includes/sitemaps/class-wp-sitemaps-stylesheet.php */
apply_filters_deprecated( 'wp_sitemaps_stylesheet_css', array( '' ), '7.2.0' );
}

/**
* Checks for the availability of the SimpleXML extension and errors if missing.
*
Expand Down
Loading
Loading