Subir ajustes de acordeon y SEO
This commit is contained in:
@@ -157,30 +157,45 @@ class WP_Sitemaps {
|
||||
* Renders sitemap templates based on rewrite rules.
|
||||
*
|
||||
* @since 5.5.0
|
||||
*
|
||||
* @global WP_Query $wp_query WordPress Query object.
|
||||
*/
|
||||
public function render_sitemaps() {
|
||||
global $wp_query;
|
||||
/*
|
||||
* Bail early if this isn't a sitemap or stylesheet route.
|
||||
*
|
||||
* This runs on every front-end request, so it comes before any
|
||||
* sanitizing. The raw query vars are tested here, matching
|
||||
* WP::handle_404(), which exempts sitemap requests from its own 404 on
|
||||
* the same basis. Testing the sanitized values instead would let a
|
||||
* request that handle_404() exempted fall through both, leaving it a 200.
|
||||
*/
|
||||
if ( ! get_query_var( 'sitemap' ) && ! get_query_var( 'sitemap-stylesheet' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$sitemap = sanitize_text_field( get_query_var( 'sitemap' ) );
|
||||
$object_subtype = sanitize_text_field( get_query_var( 'sitemap-subtype' ) );
|
||||
$stylesheet_type = sanitize_text_field( get_query_var( 'sitemap-stylesheet' ) );
|
||||
$paged = absint( get_query_var( 'paged' ) );
|
||||
|
||||
// Bail early if this isn't a sitemap or stylesheet route.
|
||||
// Force a 404 and bail early if the route did not survive sanitizing.
|
||||
if ( ! ( $sitemap || $stylesheet_type ) ) {
|
||||
$this->send_404();
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! $this->sitemaps_enabled() ) {
|
||||
$wp_query->set_404();
|
||||
status_header( 404 );
|
||||
$this->send_404();
|
||||
return;
|
||||
}
|
||||
|
||||
// Render stylesheet if this is stylesheet route.
|
||||
if ( $stylesheet_type ) {
|
||||
// Force a 404 and bail early if the stylesheet type is not recognized.
|
||||
if ( ! in_array( $stylesheet_type, array( 'sitemap', 'index' ), true ) ) {
|
||||
$this->send_404();
|
||||
return;
|
||||
}
|
||||
|
||||
$stylesheet = new WP_Sitemaps_Stylesheet();
|
||||
|
||||
$stylesheet->render_stylesheet( $stylesheet_type );
|
||||
@@ -197,7 +212,9 @@ class WP_Sitemaps {
|
||||
|
||||
$provider = $this->registry->get_provider( $sitemap );
|
||||
|
||||
// Force a 404 and bail early if the requested provider is not registered.
|
||||
if ( ! $provider ) {
|
||||
$this->send_404();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -209,8 +226,7 @@ class WP_Sitemaps {
|
||||
|
||||
// Force a 404 and bail early if no URLs are present.
|
||||
if ( empty( $url_list ) ) {
|
||||
$wp_query->set_404();
|
||||
status_header( 404 );
|
||||
$this->send_404();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -218,6 +234,26 @@ class WP_Sitemaps {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a 404 for a sitemap route that cannot be served.
|
||||
*
|
||||
* WP::handle_404() exempts sitemap requests, so every sitemap 404 is issued
|
||||
* here instead. That includes the no-cache headers handle_404() sends with
|
||||
* its own 404, so an intermediary does not retain a 404 for a route that
|
||||
* becomes valid once the site has more content.
|
||||
*
|
||||
* @since 7.1.1
|
||||
*
|
||||
* @global WP_Query $wp_query WordPress Query object.
|
||||
*/
|
||||
private function send_404(): void {
|
||||
global $wp_query;
|
||||
|
||||
$wp_query->set_404();
|
||||
status_header( 404 );
|
||||
nocache_headers();
|
||||
}
|
||||
|
||||
/**
|
||||
* Redirects a URL to the wp-sitemap.xml
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user