Class EDDSoftwareLicensingCustomFieldType
Defines the EDD Software Licensing field type.
Allows you to let your users activate/deactivate Easy Digital Download software licenses managed with the Software Licensing extension.
Scenario
- Somebody purchases your program at your site (license server) with EDD + Software Licensing installed.
- The site generates a license key and the customer receives a download link and a license key.
- The customer types the license key in your program and the program checks whether the license key is valid and activates the license if necessary.
- The program performs automatic updates if the set license is verified.
The field type will do the job of Step 3. It creates a form field that lets the user set a license key in the form input that the field type generates. And if the user presses the submit button, it sends a request to the license server in the background and activate/deactivate the license.
To set up the field, prepare 1. Product Name and 2. The store (license server) url. Then set them with the product_name and store_uri arguments in the field definition array.
Field Type Specific Arguments
store_uri
- (string) The uri of the site that installs EDD Software Licensing extension (the license server).product_name
- (string) The product name.request_time_out
- (integer) The HTTP request time-out in seconds. Default:15
label
- (array) The text labels used for the field.status
- (string) The label to indicate the license status. Default:Status
activated
- (string) The label to indicate the status of being activated. Default:Activated
deactivated
- (string) The label to indicate the status of being deactivated. Default:Deactivated
expired
- (string) The label to indicate the status of being expired. Default:Expired
activate
- (string) The label to indicate the action of activation. Default:Activate
deactivate
- (string) The label to indicate the action of activation. Default:Deactivate
Example
array( 'field_id' => 'field_type_pack_license', 'type' => 'edd_software_licensing', 'store_uri' => AdminPageFrameworkFieldTypePack_Registry::STORE_URI, 'product_name' => AdminPageFrameworkFieldTypePack_Registry::NAME, 'title' => __( 'License Activation', 'admin-page-framework-field-type-pack' ), )
Since: 1.0.0
Located at custom-field-types/edd-software-licensing/EDDSoftwareLicensingCustomFieldType.php
Methods summary
protected
|
|
protected
|
|
protected
|
|
protected
|
|
protected
|
|
protected
|
|
protected
|
#
doOnFieldRegistration( mixed $aField )
Called when a field of this field type is registered. Since
3.5.0
|
public
|
#
replyToCheckLicense( mixed $asInput, mixed $asOldInput, mixed $oFactory, mixed $aSubmitInfo )
A validation callback. This is only called when the Activate / Deactivate button of this field type is pressed. Since
3.5.0
|
protected
array
|
#
_getLicenseResponse( mixed $sAction, mixed $sLicenseKey, mixed $sProductName, mixed $sStoreURI, mixed $iTimeout = 15 )
Retrieves a response from the license server (store). Returnsarray |
protected
boolean
|
#
_activate( mixed $sLicenseKey, mixed $sProductName, mixed $sStoreURI, mixed $iTimeout = 15 )
Activates the license. Returnsboolean true if it is successfully activated; otherwise, false. |
protected
boolean
|
#
_deactivate( mixed $sLicenseKey, mixed $sProductName, mixed $sStoreURI, mixed $iTimeout = 15 )
Deactivates the license. Returnsboolean true if it is successfully deactivated; otherwise, false. |
protected
boolean
|
#
_isActivated( mixed $sLicenseKey, mixed $sProductName, mixed $sStoreURI, mixed $iTimeout = 15 )
Checks if the license is already activated or not. Returnsboolean |
public
|
|
protected
|
|
protected
string
|
#
_getLicenseStatus( array $aField )
Returns the stored status. Returnsstring 'activated' or 'deactivated' |
Magic methods summary
Properties summary
public
array
|
$aFieldTypeSlugs |
#
Defines the field type slugs used for this field type. |
protected
array
|
$aDefaultKeysExtendeed |
#
Defines the extended default key-values of this field type settings. Remark
$aDefaultKeys holds the parent class's default key-vaklues.
$_aDefaultKeys holds shared default key-values defined in the base class. |
public static
array
|
$aResponseCaches |
#
Stores response caches. |