Skip to content

feat: make it easier to do "Block until consent given" setups in Complianz and improve blocking#4549

Merged
claudiulodro merged 13 commits intotrunkfrom
add/complianz-hooks
Apr 6, 2026
Merged

feat: make it easier to do "Block until consent given" setups in Complianz and improve blocking#4549
claudiulodro merged 13 commits intotrunkfrom
add/complianz-hooks

Conversation

@claudiulodro
Copy link
Copy Markdown
Contributor

@claudiulodro claudiulodro commented Mar 5, 2026

All Submissions:

Changes proposed in this Pull Request:

Closes NEWS-1499.

This PR adds a new Privacy screen in Newspack > Settings if Complianz is active. This screen lets a user:

  • Add a "block until consent given" setup to their site regardless of what geographic area they've set Complianz up for
  • Optionally block ads until consent is given

How to test the changes in this Pull Request:

  1. Install and activate Complianz. Go through the setup wizard and select US and none of the state-specific options. This will give you a permissive setup with a default "optout" for trackers and ads (they will load by default)
Screenshot 2026-03-19 at 2 40 08 PM
  1. Have Site Kit, Google Ads, Meta Pixel, Twitter Pixel, and any other standard third-party trackers active on your site.
  2. With network inspector open, visit the site in an incognito window. Observe that scripts are loaded from stats.wp.com and parse.ly.
Screenshot 2026-03-05 at 3 39 45 PM Screenshot 2026-03-19 at 3 33 08 PM
  1. Toggle on the feature to block third party trackers until after consent is given
Screenshot 2026-03-19 at 3 34 11 PM
  1. Visit the site again. Observe that the trackers are not loaded in network inspector.
Screenshot 2026-03-19 at 3 34 50 PM
  1. Also toggle on the feature to block ads until after consent is given. Visit the site again. Observe that trackers AND ads are not loaded in network inspector (and observe visually for ads).
Screenshot 2026-03-19 at 3 35 14 PM
  1. Accept the notice. Observe that everything then loads in.
Screenshot 2026-03-19 at 3 35 22 PM

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully ran tests with your changes locally?

@claudiulodro claudiulodro requested a review from a team as a code owner March 5, 2026 23:43
Copilot AI review requested due to automatic review settings March 5, 2026 23:43
@claudiulodro claudiulodro changed the title feat: improve Complianz compatibility feat: improve Complianz compatibility for "Block until consent given" setups Mar 5, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Improves Newspack’s compatibility with the Complianz “Cookie Blocker” mode by ensuring additional third‑party trackers (and Newspack-inserted pixel scripts) are deferred until consent is granted.

Changes:

  • Add a Complianz integration that post-processes Complianz’s blocked HTML output to additionally block specific third-party script domains.
  • Introduce a newspack_pixel_script_markup filter for pixel <script> markup and use it to make pixel scripts compatible with Complianz’s blocker mode.
  • Load the new Complianz integration from the main plugin include list.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
includes/tracking/class-pixel.php Wraps rendered pixel script markup in a new filter so integrations (Complianz) can transform it.
includes/plugins/class-complianz.php Adds Complianz integration: blocks additional third‑party scripts and pixel scripts when Cookie Blocker is active.
includes/class-newspack.php Ensures the Complianz integration file is included/loaded.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread includes/plugins/class-complianz.php Outdated
@claudiulodro claudiulodro added the [Status] Needs Review The issue or pull request needs to be reviewed label Mar 6, 2026
Comment thread includes/tracking/class-pixel.php Outdated
@claudiulodro claudiulodro added [Status] Needs Changes or Feedback The issue or pull request needs action from the original creator and removed [Status] Needs Review The issue or pull request needs to be reviewed labels Mar 10, 2026
@claudiulodro claudiulodro requested a review from Copilot March 20, 2026 01:16
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 9 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/wizards/newspack/views/settings/privacy/index.tsx
Comment thread includes/wizards/newspack/class-privacy-section.php
Comment thread includes/plugins/class-complianz.php Outdated
Comment thread includes/plugins/class-complianz.php
@claudiulodro claudiulodro changed the title feat: improve Complianz compatibility for "Block until consent given" setups feat: make it easier to do "Block until consent given" setups in Complianz and improve blocking Mar 20, 2026
@claudiulodro
Copy link
Copy Markdown
Contributor Author

