Exception
8 years ago
Interval
8 years ago
Timezone
7 years ago
views
3 weeks ago
Config.php
8 years ago
Connection.php
8 years ago
Export.php
3 weeks ago
LicensingManager.php
1 year ago
Scheduling.php
1 year ago
SchedulingApi.php
3 years ago
LicensingManager.php
71 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Wpae\Scheduling; |
| 4 | |
| 5 | |
| 6 | class LicensingManager |
| 7 | { |
| 8 | private $options = false; |
| 9 | |
| 10 | public function checkLicense($licenseKey, $productName) |
| 11 | { |
| 12 | |
| 13 | if ($productName !== false) { |
| 14 | // data to send in our API request |
| 15 | $api_params = array( |
| 16 | 'edd_action' => 'activate_license', |
| 17 | 'license' => \PMXE_Plugin::decode($licenseKey), |
| 18 | 'item_name' => urlencode($productName) // the name of our product in EDD |
| 19 | ); |
| 20 | |
| 21 | // Call the custom API. |
| 22 | $response = wp_remote_get( |
| 23 | esc_url_raw(add_query_arg( |
| 24 | $api_params, |
| 25 | $this->getInfoApiUrl() |
| 26 | )), |
| 27 | array( |
| 28 | 'timeout' => 15, |
| 29 | 'sslverify' => false |
| 30 | ) |
| 31 | ); |
| 32 | |
| 33 | // make sure the response came back okay |
| 34 | if (is_wp_error($response)){ |
| 35 | return ['success' => false]; |
| 36 | } |
| 37 | |
| 38 | $responseData = \json_decode($response['body'], true); |
| 39 | |
| 40 | if(is_null($responseData) || empty($responseData['success'])) { |
| 41 | return $responseData ?? ['success' => false]; |
| 42 | } else { |
| 43 | return $responseData; |
| 44 | } |
| 45 | } else { |
| 46 | return ['success' => false]; |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | public function getLicense() |
| 51 | { |
| 52 | $options = $this->getOptions(); |
| 53 | return $options['license']; |
| 54 | } |
| 55 | |
| 56 | public function getInfoApiUrl() |
| 57 | { |
| 58 | $options = $this->getOptions(); |
| 59 | return $options['info_api_url']; |
| 60 | } |
| 61 | |
| 62 | private function getOptions() |
| 63 | { |
| 64 | // Cache the options |
| 65 | if(!$this->options) { |
| 66 | $this->options = \PMXE_Plugin::getInstance()->getOption(); |
| 67 | } |
| 68 | |
| 69 | return $this->options; |
| 70 | } |
| 71 | } |