Yoast\WP\SEO\Initializers
Disable_Core_Sitemaps::get_redirect_url()
Returns the relative sitemap URL to redirect to.
Метод класса: Disable_Core_Sitemaps{}
Хуков нет.
Возвращает
Строку|false
. The path to redirct to. False if no redirect should be done.
Использование
// private - только в коде основоного (родительского) класса $result = $this->get_redirect_url( $path );
- $path(строка) (обязательный)
- The original path.
Код Disable_Core_Sitemaps::get_redirect_url() Disable Core Sitemaps::get redirect url Yoast 22.4
private function get_redirect_url( $path ) { // Start with the simple string comparison so we avoid doing unnecessary regexes. if ( $path === '/wp-sitemap.xml' ) { return '/sitemap_index.xml'; } if ( \preg_match( '/^\/wp-sitemap-(posts|taxonomies)-(\w+)-(\d+)\.xml$/', $path, $matches ) ) { $index = ( (int) $matches[3] - 1 ); $index = ( $index === 0 ) ? '' : (string) $index; return '/' . $matches[2] . '-sitemap' . $index . '.xml'; } if ( \preg_match( '/^\/wp-sitemap-users-(\d+)\.xml$/', $path, $matches ) ) { $index = ( (int) $matches[1] - 1 ); $index = ( $index === 0 ) ? '' : (string) $index; return '/author-sitemap' . $index . '.xml'; } return false; }