Yoast\WP\SEO\Initializers
Disable_Core_Sitemaps::template_redirect
Redirects requests to the WordPress sitemap to the Yoast sitemap.
Метод класса: Disable_Core_Sitemaps{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
$Disable_Core_Sitemaps = new Disable_Core_Sitemaps(); $Disable_Core_Sitemaps->template_redirect();
Код Disable_Core_Sitemaps::template_redirect() Disable Core Sitemaps::template redirect Yoast 27.6
public function template_redirect() {
// If there is no path, nothing to do.
if ( empty( $_SERVER['REQUEST_URI'] ) ) {
return;
}
$path = \sanitize_text_field( \wp_unslash( $_SERVER['REQUEST_URI'] ) );
// If it's not a wp-sitemap request, nothing to do.
if ( \substr( $path, 0, 11 ) !== '/wp-sitemap' ) {
return;
}
$redirect = $this->get_redirect_url( $path );
if ( ! $redirect ) {
return;
}
$this->redirect->do_safe_redirect( \home_url( $redirect ), 301 );
}