Skip to content
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
3 changes: 1 addition & 2 deletions src/wp-admin/includes/class-wp-site-icon.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ class WP_Site_Icon {
/*
* App icon for Android/Chrome.
*
* @link https://developers.google.com/web/updates/2014/11/Support-for-theme-color-in-Chrome-39-for-Android
* @link https://developer.chrome.com/multidevice/android/installtohomescreen
* @link https://developer.chrome.com/blog/support-for-theme-color-in-chrome-39-for-android

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

These are unrelated changes which could be opened in a separate PR for Core-65860.

*/
192,

Expand Down
21 changes: 21 additions & 0 deletions src/wp-includes/sitemaps/class-wp-sitemaps.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public function init() {

// Add additional action callbacks.
add_filter( 'robots_txt', array( $this, 'add_robots' ), 0, 2 );
add_filter( 'pre_handle_404', array( $this, 'prevent_sitemap_404' ), 10, 2 );
}

/**
Expand Down Expand Up @@ -263,4 +264,24 @@ public function add_robots( $output, $is_public ) {

return $output;
}

/**
* Prevents core from issuing a 404 status header on valid sitemap requests
* when no standard blog posts exist.
*
* @since 6.8.0

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

since 7.1.1

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

*
* @param bool $preempt Whether to short-circuit default 404 handling.
* @param WP_Query $query The global WP_Query object.
* @return bool True to preempt 404 handling if a valid sitemap route is requested, original $preempt otherwise.
*/
public function prevent_sitemap_404( $preempt, $query ) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
public function prevent_sitemap_404( $preempt, $query ) {
public function prevent_sitemap_404( $preempt, WP_Query $query ): bool {

I'm specifically not adding a type hint to $preempt because other plugins could provide something non-bool and cause a fatal error.

if ( $query->is_main_query() && get_query_var( 'sitemap' ) ) {
if ( $this->sitemaps_enabled() ) {
return true;
}
}
Comment on lines +279 to +283

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This can be simplified:

Suggested change
if ( $query->is_main_query() && get_query_var( 'sitemap' ) ) {
if ( $this->sitemaps_enabled() ) {
return true;
}
}
if (
$query->is_main_query() &&
get_query_var( 'sitemap' ) &&
$this->sitemaps_enabled()
) {
return true;
}


return $preempt;
}
}
Loading