fix
This commit is contained in:
@@ -78,6 +78,13 @@ add_action( 'wp_head', 'sev_tort_meta_tags', 1 );
|
||||
function sev_tort_meta_tags() {
|
||||
$page = sev_tort_current_page_config();
|
||||
|
||||
if ( is_front_page() ) {
|
||||
echo '<meta name="robots" content="index, follow">' . "\n";
|
||||
printf( '<meta name="description" content="%s">' . "\n", esc_attr( 'Торты на заказ в Севастополе с доставкой и самовывозом: бенто, детские, свадебные и праздничные торты. Подберем начинку, декор и рассчитаем стоимость после заявки.' ) );
|
||||
printf( '<link rel="canonical" href="%s">' . "\n", esc_url( home_url( '/' ) ) );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! $page ) {
|
||||
return;
|
||||
}
|
||||
@@ -98,6 +105,157 @@ function sev_tort_meta_tags() {
|
||||
printf( '<link rel="canonical" href="%s">' . "\n", esc_url( home_url( '/' . $page['slug'] . '/' ) ) );
|
||||
}
|
||||
|
||||
add_filter( 'wp_robots', 'sev_tort_wp_robots', 100 );
|
||||
function sev_tort_wp_robots( $robots ) {
|
||||
$page = sev_tort_current_page_config();
|
||||
|
||||
if ( is_front_page() || ( $page && ! empty( $page['indexable'] ) ) ) {
|
||||
unset( $robots['noindex'], $robots['nofollow'] );
|
||||
$robots['index'] = true;
|
||||
$robots['follow'] = true;
|
||||
$robots['max-image-preview'] = 'large';
|
||||
}
|
||||
|
||||
if ( $page && 'politika-konfidencialnosti' === $page['slug'] ) {
|
||||
unset( $robots['index'], $robots['follow'] );
|
||||
$robots['noindex'] = true;
|
||||
$robots['nofollow'] = true;
|
||||
}
|
||||
|
||||
return $robots;
|
||||
}
|
||||
|
||||
add_action( 'wp_head', 'sev_tort_schema_markup', 20 );
|
||||
function sev_tort_schema_markup() {
|
||||
$page = sev_tort_current_page_config();
|
||||
$schema = array();
|
||||
|
||||
$schema[] = array(
|
||||
'@context' => 'https://schema.org',
|
||||
'@type' => 'Bakery',
|
||||
'@id' => home_url( '/#bakery' ),
|
||||
'name' => 'Создаем повод для праздника',
|
||||
'description' => 'Кондитерская студия в Севастополе: торты на заказ, бенто-торты, детские, свадебные и праздничные торты с доставкой.',
|
||||
'url' => home_url( '/' ),
|
||||
'image' => get_stylesheet_directory_uri() . '/assets/images/hero/bento-hero-main.png',
|
||||
'telephone' => sev_tort_site_phone(),
|
||||
'priceRange' => 'от 2 300 ₽',
|
||||
'address' => array(
|
||||
'@type' => 'PostalAddress',
|
||||
'addressLocality' => 'Севастополь',
|
||||
'addressCountry' => 'RU',
|
||||
),
|
||||
'areaServed' => array(
|
||||
'@type' => 'City',
|
||||
'name' => 'Севастополь',
|
||||
),
|
||||
'openingHours' => 'Mo-Su 09:00-20:00',
|
||||
);
|
||||
|
||||
$schema[] = array(
|
||||
'@context' => 'https://schema.org',
|
||||
'@type' => 'WebSite',
|
||||
'@id' => home_url( '/#website' ),
|
||||
'name' => 'Торты на заказ в Севастополе',
|
||||
'url' => home_url( '/' ),
|
||||
'publisher' => array( '@id' => home_url( '/#bakery' ) ),
|
||||
'inLanguage' => 'ru-RU',
|
||||
);
|
||||
|
||||
if ( is_front_page() ) {
|
||||
$schema[] = sev_tort_faq_schema(
|
||||
array(
|
||||
array(
|
||||
'q' => 'За сколько дней лучше заказывать торт?',
|
||||
'a' => 'Оптимально оставить заявку за 2-4 дня до даты праздника. Срочные заказы возможны при свободном окне в графике.',
|
||||
),
|
||||
array(
|
||||
'q' => 'Можно ли сделать торт по фотографии или референсу?',
|
||||
'a' => 'Да, можно прислать фото, описание идеи, цветовую гамму и пожелания по надписи. После уточнения деталей предложим подходящий вариант.',
|
||||
),
|
||||
array(
|
||||
'q' => 'Есть ли доставка по Севастополю?',
|
||||
'a' => 'Да, доставляем по Севастополю в согласованный интервал. Также можно забрать заказ самостоятельно после подтверждения готовности.',
|
||||
),
|
||||
)
|
||||
);
|
||||
} elseif ( $page && ! empty( $page['indexable'] ) ) {
|
||||
$schema[] = array(
|
||||
'@context' => 'https://schema.org',
|
||||
'@type' => 'Service',
|
||||
'name' => $page['h1'],
|
||||
'description' => $page['description'],
|
||||
'provider' => array( '@id' => home_url( '/#bakery' ) ),
|
||||
'areaServed' => array(
|
||||
'@type' => 'City',
|
||||
'name' => 'Севастополь',
|
||||
),
|
||||
'offers' => array(
|
||||
'@type' => 'Offer',
|
||||
'priceCurrency' => 'RUB',
|
||||
'price' => '2300',
|
||||
'url' => home_url( '/' . $page['slug'] . '/' ),
|
||||
),
|
||||
);
|
||||
|
||||
$schema[] = array(
|
||||
'@context' => 'https://schema.org',
|
||||
'@type' => 'BreadcrumbList',
|
||||
'itemListElement' => array(
|
||||
array(
|
||||
'@type' => 'ListItem',
|
||||
'position' => 1,
|
||||
'name' => 'Главная',
|
||||
'item' => home_url( '/' ),
|
||||
),
|
||||
array(
|
||||
'@type' => 'ListItem',
|
||||
'position' => 2,
|
||||
'name' => $page['label'],
|
||||
'item' => home_url( '/' . $page['slug'] . '/' ),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
if ( ! empty( $page['content']['faq'] ) ) {
|
||||
$schema[] = sev_tort_faq_schema( $page['content']['faq'] );
|
||||
}
|
||||
}
|
||||
|
||||
foreach ( array_filter( $schema ) as $item ) {
|
||||
printf( '<script type="application/ld+json">%s</script>' . "\n", wp_json_encode( $item, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES ) );
|
||||
}
|
||||
}
|
||||
|
||||
function sev_tort_faq_schema( $items ) {
|
||||
$entities = array();
|
||||
|
||||
foreach ( $items as $item ) {
|
||||
if ( empty( $item['q'] ) || empty( $item['a'] ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$entities[] = array(
|
||||
'@type' => 'Question',
|
||||
'name' => $item['q'],
|
||||
'acceptedAnswer' => array(
|
||||
'@type' => 'Answer',
|
||||
'text' => $item['a'],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if ( ! $entities ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return array(
|
||||
'@context' => 'https://schema.org',
|
||||
'@type' => 'FAQPage',
|
||||
'mainEntity' => $entities,
|
||||
);
|
||||
}
|
||||
|
||||
add_action( 'wp_head', 'sev_tort_favicon_tags', 2 );
|
||||
function sev_tort_favicon_tags() {
|
||||
$favicon_uri = get_stylesheet_directory_uri() . '/assets/images/favicon/';
|
||||
@@ -114,6 +272,10 @@ add_filter( 'pre_get_document_title', 'sev_tort_document_title' );
|
||||
function sev_tort_document_title( $title ) {
|
||||
$page = sev_tort_current_page_config();
|
||||
|
||||
if ( is_front_page() ) {
|
||||
return 'Торты на заказ в Севастополе с доставкой — заказать торт';
|
||||
}
|
||||
|
||||
if ( ! $page ) {
|
||||
return $title;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user