Task 6591 | fix: Макс пофиксил проверку вывода скриптов, чтоб они в тестовом режиме не выводились, так же почистил лишний код

dev_10_fixbugs
parent 287dc111c7
commit e1542909fa
  1. 34
      wp-content/themes/cosmopet/global-functions/multisite-functions.php
  2. 32
      wp-content/themes/cosmopet/temp-functions/blog-logic.php
  3. 20
      wp-content/themes/cosmopet/temp-functions/filters-logic.php
  4. 2
      wp-content/themes/cosmopet/templates/layout.twig

@ -82,30 +82,6 @@ function custom_canonical_url() {
}
}
add_action('wp_head', 'add_facebook_pixel');
function add_facebook_pixel() {
?>
<!-- Meta Pixel Code -->
<script>
!function(f,b,e,v,n,t,s)
{if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};
if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];
s.parentNode.insertBefore(t,s)}(window, document,'script',
'https://connect.facebook.net/en_US/fbevents.js');
fbq('init', '1791804684725971');
fbq('track', 'PageView');
</script>
<noscript>
<img height="1" width="1" style="display:none"
src="https://www.facebook.com/tr?id=1791804684725971&ev=PageView&noscript=1"/>
</noscript>
<!-- End Meta Pixel Code -->
<?php
}
add_action('woocommerce_thankyou', 'send_purchase_to_metrika');
function send_purchase_to_metrika($order_id) {
if (!$order_id) return; // Проверка, что заказ существует
@ -161,7 +137,13 @@ function send_purchase_to_metrika($order_id) {
<?php
}
add_action('wp_footer', 'add_facebook_pixel_events');
/**
* Добавление событий контрибуции для FP Pixel
* только на боевом сайте АЕ
* */
if($site_env->site_mode == 'production' and $site_env->site_region == 'ae') {
add_action('wp_footer', 'add_facebook_pixel_events');
function add_facebook_pixel_events() {
// 1. Событие AddToCart (Добавление в корзину)
if (is_product() || is_shop() || is_cart()) {
@ -273,8 +255,8 @@ add_action('wp_footer', 'add_facebook_pixel_events');
</script>
<?php
}
}
}
// Отключаем кэширование для страниц товаров
add_action('template_redirect', function() {
if (is_product()) {

@ -142,32 +142,32 @@ function get_comment_likes_count($comment_id) {
}
function is_user_liked_post($post_id) {
if (!is_user_logged_in()) {
if (!is_user_logged_in()) {
return false;
}
global $wpdb;
$table_name = $wpdb->prefix . 'cosmopet_likes';
$user_id = get_current_user_id();
$result = $wpdb->get_var($wpdb->prepare(
}
global $wpdb;
$table_name = $wpdb->prefix . 'cosmopet_likes';
$user_id = get_current_user_id();
$result = $wpdb->get_var($wpdb->prepare(
"SELECT COUNT(*) FROM $table_name WHERE post_id = %d AND user_id = %d",
$post_id, $user_id
));
return $result > 0;
));
return $result > 0;
}
function is_user_liked_comment($comment_id) {
if (!is_user_logged_in()) {
if (!is_user_logged_in()) {
return false;
}
global $wpdb;
$table_name = $wpdb->prefix . 'cosmopet_likes';
$user_id = get_current_user_id();
$result = $wpdb->get_var($wpdb->prepare(
}
global $wpdb;
$table_name = $wpdb->prefix . 'cosmopet_likes';
$user_id = get_current_user_id();
$result = $wpdb->get_var($wpdb->prepare(
"SELECT COUNT(*) FROM $table_name WHERE comment_id = %d AND user_id = %d",
$comment_id, $user_id
));
return $result > 0;
));
return $result > 0;
}

@ -9,14 +9,14 @@ register_sidebar( array(
'after_title' => '</h3>',
) );
// Для кнопки "Применить фильтр"
add_filter('wbw_filter_submit_button_text', 'change_wbw_filter_button_text');
function change_wbw_filter_button_text($text) {
return 'Ваш текст'; // Например, "Фильтровать" или "Поиск"
}
// // Для кнопки "Применить фильтр"
// add_filter('wbw_filter_submit_button_text', 'change_wbw_filter_button_text');
// function change_wbw_filter_button_text($text) {
// return 'Ваш текст'; // Например, "Фильтровать" или "Поиск"
// }
// Для кнопки сброса (если есть)
add_filter('wbw_filter_reset_button_text', 'change_wbw_reset_button_text');
function change_wbw_reset_button_text($text) {
return 'Сбросить';
}
// // Для кнопки сброса (если есть)
// add_filter('wbw_filter_reset_button_text', 'change_wbw_reset_button_text');
// function change_wbw_reset_button_text($text) {
// return 'Сбросить';
// }

@ -7,7 +7,9 @@
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
{% if site_mode == 'production' %}
{{ header_scripts }}
{% endif %}
</head>
<body class="{{bodyClass}}">

Loading…
Cancel
Save