'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); }