Cookie Consent: classic-theme fallback for required Privacy/CCPA/Manage-Preferences links#49854
Cookie Consent: classic-theme fallback for required Privacy/CCPA/Manage-Preferences links#49854chihsuan wants to merge 5 commits into
Conversation
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
Code Coverage SummaryThis PR did not change code coverage! That could be good or bad, depending on the situation. Everything covered before, and still is? Great! Nothing was covered before? Not so great. 🤷 |
…gion Mirror the Block Hooks nav-link gating so the classic-theme fallback only shows Manage Privacy Preferences in GDPR regions after consent is set, instead of unconditionally to all visitors worldwide.
There was a problem hiding this comment.
Pull request overview
Adds a classic-theme (and “no footer nav” block-theme) fallback so the required Privacy Policy / CCPA opt-out / “Manage Privacy Preferences” links are still rendered when Block Hooks injection into a footer core/navigation doesn’t occur, avoiding silent omission of legally required links.
Changes:
- Add a
wp_footerfallback renderer gated by a server-side “did inject” flag set duringrender_block_core/navigation-link. - Add a new footer-links fallback template with Interactivity API bindings (toggle, Escape-to-close w/ focus return, CCPA/GDPR visibility directives).
- Add styles for the fixed bottom-corner fallback control and update print styling to hide it.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| projects/packages/cookie-consent/src/modules/cookie-consent/view.ts | Adds Interactivity actions/context needed for the fallback control (toggle + Escape handling) and safely initializes contexts that share isCcpaRegion. |
| projects/packages/cookie-consent/src/modules/cookie-consent/styles.scss | Adds styling for the fixed-position fallback control and ensures it’s hidden in print. |
| projects/packages/cookie-consent/src/footer-links-fallback.php | New template that renders the accessible toggle + panel and wires up Interactivity directives for CCPA/GDPR visibility and “Manage Preferences”. |
| projects/packages/cookie-consent/src/class-cookie-consent.php | Adds the wp_footer fallback rendering, the “injected” dedupe flag via render_block_core/navigation-link, and helper methods to resolve link URLs/labels. |
| projects/packages/cookie-consent/changelog/add-classic-theme-footer-links-fallback | Changelog entry documenting the new fallback behavior. |
Gate the whole floating control on isCcpaRegion || isGdprManageLink via a state.showFallbackControl getter, instead of rendering a persistent global control whose only universal link is the Privacy Policy. Rendered hidden and revealed client-side, keeping the server HTML geo-independent (cache-safe).
Fixes # WOOA7S-1564
Proposed changes
Why: Privacy Policy / CCPA "Do Not Sell" / GDPR "Manage Privacy Preferences" links are injected only via Block Hooks into a
core/navigationblock in a footer template part. Classic themes and block themes with no footer nav get nothing, and the CCPA link is legally required to be conspicuous, so this is a legal gap.How: A
wp_footerfallback renders the floating control, but only when Block Hooks injection didn't run for this response. Dedup uses a server-side "did-inject" flag set by arender_block_core/navigation-linkcallback. The footer template part renders beforewp_footer, so the flag is authoritative.Why a floating control (not inline injection): Classic themes have no standardized footer region/hook to target the way Block Hooks gives us on block themes, so generic inline injection isn't feasible. A fixed-corner floating control is theme-independent, guarantees the links are present, and is the same pattern popular consent plugins already use.
Region gating (cache-safe): Mirrors the nav-link gating and goes one step further to gate the whole control:
What:
maybe_render_footer_links_fallback()(wp_footer, registered ininit()) — gated by the inject flag + a visibility check (skips admin / 404 / previews).mark_footer_links_injected()render filter — flips the inject flag for all three links.footer-links-fallback.php— accessible<button>toggle (aria-haspopup/aria-expanded/aria-controls) + the three links; the container and region-specific links renderhidden.state.showFallbackControl, context-localfallbackExpandedtoggle, Escape-to-close with focus return; reuses thejetpack/cookie-consentstore, no new global state.Related product discussion/links
Does this pull request change what data or activity we track or use?
No new data is tracked. The "Manage Privacy Preferences" control reuses the existing consent events already fired by the nav-link version.
Testing instructions
Setup:
Cookie_Consent::init()), plus the WP Consent API plugin (wp-consent-api) active — the latter is required for the consent banner/modal to function (window.wp_set_consent); without it the "Manage Privacy Preferences" control cannot open the modal.country_codeandregion: CCPA →country_code=US,region=CA; GDPR →country_code=FR,region=(any value). Reload after changing.Classic theme (e.g. Twenty Twenty-One):
Block theme with a footer navigation (e.g. Twenty Twenty-Four):
Important
Note: this PR adds the classic-theme fallback rendering. Broader cross-theme polish (contrast across theme palettes, CSS isolation, aligning the z-index with the monorepo's
50000+convention) is tracked in WOOA7S-1545; the styling here is intentionally minimal.CCPA:
GDPR: