A customizable WordPress block-based cookie consent system for GDPR compliance. Includes a modal dialog, REST API integration, cookie handling, and conditional content rendering based on user consent.
- Gutenberg block to add a Cookie Settings Button and Modal
- Customizable texts and layout inside the block editor
- Supports both required and third-party cookies
- Remembers consent using cookies
- Simple REST API to handle user interaction
- Optional filtering/removal of forbidden blocks (like YouTube embeds) when consent is not granted
- Fully stylable and extendable
- Users can open the modal to configure cookie preferences.
- The modal contains options for:
- Required cookies (always active)
- Third-party cookies (user choice)
- Clicking Accept All or Save Settings stores the consent via the REST API.
- If full consent is not granted, defined blocks (e.g. embeds) are removed from frontend rendering.
- Consent is stored in two cookies:
ctx_cookie_ok: basic consentctx_cookie_all: full consent
You can add the ctx-gdpr/modal block to any post, page, or template. It contains:
- A button with optional icon and custom title
- Modal window with:
- Paragraph/text blocks (editable)
- Two checkboxes (required cookies, third-party cookies)
- Accept/Save buttons
Use the block inspector to configure modal options such as:
- Modal title
- Fullscreen mode
- Icon symbol
- Default value for third-party cookies
- Block types to disable (e.g.
core/embed,someplugin/custom-embed)
POST /wp-json/ctx-gdpr/v2/consent
Saves user consent.
| Name | Type | Description |
|---|---|---|
| all | 1 or 0 |
1 enables full consent, 0 disables it |