Documentation

LicenseActivation
in package
Uses UtilsProvider

Handle license activation.

Table of Contents

Constants

ERROR_CODE_ALREADY_ACTIVATED  = 'rpm_wpc_already_exists'

Properties

$license  : License
License instance.

Methods

__construct()  : mixed
C'tor.
activate()  : mixed
Activate this license with a given code. It returns a `WP_Error` if a code is already active.
applyTimeOfLicenseActivationToTimestamp()  : mixed
Pass any timestamp and this method returns the day of the timestamp with the time of the license activation. This allows us to defer API calls.
deactivate()  : WP_Error|true
Deactivate the license for this blog and plugin.
executeDeferredAction()  : mixed
Schedules an action (callable) for deferred execution. The action is called only once for the given period in days. The action gets called at the time of license activation so we can scutter e.g. API calls to our license server independent of configured time and timezone of current server.
getCode()  : string|false
Get entered license code for this activation. Can be `false` if none given. If it is an empty string, the form got skipped through `#skip()`.
getHint()  : string
Get a hint for this license activation. This can happen e.g. the remote status changed (revoked, expired) and we want to user show a notice for this. Can be `false` if none given.
getInstallationType()  : mixed
See `License#INSTALLATION_TYPE_*` constants.
getLicense()  : mixed
Get license instance.
getPluginConstantPrefix()  : string
Get the prefix of this package so we can utils package natively.
getReceived()  : false|array<string|int, mixed>
Get the license activation we received from our remote license server. This returns also a result if you have deactivated your license already.
getReceivedClientProperties()  : false|array<string|int, mixed>
Get the received client properties from the last contact to our license server for this activation.
getReceivedClientProperty()  : mixed
Get a received client property by key from the last contact to our license server for this activation.
hasInteractedWithFormOnce()  : mixed
Check if the form for this license was shown the user once. This allows you e.g.
isTelemetryDataSharingOptIn()  : bool
Check if this license activation has enabled telemetry data sharing.
setupConstants()  : mixed
Make sure the RPM_WP_CLIENT constants are available.
skip()  : mixed
Mark the license as "ever seen form once", see also `#hasInteractedWithFormOnce`.

Constants

ERROR_CODE_ALREADY_ACTIVATED

public mixed ERROR_CODE_ALREADY_ACTIVATED = 'rpm_wpc_already_exists'

Properties

Methods

activate()

Activate this license with a given code. It returns a `WP_Error` if a code is already active.

public activate(string $code, string $installationType, bool $telemetry, bool $newsletterOptIn, string $firstName, string $email) : mixed
Parameters
$code : string
$installationType : string
$telemetry : bool
$newsletterOptIn : bool
$firstName : string
$email : string

applyTimeOfLicenseActivationToTimestamp()

Pass any timestamp and this method returns the day of the timestamp with the time of the license activation. This allows us to defer API calls.

public applyTimeOfLicenseActivationToTimestamp(int $timestamp) : mixed
Parameters
$timestamp : int

deactivate()

Deactivate the license for this blog and plugin.

public deactivate([bool $remote = false ][, string $validateStatus = null ][, string $help = '' ]) : WP_Error|true
Parameters
$remote : bool = false

If true, the license is also deactivate remotely

$validateStatus : string = null
$help : string = ''
Return values
WP_Error|true

executeDeferredAction()

Schedules an action (callable) for deferred execution. The action is called only once for the given period in days. The action gets called at the time of license activation so we can scutter e.g. API calls to our license server independent of configured time and timezone of current server.

public executeDeferredAction(string $actionName, callable|int $actionOrExpire[, int $periodInDays = 1 ][, string $minimumWpHook = 'init' ]) : mixed
Parameters
$actionName : string
$actionOrExpire : callable|int

If you pass int the action will be scheduled after this expiration in seconds

$periodInDays : int = 1
$minimumWpHook : string = 'init'

getCode()

Get entered license code for this activation. Can be `false` if none given. If it is an empty string, the form got skipped through `#skip()`.

public getCode() : string|false
Return values
string|false

getHint()

Get a hint for this license activation. This can happen e.g. the remote status changed (revoked, expired) and we want to user show a notice for this. Can be `false` if none given.

public getHint() : string
Return values
string

getInstallationType()

See `License#INSTALLATION_TYPE_*` constants.

public getInstallationType() : mixed

getLicense()

Get license instance.

public getLicense() : mixed
Tags
codeCoverageIgnore

getPluginConstantPrefix()

Get the prefix of this package so we can utils package natively.

public getPluginConstantPrefix() : string
Return values
string

getReceived()

Get the license activation we received from our remote license server. This returns also a result if you have deactivated your license already.

public getReceived() : false|array<string|int, mixed>
Return values
false|array<string|int, mixed>

getReceivedClientProperties()

Get the received client properties from the last contact to our license server for this activation.

public getReceivedClientProperties() : false|array<string|int, mixed>

This returns also a result if you have deactivated your license already.

Return values
false|array<string|int, mixed>

getReceivedClientProperty()

Get a received client property by key from the last contact to our license server for this activation.

public getReceivedClientProperty(string $key[, mixed $default = false ]) : mixed

This returns also a result if you have deactivated your license already.

Parameters
$key : string
$default : mixed = false

hasInteractedWithFormOnce()

Check if the form for this license was shown the user once. This allows you e.g.

public hasInteractedWithFormOnce() : mixed

show a form of the license activation directly after using the plugin for the first time.

When the current user cannot activate plugins, a license activation form should never be loaded.

isTelemetryDataSharingOptIn()

Check if this license activation has enabled telemetry data sharing.

public isTelemetryDataSharingOptIn([bool $set = null ]) : bool

Attention: When you provide a $set variable, please also call License#syncWithRemote so the external update server gets noticed about this change!

Parameters
$set : bool = null
Return values
bool

When $set is a boolean, it will return true if telemetry data sharing was successfully enabled

setupConstants()

Make sure the RPM_WP_CLIENT constants are available.

public static setupConstants() : mixed

skip()

Mark the license as "ever seen form once", see also `#hasInteractedWithFormOnce`.

public skip([bool $noUsage = false ]) : mixed

You should use the REST API endpoint plugin-update/:slug/skip for this.

$noUsage = true:

Mark the license as "no usage". That means, the license code is not needed and not considered for "fully licensed" or "partial licensed".

Use case: User has installed the plugin network wide, but want to use the premium plugin only on one sub site.

Parameters
$noUsage : bool = false

        
On this page

Search results