Updated title and description to better reflect changes to this feature since initial PR.

@claudiulodro claudiulodro added [Status] Needs Review The issue or pull request needs to be reviewed and removed [Status] Needs Changes or Feedback The issue or pull request needs action from the original creator labels Mar 20, 2026
Copy link
Copy Markdown
Contributor

@leogermani leogermani left a comment

Choose a reason for hiding this comment

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

pre approving but there are some conflicts to resolve.

Works fine for me.

One thing I miss in the PR, and I think we should add to the class docs, or a README or something is the "why". Why and what are we doing here?

  • Are we extending complianz to also block Newspack specific features that wouldn't be blocked otherwise, like Ads and pixel trackers?
  • Why do we need an option to force a specific behavior of Complianz? Or the behavior is not quite what we want?

Copy link
Copy Markdown
Member

@adekbadek adekbadek left a comment

Choose a reason for hiding this comment

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

Tested locally with Complianz 7.4.5 – UI works as expected, settings persist, toggles interact correctly. Verified all four Complianz hooks (cmplz_cookie_blocker_output, cmplz_option_enable_cookie_blocker, cmplz_consenttype, cmplz_can_run_cookie_blocker) against the Complianz source – all are used correctly with the right arguments, return values, and data attribute conventions (data-cmplz-src, type="text/plain", data-category).

A few suggestions inline.

Comment thread includes/plugins/class-complianz.php
Comment thread includes/plugins/class-complianz.php
Comment thread includes/wizards/newspack/class-privacy-section.php Outdated
Comment thread tests/unit-tests/plugins/complianz.php Outdated
Comment thread src/wizards/newspack/views/settings/privacy/index.tsx Outdated
@claudiulodro claudiulodro added [Status] Needs Changes or Feedback The issue or pull request needs action from the original creator and removed [Status] Needs Review The issue or pull request needs to be reviewed labels Apr 2, 2026
@claudiulodro claudiulodro added [Status] Needs Review The issue or pull request needs to be reviewed and removed [Status] Needs Changes or Feedback The issue or pull request needs action from the original creator labels Apr 3, 2026
@claudiulodro
Copy link
Copy Markdown
Contributor Author

I've addressed all feedback as well as some new feedback my agents raised. Thanks for reviewing it, Leo and Adam!

Copy link
Copy Markdown
Member

@adekbadek adekbadek left a comment

Choose a reason for hiding this comment

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

👌

@github-actions github-actions Bot added [Status] Approved The pull request has been reviewed and is ready to merge and removed [Status] Needs Review The issue or pull request needs to be reviewed labels Apr 6, 2026
@claudiulodro claudiulodro merged commit 44dda72 into trunk Apr 6, 2026
13 checks passed
@claudiulodro claudiulodro deleted the add/complianz-hooks branch April 6, 2026 16:41
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 6, 2026

Hey @claudiulodro, good job getting this PR merged! 🎉

Now, the needs-changelog label has been added to it.

Please check if this PR needs to be included in the "Upcoming Changes" and "Release Notes" doc. If it doesn't, simply remove the label.

If it does, please add an entry to our shared document, with screenshots and testing instructions if applicable, then remove the label.

Thank you! ❤️

matticbot pushed a commit that referenced this pull request Apr 16, 2026
# [6.38.0-alpha.1](v6.37.0...v6.38.0-alpha.1) (2026-04-16)

### Bug Fixes

