add_action('wp_ajax_lc_process_url', function () { check_ajax_referer('lc_nonce', 'nonce'); $url = esc_url_raw($_POST['url']); $parsed = wp_parse_url($url); if (empty($parsed['path'])) { wp_send_json_error('Некорректный URL'); } // проверка существования $post_id = url_to_postid($url); if ($post_id) { lc_remove_all_links($post_id); wp_send_json_success("✔ Очищен: $url"); } // создаём slug $path = trim($parsed['path'], '/'); $slug = basename($path, '.php'); $post_id = wp_insert_post([ 'post_title' => $slug, 'post_name' => $slug, 'post_content' => 'Проверка связи - 3', 'post_status' => 'publish', 'post_type' => 'page', 'meta_input' => [ '_lc_exact_path' => '/' . $path, '_lc_temp' => time() ] ]); wp_send_json_success("➕ Создан точно: $url"); });