license.php
Maintains license state and server communication. The gate controls editor entry while leaving public rendering intact, with bounded grace after the last valid response.
Responsibility#
Maintains license state and server communication. The gate controls editor entry while leaving public rendering intact, with bounded grace after the last valid response.
This is an implementation reference for the released 0.9.13 module. Internal PHP helpers are not a compatibility promise for third-party callers. Prefer the documented REST, Abilities, theme, and filter contracts.
Related modules#
Module constants#
const CANTATA_EDIT_LICENSE_OPTION = 'cantata_edit_license';
const CANTATA_EDIT_LICENSE_GRACE = 14 * DAY_IN_SECONDS;
const CANTATA_EDIT_LICENSE_EVERY = DAY_IN_SECONDS;
These values describe this release. Defined configuration constants and generated identifiers can have different ownership; do not edit stored values directly without following the corresponding workflow.
Literal option and cache keys#
cantata_edit_license_checked, cantata_edit_license_release_tried, update_plugins. These are direct literal keys found in this module; dynamically constructed keys and metadata constants are covered by the storage reference.
WordPress hooks#
| Operation | Hook |
|---|---|
add_filter |
cantata_edit_is_dev_site |
apply_filters |
cantata_edit_is_dev_site |
add_action |
init |
add_action |
admin_init |
add_filter |
cantata_edit_can_open_editor |
add_action and add_filter subscribe to a hook; do_action and apply_filters expose a hook. A subscription is not itself a new extension API. Dynamic hook names are not included in this literal inventory.
Function and method reference#
cantata_edit_is_dev_site#
function cantata_edit_is_dev_site(): bool
Local and development sites are always licensed, so Studio copies and test runs never hit the gate. Filterable, so the gate itself can be tried on a local site: add_filter( 'cantata_edit_is_dev_site', '__return_false' ).
Source location: includes/license.php:36.
cantata_edit_license#
function cantata_edit_license(): array
The stored license record, with defaults.
Source location: includes/license.php:46.
cantata_edit_license_save#
function cantata_edit_license_save( array $license ): void
Internal implementation helper in this module. Its name and signature identify the operation and accepted PHP values; it is not a standalone authenticated endpoint.
Implementation connections: cantata_edit_license.
Source location: includes/license.php:61.
cantata_edit_license_state#
function cantata_edit_license_state(): string
Internal implementation helper in this module. Its name and signature identify the operation and accepted PHP values; it is not a standalone authenticated endpoint.
Implementation connections: cantata_edit_is_dev_site, cantata_edit_license.
Source location: includes/license.php:83.
cantata_edit_license_problem#
function cantata_edit_license_problem(): string
What to tell someone about an invalid license: the server's word, or that a valid answer is too old to rely on.
Implementation connections: cantata_edit_license.
Source location: includes/license.php:100.
cantata_edit_license_allows_editing#
function cantata_edit_license_allows_editing(): bool
Internal implementation helper in this module. Its name and signature identify the operation and accepted PHP values; it is not a standalone authenticated endpoint.
Implementation connections: cantata_edit_license_state.
Source location: includes/license.php:105.
cantata_edit_license_allows_updates#
function cantata_edit_license_allows_updates(): bool
Whether updates may be downloaded. The server decides for real (no package without a valid key); this only picks what to say.
Implementation connections: cantata_edit_license_state.
Source location: includes/license.php:110.
cantata_edit_api#
function cantata_edit_api( string $action, array $args = [] )
One call to the license server. Returns the decoded body, or WP_Error when the server couldn't be reached or answered nonsense. A WP_Error never changes the stored status: only an answer does.
Implementation connections: cantata_edit_license.
Source location: includes/license.php:118.
cantata_edit_license_record#
function cantata_edit_license_record( array $body ): array
Record the server's answer about the key.
Implementation connections: cantata_edit_license, cantata_edit_license_save.
Source location: includes/license.php:143.
cantata_edit_license_activate#
function cantata_edit_license_activate( string $key )
Activate a key for this site. Returns the stored license, or WP_Error.
Implementation connections: cantata_edit_api, cantata_edit_license, cantata_edit_license_error_text, cantata_edit_license_record, cantata_edit_license_release_old_seats, cantata_edit_license_save.
Source location: includes/license.php:166.
cantata_edit_license_release_old_seats#
function cantata_edit_license_release_old_seats(): void
Tell the server to free this site's seat on each earlier key. A key leaves the list once the server answers at all (deactivated, or it doesn't know the key); an unreachable server keeps it for the next try on the dashboard.
Implementation connections: cantata_edit_api, cantata_edit_license, cantata_edit_license_save.
Source location: includes/license.php:194.
cantata_edit_license_deactivate#
function cantata_edit_license_deactivate(): void
Free this site's activation and forget the key. The server is told if it can be reached, but the key is forgotten either way.
Implementation connections: cantata_edit_api, cantata_edit_license, cantata_edit_license_save.
Source location: includes/license.php:214.
cantata_edit_license_check_due#
function cantata_edit_license_check_due(): bool
Re-check the key when it's due: about once a day while valid, hourly otherwise. Runs on the dashboard, and when someone opens the editor near or past the grace deadline, so a site nobody administers isn't shut out by a stale answer. Visitors never wait on the server. Returns true when the server was asked.
Implementation connections: cantata_edit_api, cantata_edit_is_dev_site, cantata_edit_license, cantata_edit_license_record, cantata_edit_license_release_old_seats, cantata_edit_license_save.
Source location: includes/license.php:231.
cantata_edit_license_error_text#
function cantata_edit_license_error_text( string $code ): string
Internal implementation helper in this module. Its name and signature identify the operation and accepted PHP values; it is not a standalone authenticated endpoint.
Implementation connections: cantata_edit_license, cantata_edit_license_allows_editing, cantata_edit_license_check_due, cantata_edit_license_problem, cantata_edit_license_state, cantata_edit_product_name, cantata_edit_settings_url.
Source location: includes/license.php:257.