diff --git a/wp-content/themes/sevastopol-tort-child/inc/routes.php b/wp-content/themes/sevastopol-tort-child/inc/routes.php
index 788a8b8..04ac2e9 100644
--- a/wp-content/themes/sevastopol-tort-child/inc/routes.php
+++ b/wp-content/themes/sevastopol-tort-child/inc/routes.php
@@ -17,6 +17,97 @@ function sev_tort_query_vars( $vars ) {
return $vars;
}
+add_action( 'template_redirect', 'sev_tort_static_seo_files', 0 );
+function sev_tort_static_seo_files() {
+ $path = isset( $_SERVER['REQUEST_URI'] ) ? parse_url( wp_unslash( $_SERVER['REQUEST_URI'] ), PHP_URL_PATH ) : '';
+ $path = trim( (string) $path, '/' );
+
+ if ( 'sitemap_index.xml' === $path ) {
+ sev_tort_send_sitemap_index();
+ }
+
+ if ( 'sitemap.xml' === $path ) {
+ sev_tort_send_sitemap();
+ }
+
+ if ( 'robots.txt' === $path ) {
+ sev_tort_send_robots();
+ }
+}
+
+function sev_tort_send_sitemap_index() {
+ status_header( 200 );
+ header( 'Content-Type: application/xml; charset=UTF-8' );
+
+ echo '' . "\n";
+ echo '' . "\n";
+ echo "\t" . '' . "\n";
+ echo "\t\t" . '' . esc_url( home_url( '/sitemap.xml' ) ) . '' . "\n";
+ echo "\t\t" . '' . esc_html( gmdate( 'Y-m-d' ) ) . '' . "\n";
+ echo "\t" . '' . "\n";
+ echo '';
+ exit;
+}
+
+function sev_tort_send_sitemap() {
+ status_header( 200 );
+ header( 'Content-Type: application/xml; charset=UTF-8' );
+
+ $pages = sev_tort_pages();
+ $urls = array(
+ array(
+ 'loc' => home_url( '/' ),
+ 'changefreq' => 'weekly',
+ 'priority' => '1.0',
+ ),
+ );
+
+ foreach ( $pages as $page ) {
+ if ( empty( $page['indexable'] ) ) {
+ continue;
+ }
+
+ $priority = in_array( $page['slug'], array( 'torty-na-zakaz', 'bento', 'detskie', 'svadebnye', 'na-den-rozhdeniya', 'ceny' ), true ) ? '0.9' : '0.8';
+
+ $urls[] = array(
+ 'loc' => home_url( '/' . $page['slug'] . '/' ),
+ 'changefreq' => 'weekly',
+ 'priority' => $priority,
+ );
+ }
+
+ echo '' . "\n";
+ echo '' . "\n";
+
+ foreach ( $urls as $url ) {
+ echo "\t" . '' . "\n";
+ echo "\t\t" . '' . esc_url( $url['loc'] ) . '' . "\n";
+ echo "\t\t" . '' . esc_html( gmdate( 'Y-m-d' ) ) . '' . "\n";
+ echo "\t\t" . '' . esc_html( $url['changefreq'] ) . '' . "\n";
+ echo "\t\t" . '' . esc_html( $url['priority'] ) . '' . "\n";
+ echo "\t" . '' . "\n";
+ }
+
+ echo '';
+ exit;
+}
+
+function sev_tort_send_robots() {
+ status_header( 200 );
+ header( 'Content-Type: text/plain; charset=UTF-8' );
+
+ echo "User-agent: *\n";
+ echo "Disallow: /wp-admin/\n";
+ echo "Allow: /wp-admin/admin-ajax.php\n";
+ echo "Disallow: /wp-includes/\n";
+ echo "Disallow: /wp-content/plugins/\n";
+ echo "Disallow: /wp-content/cache/\n";
+ echo "Disallow: /wp-json/\n";
+ echo "Disallow: /*?s=\n\n";
+ echo 'Sitemap: ' . esc_url( home_url( '/sitemap.xml' ) ) . "\n";
+ exit;
+}
+
add_action( 'template_redirect', 'sev_tort_route_status' );
function sev_tort_route_status() {
if ( sev_tort_current_page_config() ) {