diff --git a/digipass-class.php b/digipass-class.php index 4cf6377..8bb5127 100755 --- a/digipass-class.php +++ b/digipass-class.php @@ -140,7 +140,7 @@ private static function get_blog_ids() */ private static function single_activate() { - // TODO: Define activation functionality here + // Activation functionality } /** @@ -148,7 +148,7 @@ private static function single_activate() */ private static function single_deactivate() { - // TODO: Define deactivation functionality here + // Deactivation functionality } /** diff --git a/options.php b/options.php index 66fb385..d86cb13 100644 --- a/options.php +++ b/options.php @@ -11,7 +11,7 @@ define('DP_OPTIONS', 'DP_OPTIONS'); -define('API_KEY', '31c7bc4e-90ff-44fb-9f07-b88eb06ed9dc'); +define('DP_API_KEY', '31c7bc4e-90ff-44fb-9f07-b88eb06ed9dc'); if (is_admin()) { @@ -186,7 +186,7 @@ function dp_page_init() register_setting( 'DP_OPTIONS_GROUP', // Option group DP_OPTIONS, // Option name - 'dp_sanitize' // dp_sanitize + 'dp_sanitize' // Sanitize ); add_settings_section( @@ -216,7 +216,7 @@ function dp_page_init() */ function dp_sanitize($input) { - $input['dp_netlicensing_apikey'] = dp_sanitize_text_field($input['dp_netlicensing_apikey']); + $input['dp_netlicensing_apikey'] = sanitize_text_field($input['dp_netlicensing_apikey']); return $input; } diff --git a/php/curl/curl.php b/php/curl/curl.php index 9d9497f..f3a2e1d 100755 --- a/php/curl/curl.php +++ b/php/curl/curl.php @@ -8,6 +8,8 @@ * @package curl * @author Sean Huber **/ +if (!class_exists('Curl')) { + class Curl { /** @@ -253,4 +255,6 @@ protected function set_request_options($url, $vars) { } } -} \ No newline at end of file +} + +} diff --git a/php/curl/curl_response.php b/php/curl/curl_response.php index 324bafd..a52da90 100755 --- a/php/curl/curl_response.php +++ b/php/curl/curl_response.php @@ -7,6 +7,8 @@ * @package curl * @author Sean Huber **/ +if (!class_exists('CurlResponse')) { + class CurlResponse { /** @@ -75,4 +77,6 @@ function __toString() { return $this->body; } -} \ No newline at end of file +} + +} diff --git a/php/netlicensing/netlicensing.php b/php/netlicensing/netlicensing.php index 2115e1f..c9d014d 100755 --- a/php/netlicensing/netlicensing.php +++ b/php/netlicensing/netlicensing.php @@ -6,50 +6,54 @@ * @package netlicensing * @author Labs64 **/ -class NetLicensing -{ +if (!class_exists('NetLicensing')) { - const NLIC_BASE_URL = 'https://netlicensing.labs64.com/core/v2/rest'; + class NetLicensing + { - private $curl = null; + const NLIC_BASE_URL = 'https://netlicensing.labs64.com/core/v2/rest'; - /** - * Initializes a NetLicensing object - **/ - function __construct($apiKey) - { - $user_agent = 'NetLicensing/PHP ' . PHP_VERSION . ' (http://netlicensing.labs64.com)' . '; ' . $_SERVER['HTTP_USER_AGENT']; + private $curl = null; - $this->curl = new Curl(); - $this->curl->headers['Authorization'] = 'Basic ' . base64_encode("apiKey:" . $apiKey); - $this->curl->headers['Accept'] = 'application/json'; - $this->curl->user_agent = $user_agent; - } + /** + * Initializes a NetLicensing object + **/ + function __construct($apiKey) + { + $user_agent = 'NetLicensing/PHP ' . PHP_VERSION . ' (http://netlicensing.labs64.com)' . '; ' . $_SERVER['HTTP_USER_AGENT']; - /** - * Validates active licenses of the licensee - * - * Returns a object containing licensee validation result - * - * @param string $productNumber - * @param string $licenseeNumber - * @param string $licenseeName - * @return licensee validation result - **/ - function validate($productNumber, $licenseeNumber, $licenseeName = '') - { - if (empty($licenseeName)) { - $licenseeName = $licenseeNumber; + $this->curl = new Curl(); + $this->curl->headers['Authorization'] = 'Basic ' . base64_encode("apiKey:" . $apiKey); + $this->curl->headers['Accept'] = 'application/json'; + $this->curl->user_agent = $user_agent; } - $params = array( - 'productNumber' => $productNumber, - 'name' => $licenseeName, - ); - $url = self::NLIC_BASE_URL . '/licensee/' . $licenseeNumber . '/validate'; - $response = $this->curl->get($url, $params); + /** + * Validates active licenses of the licensee + * + * Returns a object containing licensee validation result + * + * @param string $productNumber + * @param string $licenseeNumber + * @param string $licenseeName + * @return licensee validation result + **/ + function validate($productNumber, $licenseeNumber, $licenseeName = '') + { + if (empty($licenseeName)) { + $licenseeName = $licenseeNumber; + } + $params = array( + 'productNumber' => $productNumber, + 'name' => $licenseeName, + ); + $url = self::NLIC_BASE_URL . '/licensee/' . $licenseeNumber . '/validate'; + + $response = $this->curl->get($url, $params); + + return $response->body; + } - return $response->body; } }