Opened 5 years ago
Closed 5 years ago
#50592 closed defect (bug) (fixed)
Sitemaps: Pass full paths to home_url()
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 5.5 | Priority: | normal |
| Severity: | normal | Version: | 5.5 |
| Component: | Sitemaps | Keywords: | has-patch commit |
| Focuses: | Cc: |
Description (last modified by )
When using plain permalinks, WP_Sitemaps_Index::get_index_url() builds the sitemap index url like this:
add_query_arg( 'sitemap', 'index', home_url( '/' ) );
There is no issue on a fresh install but it causes issues with plugins or themes using the filter home_url. Any function hooked to this filter will interpret that the url being built is the homepage url when it's actually the sitemap index url which is being built.
I propose to change this to:
home_url( '/?sitemap=index' );
The result should be the same for WordPress but would be less confusing for users of the home_url filter.
I noticed 2 other similar constructions in: https://github.com/WordPress/WordPress/blob/fe823d698f5e57135c102e02d7e23d4019ac59d5/wp-includes/sitemaps/class-wp-sitemaps-renderer.php#L70 and https://github.com/WordPress/WordPress/blob/fe823d698f5e57135c102e02d7e23d4019ac59d5/wp-includes/sitemaps/class-wp-sitemaps-renderer.php#L101
For information, I looked at other places of WordPress how is handled this type of case, and I found:
$permalink = home_url( '?p=' . $post->ID );inget_permalink().$link = home_url( '?page_id=' . $post->ID );in_get_page_link().