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 |
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
add_filter('lmfwc_table_licenses_column_name', function($columns) { $columns['foo_fighters'] = 'Foo Fighters'; return $columns; });
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. |
add_filter('lmfwc_table_licenses_column_name', function($columns) { if ($column_name !== 'foo_fighters') { return $item; } $item[$column_name] = "Walk"; return $item; });
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
add_action('lmfwc_event_post_order_license_keys', function($args) { $orderId = $args['orderId']; $licenses = $args['licenses']; foreach ($licenses as $license) { // Do something } });
4.Functions reference #
4.1.lmfwc_add_license() #
function lmfwc_add_license(string $licenseKey, array $licenseData)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
4.2.lmfwc_get_license() #
function lmfwc_get_license(string $licenseKey)
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
4.3.lmfwc_get_licenses() #
function lmfwc_get_licenses(array $query)
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
4.4.lmfwc_update_license() #
function lmfwc_update_license(string $licenseKey, array $licenseData)
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
4.5.lmfwc_delete_license() #
function lmfwc_delete_license(string $licenseKey)
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
4.6.lmfwc_activate_license() #
function lmfwc_activate_license(string $licenseKey)
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
4.7.lmfwc_deactivate_license() #
function lmfwc_deactivate_license(string $licenseKey)
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
4.8.lmfwc_add_license_meta() #
function lmfwc_add_license_meta(int $licenseId, string $metaKey, mixed $metaValue)
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
4.9.lmfwc_get_license_meta() #
function lmfwc_get_license_meta(int $licenseId, string $metaKey, bool $single = false)
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
4.10.lmfwc_update_license_meta() #
function lmfwc_update_license_meta(int $licenseId, string $metaKey, mixed $metaValue, mixed $previousValue = null)
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
4.11.lmfwc_delete_license_meta() #
function lmfwc_delete_license_meta(int $licenseId, string $metaKey, mixed $metaValue = null)
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.