Files
laryngologia.luxmedkrakow.pl/wp-content/mu-plugins/elementor-webhook-relay.php
Jacek Pyziak 77180aecf3 Add Cookie Notice Pro plugin with styles and Google Consent Mode integration
- Introduced Cookie Notice Pro plugin for GDPR compliance with a customizable cookie information popup.
- Added CSS styles for the cookie notice, including light and dark themes, animations, and responsive design.
- Implemented Google Consent Mode v2 with default denied settings and Google Tag Manager integration.
- Created Elementor Webhook Relay plugin to forward form submissions to Google Apps Script.
2026-05-12 23:08:26 +02:00

45 lines
1.7 KiB
PHP

<?php
/**
* Plugin Name: Elementor Webhook Relay → Apps Script
* Description: Pośrednik między Elementor Form Webhook a Google Apps Script.
* Apps Script zwraca redirect 302 którego Elementor nie obsługuje czysto;
* ten relay przyjmuje POST, odsyła Elementorowi 200 OK,
* a w tle (fire-and-forget) forwarduje payload do Apps Script.
*
* Endpoint: POST /wp-json/relay/v1/webhook
*
* Konfiguracja per-strona: zmień stałą APPS_SCRIPT_URL poniżej.
*/
if (!defined('ABSPATH')) { exit; }
// ───── KONFIGURACJA — ZMIEŃ NA SWÓJ ─────
const RELAY_APPS_SCRIPT_URL = 'https://script.google.com/macros/s/AKfycbyy5Ns3Ec2hbCwwaPBG57HHxsS2jvNxalznOPPfHiJT3aaa-w-YAkARprKt0Lrjr9c4/exec';
// ────────────────────────────────────────
add_action('rest_api_init', function () {
register_rest_route('relay/v1', '/webhook', [
'methods' => 'POST',
'callback' => 'relay_webhook_handler',
'permission_callback' => '__return_true', // publiczny endpoint — Elementor woła bez auth
]);
});
function relay_webhook_handler(WP_REST_Request $request) {
$params = $request->get_params();
// Fire-and-forget POST do Apps Script — nie czekamy na odpowiedź.
// Routing per arkusz odbywa się po stronie Apps Script (po form_name).
wp_remote_post(RELAY_APPS_SCRIPT_URL, [
'timeout' => 5,
'blocking' => false,
'body' => $params,
'sslverify' => true,
'headers' => [
'Content-Type' => 'application/x-www-form-urlencoded',
],
]);
return new WP_REST_Response(['ok' => true], 200);
}