sitemap
This commit is contained in:
@@ -17,8 +17,23 @@ function sev_tort_query_vars( $vars ) {
|
|||||||
return $vars;
|
return $vars;
|
||||||
}
|
}
|
||||||
|
|
||||||
add_action( 'template_redirect', 'sev_tort_static_seo_files', 0 );
|
add_filter( 'wp_sitemaps_enabled', '__return_false' );
|
||||||
|
|
||||||
|
add_filter( 'redirect_canonical', 'sev_tort_disable_static_seo_redirects', 10, 2 );
|
||||||
|
function sev_tort_disable_static_seo_redirects( $redirect_url, $requested_url ) {
|
||||||
|
if ( sev_tort_is_static_seo_path() ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $redirect_url;
|
||||||
|
}
|
||||||
|
|
||||||
|
add_action( 'init', 'sev_tort_static_seo_files', 0 );
|
||||||
function sev_tort_static_seo_files() {
|
function sev_tort_static_seo_files() {
|
||||||
|
if ( ! sev_tort_is_static_seo_path() ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$path = isset( $_SERVER['REQUEST_URI'] ) ? parse_url( wp_unslash( $_SERVER['REQUEST_URI'] ), PHP_URL_PATH ) : '';
|
$path = isset( $_SERVER['REQUEST_URI'] ) ? parse_url( wp_unslash( $_SERVER['REQUEST_URI'] ), PHP_URL_PATH ) : '';
|
||||||
$path = trim( (string) $path, '/' );
|
$path = trim( (string) $path, '/' );
|
||||||
|
|
||||||
@@ -35,6 +50,13 @@ function sev_tort_static_seo_files() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function sev_tort_is_static_seo_path() {
|
||||||
|
$path = isset( $_SERVER['REQUEST_URI'] ) ? parse_url( wp_unslash( $_SERVER['REQUEST_URI'] ), PHP_URL_PATH ) : '';
|
||||||
|
$path = trim( (string) $path, '/' );
|
||||||
|
|
||||||
|
return in_array( $path, array( 'sitemap.xml', 'sitemap_index.xml', 'robots.txt' ), true );
|
||||||
|
}
|
||||||
|
|
||||||
function sev_tort_send_sitemap_index() {
|
function sev_tort_send_sitemap_index() {
|
||||||
status_header( 200 );
|
status_header( 200 );
|
||||||
header( 'Content-Type: application/xml; charset=UTF-8' );
|
header( 'Content-Type: application/xml; charset=UTF-8' );
|
||||||
|
|||||||
Reference in New Issue
Block a user