fix(seo): не выводить прод-счётчики на dev-хостах, Clean-param для рекламных метк, dynamic URLs в JSON-LD

- functions.php: dekart_is_dev_host() + гейт для Яндекс.Метрики/GTM на dev/local
  (dev-трафик больше не попадает в прод-счётчик 99835482 под внутренним IP)
- robots.txt: Clean-param clckid/yclid/gclid/etext/y_ref (Webmaster INSIGNIFICANT_CGI_PARAMETER)
- page-elementary-school.php: захардкоженный домен заменён на home_url()
This commit is contained in:
Dekart Deploy Bot 2026-09-29 17:53:51 +00:00
parent 2d58edaedb
commit 460f87746e
3 changed files with 52 additions and 14 deletions

View File

@ -42,6 +42,7 @@ Disallow: /cabinet/
Clean-param: age&grade&sort&filter&view&sid&_openstat /
Clean-param: utm_source&utm_medium&utm_campaign&utm_content&utm_term&from /
Clean-param: ref&_openstat&sid /
Clean-param: clckid&yclid&gclid&etext&y_ref /
# Глобальная директива Sitemap (видна всем ботам)
Sitemap: https://schelkovo.dekart.school/sitemap_index.xml

View File

@ -3515,6 +3515,29 @@ function dekart_acf_delete_json($post_id)
// (ТОП-меню удалено; опции зарегистрированы в dekart_branch_group;
// вывод на фронте — те же хуки wp_head/wp_body_open/wp_footer)
// ─────────────────────────────────────────────────────────────
/**
* True on dev/local hosts — счётчики и трекеры на них не выводятся,
* чтобы dev-трафик не попадал в прод-Метрику/GA под внутренним IP
* (симптом: landing http://192.168.50.107:8081/ в целевом счётчике).
* Прод-домены (schelkovo/pushkino/balashiha.dekart.school, dekart-school.ru …) — не dev.
*/
function dekart_is_dev_host()
{
$host = isset($_SERVER['HTTP_HOST']) ? strtolower((string) $_SERVER['HTTP_HOST']) : '';
$host = preg_replace('/:\d+$/', '', $host); // strip port
if ($host === '') {
return true;
}
$dev_hosts = array('localhost', '127.0.0.1', '::1', '192.168.50.107');
if (in_array($host, $dev_hosts, true)) {
return true;
}
if (strpos($host, 'dev.') === 0 || substr($host, -6) === '.local') {
return true;
}
return (bool) filter_var($host, FILTER_VALIDATE_IP);
}
add_action('admin_init', 'dekart_counters_settings');
function dekart_counters_settings()
{
@ -3523,6 +3546,11 @@ function dekart_counters_settings()
register_setting('dekart_counters_group', 'dekart_counter_gtm_body');
register_setting('dekart_counters_group', 'dekart_counter_footer');
// На dev/local дефолтные прод-счётчики не заводим — не должны уехать в аналитику.
if (dekart_is_dev_host()) {
return;
}
$yandex_default = "<!-- Yandex.Metrika counter -->\n<script>\n (function(m,e,t,r,i,k,a){\n m[i]=m[i]||function(){(m[i].a=m[i].a||[]).push(arguments)};\n m[i].l=1*new Date();\n for (var j = 0; j < document.scripts.length; j++) {if (document.scripts[j].src === r) { return; }}\n k=e.createElement(t),a=e.getElementsByTagName(t)[0],k.async=1,k.src=r,a.parentNode.insertBefore(k,a)\n })(window, document,'script','https://mc.yandex.ru/metrika/tag.js', 'ym');\n\n ym(99835482, 'init', {webvisor:true, clickmap:true, referrer: document.referrer, url: location.href, accurateTrackBounce:true, trackLinks:true});\n</script>\n<!-- /Yandex.Metrika counter -->";
$gtm_head_default = "<!-- Google Tag Manager -->\n<script>\n(function(w,d,s,l,i){\n w[l]=w[l]||[];\n w[l].push({'gtm.start':new Date().getTime(),event:'gtm.js'});\n var f=d.getElementsByTagName(s)[0],\n j=d.createElement(s),\n dl=l!='dataLayer'?'&l='+l:'';\n j.async=true;\n j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;\n f.parentNode.insertBefore(j,f);\n})(window,document,'script','dataLayer','GTM-WJVZ4MKN');\n</script>\n<!-- /Google Tag Manager -->";
@ -3590,6 +3618,9 @@ function dekart_counters_page()
add_action('wp_head', 'dekart_output_counters', 1);
function dekart_output_counters()
{
if (dekart_is_dev_host()) {
return;
}
$yandex = stripslashes(get_option('dekart_counter_yandex', ''));
$gtmhead = stripslashes(get_option('dekart_counter_gtm_head', ''));
if ($yandex) {
@ -3603,6 +3634,9 @@ function dekart_output_counters()
add_action('wp_body_open', 'dekart_output_gtm_body', 1);
function dekart_output_gtm_body()
{
if (dekart_is_dev_host()) {
return;
}
$gtmbody = stripslashes(get_option('dekart_counter_gtm_body', ''));
if ($gtmbody) {
echo "\n" . $gtmbody . "\n";
@ -3612,6 +3646,9 @@ function dekart_output_gtm_body()
add_action('wp_footer', 'dekart_output_counters_footer', 100);
function dekart_output_counters_footer()
{
if (dekart_is_dev_host()) {
return;
}
$footer = stripslashes(get_option('dekart_counter_footer', ''));
if ($footer) {
echo "\n" . $footer . "\n";

View File

@ -72,31 +72,31 @@ $school_modified = get_the_modified_time('c', $post_id);
"@graph": [
{
"@type": "WebPage",
"@id": "https://schelkovo.dekart.school/nachalnaya-shkola/",
"url": "https://schelkovo.dekart.school/nachalnaya-shkola/",
"@id": "<?php echo esc_url(untrailingslashit(home_url())); ?>/nachalnaya-shkola/",
"url": "<?php echo esc_url(untrailingslashit(home_url())); ?>/nachalnaya-shkola/",
"name": "Частная начальная школа «Декарт» в Щелково: 1-4 классы",
"isPartOf": {"@id": "https://schelkovo.dekart.school/#website"},
"isPartOf": {"@id": "<?php echo esc_url(untrailingslashit(home_url())); ?>/#website"},
"datePublished": "<?php echo esc_attr($school_published); ?>",
"dateModified": "<?php echo esc_attr($school_modified); ?>",
"description": "Частная начальная школа «Декарт» в Щелково для учеников 1-4 классов. Углубленная программа, английский с 1 класса, классы до 12 человек. Запишитесь на экскурсию!",
"breadcrumb": {"@id": "https://schelkovo.dekart.school/nachalnaya-shkola/#breadcrumb"},
"breadcrumb": {"@id": "<?php echo esc_url(untrailingslashit(home_url())); ?>/nachalnaya-shkola/#breadcrumb"},
"inLanguage": "ru-RU",
"potentialAction": [
{
"@type": "ReadAction",
"target": ["https://schelkovo.dekart.school/nachalnaya-shkola/"]
"target": ["<?php echo esc_url(untrailingslashit(home_url())); ?>/nachalnaya-shkola/"]
}
]
},
{
"@type": "BreadcrumbList",
"@id": "https://schelkovo.dekart.school/nachalnaya-shkola/#breadcrumb",
"@id": "<?php echo esc_url(untrailingslashit(home_url())); ?>/nachalnaya-shkola/#breadcrumb",
"itemListElement": [
{
"@type": "ListItem",
"position": 1,
"name": "Главная страница",
"item": "https://schelkovo.dekart.school/"
"item": "<?php echo esc_url(untrailingslashit(home_url())); ?>/"
},
{
"@type": "ListItem",
@ -107,21 +107,21 @@ $school_modified = get_the_modified_time('c', $post_id);
},
{
"@type": "WebSite",
"@id": "https://schelkovo.dekart.school/#website",
"url": "https://schelkovo.dekart.school/",
"@id": "<?php echo esc_url(untrailingslashit(home_url())); ?>/#website",
"url": "<?php echo esc_url(untrailingslashit(home_url())); ?>/",
"name": "Частная школа Декарт",
"description": "Частная школа Декарт в Щелково",
"publisher": {"@id": "https://schelkovo.dekart.school/#organization"},
"publisher": {"@id": "<?php echo esc_url(untrailingslashit(home_url())); ?>/#organization"},
"inLanguage": "ru-RU"
},
{
"@type": ["School", "LocalBusiness"],
"@id": "https://schelkovo.dekart.school/#organization",
"@id": "<?php echo esc_url(untrailingslashit(home_url())); ?>/#organization",
"name": "Частная начальная школа «Декарт» в Щёлково",
"description": "Лицензированная начальная школа в Щёлково. Малые классы, углубленная программа, продленка и всестороннее развитие ребенка.",
"url": "https://schelkovo.dekart.school/nachalnaya-shkola/",
"logo": "https://schelkovo.dekart.school/wp-content/uploads/2025/04/2-1-1.jpg",
"image": "https://schelkovo.dekart.school/wp-content/uploads/2023/05/logo-dekart.png",
"url": "<?php echo esc_url(untrailingslashit(home_url())); ?>/nachalnaya-shkola/",
"logo": "<?php echo esc_url(untrailingslashit(home_url())); ?>/wp-content/uploads/2025/04/2-1-1.jpg",
"image": "<?php echo esc_url(untrailingslashit(home_url())); ?>/wp-content/uploads/2023/05/logo-dekart.png",
"telephone": "+79303334151",
"address": {
"@type": "PostalAddress",