public function getLicenseKey($key) { if (!$key or $key === '') { return false; } $result = wp_remote_get($this->baseUrl . '?edd_action=check_license&item_name=WP+Pusher&license=' . $key . '&url=' . home_url()); if (is_wp_error($result)) { add_settings_error('invalid-license-server-message', '', 'We couldn\'t check your license. Are you connected to the Internet?'); } $code = wp_remote_retrieve_response_code($result); if ($code !== 200) { return false; } $body = wp_remote_retrieve_body($result); $array = json_decode($body, true); if (!$array) { return false; } if ($array['license'] === 'invalid') { return false; } if ($array['license'] !== 'active') { $key = $this->registerKeyForSite($key); if (!$key) { return false; } } // For backwards compatability: $array['token'] = $key; return LicenseKey::fromEddResponseArray($array); }