Skip to content

Conversation

@dkoo
Copy link
Contributor

@dkoo dkoo commented Dec 6, 2025

All Submissions:

Changes proposed in this Pull Request:

Implements the logic for the previously noop "Exclusion rule" checkbox for content rules.

Closes NPPD-1029.

How to test the changes in this Pull Request:

  1. In Audience > Content Gates create a content gate if none exists.
  2. Add at least one content rule and confirm that you can toggle on and off the "Exclusion rule" checkbox.
  3. Configure the rule for exclusions. For example, to apply the gate to all posts of the post post type without the "News" and "Opinion" categories, select those categories and then check the box:
Screenshot 2025-12-05 at 5 18 06 PM
  1. Add access rules and publish the gate if not already published.
  2. View posts that that DON'T match the excluded values and confirm that you DO see the gate.
  3. As a reader, view posts that DO match the excluded values and confirm that you DON'T see the gate (content is not restricted).
  4. Review the new unit tests and confirm they make sense and pass.

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?

@dkoo dkoo requested a review from a team as a code owner December 6, 2025 00:14
@dkoo dkoo self-assigned this Dec 6, 2025
@dkoo dkoo added [Status] Needs Review The issue or pull request needs to be reviewed [Status] Needs Design Review labels Dec 6, 2025
@dkoo dkoo requested a review from a team December 6, 2025 00:14
@dkoo
Copy link
Contributor Author

dkoo commented Dec 6, 2025

Tagging @thomasguillot for a design review. Do you think this is enough to configure exclusion rules, or do we need to allow specifying both inclusions and exclusions (this could make the UI fairly complicated)?

@dkoo dkoo force-pushed the feat/exclusion-content-rules branch from b82c974 to 38489ec Compare December 6, 2025 00:24
@dkoo dkoo changed the base branch from feat/update-content-gates-ui to refactor/separate-content-gate-cpts December 6, 2025 00:24
@dkoo dkoo changed the base branch from refactor/separate-content-gate-cpts to feat/update-content-gates-ui December 6, 2025 00:25
Copy link

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

This pull request implements the functionality for content rule exclusions in content gates, allowing publishers to configure gates that apply to all content EXCEPT items matching specified criteria (e.g., all posts except those in certain categories).

  • Adds exclusion boolean field to content rules across the full stack (TypeScript types, React components, PHP API schema, and backend logic)
  • Updates the content gate evaluation logic to properly handle exclusion rules when determining which gates apply to a post
  • Removes unused/obsolete code including taxonomy associations and legacy meta fields from content gate and membership post types

Reviewed changes

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

Show a summary per file
File Description
tests/unit-tests/content-gate/content-gates.php Adds comprehensive unit tests for content gate functionality including exclusion rule behavior
src/wizards/audience/views/content-gates/types/index.d.ts Adds optional exclusion field to TypeScript types and removes unused collapse property
src/wizards/audience/views/content-gates/content-rules.tsx Implements handler for exclusion checkbox changes and passes exclusion state to child components
src/wizards/audience/views/content-gates/content-rule-control.tsx Renders the "Exclusion rule" checkbox and wires up its onChange handler for both rule types
includes/wizards/audience/class-audience-content-gates.php Updates REST API schema to include exclusion field and sanitizes it in content rule processing
includes/plugins/wc-memberships/class-memberships.php Removes unused taxonomy associations and obsolete meta field registrations
includes/content-gate/class-content-restriction-control.php Implements core exclusion logic for evaluating whether posts match gates with exclusion rules
includes/content-gate/class-content-gate.php Adds optional post_status parameter to get_gates() method and removes unused taxonomy associations

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

Base automatically changed from feat/update-content-gates-ui to trunk December 12, 2025 16:18
@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 Dec 17, 2025
@dkoo dkoo merged commit 1e5718b into trunk Dec 17, 2025
16 checks passed
@dkoo dkoo deleted the feat/exclusion-content-rules branch December 17, 2025 17:58
@github-actions
Copy link

Hey @dkoo, 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! ❤️

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 [Status] Needs Design Review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants