Add global functions for capability checks - #187
Open
pramodjodhani wants to merge 4 commits into
Open
Conversation
Expose lw_harbor_get_licensed_products(), lw_harbor_is_capability_licensed(), and lw_harbor_is_capability_license_active() so consuming plugins can query the cached license catalog without reimplementing License_Repository logic.
…lity_licensed to lw_harbor_is_capability_license_active
pramodjodhani
commented
Jul 29, 2026
|
|
||
| foreach ( $products as $entry ) { | ||
| if ( | ||
| $this->is_capability_covered_by_license( $entry->get_validation_status() ) |
Member
Author
There was a problem hiding this comment.
If we used is_valid() here, we'd get false for entries like:
- not_activated
- activation_required
- out_of_activations
- tier_selection_required
Those are not valid, but they are covered by the license. That's why I had to create is_capability_covered_by_license function.
8 tasks
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
Adds two global Harbor functions so consuming plugins can check capability licensing against the cached unified license catalog, without reimplementing
License_Repositorylogic locally.lw_harbor_is_capability_license_available( $capability_slug )— returns true when the unified key includes the capability, regardless of whether the product is activated on the current domain (e.g.not_activatedentries still count).lw_harbor_is_capability_license_active( $capability_slug )— returns true when the capability is on a product that is valid and activated on the current domain.Repository support is added via
License_Repository::has_capability()andLicense_Repository::is_capability_active().has_capability()uses a privateis_capability_covered_by_license()helper to distinguish "on the license but not activated here" from statuses where the license genuinely doesn't cover the product (expired, no entitlement, etc.).Both functions follow the existing global function pattern: version-leader registry, no remote API calls, local cache only.
Motivation
the-events-calendar/tribe-common#2960 (comment)
Usage
Test plan
lw_harbor_is_capability_license_available()returns true for anot_activatedproduct with the capabilitylw_harbor_is_capability_license_active()returns false for the samenot_activatedproductlw_harbor_is_capability_license_available()returns false for expired products