From ad66d75abb68fd6164159180c97a627abc590ed5 Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 17 Jul 2025 19:50:48 +0300 Subject: [PATCH] =?UTF-8?q?Task:7359=20|=20=D0=94=D0=BE=D0=B1=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BA=D1=83?= =?UTF-8?q?=20=D1=82=D0=B5=D1=81=D1=82=D0=B0=20=D0=B2=20=D0=BA=D0=BB=D0=B0?= =?UTF-8?q?=D1=81=D1=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../global-functions/multisite-functions.php | 38 +++++++++---------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/wp-content/themes/cosmopet/global-functions/multisite-functions.php b/wp-content/themes/cosmopet/global-functions/multisite-functions.php index e263ce4..60c0108 100644 --- a/wp-content/themes/cosmopet/global-functions/multisite-functions.php +++ b/wp-content/themes/cosmopet/global-functions/multisite-functions.php @@ -5,9 +5,10 @@ global $site_env; $site_env = new SiteEnvironment(); // глобальный объект выполняющий проверку по домену class SiteEnvironment { - public string $mode; - public string $region; - + public string $site_mode; + public string $site_region; + public bool $is_gp_test_mode; + public function __construct(string $host = null) { $map = [ @@ -23,12 +24,15 @@ class SiteEnvironment $this->site_mode = $config['mode']; $this->site_region = $config['region']; - } + // Логика тестового режима + $this->is_gp_test_mode = (isset($_GET['gp-test']) && $_GET['gp-test'] == '1') || (is_user_logged_in() && current_user_can('administrator')); + } } + add_filter('timber/twig', function (\Twig\Environment $twig) { global $site_env; @@ -76,27 +80,17 @@ function custom_canonical_url() { } /** - * Добавление событий контрибуции для FP Pixel - * только на боевом сайте АЕ + * Добавление событий контрибуции для FP Pixel + * Только на боевом сайте AE, с учетом тестового режима через site_env->is_gp_test_mode */ -// if ($site_env->site_mode == 'production' && $site_env->site_region == 'ae') { - // Проверка на тестовый режим для метрик - function is_gp_test_mode() { - if (isset($_GET['gp-test']) && $_GET['gp-test'] == '1') { - return true; - } - if (is_user_logged_in() && current_user_can('administrator')) { - return true; - } - return false; - } +if (isset($site_env) && $site_env->site_mode === 'production' && $site_env->site_region === 'ae' && !$site_env->is_gp_test_mode) { add_action('wp_footer', 'add_facebook_pixel_events'); function add_facebook_pixel_events() { - if (is_gp_test_mode()) return; + global $site_env, $product; - global $product; + if ($site_env->is_gp_test_mode) return; // 1. ViewContent if (is_product() && $product && $product->get_price() > 0) { @@ -237,7 +231,8 @@ function custom_canonical_url() { add_action('woocommerce_thankyou', 'send_purchase_to_metrika'); function send_purchase_to_metrika($order_id) { - if (is_gp_test_mode()) return; + global $site_env; + if ($site_env->is_gp_test_mode) return; if (!$order_id) return; @@ -288,7 +283,8 @@ function custom_canonical_url() {