Files
naczyniowa.luxmedkrakow.pl/wp-content/mu-plugins/elementor-webhook-relay.php
Jacek Pyziak f231fb6efe Add Cookie Notice Pro plugin with styles and Google Consent Mode integration
- Introduced Cookie Notice Pro plugin to manage cookie consent for GDPR compliance.
- Added CSS styles for the cookie notice popup, including light and dark themes.
- Implemented Google Consent Mode with default denied settings and GTM integration.
- Created Elementor Webhook Relay plugin to forward form submissions to Google Apps Script.
2026-05-12 23:10:34 +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ź.
// timeout 0.01 + blocking=false = wysyłamy i wracamy do Elementora natychmiast.
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);
}