Skip to content

Cookie Consent: Make consent copy configurable#50000

Draft
chihsuan wants to merge 1 commit into
trunkfrom
auto/WOOA7S-1601
Draft

Cookie Consent: Make consent copy configurable#50000
chihsuan wants to merge 1 commit into
trunkfrom
auto/WOOA7S-1601

Conversation

@chihsuan

Copy link
Copy Markdown
Member

Fixes WOOA7S-1601

Proposed changes

  • Add a normalized copy config group for Cookie Consent banner, modal, footer link, CCPA page, and snackbar strings.
  • Keep package defaults translatable in the jetpack-cookie-consent text domain while allowing consumers to provide translated overrides from their own text domain.
  • Replace commerce-flavored default wording with generic visitor/site wording.
  • Make template fallback copy self-healing when copy is 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

  • Confirm PHP syntax passed for:
    • 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.php
  • Confirm template fallback smoke coverage: rendering the banner and CCPA templates with missing copy uses package defaults without undefined-key warnings.
  • Confirm config normalization smoke coverage: partial copy overrides are preserved, non-scalar copy values are ignored, and default copy is translated once per config build.
  • Confirm lint/test/build validation passed:
    • 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.php
    • 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
  • Confirm rg -n "shopping|shopper|cart|customer account|Shoppers" projects/packages/cookie-consent returns no matches.

Known validation note: mise x node@24.15.0 -- pnpm jetpack phan --allow-polyfill-parser packages/cookie-consent still reports existing package-wide issues in class-consent-log-controller.php and PHP test stubs, not in the changed files.

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)
@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • 🔴 Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

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:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!

@github-actions github-actions Bot added the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label Jun 26, 2026
@jp-launch-control

jp-launch-control Bot commented Jun 26, 2026

Copy link
Copy Markdown

Code Coverage Summary

This 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. 🤷

Full summary · PHP report

@chihsuan chihsuan self-assigned this Jun 26, 2026
@chihsuan chihsuan marked this pull request as draft June 26, 2026 09:29
@chihsuan chihsuan requested a review from Copilot June 26, 2026 09:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 copy config 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Docs [Package] Cookie Consent [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants