PHP Class Yoast_License_Manager

Inheritance: implements iYoast_License_Manager
Show file Open project: yoast/license-manager Class Usage Examples

Protected Properties

Property Type Description
$is_network_activated Boolean indicating whether this plugin is network activated
$prefix Used to prefix ID's, option names, etc..
$product The license

Public Methods

Method Description
__construct ( Yoast_Product $product ) Constructor
activate_license ( ) : boolean Remotely activate License
catch_post_request ( ) Check if the license form has been submitted
deactivate_license ( ) : boolean Remotely deactivate License
display_admin_notices ( ) Display license specific admin notices, namely:
get_license_expiry_date ( ) : string Gets the license expiry date
get_license_key ( ) : string Gets the license key from constant or option
get_license_status ( ) : string Get the license status
license_is_valid ( ) : boolean Checks whether the license status is active
output_script ( ) Output the script containing the YoastLicenseManager JS Object
set_license_constant_name ( string $license_constant_name ) Set the constant used to define the license
set_license_expiry_date ( $expiry_date ) Stores the license expiry date
set_license_key ( string $license_key ) Set the license key
set_license_status ( string $license_status ) Set the license status
setup_hooks ( ) Setup hooks
show_license_form ( boolean $embedded = true ) Show a form where users can enter their license key
show_license_form_heading ( )

Protected Methods

Method Description
call_license_api ( string $action ) : mixed
get_api_availability ( ) : array Get the API availability information
get_curl_version ( ) : mixed Get the current curl version, or false
get_option ( string $name ) : mixed Gets a license related option
get_options ( ) : array Get all license related options
set_notice ( string $message, $success = true ) Set a notice to display in the admin area
set_option ( string $name, mixed $value ) Set a license related option
set_options ( array $options ) Set license related options

Private Methods

Method Description
check_api_host_availability ( ) : boolean Check if the API host address is available from this server
maybe_set_license_key_from_constant ( ) Maybe set license key from a defined constant

Method Details

__construct() public method

Constructor
public __construct ( Yoast_Product $product )
$product Yoast_Product

activate_license() public method

Remotely activate License
public activate_license ( ) : boolean
return boolean True if the license is now activated, false if not

call_license_api() protected method

protected call_license_api ( string $action ) : mixed
$action string activate|deactivate
return mixed

catch_post_request() public method

Check if the license form has been submitted
public catch_post_request ( )

deactivate_license() public method

Remotely deactivate License
public deactivate_license ( ) : boolean
return boolean True if the license is now deactivated, false if not

display_admin_notices() public method

- License for the product isn't activated - External requests are blocked through WP_HTTP_BLOCK_EXTERNAL

get_api_availability() protected method

Get the API availability information
protected get_api_availability ( ) : array
return array

get_curl_version() protected method

Get the current curl version, or false
protected get_curl_version ( ) : mixed
return mixed

get_license_expiry_date() public method

Gets the license expiry date
public get_license_expiry_date ( ) : string
return string

get_license_key() public method

Gets the license key from constant or option
public get_license_key ( ) : string
return string $license_key

get_license_status() public method

Get the license status
public get_license_status ( ) : string
return string $license_status;

get_option() protected method

Gets a license related option
protected get_option ( string $name ) : mixed
$name string The option name
return mixed The option value

get_options() protected method

Get all license related options
protected get_options ( ) : array
return array Array of license options

license_is_valid() public method

Checks whether the license status is active
public license_is_valid ( ) : boolean
return boolean True if license is active

output_script() public method

This takes care of disabling the 'activate' and 'deactivate' buttons
public output_script ( )

set_license_constant_name() public method

Set the constant used to define the license
public set_license_constant_name ( string $license_constant_name )
$license_constant_name string The license constant name

set_license_expiry_date() public method

Stores the license expiry date
public set_license_expiry_date ( $expiry_date )

set_license_key() public method

Set the license key
public set_license_key ( string $license_key )
$license_key string

set_license_status() public method

Set the license status
public set_license_status ( string $license_status )
$license_status string

set_notice() protected method

Set a notice to display in the admin area
protected set_notice ( string $message, $success = true )
$message string The message to display

set_option() protected method

Set a license related option
protected set_option ( string $name, mixed $value )
$name string The option name
$value mixed The option value

set_options() protected method

Set license related options
protected set_options ( array $options )
$options array Array of new license options

setup_hooks() public method

Setup hooks
public setup_hooks ( )

show_license_form() public method

Show a form where users can enter their license key
public show_license_form ( boolean $embedded = true )
$embedded boolean Boolean indicating whether this form is embedded in another form?

show_license_form_heading() public method

Property Details

$is_network_activated protected property

Boolean indicating whether this plugin is network activated
protected $is_network_activated

$prefix protected property

Used to prefix ID's, option names, etc..
protected $prefix

$product protected property

The license
protected $product