2026-10-02 GLOBAL

This commit is contained in:
Dekart Deploy Bot 2026-10-02 01:27:48 +00:00
parent 3c35e3bd67
commit e1ae8e89f5
3 changed files with 112 additions and 4 deletions

View File

@ -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)

View File

@ -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'];

View File

@ -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();
</div>
<?php endif; ?>
<?php
// Единый источник рейтинга
$pksh_rating_text = get_option('branch_rating_text');
if (! $pksh_rating_text) {
$pksh_rating = get_option('branch_avg_rating') ?: get_option('branch_rating_yandex');
$pksh_count = get_option('branch_ext_review_count');
if ($pksh_rating && $pksh_count) {
$pksh_rating_text = sprintf('%s из 5 на основе %s отзывов на внешних площадках', $pksh_rating, $pksh_count);
}
}
if ($pksh_rating_text) :
?>
<div class="ds-hero__rating-badge">
<span class="ds-hero__rating-stars" aria-hidden="true">★★★★★</span>
<span class="ds-hero__rating-text">4.9 из 5 на основе <?php echo esc_html($ext_review_count ?: '190'); ?> отзывов на внешних площадках</span>
<span class="ds-hero__rating-text"><?php echo esc_html($pksh_rating_text); ?></span>
</div>
<?php endif; ?>
<button class="ds-hero__cta-btn open-bitrix-form">Записаться на бесплатное пробное</button>