Sitemaps: Pass full paths to home_url() calls.

This makes it easier for plugins using the `home_url` filter to detect sitemap URLs.

Props Chouby.
Fixes #50592.
Built from https://develop.svn.wordpress.org/trunk@48470


git-svn-id: http://core.svn.wordpress.org/trunk@48239 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Pascal Birchler 2020-07-14 11:43:03 +00:00
parent cc32e7f753
commit 66c6ad97bc
4 changed files with 17 additions and 28 deletions

View File

@ -75,7 +75,7 @@ class WP_Sitemaps_Index {
global $wp_rewrite; global $wp_rewrite;
if ( ! $wp_rewrite->using_permalinks() ) { if ( ! $wp_rewrite->using_permalinks() ) {
return add_query_arg( 'sitemap', 'index', home_url( '/' ) ); return home_url( '/?sitemap=index' );
} }
return home_url( '/wp-sitemap.xml' ); return home_url( '/wp-sitemap.xml' );

View File

@ -145,35 +145,24 @@ abstract class WP_Sitemaps_Provider {
public function get_sitemap_url( $name, $page ) { public function get_sitemap_url( $name, $page ) {
global $wp_rewrite; global $wp_rewrite;
if ( ! $wp_rewrite->using_permalinks() ) { // Accounts for cases where name is not included, ex: sitemaps-users-1.xml.
return add_query_arg( $params = array_filter(
// Accounts for cases where name is not included, ex: sitemaps-users-1.xml. array(
array_filter( 'sitemap' => $this->name,
array( 'sitemap-subtype' => $name,
'sitemap' => $this->name, 'paged' => $page,
'sitemap-subtype' => $name, )
'paged' => $page, );
)
),
home_url( '/' )
);
}
$basename = sprintf( $basename = sprintf(
'/wp-sitemap-%1$s.xml', '/wp-sitemap-%1$s.xml',
implode( implode( '-', $params )
'-',
// Accounts for cases where name is not included, ex: sitemaps-users-1.xml.
array_filter(
array(
$this->name,
$name,
(string) $page,
)
)
)
); );
if ( ! $wp_rewrite->using_permalinks() ) {
$basename = '/?' . http_build_query( $params, null, '&' );
}
return home_url( $basename ); return home_url( $basename );
} }

View File

@ -67,7 +67,7 @@ class WP_Sitemaps_Renderer {
$sitemap_url = home_url( '/wp-sitemap.xsl' ); $sitemap_url = home_url( '/wp-sitemap.xsl' );
if ( ! $wp_rewrite->using_permalinks() ) { if ( ! $wp_rewrite->using_permalinks() ) {
$sitemap_url = add_query_arg( 'sitemap-stylesheet', 'sitemap', home_url( '/' ) ); $sitemap_url = home_url( '/?sitemap-stylesheet=sitemap' );
} }
/** /**
@ -98,7 +98,7 @@ class WP_Sitemaps_Renderer {
$sitemap_url = home_url( '/wp-sitemap-index.xsl' ); $sitemap_url = home_url( '/wp-sitemap-index.xsl' );
if ( ! $wp_rewrite->using_permalinks() ) { if ( ! $wp_rewrite->using_permalinks() ) {
$sitemap_url = add_query_arg( 'sitemap-stylesheet', 'index', home_url( '/' ) ); $sitemap_url = home_url( '/?sitemap-stylesheet=index' );
} }
/** /**

View File

@ -13,7 +13,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '5.5-beta1-48469'; $wp_version = '5.5-beta1-48470';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.