get_route(), '/contact-form-7/') !== false) {\n $form_id = $request->get_param('_wpcf7');\n if ($form_id) {\n $form = wpcf7_contact_form($form_id);\n if ($form) {\n $tags = $form->scan_form_tags();\n foreach ($tags as $tag) {\n // Fill empty radio buttons with their default value so CF7 doesn't throw "An undefined value was submitted"\n if ($tag->type === 'radio' && empty($_POST[$tag->name]) && !empty($tag->values)) {\n $_POST[$tag->name] = ((array) $tag->values)[0];\n }\n }\n }\n }\n }\n return $result;\n}, 10, 3);\n\n// 2. Trigger n8n webhook\nadd_action('wpcf7_submit', 'jcp_trigger_n8n_webhook', 10, 2);\nadd_action('wpcf7_before_send_mail', 'jcp_trigger_n8n_webhook', 10, 2);\nadd_action('wpcf7_mail_sent', 'jcp_trigger_n8n_webhook', 10, 1);\n\nfunction jcp_trigger_n8n_webhook($form = null, $arg2 = null) {\n static $sent = [];\n if (!$form || !is_a($form, 'WPCF7_ContactForm') || isset($sent[$form->id()])) return;\n $sent[$form->id()] = true;\n\n $sub = WPCF7_Submission::get_instance();\n $data = $sub ? $sub->get_posted_data() : $_POST;\n $url = $sub ? $sub->get_meta('url') : (wp_get_referer() ?: home_url($_SERVER['REQUEST_URI']));\n $clean = [];\n\n // Чистимо дані від wpcf7 та масивів\n foreach ($data as $k => $v) {\n if (strpos($k, '_wpcf7') !== 0) $clean[$k] = is_array($v) ? implode(', ', $v) : $v;\n }\n\n // Видалення полів з неактивних гілок (Regex-оптимізація)\n $html = $form->prop('form');\n $branch = 'br-0';\n if (preg_match('/data-step-type=["\']splitter["\'].*?\[radio\s+([^\s\]]+)\s+.*?("(?:[^"\\\\]|\\\\.)*"(?:\s+"(?:[^"\\\\]|\\\\.)*")*)/is', $html, $m)) {\n preg_match_all('/"((?:[^"\\\\]|\\\\.)*)"/', $m[2], $opts);\n if (isset($clean[$m[1]]) && ($idx = array_search($clean[$m[1]], $opts[1] ?? [])) !== false) {\n $branch = 'br-' . $idx;\n }\n }\n\n if (preg_match_all('/class=[\"\'][^\"\']*?branch-group\s+(br-\d+)[^\"\']*?[\"\'](.*?)?(?=
$br) {\n if ($br !== $branch && preg_match_all('/\[(?:text|email|tel|url|textarea|select|radio|checkbox)\*?\s+([^\s\]]+)/i', $matches[2][$i], $tags)) {\n foreach ($tags[1] as $t) { unset($clean[$t]); }\n }\n }\n }\n\n $labels = [];\n if (preg_match_all('/
]*class=["\'][^"\']*yur-quiz-label[^"\']*["\'][^>]*>(.*?)<\/span>.*?\[(?:text|email|tel|url|textarea|select|radio|checkbox)\*?\s+([^\s\]]+)/is', $html, $m)) {\n $labels = array_combine($m[2], array_map('trim', array_map('strip_tags', $m[1])));\n }\n\n $final_payload = [\n 'user_city' => isset($clean['user-city']) ? $clean['user-city'] : (isset($clean['city']) ? $clean['city'] : ''),\n 'your_phone' => isset($clean['your-phone']) ? $clean['your-phone'] : (isset($clean['phone']) ? $clean['phone'] : ''),\n 'source_url' => $url,\n 'form_id' => $form->id(),\n 'form_title' => $form->title(),\n 'answers' => []\n ];\n\n $exclude = ['user-city', 'city', 'your-phone', 'phone'];\n foreach ($clean as $k => $v) {\n if (!in_array($k, $exclude) && $k !== 'source_url' && $k !== 'form_id' && $k !== 'form_title') {\n $question = isset($labels[$k]) ? $labels[$k] : $k;\n // Decode HTML entities in case there are quotes or amps in the label\n $question = html_entity_decode($question, ENT_QUOTES | ENT_XML1, 'UTF-8');\n $final_payload['answers'][$question] = $v;\n }\n }\n\n
$final_payload['utm_source'] = isset($_COOKIE['utm_source']) ? sanitize_text_field($_COOKIE['utm_source']) : '';
$final_payload['utm_medium'] = isset($_COOKIE['utm_medium']) ? sanitize_text_field($_COOKIE['utm_medium']) : '';
$final_payload['utm_campaign'] = isset($_COOKIE['utm_campaign']) ? sanitize_text_field($_COOKIE['utm_campaign']) : '';
$final_payload['utm_term'] = isset($_COOKIE['utm_term']) ? sanitize_text_field($_COOKIE['utm_term']) : '';
$final_payload['utm_content'] = isset($_COOKIE['utm_content']) ? sanitize_text_field($_COOKIE['utm_content']) : '';
$final_payload['gclid'] = isset($_COOKIE['gclid']) ? sanitize_text_field($_COOKIE['gclid']) : '';
\n $bbcode = [];\n foreach ($final_payload['answers'] as $q => $a) {\n $bbcode[] = "[b]" . $q . "[/b]\n" . $a;\n }\n $final_payload['answers_bbcode'] = implode("\n\n", $bbcode);\n\n $res = wp_remote_post('https://n8n.jurconsult.click/webhook/contact-form-from-jurconsult', [\n 'body' => json_encode($final_payload),\n 'headers' => ['Content-Type' => 'application/json'],\n 'timeout' => 5,\n 'blocking' => true, // changed to true for debugging\n 'sslverify' => false\n ]);\n\n update_option('jcp_last_n8n_webhook_log', [\n 'time' => current_time('mysql'),\n 'form_id' => $form->id(),\n 'payload' => $final_payload,\n 'code' => is_wp_error($res) ? $res->get_error_message() : wp_remote_retrieve_response_code($res)\n ]);\n} Сторінка не знайдена | ЮРКОНСАЛТ | Адвокатське бюро
Перейти до вмісту Схоже, що тут нічого не знайдено. Може спробуйте пошук?
Cookie Consent Ми дбаємо про ваш комфорт, тому використовуємо файли cookie, щоб сайт працював швидко та без збоїв. Натисніть «Продовжити » для продовження роботи з сайтом.
Manage your cookie preferences below:
Essential cookies enable basic functions and are necessary for the proper function of the website.
Cookie Preferences
This cookie is used to store the user's cookie consent preferences.
30 days
These cookies are needed for adding comments on this website.
comment_author
Used to track the user across multiple sessions.
Session
comment_author_email
Used to track the user across multiple sessions.
Session
comment_author_url
Used to track the user across multiple sessions.
Session
Google Tag Manager simplifies the management of marketing tags on your website without code changes.
cookiePreferences
Registers cookie preferences of a user
2 years
td
Registers statistical data on users' behaviour on the website. Used for internal analytics by the website operator.
session