diff --git a/wp-content/themes/dekart/deploy-runner.php b/wp-content/themes/dekart/deploy-runner.php index d0003fd..751ec22 100644 --- a/wp-content/themes/dekart/deploy-runner.php +++ b/wp-content/themes/dekart/deploy-runner.php @@ -56,7 +56,7 @@ if ($dk_expected === '' || !hash_equals($dk_expected, $dk_given)) { exit("Not found\n"); } -$allowed_migrations = ['003', '004', '005']; +$allowed_migrations = ['003', '004', '005', '006']; $migrate = isset($_GET['migrate']) ? $_GET['migrate'] : ''; @@ -87,6 +87,58 @@ function dp_get_theme_dir() return $theme_dir; } +// Позиция //-комментария вне строковых литералов или false +function dp_js_comment_pos($line) +{ + $len = strlen($line); + $q = ''; + $esc = false; + for ($i = 0; $i < $len; $i++) { + $ch = $line[$i]; + if ($q !== '') { + if ($esc) { + $esc = false; + } elseif ($ch === '\\') { + $esc = true; + } elseif ($ch === $q) { + $q = ''; + } + continue; + } + if ($ch === '"' || $ch === "'" || $ch === '`') { + $q = $ch; + continue; + } + if ($ch === '/' && $i + 1 < $len && $line[$i + 1] === '/') { + return $i; + } + } + return false; +} + +// Удаляет //-комментарии (строки и хвосты), переносы строк сохраняет +function dp_strip_js_comments($code) +{ + $parts = preg_split('/(\r\n|\n|\r)/', $code, -1, PREG_SPLIT_DELIM_CAPTURE); + $out = ''; + $n = count($parts); + for ($p = 0; $p < $n; $p += 2) { + $text = $parts[$p]; + $eol = isset($parts[$p + 1]) ? $parts[$p + 1] : ''; + $idx = dp_js_comment_pos($text); + $had = false; + if ($idx !== false) { + $text = rtrim(substr($text, 0, $idx)); + $had = true; + } + if ($had && trim($text) === '') { + continue; // строка-комментарий целиком + } + $out .= $text . $eol; + } + return $out; +} + if ($migrate === '003') { // Fix banner_text typo: rарантированная → гарантированная $conn = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); @@ -238,6 +290,50 @@ if ($migrate === '005') { } } +if ($migrate === '006') { + // Чистка построчных //-комментариев в inline-JS сниппете плагина custom-css-js (post 518 «B24form»). + // Правим и БД, и физический файл uploads/custom-css-js/518.js (плагин отдаёт его как есть). + $conn = dp_get_wpdb(); + + $post_id = 518; + $res = mysqli_query($conn, "SELECT post_content FROM wp_posts WHERE ID = $post_id AND post_type = 'custom-css-js'"); + $row = $res ? mysqli_fetch_assoc($res) : null; + + if (!$row) { + echo "⚠️ Snippet $post_id (custom-css-js) not found — skip\n"; + } else { + $content = (string) $row['post_content']; + $clean = dp_strip_js_comments($content); + if ($clean === $content) { + echo "ℹ️ DB content unchanged — no // comments\n"; + } else { + $esc = mysqli_real_escape_string($conn, $clean); + mysqli_query($conn, "UPDATE wp_posts SET post_content = '$esc' WHERE ID = $post_id"); + echo "✅ DB post $post_id: " . strlen($content) . " → " . strlen($clean) . " chars\n"; + } + + $theme_dir = dp_get_theme_dir(); + $upload_dir = dirname(dirname($theme_dir)) . '/uploads/custom-css-js'; + foreach (["$post_id.js", "$post_id.min.js"] as $fname) { + $file = $upload_dir . '/' . $fname; + if (!is_file($file)) { + echo "ℹ️ File absent: $fname\n"; + continue; + } + $raw = file_get_contents($file); + $fixed = dp_strip_js_comments($raw); + if ($fixed !== $raw) { + file_put_contents($file, $fixed); + echo "✅ File $fname: " . strlen($raw) . " → " . strlen($fixed) . " bytes\n"; + } else { + echo "ℹ️ File unchanged: $fname\n"; + } + } + } + + mysqli_close($conn); +} + echo "\n=== Migration complete ===\n"; // Self-destruct: rename this file (кроме 005 — оставляем для повторного сброса OPcache) diff --git a/wp-content/themes/dekart/inc/class-pksh-data.php b/wp-content/themes/dekart/inc/class-pksh-data.php index c33cb51..080f6db 100644 --- a/wp-content/themes/dekart/inc/class-pksh-data.php +++ b/wp-content/themes/dekart/inc/class-pksh-data.php @@ -188,7 +188,7 @@ class Pksh_Data return $cached; } if (! array_key_exists('ext_review_count', $this->branch)) { - $this->branch['ext_review_count'] = get_option('branch_ext_review_count', '247'); + $this->branch['ext_review_count'] = get_option('branch_ext_review_count', ''); } wp_cache_set($cache_key, $this->branch['ext_review_count'], 'dekart_branch', DAY_IN_SECONDS); return $this->branch['ext_review_count']; diff --git a/wp-content/themes/dekart/template-parts/pksh/hero.php b/wp-content/themes/dekart/template-parts/pksh/hero.php index 47ad17d..19fc02d 100644 --- a/wp-content/themes/dekart/template-parts/pksh/hero.php +++ b/wp-content/themes/dekart/template-parts/pksh/hero.php @@ -13,7 +13,6 @@ $branch_city_clean = $data->get_city_clean(); $city_prep = $data->get_city_prep(); $h1_hero = $data->get_h1(); $subtitle_hero = $data->get_subtitle(); -$ext_review_count = $data->get_ext_review_count(); $opt_phone = $data->get_phone(); $hero_phone_clean = $data->get_phone_clean(); $banner_img_id = $data->get_banner_image_id(); @@ -69,10 +68,23 @@ $hero_definition = $data->get_hero_definition(); +
- 4.9 из 5 на основе отзывов на внешних площадках +
+