Admin Page Framework - Field Type Pack Documentation
  • Package
  • Class

Packages

  • AdminPageFrameworkFieldTypePack
    • CustomFieldType

Classes

  • AutoCompleteCustomFieldType
  • DateCustomFieldType
  • DateRangeCustomFieldType
  • DateTimeCustomFieldType
  • DateTimeRangeCustomFieldType
  • DialCustomFieldType
  • EDDSoftwareLicensingCustomFieldType
  • FontCustomFieldType
  • GeometryCustomFieldType
  • GridCustomFieldType
  • ImageCheckboxCustomFieldType
  • ImageRadioCustomFieldType
  • LinkCustomFieldType
  • RevealerCustomFieldType
  • TimeCustomFieldType
  • TimeRangeCustomFieldType

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

  1. Somebody purchases your program at your site (license server) with EDD + Software Licensing installed.
  2. The site generates a license key and the customer receives a download link and a license key.
  3. 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.
  4. 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' ),
)
Package: AdminPageFrameworkFieldTypePack\CustomFieldType
Since: 1.0.0
Located at custom-field-types/edd-software-licensing/EDDSoftwareLicensingCustomFieldType.php

Methods summary

protected
# construct( )

User constructor.

Set up properties.

protected
# setUp( )

Loads the field type necessary components.

protected
# getEnqueuingScripts( )

Returns an array holding the urls of enqueuing scripts.

protected
# getEnqueuingStyles( )
protected
# getScripts( )

Returns the field type specific JavaScript script.

protected
# getStyles( )

Returns the field type specific CSS rules.

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).

Returns

array
protected boolean
# _activate( mixed $sLicenseKey, mixed $sProductName, mixed $sStoreURI, mixed $iTimeout = 15 )

Activates the license.

Returns

boolean
true if it is successfully activated; otherwise, false.
protected boolean
# _deactivate( mixed $sLicenseKey, mixed $sProductName, mixed $sStoreURI, mixed $iTimeout = 15 )

Deactivates the license.

Returns

boolean
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.

Returns

boolean
public
# getField( mixed $aField )

Returns the output of the field type.

protected
# _getSetLicenseKey( array $aField )

Returns the user-set license key

protected string
# _getLicenseStatus( array $aField )

Returns the stored status.

Returns

string
'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.

Admin Page Framework - Field Type Pack Documentation generated by ApiGen 2.8.0