Internal API

1.Database structure #

1.1.lmfwc_api_keys #

Table structure

 

Name Type Null Default
id BIGINT(20) false None
user_id BIGINT(20) false None
description VARCHAR(200) true null
permissions VARCHAR(10) false None
consumer_key CHAR(64) false None
consumer_secret CHAR(43) false None
nonces LONGTEXT true null
truncated_key CHAR(7) false None
last_access DATETIME true null
created_at DATETIME true null
created_by BIGING(20) true null
updated_at DATETIME true null
updated_by BIGING(20) true null

1.2.lmfwc_generators #

Table structure

 

Name Type Null Default
id BIGINT(20) false None
name VARCHAR(255) false None
charset VARCHAR(255) false None
chunks INT(10) false None
chunk_length INT(10) false None
times_activated_max INT(10) true null
separator VARCHAR(255) true null
prefix VARCHAR(255) true null
suffix VARCHAR(255) true null
expires_in INT(10) true null
created_at DATETIME true null
created_by BIGING(20) true null
updated_at DATETIME true null
updated_by BIGING(20) true null

1.3.lmfwc_licenses #

Table structure

Name Type Null Default
id BIGINT(20) false None
order_id BIGINT(20) true null
product_id BIGINT(20) true null
user_id BIGINT(20) true null
license_key LONGTEXT false None
hash LONGTEXT false None
expires_at DATETIME true null
valid_for INT(32) false null
source VARCHAR(255) false None
status TINYINT(1) false None
times_activated INT(10) true null
times_activated_max INT(10) true null
created_at DATETIME true null
created_by BIGING(20) true null
updated_at DATETIME true null
updated_by BIGING(20) true null

1.4.lmfwc_licenses_meta #

Table structure

Name Type Null Default
meta_id BIGINT(20) false None
license_id BIGINT(20) false 0
meta_key VARCHAR(255) true null
meta_value LONGTEXT true null
created_at DATETIME true null
created_by BIGING(20) true null
updated_at DATETIME true null
updated_by BIGING(20) true null

1.5.Products Installed on #

Column

Type

Comment

meta_id

bigint(20) unsigned Auto Increment

license_id

bigint(20) unsigned [0]

meta_key

varchar(255) NULL

meta_value

longtext NULL

created_at

datetime NULL

created_by

bigint(20) unsigned NULL

updated_at

datetime NULL

updated_by

bigint(20) unsigned NULL

 

2.Filters reference #

2.1.lmfwc_table_licenses_column_name #

Description

This filter is used to add or modify column headers on the Licenses page/table.

Parameters

Name Type Description
$columns Array Array containing key/value pairs of existing columns.

Usage

[php]add_filter('lmfwc_table_licenses_column_name', function($columns) {
  $columns['foo_fighters'] = 'Foo Fighters';
​
  return $columns;
});[/php]

This will add a new column by the name of Foo Fighters.

2.2.lmfwc_table_licenses_column_value #

Description

This filter is used to add or modify column values on the Licenses page/table.

Parameters

Name Type Description
$item Array Associative array of column name and value pairs.
$column_name Array Name of the current column.
[php]add_filter('lmfwc_table_licenses_column_name', function($columns) {
  if ($column_name !== 'foo_fighters') {
    return $item;
  }
​
  $item[$column_name] = "Walk";
​
  return $item;
});[/php]

This will add the text “Walk” into the foo_fighters column.

3.Actions reference #

3.1.lmfwc_event_post_order_license_keys #

Description

This action fires after license keys have been sold. The hook fires for license keys which have been generated, as well as license keys which have been sold from stock.

Parameters

Name Type Description
$args array Associative array containing two keys: orderId and licenses.

Usage

[php]add_action('lmfwc_event_post_order_license_keys', function($args) {
​
  $orderId = $args['orderId'];
  $licenses = $args['licenses'];
​
  foreach ($licenses as $license) {
    // Do something
  }
​
});[/php]

4.Functions reference #

4.1.lmfwc_add_license() #

[php]
function lmfwc_add_license(string $licenseKey, array $licenseData)
[/php]

Description

Adds a new license to the database.

Parameters

$licenseKey (string) (Required)
The license key being added.

$licenseData (array) (Optional)
Key/value pairs. The keys must match the license table columns names.

Return value

(bool|LicenseManagerForWooCommerce\Models\Resources\License)
License model on success, false on failure.

Source code

/includes/functions/lmfwc-license-functions.php#24

4.2.lmfwc_get_license() #

[php]function lmfwc_get_license(string $licenseKey)[/php]

Description

Retrieves an existing license from the database.

Parameters

$licenseKey (string) (Required)
The license key to retrieve.

Return value

(bool|LicenseManagerForWooCommerce\Models\Resources\License)
License model on success, false on failure.

