Guide

Privacy Consent architecture

Blocks, WP Consent API bridge, and VIP cache behavior.

Bootstrap

Loader → Plugin → Consent_API_Handler, Cookie_Scanner, VIP_Compatibility, and both block classes. WP Consent API hooks register at plugins_loaded priority 20. Local environments load block PHP from src/; other environments load from build/.

Client-side visibility

Banner visibility initializes to false in server-rendered Interactivity API state. callbacks.onInit in the browser decides whether to show the banner using Global Privacy Control → WP Consent API → localStorage fallback. That order keeps VIP edge cache from baking one visitor’s consent into HTML for everyone else.

Runtime helper: window.prcCookieBanner (show, hide, handleConsent, getState, getActions, setConsent, getConsent, checkConsent).

IndexWP Consent API categoryLabel
0functionalEssential
1statisticsAnalytics
2marketingMarketing
3preferencesPreferences

With WP Consent API v2, default marketing services include meta, pinterest, linkedin, and reddit. Extend via prc_privacy_consent_services.

VIP compatibility

VIP_Compatibility varies edge cache on consent cookies (wpcom_vip_cache_vary_headers), sends X-Batcache: no on plugin AJAX, and refreshes the cookie list via AJAX when the cookie-list block is present so listings stay accurate behind cache.

Key hooks

HookRole
prc_privacy_consent_consent_updatedAfter visitor submits consent
prc_cookie_banner_register_cookiesRegister cookies with WP Consent API
prc_cookie_list_categoriesMutate categories before cookie-list render

Was this helpful?