diff --git a/software-license-manager/client-side-examples/sample-php-scripts/create-license.php b/software-license-manager/client-side-examples/sample-php-scripts/create-license.php
index 1c050e1..2526cdf 100644
--- a/software-license-manager/client-side-examples/sample-php-scripts/create-license.php
+++ b/software-license-manager/client-side-examples/sample-php-scripts/create-license.php
@@ -1,12 +1,12 @@
20, 'sslverify' => false));
// Check for error in the response
- if (is_wp_error($response)){
- echo "Unexpected Error! The query returned with an error.";
+ if (is_wp_error($response)) {
+ echo 'Unexpected Error! The query returned with an error.';
}
//var_dump($response);//uncomment it if you want to look at the full response
@@ -58,18 +58,17 @@ function sample_license_management_page() {
// TODO - Do something with it.
//var_dump($license_data);//uncomment it to look at the data
- if($license_data->result == 'success'){//Success was returned for the license activation
+ if ('success' === $license_data->result) {//Success was returned for the license activation
- //Uncomment the followng line to see the message that returned from the license server
+ //Uncomment the following line to see the message that returned from the license server
echo '
The following message was returned from the server: '.$license_data->message;
//Save the license key in the options table
update_option('sample_license_key', $license_key);
- }
- else{
+ } else {
//Show error to the user. Probably entered incorrect license key.
- //Uncomment the followng line to see the message that returned from the license server
+ //Uncomment the following line to see the message that returned from the license server
echo '
The following message was returned from the server: '.$license_data->message;
}
@@ -94,8 +93,8 @@ function sample_license_management_page() {
$response = wp_remote_get($query, array('timeout' => 20, 'sslverify' => false));
// Check for error in the response
- if (is_wp_error($response)){
- echo "Unexpected Error! The query returned with an error.";
+ if (is_wp_error($response)) {
+ echo 'Unexpected Error! The query returned with an error.';
}
//var_dump($response);//uncomment it if you want to look at the full response
@@ -106,18 +105,17 @@ function sample_license_management_page() {
// TODO - Do something with it.
//var_dump($license_data);//uncomment it to look at the data
- if($license_data->result == 'success'){//Success was returned for the license activation
+ if ('success' === $license_data->result) {//Success was returned for the license activation
- //Uncomment the followng line to see the message that returned from the license server
+ //Uncomment the following line to see the message that returned from the license server
echo '
The following message was returned from the server: '.$license_data->message;
- //Remove the licensse key from the options table. It will need to be activated again.
+ //Remove the license key from the options table. It will need to be activated again.
update_option('sample_license_key', '');
- }
- else{
+ } else {
//Show error to the user. Probably entered incorrect license key.
- //Uncomment the followng line to see the message that returned from the license server
+ //Uncomment the following line to see the message that returned from the license server
echo '
The following message was returned from the server: '.$license_data->message;
}
@@ -141,4 +139,4 @@ function sample_license_management_page() {
';
-}
\ No newline at end of file
+}
diff --git a/software-license-manager/includes/slm-api-listener.php b/software-license-manager/includes/slm-api-listener.php
index 87dd098..27b648d 100644
--- a/software-license-manager/includes/slm-api-listener.php
+++ b/software-license-manager/includes/slm-api-listener.php
@@ -27,7 +27,7 @@ function __construct() {
}
function creation_api_listener() {
- if (isset($_REQUEST['slm_action']) && trim($_REQUEST['slm_action']) == 'slm_create_new') {
+ if (isset($_REQUEST['slm_action']) && trim($_REQUEST['slm_action']) === 'slm_create_new') {
//Handle the licene creation API query
global $slm_debug_logger;
@@ -36,15 +36,15 @@ function creation_api_listener() {
SLM_API_Utility::verify_secret_key_for_creation(); //Verify the secret key first.
- $slm_debug_logger->log_debug("API - license creation (slm_create_new) request received.");
+ $slm_debug_logger->log_debug('API - license creation (slm_create_new) request received.');
//Action hook
do_action('slm_api_listener_slm_create_new');
$fields = array();
- if (isset($_REQUEST['license_key']) && !empty($_REQUEST['license_key'])){
+ if (isset($_REQUEST['license_key']) && !empty($_REQUEST['license_key'])) {
$fields['license_key'] = strip_tags($_REQUEST['license_key']);//Use the key you pass via the request
- }else{
+ } else {
$fields['license_key'] = uniqid($lic_key_prefix);//Use random generated key
}
$fields['lic_status'] = isset( $_REQUEST['lic_status'] ) ? wp_unslash( strip_tags( $_REQUEST['lic_status'] ) ) : 'pending';
@@ -58,8 +58,8 @@ function creation_api_listener() {
} else {
$fields['max_allowed_domains'] = strip_tags($_REQUEST['max_allowed_domains']);
}
- $fields['date_created'] = isset($_REQUEST['date_created'])?strip_tags($_REQUEST['date_created']):date("Y-m-d");
- $fields['date_expiry'] = isset($_REQUEST['date_expiry'])?strip_tags($_REQUEST['date_expiry']):'';
+ $fields['date_created'] = isset($_REQUEST['date_created']) ? strip_tags($_REQUEST['date_created']) : date('Y-m-d');
+ $fields['date_expiry'] = isset($_REQUEST['date_expiry']) ? strip_tags($_REQUEST['date_expiry']) : '';
$fields['product_ref'] = isset( $_REQUEST['product_ref'] ) ? wp_unslash( strip_tags( $_REQUEST['product_ref'] ) ) : '';
global $wpdb;
@@ -85,13 +85,13 @@ function creation_api_listener() {
*/
function activation_api_listener() {
- if (isset($_REQUEST['slm_action']) && trim($_REQUEST['slm_action']) == 'slm_activate') {
+ if (isset($_REQUEST['slm_action']) && trim($_REQUEST['slm_action']) === 'slm_activate') {
//Handle the license activation API query
global $slm_debug_logger;
SLM_API_Utility::verify_secret_key(); //Verify the secret key first.
- $slm_debug_logger->log_debug("API - license activation (slm_activate) request received.");
+ $slm_debug_logger->log_debug('API - license activation (slm_activate) request received.');
//Action hook
do_action('slm_api_listener_slm_activate');
@@ -106,28 +106,28 @@ function activation_api_listener() {
$tbl_name = SLM_TBL_LICENSE_KEYS;
$reg_table = SLM_TBL_LIC_DOMAIN;
$key = $fields['lic_key'];
- $sql_prep1 = $wpdb->prepare("SELECT * FROM $tbl_name WHERE license_key = %s", $key);
+ $sql_prep1 = $wpdb->prepare("SELECT * FROM {$tbl_name} WHERE license_key = %s", $key);
$retLic = $wpdb->get_row($sql_prep1, OBJECT);
- $sql_prep2 = $wpdb->prepare("SELECT * FROM $reg_table WHERE lic_key = %s", $key);
+ $sql_prep2 = $wpdb->prepare("SELECT * FROM {$reg_table} WHERE lic_key = %s", $key);
$reg_domains = $wpdb->get_results($sql_prep2, OBJECT);
if ($retLic) {
- if ($retLic->lic_status == 'blocked') {
+ if ('blocked' === $retLic->lic_status) {
$args = (array('result' => 'error', 'message' => 'Your License key is blocked', 'error_code' => SLM_Error_Codes::LICENSE_BLOCKED));
SLM_API_Utility::output_api_response($args);
- } elseif ($retLic->lic_status == 'expired') {
+ } elseif ('expired' === $retLic->lic_status) {
$args = (array('result' => 'error', 'message' => 'Your License key has expired', 'error_code' => SLM_Error_Codes::LICENSE_EXPIRED));
SLM_API_Utility::output_api_response($args);
}
if (count($reg_domains) < floor($retLic->max_allowed_domains)) {
foreach ($reg_domains as $reg_domain) {
- if (isset($_REQUEST['migrate_from']) && (trim($_REQUEST['migrate_from']) == $reg_domain->registered_domain)) {
+ if (isset($_REQUEST['migrate_from']) && (trim($_REQUEST['migrate_from']) === $reg_domain->registered_domain)) {
$wpdb->update($reg_table, array('registered_domain' => $fields['registered_domain']), array('registered_domain' => trim(strip_tags($_REQUEST['migrate_from']))));
$args = (array('result' => 'success', 'message' => 'Registered domain has been updated'));
SLM_API_Utility::output_api_response($args);
}
- if ($fields['registered_domain'] == $reg_domain->registered_domain) {
+ if ($fields['registered_domain'] === $reg_domain->registered_domain) {
$args = (array('result' => 'error', 'message' => 'License key already in use on ' . $reg_domain->registered_domain, 'error_code' => SLM_Error_Codes::LICENSE_IN_USE));
SLM_API_Utility::output_api_response($args);
}
@@ -135,7 +135,7 @@ function activation_api_listener() {
$fields['lic_key_id'] = $retLic->id;
$wpdb->insert($reg_table, $fields);
- $slm_debug_logger->log_debug("Updating license key status to active.");
+ $slm_debug_logger->log_debug('Updating license key status to active.');
$data = array('lic_status' => 'active');
$where = array('id' => $retLic->id);
$updated = $wpdb->update($tbl_name, $data, $where);
@@ -146,7 +146,7 @@ function activation_api_listener() {
//Lets loop through the domains to see if it is being used on an existing domain or not.
foreach ($reg_domains as $reg_domain) {
- if ($fields['registered_domain'] == $reg_domain->registered_domain) {
+ if ($fields['registered_domain'] === $reg_domain->registered_domain) {
//Not used on an existing domain. Return error: LICENSE_IN_USE_ON_DOMAIN_AND_MAX_REACHED
$args = (array('result' => 'error', 'message' => 'Reached maximum activation. License key already in use on ' . $reg_domain->registered_domain, 'error_code' => SLM_Error_Codes::LICENSE_IN_USE_ON_DOMAIN_AND_MAX_REACHED));
SLM_API_Utility::output_api_response($args);
@@ -165,13 +165,13 @@ function activation_api_listener() {
}
function deactivation_api_listener() {
- if (isset($_REQUEST['slm_action']) && trim($_REQUEST['slm_action']) == 'slm_deactivate') {
+ if (isset($_REQUEST['slm_action']) && trim($_REQUEST['slm_action']) === 'slm_deactivate') {
//Handle the license deactivation API query
global $slm_debug_logger;
SLM_API_Utility::verify_secret_key(); //Verify the secret key first.
- $slm_debug_logger->log_debug("API - license deactivation (slm_deactivate) request received.");
+ $slm_debug_logger->log_debug('API - license deactivation (slm_deactivate) request received.');
//Action hook
do_action('slm_api_listener_slm_deactivate');
@@ -186,11 +186,11 @@ function deactivation_api_listener() {
global $wpdb;
$registered_dom_table = SLM_TBL_LIC_DOMAIN;
- $sql_prep = $wpdb->prepare("DELETE FROM $registered_dom_table WHERE lic_key=%s AND registered_domain=%s", $license_key, $registered_domain);
+ $sql_prep = $wpdb->prepare("DELETE FROM {$registered_dom_table} WHERE lic_key=%s AND registered_domain=%s", $license_key, $registered_domain);
$delete = $wpdb->query($sql_prep);
- if ($delete === false) {
- $slm_debug_logger->log_debug("Error - failed to delete the registered domain from the database.");
- } else if ($delete == 0) {
+ if (false === $delete) {
+ $slm_debug_logger->log_debug('Error - failed to delete the registered domain from the database.');
+ } else if (0 == $delete) {
$args = (array('result' => 'error', 'message' => 'The license key on this domain is already inactive', 'error_code' => SLM_Error_Codes::DOMAIN_ALREADY_INACTIVE));
SLM_API_Utility::output_api_response($args);
} else {
@@ -201,17 +201,17 @@ function deactivation_api_listener() {
}
function check_api_listener() {
- if (isset($_REQUEST['slm_action']) && trim($_REQUEST['slm_action']) == 'slm_check') {
+ if (isset($_REQUEST['slm_action']) && trim($_REQUEST['slm_action']) === 'slm_check') {
//Handle the license check API query
global $slm_debug_logger;
SLM_API_Utility::verify_secret_key(); //Verify the secret key first.
- $slm_debug_logger->log_debug("API - license check (slm_check) request received.");
+ $slm_debug_logger->log_debug('API - license check (slm_check) request received.');
$fields = array();
$fields['lic_key'] = trim(strip_tags($_REQUEST['license_key']));
- $slm_debug_logger->log_debug("License key: " . $fields['lic_key']);
+ $slm_debug_logger->log_debug('License key: ' . $fields['lic_key']);
//Action hook
do_action('slm_api_listener_slm_check');
@@ -220,10 +220,10 @@ function check_api_listener() {
$tbl_name = SLM_TBL_LICENSE_KEYS;
$reg_table = SLM_TBL_LIC_DOMAIN;
$key = $fields['lic_key'];
- $sql_prep1 = $wpdb->prepare("SELECT * FROM $tbl_name WHERE license_key = %s", $key);
+ $sql_prep1 = $wpdb->prepare("SELECT * FROM {$tbl_name} WHERE license_key = %s", $key);
$retLic = $wpdb->get_row($sql_prep1, OBJECT);
- $sql_prep2 = $wpdb->prepare("SELECT * FROM $reg_table WHERE lic_key = %s", $key);
+ $sql_prep2 = $wpdb->prepare("SELECT * FROM {$reg_table} WHERE lic_key = %s", $key);
$reg_domains = $wpdb->get_results($sql_prep2, OBJECT);
if ($retLic) {//A license key exists
$args = apply_filters( 'slm_check_response_args', array(
diff --git a/software-license-manager/includes/slm-debug-logger.php b/software-license-manager/includes/slm-debug-logger.php
index f0ab6ae..2d5c160 100644
--- a/software-license-manager/includes/slm-debug-logger.php
+++ b/software-license-manager/includes/slm-debug-logger.php
@@ -26,7 +26,7 @@ function __construct()
$this->log_folder_path = WP_LICENSE_MANAGER_PATH . '/logs';
//Check config and if debug is enabled then set the enabled flag to true
$options = get_option('slm_plugin_options');
- if(!empty($options['enable_debug'])){//Debugging is enabled
+ if (!empty($options['enable_debug'])) {//Debugging is enabled
$this->debug_enabled = true;
}
}
@@ -39,10 +39,9 @@ function get_debug_timestamp()
function get_debug_status($level)
{
$size = count($this->debug_status);
- if($level >= $size){
+ if ($level >= $size) {
return 'UNKNOWN';
- }
- else{
+ } else {
return $this->debug_status[$level];
}
}
@@ -57,7 +56,7 @@ function get_section_break($section_break)
function reset_log_file($file_name='')
{
- if(empty($file_name)){
+ if (empty($file_name)) {
$file_name = $this->default_log_file;
}
$debug_log_file = $this->log_folder_path.'/'.$file_name;
@@ -69,9 +68,9 @@ function reset_log_file($file_name='')
function append_to_file($content,$file_name)
{
- if(empty($file_name))$file_name = $this->default_log_file;
+ if (empty($file_name))$file_name = $this->default_log_file;
$debug_log_file = $this->log_folder_path.'/'.$file_name;
- $fp=fopen($debug_log_file,'a');
+ $fp=fopen($debug_log_file, 'a');
fwrite($fp, $content);
fclose($fp);
}
@@ -102,7 +101,7 @@ function log_debug_cron($message,$level=0,$section_break=false)
static function log_debug_st($message,$level=0,$section_break=false,$file_name='')
{
$options = get_option('slm_plugin_options');
- if(empty($options['enable_debug'])){//Debugging is disabled
+ if (empty($options['enable_debug'])) {//Debugging is disabled
return;
}
$content = '['.date('m/d/Y g:i A').'] - STATUS : '. $message . "\n";
diff --git a/software-license-manager/includes/slm-init-time-tasks.php b/software-license-manager/includes/slm-init-time-tasks.php
index be2667d..5f2d7df 100644
--- a/software-license-manager/includes/slm-init-time-tasks.php
+++ b/software-license-manager/includes/slm-init-time-tasks.php
@@ -2,7 +2,7 @@
class SLM_Init_Time_Tasks{
- function __construct(){
+ function __construct() {
$this->load_scripts();
//Add other init time operations here
@@ -15,12 +15,12 @@ function load_scripts()
wp_enqueue_script('jquery');
//Load all admin side scripts and styles only
- if(is_admin())
+ if (is_admin())
{
wp_enqueue_script('jquery-ui-datepicker');
wp_enqueue_script('wplm-custom-admin-js', WP_LICENSE_MANAGER_URL . '/js/wplm-custom-admin.js', array( 'jquery-ui-dialog' ));//admin only custom js code
- if (isset($_GET['page']) && $_GET['page'] == 'wp_lic_mgr_addedit') {//Only include if we are in the license add/edit interface
+ if (isset($_GET['page']) && 'wp_lic_mgr_addedit' === $_GET['page']) {//Only include if we are in the license add/edit interface
wp_enqueue_style('jquery-ui-style', WP_LICENSE_MANAGER_URL .'/css/jquery-ui.css');
}
//wp_enqueue_style('dialogStylesheet', includes_url().'css/jquery-ui-dialog.css');
@@ -33,9 +33,9 @@ function slm_daily_cron_event_handler()
do_action('slm_daily_cron_event_triggered');
- if ( isset($options['enable_auto_key_expiry']) && $options['enable_auto_key_expiry'] == '1'){
+ if ( isset($options['enable_auto_key_expiry']) && '1' == $options['enable_auto_key_expiry']) {
//Do the auto key expiry task
- SLM_Debug_Logger::log_debug_st("SLM daily cronjob - auto expiry of license key is enabled.");
+ SLM_Debug_Logger::log_debug_st('SLM daily cronjob - auto expiry of license key is enabled.');
SLM_Utility::do_auto_key_expiry();
}
diff --git a/software-license-manager/includes/slm-third-party-integration.php b/software-license-manager/includes/slm-third-party-integration.php
index 367a890..2e75cae 100644
--- a/software-license-manager/includes/slm-third-party-integration.php
+++ b/software-license-manager/includes/slm-third-party-integration.php
@@ -8,15 +8,15 @@
function slm_handle_estore_email_body_filter($body, $payment_data, $cart_items) {
global $slm_debug_logger, $wpdb;
- $slm_debug_logger->log_debug("WP eStore integration - checking if a license key needs to be created for this transaction.");
- $products_table_name = $wpdb->prefix . "wp_eStore_tbl";
- $slm_data = "";
+ $slm_debug_logger->log_debug('WP eStore integration - checking if a license key needs to be created for this transaction.');
+ $products_table_name = "{$wpdb->prefix}wp_eStore_tbl";
+ $slm_data = '';
//Check if this is a recurring payment.
if ( function_exists('is_paypal_recurring_payment') ) {
$recurring_payment = is_paypal_recurring_payment($payment_data);
- if( $recurring_payment ){
- $slm_debug_logger->log_debug("This is a recurring payment. No need to create a new license key.");
+ if ( $recurring_payment ) {
+ $slm_debug_logger->log_debug('This is a recurring payment. No need to create a new license key.');
do_action('slm_estore_recurring_payment_received', $payment_data, $cart_items);
return $body;
}
@@ -26,19 +26,19 @@ function slm_handle_estore_email_body_filter($body, $payment_data, $cart_items)
$prod_id = $current_cart_item['item_number'];
$item_name = $current_cart_item['item_name'];
$quantity = $current_cart_item['quantity'];
- if(empty($quantity)){
+ if (empty($quantity)) {
$quantity = 1;
}
$slm_debug_logger->log_debug('License Manager - Item Number: ' . $prod_id . ', Quantity: ' . $quantity . ', Item Name: ' . $item_name);
- $retrieved_product = $wpdb->get_row("SELECT * FROM $products_table_name WHERE id = '$prod_id'", OBJECT);
+ $retrieved_product = $wpdb->get_row("SELECT * FROM {$products_table_name} WHERE id = '$prod_id'", OBJECT);
$package_product = eStore_is_package_product($retrieved_product);
if ($package_product) {
$slm_debug_logger->log_debug('Checking license key generation for package/bundle product.');
$product_ids = explode(',', $retrieved_product->product_download_url);
foreach ($product_ids as $id) {
$id = trim($id);
- $retrieved_product_for_specific_id = $wpdb->get_row("SELECT * FROM $products_table_name WHERE id = '$id'", OBJECT);
+ $retrieved_product_for_specific_id = $wpdb->get_row("SELECT * FROM {$products_table_name} WHERE id = '$id'", OBJECT);
//$slm_data .= slm_estore_check_and_generate_key($retrieved_product_for_specific_id, $payment_data, $cart_items, $item_name);
$slm_data .= slm_estore_check_and_create_key_for_qty($retrieved_product_for_specific_id, $payment_data, $cart_items, $item_name, $quantity);
}
@@ -48,12 +48,12 @@ function slm_handle_estore_email_body_filter($body, $payment_data, $cart_items)
}
}
- $body = str_replace("{slm_data}", $slm_data, $body);
+ $body = str_replace('{slm_data}', $slm_data, $body);
return $body;
}
-function slm_estore_check_and_create_key_for_qty($retrieved_product, $payment_data, $cart_items, $item_name, $quantity){
- $prod_key_data = "";
+function slm_estore_check_and_create_key_for_qty($retrieved_product, $payment_data, $cart_items, $item_name, $quantity) {
+ $prod_key_data = '';
for ($i = 0; $i < $quantity; $i++) {
$prod_key_data .= slm_estore_check_and_generate_key($retrieved_product, $payment_data, $cart_items, $item_name);
}
@@ -86,7 +86,7 @@ function slm_estore_create_license($retrieved_product, $payment_data, $cart_item
//Lets check any product specific configuration.
$prod_id = $retrieved_product->id;
- $product_meta = $wpdb->get_row("SELECT * FROM $product_meta_table_name WHERE prod_id = '$prod_id' AND meta_key='slm_max_allowed_domains'", OBJECT);
+ $product_meta = $wpdb->get_row("SELECT * FROM {$product_meta_table_name} WHERE prod_id = '$prod_id' AND meta_key='slm_max_allowed_domains'", OBJECT);
if ($product_meta) {
//Found product specific SLM config data.
$max_domains = $product_meta->meta_value;
@@ -94,7 +94,7 @@ function slm_estore_create_license($retrieved_product, $payment_data, $cart_item
//Use the default value from settings (the $max_domains variable contains the default value already).
}
//Lets check if any product specific expiry date is set
- $product_meta = $wpdb->get_row("SELECT * FROM $product_meta_table_name WHERE prod_id = '$prod_id' AND meta_key='slm_date_of_expiry'", OBJECT);
+ $product_meta = $wpdb->get_row("SELECT * FROM {$product_meta_table_name} WHERE prod_id = '$prod_id' AND meta_key='slm_date_of_expiry'", OBJECT);
if ($product_meta) {
//Found product specific SLM config data.
$num_days_before_expiry = $product_meta->meta_value;
@@ -115,7 +115,7 @@ function slm_estore_create_license($retrieved_product, $payment_data, $cart_item
$fields['company_name'] = $payment_data['company_name'];
$fields['txn_id'] = $payment_data['txn_id'];
$fields['max_allowed_domains'] = $max_domains;
- $fields['date_created'] = date("Y-m-d"); //Today's date
+ $fields['date_created'] = date('Y-m-d'); //Today's date
$fields['date_expiry'] = $slm_date_of_expiry;
$fields['product_ref'] = $prod_id;//WP eStore product ID
$fields['subscr_id'] = isset($payment_data['subscr_id']) ? $payment_data['subscr_id'] : '';
@@ -129,11 +129,11 @@ function slm_estore_create_license($retrieved_product, $payment_data, $cart_item
if (!$result) {
$slm_debug_logger->log_debug('Notice! initial database table insert failed on license key table (User Email: ' . $fields['email'] . '). Trying again by converting charset', true);
//Convert the default PayPal IPN charset to UTF-8 format
- $first_name = mb_convert_encoding($fields['first_name'], "UTF-8", "windows-1252");
+ $first_name = mb_convert_encoding($fields['first_name'], 'UTF-8', 'windows-1252');
$fields['first_name'] = esc_sql($first_name);
- $last_name = mb_convert_encoding($fields['last_name'], "UTF-8", "windows-1252");
+ $last_name = mb_convert_encoding($fields['last_name'], 'UTF-8', 'windows-1252');
$fields['last_name'] = esc_sql($last_name);
- $company_name = mb_convert_encoding($fields['company_name'], "UTF-8", "windows-1252");
+ $company_name = mb_convert_encoding($fields['company_name'], 'UTF-8', 'windows-1252');
$fields['company_name'] = esc_sql($company_name);
$result = $wpdb->insert($tbl_name, $fields);
@@ -161,25 +161,25 @@ function slm_estore_product_configuration_html($product_config_html, $prod_id) {
if (empty($prod_id)) {
//New product add
- $slm_max_allowed_domains = "";
- $slm_date_of_expiry = "";
+ $slm_max_allowed_domains = '';
+ $slm_date_of_expiry = '';
} else {
//Existing product edit
//Retrieve the max domain value
- $product_meta = $wpdb->get_row("SELECT * FROM $product_meta_table_name WHERE prod_id = '$prod_id' AND meta_key='slm_max_allowed_domains'", OBJECT);
+ $product_meta = $wpdb->get_row("SELECT * FROM {$product_meta_table_name} WHERE prod_id = '$prod_id' AND meta_key='slm_max_allowed_domains'", OBJECT);
if ($product_meta) {
$slm_max_allowed_domains = $product_meta->meta_value;
} else {
- $slm_max_allowed_domains = "";
+ $slm_max_allowed_domains = '';
}
//Retrieve the expiry date value
- $product_meta = $wpdb->get_row("SELECT * FROM $product_meta_table_name WHERE prod_id = '$prod_id' AND meta_key='slm_date_of_expiry'", OBJECT);
+ $product_meta = $wpdb->get_row("SELECT * FROM {$product_meta_table_name} WHERE prod_id = '$prod_id' AND meta_key='slm_date_of_expiry'", OBJECT);
if ($product_meta) {
$slm_date_of_expiry = $product_meta->meta_value;
} else {
- $slm_date_of_expiry = "";
+ $slm_date_of_expiry = '';
}
}
@@ -232,13 +232,13 @@ function slm_estore_product_updated($prod_dat_array, $prod_id) {
$product_meta_table_name = WP_ESTORE_PRODUCTS_META_TABLE_NAME;
//Find the existing value for the max domains field (for the given product)
- $product_meta = $wpdb->get_row("SELECT * FROM $product_meta_table_name WHERE prod_id = '$prod_id' AND meta_key='slm_max_allowed_domains'", OBJECT);
+ $product_meta = $wpdb->get_row("SELECT * FROM {$product_meta_table_name} WHERE prod_id = '{$prod_id}' AND meta_key='slm_max_allowed_domains'", OBJECT);
if ($product_meta) {
//Found existing value so lets update it
//Better to do specific update (so the other meta values for example "download_limit_count" doesn't get set to empty).
- $meta_key_name = "slm_max_allowed_domains";
+ $meta_key_name = 'slm_max_allowed_domains';
$meta_value = $prod_dat_array['slm_max_allowed_domains'];
- $update_db_qry = "UPDATE $product_meta_table_name SET meta_value='$meta_value' WHERE prod_id='$prod_id' AND meta_key='$meta_key_name'";
+ $update_db_qry = "UPDATE {$product_meta_table_name} SET meta_value='{$meta_value}' WHERE prod_id='{$prod_id}' AND meta_key='{$meta_key_name}'";
$results = $wpdb->query($update_db_qry);
} else {
@@ -251,13 +251,13 @@ function slm_estore_product_updated($prod_dat_array, $prod_id) {
}
//Find the existing value for the expiry date field (for the given product)
- $product_meta = $wpdb->get_row("SELECT * FROM $product_meta_table_name WHERE prod_id = '$prod_id' AND meta_key='slm_date_of_expiry'", OBJECT);
+ $product_meta = $wpdb->get_row("SELECT * FROM {$product_meta_table_name} WHERE prod_id = '{$prod_id}' AND meta_key='slm_date_of_expiry'", OBJECT);
if ($product_meta) {
//Found existing value so lets update it
//Better to do specific update (so the other meta values for example "download_limit_count" doesn't get set to empty).
- $meta_key_name = "slm_date_of_expiry";
+ $meta_key_name = 'slm_date_of_expiry';
$meta_value = $prod_dat_array['slm_date_of_expiry'];
- $update_db_qry = "UPDATE $product_meta_table_name SET meta_value='$meta_value' WHERE prod_id='$prod_id' AND meta_key='$meta_key_name'";
+ $update_db_qry = "UPDATE {$product_meta_table_name} SET meta_value='{$meta_value}' WHERE prod_id='{$prod_id}' AND meta_key='{$meta_key_name}'";
$results = $wpdb->query($update_db_qry);
} else {
diff --git a/software-license-manager/includes/slm-utility.php b/software-license-manager/includes/slm-utility.php
index 2fdb8f5..b5a5807 100644
--- a/software-license-manager/includes/slm-utility.php
+++ b/software-license-manager/includes/slm-utility.php
@@ -7,21 +7,21 @@ class SLM_Utility {
static function do_auto_key_expiry() {
global $wpdb;
- $current_date = (date ("Y-m-d"));
+ $current_date = (date ('Y-m-d'));
$tbl_name = SLM_TBL_LICENSE_KEYS;
- $sql_prep = $wpdb->prepare("SELECT * FROM $tbl_name WHERE lic_status !=%s", 'expired');//Load the non-expired keys
+ $sql_prep = $wpdb->prepare("SELECT * FROM {$tbl_name} WHERE lic_status !=%s", 'expired');//Load the non-expired keys
$licenses = $wpdb->get_results($sql_prep, OBJECT);
- if(!$licenses){
- SLM_Debug_Logger::log_debug_st("do_auto_key_expiry() - no license keys found.");
+ if (!$licenses) {
+ SLM_Debug_Logger::log_debug_st('do_auto_key_expiry() - no license keys found.');
return false;
}
- foreach($licenses as $license){
+ foreach ($licenses as $license) {
$key = $license->license_key;
$expiry_date = $license->date_expiry;
- if ($expiry_date == '0000-00-00'){
- SLM_Debug_Logger::log_debug_st("This key (".$key.") doesn't have a valid expiry date set. The expiry of this key will not be checked.");
+ if ('0000-00-00' === $expiry_date) {
+ SLM_Debug_Logger::log_debug_st("This key ({$key}) doesn't have a valid expiry date set. The expiry of this key will not be checked.");
continue;
}
@@ -29,11 +29,11 @@ static function do_auto_key_expiry() {
$expire_dt = new DateTime($expiry_date);
if ($today_dt > $expire_dt) {
//This key has reached the expiry. So expire this key.
- SLM_Debug_Logger::log_debug_st("This key (".$key.") has expired. Expiry date: ".$expiry_date.". Setting license key status to expired.");
+ SLM_Debug_Logger::log_debug_st("This key ({$key}) has expired. Expiry date: {$expiry_date}. Setting license key status to expired.");
$data = array('lic_status' => 'expired');
$where = array('id' => $license->id);
$updated = $wpdb->update($tbl_name, $data, $where);
- do_action('slm_license_key_expired',$license->id);//Trigger the license expired action hook.
+ do_action('slm_license_key_expired', $license->id);//Trigger the license expired action hook.
}
}
@@ -61,7 +61,7 @@ static function delete_registered_domains_of_key($key_row_id) {
global $slm_debug_logger;
global $wpdb;
$reg_table = SLM_TBL_LIC_DOMAIN;
- $sql_prep = $wpdb->prepare("SELECT * FROM $reg_table WHERE lic_key_id = %s", $key_row_id);
+ $sql_prep = $wpdb->prepare("SELECT * FROM {$reg_table} WHERE lic_key_id = %s", $key_row_id);
$reg_domains = $wpdb->get_results($sql_prep, OBJECT);
foreach ($reg_domains as $domain) {
$row_to_delete = $domain->id;
diff --git a/software-license-manager/js/wplm-custom-admin.js b/software-license-manager/js/wplm-custom-admin.js
index fb6639a..abdff10 100644
--- a/software-license-manager/js/wplm-custom-admin.js
+++ b/software-license-manager/js/wplm-custom-admin.js
@@ -1,7 +1,7 @@
-jQuery(document).ready(function($){
+jQuery(function(){
//Add date picker listener on date fields
- if ($.fn.datepicker){
- $('.wplm_pick_date').datepicker({
+ if (jQuery.fn.datepicker) {
+ jQuery('.wplm_pick_date').datepicker({
dateFormat : 'yy-mm-dd'
});
}
diff --git a/software-license-manager/menu/includes/slm-list-table-class.php b/software-license-manager/menu/includes/slm-list-table-class.php
index 82e9df9..6e11922 100644
--- a/software-license-manager/menu/includes/slm-list-table-class.php
+++ b/software-license-manager/menu/includes/slm-list-table-class.php
@@ -149,7 +149,7 @@ function set_pagination_args( $args ) {
* @return array
*/
function get_pagination_arg( $key ) {
- if ( 'page' == $key )
+ if ( 'page' === $key )
return $this->get_pagenum();
if ( isset( $this->_pagination_args[$key] ) )
@@ -281,7 +281,7 @@ function bulk_actions() {
echo "\n";
foreach ( $this->_actions as $name => $title ) {
- $class = 'edit' == $name ? ' class="hide-if-no-js"' : '';
+ $class = 'edit' === $name ? ' class="hide-if-no-js"' : '';
echo "\t\n";
}
@@ -400,7 +400,7 @@ function view_switcher( $current_mode ) {
'; echo $message; echo '