Cookie Consent: Make consent copy configurable#50000
Conversation
Summary: - Add a normalized copy config group with translated package defaults for banner, modal, footer link, CCPA page, and snackbar strings. - Render server templates and injected CCPA UI from resolved copy values. - Document consumer translation of overrides and add a package changelog. Rationale: - Consumers need to supply product-appropriate privacy copy without editing package source while keeping package defaults in the package text domain. - Copy normalization lets consumers override individual keys without having to duplicate the full default map. Tests: - php -l projects/packages/cookie-consent/src/class-cookie-consent.php - php -l projects/packages/cookie-consent/src/cookie-banner-content.php - php -l projects/packages/cookie-consent/src/ccpa-content.php - PHP copy override smoke test with WordPress function stubs - composer phpcs:lint -- changed PHP files - mise x node@24.15.0 -- pnpm --filter @automattic/jetpack-cookie-consent test - mise x node@24.15.0 -- pnpm --filter @automattic/jetpack-cookie-consent typecheck - mise x node@24.15.0 -- pnpm --filter @automattic/jetpack-cookie-consent build - mise x node@24.15.0 -- pnpm jetpack phan --allow-polyfill-parser packages/cookie-consent (fails: existing class-consent-log-controller.php issues)
|
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. 🤷 |
There was a problem hiding this comment.
Pull request overview
This PR makes the Cookie Consent package’s user-facing UI text configurable via a normalized copy config group, while keeping package defaults translatable in the jetpack-cookie-consent text domain and allowing consumers to override (and translate) strings in their own domain.
Changes:
- Introduces
Cookie_Consent::get_default_copy()plus config normalization (normalize_copy) so partial overrides are merged with translated defaults. - Updates the banner and CCPA templates (and snackbar/footer link strings) to read from the normalized
copyconfig instead of hard-coded translations. - Renames “shopper” terminology to “visitor” in module comments/docs and updates README guidance for consumer overrides.
Reviewed changes
Copilot reviewed 10 out of 10 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 | Updates module header/comment wording to “Cookie Consent” and “visitor”. |
| projects/packages/cookie-consent/src/modules/cookie-consent/utils.ts | Updates inline comment wording to “visitor”. |
| projects/packages/cookie-consent/src/modules/cookie-consent/tracks.ts | Updates tracking docblocks to “visitor” and “Cookie Consent” naming. |
| projects/packages/cookie-consent/src/modules/cookie-consent/logger.ts | Updates module header/comment wording to “Cookie Consent”. |
| projects/packages/cookie-consent/src/modules/cookie-consent/index.ts | Updates module header comment wording to “Cookie Consent”. |
| projects/packages/cookie-consent/src/cookie-banner-content.php | Reads banner/modal UI strings from $config['copy'] with a default-copy fallback. |
| projects/packages/cookie-consent/src/class-cookie-consent.php | Adds default-copy + normalization and wires copy into config and UI outputs (CCPA page title, footer link, snackbar). |
| projects/packages/cookie-consent/src/ccpa-content.php | Reads CCPA page strings from $config['copy'] with a default-copy fallback. |
| projects/packages/cookie-consent/README.md | Documents how consumers override/translate copy values via the config filter. |
| projects/packages/cookie-consent/changelog/wooa7s-1601-configurable-copy | Adds changelog entry for configurable banner/CCPA copy. |
Fixes WOOA7S-1601
Proposed changes
copyconfig group for Cookie Consent banner, modal, footer link, CCPA page, and snackbar strings.jetpack-cookie-consenttext domain while allowing consumers to provide translated overrides from their own text domain.copyis missing or non-array, and avoid recomputing default copy during config normalization.Related product discussion/links
Does this pull request change what data or activity we track or use?
No. This changes configurable UI copy and generic code comments only; it does not add tracking events or change tracked data.
Testing instructions
projects/packages/cookie-consent/src/class-cookie-consent.phpprojects/packages/cookie-consent/src/cookie-banner-content.phpprojects/packages/cookie-consent/src/ccpa-content.phpcopyuses package defaults without undefined-key warnings.composer phpcs:lint -- projects/packages/cookie-consent/src/class-cookie-consent.php projects/packages/cookie-consent/src/cookie-banner-content.php projects/packages/cookie-consent/src/ccpa-content.phpmise x node@24.15.0 -- pnpm --filter @automattic/jetpack-cookie-consent testmise x node@24.15.0 -- pnpm --filter @automattic/jetpack-cookie-consent typecheckmise x node@24.15.0 -- pnpm --filter @automattic/jetpack-cookie-consent buildrg -n "shopping|shopper|cart|customer account|Shoppers" projects/packages/cookie-consentreturns no matches.Known validation note:
mise x node@24.15.0 -- pnpm jetpack phan --allow-polyfill-parser packages/cookie-consentstill reports existing package-wide issues inclass-consent-log-controller.phpand PHP test stubs, not in the changed files.