* `is_donor` read-only only on WooCommerce-backed donations ([1dde930](1dde930))
* **access-control:** fix incorrect class name ([#4638](#4638)) ([a7a7908](a7a7908))
* **access-control:** hide My Account group features if Memberships is still active ([#4650](#4650)) ([214fa0d](214fa0d))
* add object-level authorization to corrections REST endpoint ([#4643](#4643)) ([a39a62d](a39a62d))
* address false positives in subscription status alerts on My Account ([f7d6bb8](f7d6bb8))
* address false positives in subscription status alerts on My Account ([31c8313](31c8313))
* clear stored referrer data where referrer is none or local ([c7ef6f3](c7ef6f3))
* count `pending-cancel` by testing against our canonical constant ([2a1f85b](2a1f85b))
* count `pending-cancel` by testing against our canonical constant ([8906b64](8906b64))
* include products without children when reviewing active subscriptions ([d714f3c](d714f3c))
* include products without children when reviewing active subscriptions ([aae3da2](aae3da2))
* limit success and notice snackbar treatments to My Account page ([3b40bec](3b40bec))
* **my-account:** limit notice/success snackbar overrides to My Account ([49517c1](49517c1))
* normalize referrer data when comparing ([d377afb](d377afb))
* **reader-activation:** clear referrer data when none provided ([696012b](696012b))
* **reader-data:** make is_donor read-only only when platform has server-side tracking ([92b0d34](92b0d34))
* update docblock to reflect simple product support ([ea1f03e](ea1f03e))
* update docblock to reflect simple product support ([ba14f85](ba14f85))
* **woocommerce:** image handling in paginated block ([#4149](#4149)) ([1c91f6c](1c91f6c))

### Features

* **access-control:** advanced settings for RSS content restriction ([#4613](#4613)) ([85aa560](85aa560))
* **access-control:** update default patterns ([#4569](#4569)) ([7f9a6c9](7f9a6c9))
* add filter for future integrations to self-declare server-side (secure?) donor tracking ([76e40fc](76e40fc))
* add README.md for the Overlay Block ([#4651](#4651)) ([6d7de6e](6d7de6e))
* **advertising:** replace placements UI with inline expandable cards ([#4625](#4625)) ([e5de003](e5de003))
* **block-theme:** add overlay block for the block theme ([#4578](#4578)) ([af1e4b9](af1e4b9))
* **components:** update CardFeature button size and variant ([#4609](#4609)) ([1d03d4c](1d03d4c))
* **content-gate:** add per-block access control for Group, Stack, and Row blocks ([#4646](#4646)) ([5bdf458](5bdf458))
* **content-gate:** add POST method for external IP access checks ([#4598](#4598)) ([36bfeea](36bfeea))
* **google-site-kit:** enable custom GA frontend params by default ([#4664](#4664)) ([19830ce](19830ce))
* **handoff:** add URL-based handoff with customizable banner text ([#4603](#4603)) ([be59c68](be59c68))
* **integrations:** add My Account menu hook to integration abstraction ([#4640](#4640)) ([4ef2c91](4ef2c91))
* **integrations:** add subscription and donation metadata ([#4597](#4597)) ([ca928f8](ca928f8))
* **integrations:** implement profile metadata ([#4624](#4624)) ([b1daf85](b1daf85))
* make it easier to do "Block until consent given" setups in Complianz and improve blocking ([#4549](#4549)) ([44dda72](44dda72))
* reader activation segments ([#4604](#4604)) ([3821fed](3821fed))
* **reader-data:** add engagement fields ([#4594](#4594)) ([1cba4ef](1cba4ef))
* **reader-data:** store sync reconciliation ([#4633](#4633)) ([69bdda4](69bdda4))
* require reader to set name when commenting ([#4647](#4647)) ([db5ad73](db5ad73))
* session hydration ([#4618](#4618)) ([665b152](665b152))

### Reverts

* address false positives in subscription status alerts on My Account ([9d203b0](9d203b0))
@github-actions
Copy link
Copy Markdown

🎉 This PR is included in version 6.38.0-alpha.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Labels

[Status] Approved The pull request has been reviewed and is ready to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants