Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function edd_activate() {
- $license_key = trim($_POST['key']);
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
- curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
- curl_setopt($ch, CURLOPT_TIMEOUT, 0);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_URL, 'https://wpfusionplugin.com/?edd_action=activate_license&license=' . $license_key . '&item_name=' . urlencode( 'WP Fusion' ) . '&url=' . home_url());
- curl_setopt($ch, CURLOPT_SSLVERSION, 1);
- $response = curl_exec($ch);
- $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
- if ($errno = curl_errno($ch)){
- $error_message = curl_strerror($errno);
- wp_send_json_error( $error_message );
- die();
- }
- // decode the license data
- $license_data = json_decode( $response );
- // $license_data->license will be either "valid" or "invalid"
- // Store the options locally
- $this->set('license_status', $license_data->license );
- $this->set('license_key', $license_key );
- if($license_data->license == 'valid') {
- wp_send_json_success('activated');
- } else {
- wp_send_json_error( '<pre>' . print_r($license_data, true) . '</pre>' );
- }
- die();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement