Plugin_License implements Registerable, License

License magic.

Tags
author

Barn2 Plugins [email protected]

license

GPL-3.0

copyright

Barn2 Media Ltd

version
1.2.1

Interfaces, Classes and Traits

Registerable
An object that can be registered with WordPress via the Plugin API, i.e. add_action() and add_filter().
License
Interface to represent a plugin license.

Table of Contents

RENEWAL_DISCOUNT_CODE  = 'RENEWAL20'
$home_url  : mixed
$item_id  : mixed
$legacy_db_prefix  : mixed
$license_api  : mixed
$license_data  : mixed
$license_option  : mixed
__construct()  : mixed
Creates a new plugin license instance.
activate()  : bool
Attempt to activate the specified license key.
deactivate()  : bool
Attempt to deactivate the current license key.
exists()  : mixed
get_active_url()  : mixed
get_error_code()  : mixed
get_error_message()  : mixed
get_item_id()  : mixed
get_license_key()  : mixed
get_renewal_url()  : mixed
get_setting_name()  : mixed
get_status()  : mixed
get_status_help_text()  : mixed
has_site_moved()  : mixed
is_active()  : mixed
is_disabled()  : mixed
is_expired()  : mixed
is_inactive()  : mixed
is_valid()  : mixed
migrate_legacy_license()  : mixed
override()  : mixed
refresh()  : void
Refresh the current license key information from the EDD Licensing server. Ensures the correct license state for this plugin is stored in the database.
register()  : void
Register this object with WordPress.
clean_license_url()  : string
Cleans the URL to use for the license.
format_license_info()  : mixed
get_default_data()  : mixed
get_home_url()  : mixed
get_license_data()  : mixed
get_license_disabled_message()  : mixed
get_license_expired_message()  : mixed
get_license_inactive_message()  : mixed
get_license_info()  : mixed
is_license_overridden()  : mixed
is_valid_status()  : mixed
sanitize_license_data()  : mixed
set_license_data()  : mixed
set_missing_license()  : mixed
set_site_inactive()  : mixed
set_status()  : mixed
to_license_status()  : mixed
update_license_data()  : mixed

Constants

RENEWAL_DISCOUNT_CODE

public mixed RENEWAL_DISCOUNT_CODE = 'RENEWAL20'

Properties

Methods

__construct()

Creates a new plugin license instance.

public __construct(int $item_id, License_API $license_api[, string $legacy_db_prefix = '' ]) : mixed
Parameters
$item_id : int

The item ID for this plugin.

$license_api : License_API

The API to perform the various license actions (activate, deactivate, etc).

$legacy_db_prefix : string = ''

Legacy plugins only - the database prefix for the license settings.

Return values
mixed —

activate()

Attempt to activate the specified license key.

public activate(string $license_key) : bool
Parameters
$license_key : string

The license key to activate.

Return values
bool —

true if successfully activated, false otherwise.

deactivate()

Attempt to deactivate the current license key.

public deactivate() : bool
Return values
bool —

true if successfully deactivated, false otherwise.

get_active_url()

public get_active_url() : mixed
Return values
mixed —

get_error_code()

public get_error_code() : mixed
Return values
mixed —

get_error_message()

public get_error_message() : mixed
Return values
mixed —

get_item_id()

public get_item_id() : mixed
Return values
mixed —

get_license_key()

public get_license_key() : mixed
Return values
mixed —

get_renewal_url()

public get_renewal_url([mixed $apply_discount = true ]) : mixed
Parameters
$apply_discount : mixed = true
Return values
mixed —

get_setting_name()

public get_setting_name() : mixed
Return values
mixed —

get_status()

public get_status() : mixed
Return values
mixed —

get_status_help_text()

public get_status_help_text() : mixed
Return values
mixed —

has_site_moved()

public has_site_moved() : mixed
Return values
mixed —

is_disabled()

public is_disabled() : mixed
Return values
mixed —

is_expired()

public is_expired() : mixed
Return values
mixed —

is_inactive()

public is_inactive() : mixed
Return values
mixed —

migrate_legacy_license()

public migrate_legacy_license() : mixed
Return values
mixed —

override()

public override(mixed $license_key, mixed $status) : mixed
Parameters
$license_key : mixed
$status : mixed
Return values
mixed —

refresh()

Refresh the current license key information from the EDD Licensing server. Ensures the correct license state for this plugin is stored in the database.

public refresh() : void
Return values
void —

register()

Register this object with WordPress.

public register() : void
Return values
void —

clean_license_url()

Cleans the URL to use for the license.

private clean_license_url(string $url) : string

As in EDD Software Licensing, we ignore www. and http/https in URL to prevent similar URLs causing separate license activations.

Parameters
$url : string

The URL to clean.

Return values
string —

Cleaned URL.

format_license_info()

private format_license_info(mixed $api_response) : mixed
Parameters
$api_response : mixed
Return values
mixed —

get_default_data()

private get_default_data() : mixed
Return values
mixed —

get_home_url()

private get_home_url() : mixed
Return values
mixed —

get_license_data()

private get_license_data() : mixed
Return values
mixed —

get_license_disabled_message()

private get_license_disabled_message() : mixed
Return values
mixed —

get_license_expired_message()

private get_license_expired_message() : mixed
Return values
mixed —

get_license_inactive_message()

private get_license_inactive_message() : mixed
Return values
mixed —

get_license_info()

private get_license_info() : mixed
Return values
mixed —

is_license_overridden()

private is_license_overridden() : mixed
Return values
mixed —

is_valid_status()

private is_valid_status(mixed $status) : mixed
Parameters
$status : mixed
Return values
mixed —

sanitize_license_data()

private sanitize_license_data(array<string|int, mixed> $data) : mixed
Parameters
$data : array<string|int, mixed>
Return values
mixed —

set_license_data()

private set_license_data(array<string|int, mixed> $data) : mixed
Parameters
$data : array<string|int, mixed>
Return values
mixed —

set_missing_license()

private set_missing_license() : mixed
Return values
mixed —

set_site_inactive()

private set_site_inactive() : mixed
Return values
mixed —

set_status()

private set_status(mixed $status) : mixed
Parameters
$status : mixed
Return values
mixed —

to_license_status()

private to_license_status(mixed $api_license_status) : mixed
Parameters
$api_license_status : mixed
Return values
mixed —

update_license_data()

private update_license_data(array<string|int, mixed> $data) : mixed
Parameters
$data : array<string|int, mixed>
Return values
mixed —

Search results