Advertisement
verygoodplugins

Untitled

May 13th, 2016
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.33 KB | None | 0 0
  1.     public function edd_activate() {
  2.  
  3.         $license_key = trim($_POST['key']);
  4.  
  5.         $ch = curl_init();
  6.         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
  7.         curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
  8.         curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
  9.         curl_setopt($ch, CURLOPT_TIMEOUT, 0);
  10.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  11.         curl_setopt($ch, CURLOPT_URL, 'https://wpfusionplugin.com/?edd_action=activate_license&license=' . $license_key . '&item_name=' . urlencode( 'WP Fusion' ) . '&url=' . home_url());
  12.         curl_setopt($ch, CURLOPT_SSLVERSION, 1);
  13.         $response = curl_exec($ch);
  14.         $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
  15.  
  16.         if ($errno = curl_errno($ch)){
  17.             $error_message = curl_strerror($errno);
  18.             wp_send_json_error( $error_message );
  19.             die();
  20.         }
  21.  
  22.         // decode the license data
  23.         $license_data = json_decode( $response );
  24.        
  25.         // $license_data->license will be either "valid" or "invalid"
  26.  
  27.         // Store the options locally
  28.         $this->set('license_status', $license_data->license );
  29.         $this->set('license_key', $license_key );
  30.  
  31.         if($license_data->license == 'valid') {
  32.             wp_send_json_success('activated');
  33.         } else {
  34.             wp_send_json_error( '<pre>' . print_r($license_data, true) . '</pre>' );
  35.         }
  36.  
  37.         die();
  38.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement