From c8a3e68484d7810e704ec14bae7c26d4c3f0832f Mon Sep 17 00:00:00 2001 From: Dekart Deploy Bot Date: Sun, 4 Oct 2026 21:09:11 +0000 Subject: [PATCH] 2026-10-04 GLOBAL --- wp-content/themes/dekart/functions.php | 1 + .../themes/dekart/inc/js-snippet-comments.php | 109 ++++++++++++++++++ 2 files changed, 110 insertions(+) create mode 100644 wp-content/themes/dekart/inc/js-snippet-comments.php diff --git a/wp-content/themes/dekart/functions.php b/wp-content/themes/dekart/functions.php index 26585d3..5b8faf2 100644 --- a/wp-content/themes/dekart/functions.php +++ b/wp-content/themes/dekart/functions.php @@ -4624,6 +4624,7 @@ function dekart_flush_cache_page() */ require_once __DIR__ . '/inc/schema.php'; require_once __DIR__ . '/inc/webmaster-recrawl.php'; +require_once __DIR__ . '/inc/js-snippet-comments.php'; /** * Фильтр: замена H1 для страницы "Подготовка к школе" (ID 2) diff --git a/wp-content/themes/dekart/inc/js-snippet-comments.php b/wp-content/themes/dekart/inc/js-snippet-comments.php new file mode 100644 index 0000000..dead10c --- /dev/null +++ b/wp-content/themes/dekart/inc/js-snippet-comments.php @@ -0,0 +1,109 @@ + 'custom-css-js', + 'post_status' => 'publish', + 'posts_per_page' => -1, + 'fields' => 'ids', + )); + if (empty($posts)) { + return; // сниппетов нет — повторим позже + } + + $upload = wp_upload_dir(); + $dir = trailingslashit($upload['basedir']) . 'custom-css-js'; + + foreach ($posts as $pid) { + $content = (string) get_post_field('post_content', $pid); + if (false === strpos($content, 'open-bitrix-form')) { + continue; // чистим только сниппет формы B24 + } + + $clean = dekart_js_strip_comments($content); + if ($clean !== $content) { + wp_update_post(array( 'ID' => $pid, 'post_content' => $clean )); + } + + foreach (array( $pid . '.js', $pid . '.min.js' ) as $fname) { + $file = $dir . '/' . $fname; + if (! is_file($file)) { + continue; + } + $raw = (string) file_get_contents($file); + $fixed = dekart_js_strip_comments($raw); + if ($fixed !== $raw) { + file_put_contents($file, $fixed); + } + } + } + + update_option('dekart_js_snippet_migration', DEKART_JS_SNIPPET_MIGRATION, false); +}