-
Notifications
You must be signed in to change notification settings - Fork 58
feat(content-gating): enable content rule exclusions #4346
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
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)? |
b82c974 to
38489ec
Compare
There was a problem hiding this 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
exclusionboolean 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.
|
Hey @dkoo, good job getting this PR merged! 🎉 Now, the 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! ❤️ |
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:
postpost type without the "News" and "Opinion" categories, select those categories and then check the box:Other information: