Advertisement
verygoodplugins

Untitled

May 14th, 2016
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.11 KB | None | 0 0
  1. <?php
  2.  
  3. // Support for old curl versions
  4. add_action('http_api_curl', 'curl_settings', 10, 3);
  5.  
  6.  
  7. function curl_settings( &$cr, $request, $url ) {
  8.  
  9.     if(wp_fusion()->settings->get('override_curl') != true || $url != WPF_STORE_URL)
  10.         return;
  11.  
  12.     curl_setopt($cr, CURLOPT_SSLVERSION, 1);
  13.  
  14. }
  15.  
  16. // Ajax activate
  17.  
  18. function edd_activate($retry = false) {
  19.  
  20.     $license_key = trim($_POST['key']);
  21.  
  22.     // data to send in our API request
  23.     $api_params = array(
  24.         'edd_action'=> 'activate_license',
  25.         'license'   => $license_key,
  26.         'item_name' => urlencode( 'WP Fusion' ), // the name of our product in EDD
  27.         'url'       => home_url()
  28.     );
  29.    
  30.     // Call the custom API.
  31.     $response = wp_remote_post( WPF_STORE_URL, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );
  32.  
  33.     // make sure the response came back okay
  34.     if ( is_wp_error( $response ) ) {
  35.  
  36.         if($response->get_error_code() == 'http_request_failed' && $retry == false) {
  37.  
  38.             wp_fusion()->settings->set('override_curl', true);
  39.             edd_activate(true);
  40.  
  41.         } else {
  42.  
  43.             wp_send_json_error( $response->get_error_message() );
  44.             die();
  45.  
  46.         }
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement