feat(integrations): add content gate metadata#4605
Open
chickenn00dle wants to merge 3 commits intotrunkfrom
Open
feat(integrations): add content gate metadata#4605chickenn00dle wants to merge 3 commits intotrunkfrom
chickenn00dle wants to merge 3 commits intotrunkfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds Reader Activation Sync contact metadata for Content Gate access so ESP/CRM contacts can be annotated with whether they can bypass custom content gates and what grants that access.
Changes:
- Implement
Reader_Activation\Sync\Contact_Metadata\Content_Gateto computeContent_AccessandContent_Access_Sourcefrom published content gates’ custom access rules. - Expose
User_Gate_Access::evaluate_gate_for_user()publicly for reuse by the metadata class. - Add unit tests covering basic content-gate metadata behavior (primarily email domain rules).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
includes/reader-activation/sync/contact-metadata/class-content-gate.php |
Computes and returns Content Gate metadata fields for sync, including source derivation from per-rule evaluation. |
includes/content-gate/class-user-gate-access.php |
Makes evaluate_gate_for_user() public so other components can reuse detailed evaluation results. |
tests/unit-tests/content-gate/class-content-gate-metadata.php |
Adds unit tests validating metadata output for no gates, invalid user, and email-domain rule scenarios. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
includes/reader-activation/sync/contact-metadata/class-content-gate.php
Outdated
Show resolved
Hide resolved
includes/reader-activation/sync/contact-metadata/class-content-gate.php
Outdated
Show resolved
Hide resolved
includes/reader-activation/sync/contact-metadata/class-content-gate.php
Outdated
Show resolved
Hide resolved
5f3c4c1 to
be9c88e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the
Content_Gatemetadata class for reader activation sync, adding two fields that track whether a reader has access to gated content and what grants that access."Yes"or"No"— whether the reader can bypass any published content gate with custom access rules. Never empty."domain"(email domain rule), or"group"(institutional access). Empty when Content_Access is"No".Makes
User_Gate_Access::evaluate_gate_for_user()public so the metadata class can reuse its detailed per-rule evaluation results.Fixes
get_access_source_labelsto only include product names the user has actually purchased, rather than all products configured on the gate rule. UsesAccess_Rules::has_active_subscription()to check each product individually, covering both individual and group subscriptions.Closes NPPD-1390
Test plan
wp-config.php:Content_Access = "No"andContent_Access_Source= empty (since the reader has no subscriptions)Content_Access = "Yes"andContent_Access_Source= only the purchased product name (e.g.,"Basic Plan"), NOT both productsContent_Access_Sourcenow includes both product names"domain"when the reader's email matches"group"when the reader matchesContent_Access = "Yes"with empty source🤖 Generated with Claude Code