Source code

/includes/functions/lmfwc-license-functions.php#113

4.3.lmfwc_get_licenses() #

[php]function lmfwc_get_licenses(array $query)[/php]

Description

Retrieves multiple existing licenses from the database.

Parameters

$query (array) (Required)
Key/value pairs. The keys will be used to match the license table columns names, and the values will be used to match the values of those columns.

Return value

(bool|LicenseManagerForWooCommerce\Models\Resources\License[])
License model array on success, false on failure.

Source code

/includes/functions/lmfwc-license-functions.php#136

4.4.lmfwc_update_license() #

[php]function lmfwc_update_license(string $licenseKey, array $licenseData)[/php]

Description

Updates an existing license.

Parameters

$licenseKey (string) (Required)
The license key being updated.

$licenseData (array) (Optional)
Key/value pairs. The keys must match the license table columns names.

Return value

(bool|LicenseManagerForWooCommerce\Models\Resources\License)
License model on success, false on failure.

Source code

/includes/functions/lmfwc-license-functions.php#155

4.5.lmfwc_delete_license() #

[php]function lmfwc_delete_license(string $licenseKey)[/php]

Description

Deletes a license from the database.

Parameters

$licenseKey (string) (Required)
The license key to delete.

Return value

(bool)
True on success, false on failure.

Source code

/includes/functions/lmfwc-license-functions.php#304

4.6.lmfwc_activate_license() #

[php]function lmfwc_activate_license(string $licenseKey)[/php]

Description

Activates a license if it has not already reached its maximum activation count.

Parameters

$licenseKey (string) (Required)
The license key to activate.

Return value

(bool|LicenseManagerForWooCommerce\Models\Resources\License)
License model on success, false on failure.

Source code

/includes/functions/lmfwc-license-functions.php#343

4.7.lmfwc_deactivate_license() #

[php]function lmfwc_deactivate_license(string $licenseKey)[/php]

Description

Deactivates a license if it has not already reached 0 activations.

Parameters

$licenseKey (string) (Required)
The license key to deactivate.

Return value

(bool|LicenseManagerForWooCommerce\Models\Resources\License)
License model on success, false on failure.

Source code

/includes/functions/lmfwc-license-functions.php#399

4.8.lmfwc_add_license_meta() #

[php]function lmfwc_add_license_meta(int $licenseId, string $metaKey, mixed $metaValue)[/php]

Description

Adds a new meta entry to a license, if it already exists a new row in the database table will be added.

Parameters

$licenseId (string) (Required)
The ID of the license key.

$metaKey (string) (Required)
Name of the meta entry.

$metaValue (mixed) (Required)
Value of the meta entry.

Return value

(mixed|bool)
Meta value on success, false on failure.

Source code

/includes/functions/lmfwc-meta-functions.php#24

4.9.lmfwc_get_license_meta() #

[php]function lmfwc_get_license_meta(int $licenseId, string $metaKey, bool $single = false)[/php]

Description

Retrieves single or multiple license meta entries.

Parameters

$licenseId (string) (Required)
The ID of the license key.

$metaKey (string) (Required)
Name of the meta entry.

$single (bool) (Optional)
If multiple meta entries exists, setting this parameter to true will retrieve all of them.

Return value

(mixed|mixed[]|bool)
Meta value on success, false on failure.

Source code

/includes/functions/lmfwc-meta-functions.php#57

4.10.lmfwc_update_license_meta() #

[php]function lmfwc_update_license_meta(int $licenseId, string $metaKey, mixed $metaValue, mixed $previousValue = null)[/php]

Description

Updates an existing license meta entry. If the meta key doesn’t already exist, a new row in the database table will be added. If the $previousValue parameter is passed, the meta entry with that value will be updated.

Parameters

$licenseId (string) (Required)
The ID of the license key.

$metaKey (string) (Required)
Name of the meta entry.

$metaValue (mixed) (Required)
Value of the meta entry.

$previousValue (mixed) (Optional)
The previous value of the meta entry.

Return value

(bool)
True on success, false on failure.

Source code

/includes/functions/lmfwc-meta-functions.php#107

4.11.lmfwc_delete_license_meta() #

[php]function lmfwc_delete_license_meta(int $licenseId, string $metaKey, mixed $metaValue = null)[/php]

Description

Deletes a license meta entry. If the $metaValue parameter is passed, the function will look for the meta entry with a matching value to delete.

Parameters

$licenseId (string) (Required)
The ID of the license key.

$metaKey (string) (Required)
Name of the meta entry.

$metaValue (mixed) (Optional)
Value of the meta entry.

Return value

(bool)
True on success, false on failure.

Source code

/includes/functions/lmfwc-meta-functions.php#158

Help Guide Powered by Documentor
Suggest Edit
Scroll to Top