Repository navigation
Conversation
Introduce ScriptBlocker, a new Frontend module that holds back arbitrary third-party <script src="..."> and <iframe src="..."> embeds (YouTube, Maps, social widgets, custom tracking snippets) until the visitor accepts the configured consent category — complementing CookieNotice's existing Google Consent Mode v2 support, which only affects Consent-Mode-aware tags. Server-side: a new "Script & Iframe Blocking" settings field stores a list of match-pattern/category rules (one-rule-per-line "pattern|category" textarea, a simple v1 given no existing repeatable-rows UI to match). When at least one rule is configured, ScriptBlocker buffers the frontend HTML (ob_start(), skipped entirely for admin/AJAX/REST/cron requests, and never started at all when no rules exist) and rewrites matching opening tags to inert placeholders via conservative, well-anchored regexes: <script> gets type="text/plain" with its src moved to data-frcn-src, and <iframe> gets its src swapped to "about:blank" with the real URL likewise moved to data-frcn-src. Client-side: a new frontconsent-script-blocker.js file (enqueued only when rules are configured) revives placeholders once their category is allowed — creating a brand-new <script> element (cloning a text/plain script and changing its type would not make it execute) or restoring an <iframe>'s real src — hooking into the same frcnCookieConsent event frontconsent-cookie-notice.js already dispatches. Test coverage: tests/Unit/ScriptBlockerTest.php covers matching/non-matching scripts and iframes, self-closing tags, attribute order/quoting variations, multiple tags on one page, case-insensitivity, and a data-src lazy-load attribute correctly not being confused with the real src (a real bug found and fixed during development, alongside a case-sensitivity bug in the buffering short-circuit). tests/js/script-blocker.test.js covers script revival, iframe src restoration, a rejected category being left alone, and a per-category override extension point. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The persistent "Cookie preferences" reopen trigger rendered as a text
pill ("Preferencias de cookies" in Spanish) instead of reusing the same
cookie icon already shown inside the banner. Reported live on a
production site. Now icon-only (the same .frcn-cookie-notice__icon
glyph, sized to its own 44x44px circular button), with the accessible
name carried entirely by aria-label instead of visible text.
Also fixes the same "Learn more" link accessibility issue already fixed
in FrontBlocks (closemarketing/frontblocks#316): the link now uses the
policy page's own title instead of a generic label (WCAG 2.4.4), and
gets explicit hover/focus colors so a theme's global a:hover style can't
make the text unreadable against its background.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Adds a real <button> to the left of Reject/Accept, showing the existing cookie icon, printed through the existing frcn_cookie_notice_before_actions action so a PRO add-on can hook the same extension point. Clicking it (or the persistent reopen trigger) opens a modal preferences panel (role="dialog", aria-modal="true") with a static "Strictly necessary" section and Accept all / Reject all / Save changes actions, all funneled through the exact same client-side decision-recording function the banner's own Accept/Reject buttons already use, and the same AJAX log_consent_callback() server-side. PRO-ready extension points, per the issue: - New frcn_cookie_preferences_categories action, fired inside the panel where a PRO add-on renders its own per-category toggles. - New frcn_cookie_consent_categories filter, applied around the optional per-category map in log_consent_callback()'s response — purely additive, the binary accepted/rejected cookie format is unchanged. - New frcn_cookie_customize_button_label / frcn_cookie_customize_button_enabled filters for the button's copy and visibility. The panel is printed unconditionally (including on the policy page) and hidden by default via the `hidden` attribute, keeping the output cache-neutral like the rest of the banner. Without JS the button is hidden via the existing <noscript> fallback; Accept/Reject keep working through the no-JS <form> fallback as before. Also updates the reopen trigger to open this same panel instead of clearing the consent cookie and reloading the page — now that the panel renders even on the policy page, there's no need to navigate away to reach it. Documented in docs/preferences-panel-hooks.md. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The button has the hidden HTML attribute, but .frcn-cookie-reopen's own
display: flex rule (an author style) overrode the browser's built-in
[hidden] { display: none }, regardless of selector specificity — so it
showed up immediately for every visitor instead of only appearing once
a decision cookie exists. Reported live by a user testing the branch.
Add the missing .frcn-cookie-reopen[hidden] override, matching the same
pattern already used for .frcn-cookie-preferences. New regression test
locks this in.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…rketing/frontconsent into feature/customize-preferences-panel # Conflicts: # assets/cookie-notice/frontconsent-cookie-notice.css # assets/cookie-notice/frontconsent-cookie-notice.min.css
…ions The panel had no visible feedback: Accept all/Reject all/Save changes all recorded a decision, but the panel's own markup looked identical regardless of what was clicked, since the only category shown was the static, always-on "Strictly necessary" block. A visitor had no way to tell whether their action had any effect. Add a real "Analytics & Marketing" checkbox (data-frcn-category="optional") after the necessary block. frontconsent-cookie-notice.js already had the plumbing to read panel toggles on Save changes/Accept all (collectPreferencesCategories()) — it only lacked an actual toggle to read. Added the missing half: syncPreferencesToggles(), called every time the panel opens, reflects the checkbox from the real consent cookie (accepted/rejected), which stays the single source of truth — the toggle is presentation, not a second stored state. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Analytics and Marketing gated the exact same binary accepted/rejected
decision despite showing as separate concepts ("analytics y marketing
son diferentes"). Replace the single "Analytics & Marketing" checkbox
with two independent ones (data-frcn-category="analytics"/"marketing")
and make the split functionally meaningful end to end:
- frontconsent-cookie-notice.js persists the visitor's actual
per-category selection into a new frontconsent_categories cookie
(JSON, e.g. {"analytics":true,"marketing":false}) alongside the
existing binary consent cookie, and syncs each toggle's checked
state from it independently when the panel opens.
- CookieNotice::get_config_callback() reads that cookie server-side
and builds a real allowedCategories map (still filterable via
frcn_cookie_notice_allowed_tracking_categories for PRO), instead of
always returning null. frcnCookieNoticeInject() already gated GTM/
GA4 ('analytics') separately from Clientify/Brevo/OpenAI ads
('marketing') on this map — it just needed a real value to gate on.
- Backward compatible: a visitor who accepted before this cookie
existed has no frontconsent_categories cookie yet; both categories
default to allowed for them (matching the previous allow-all
behavior) until they make an explicit per-category choice.
Updates existing PHPUnit/JS tests for the new markup and cookie logic,
and adds coverage for the malformed-cookie fallback and the backward-
compat default.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… tuwebcumple.es Brings the preferences panel (Customize button, Analytics/Marketing toggles) onto current main and fixes what the merge left out: - Re-apply #18's cookie purge inside the new decision flow, now category-aware: Analytics-only visitors keep _ga but lose marketing cookies. - Google Consent Mode signals per category (analytics_storage from Analytics, ad_* from Marketing) in the inline default, the CSP fallback and updates. - Expose window.frcnCookieNoticeIsCategoryAllowed so the script/iframe blocker honours categories instead of the binary decision. - Reload after a withdrawal so tags already running on the page stop. - Switch YouTube iframes to youtube-nocookie.com and add dnt=1 to Vimeo (filter frcn_privacy_enhanced_embeds). - Disable FrontBlocks PRO's legacy categories module once: it hooks the retired frbl_* banner, so under FrontConsent it printed a dialog with no button to open it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
They are gated as Analytics (data-frcn-consent=analytics), so treating them as Marketing in the purge list deleted them on every page view for visitors who accepted Analytics only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The minified assets were dropped by accident in 55f247f: the build-assets JS test deletes them after running, and they were staged right after it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
@amulero I need documentation from this PR. |
tuwebcumple.es flagged "withdrawing consent really undoes it": after accepting and then rejecting on close.marketing, the OpenAI ChatGPT Ads pixel left its __obref cookie and an oaiq_cs:<pixel id> sessionStorage entry behind. - Add __obref and oaiq_* to the purge list. - Apply the purge list to localStorage/sessionStorage keys as well. - Version 1.0.3-beta.withdraw. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.