Advertisement
verygoodplugins

Untitled

May 7th, 2016
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.11 KB | None | 0 0
  1. function instance() {
  2.     updater();
  3. }
  4.  
  5. updater() {
  6.  
  7.     $license_status = edd_check_license($license_key);
  8.  
  9.     if($license_status == 'valid') {
  10.        
  11.         $edd_updater = new WPF_Plugin_Updater( etc );
  12.  
  13.     } else {
  14.  
  15.         global $pagenow;
  16.  
  17.         if ( 'plugins.php' === $pagenow )
  18.             add_action("after_plugin_row_" . WPF_PLUGIN_PATH, 'display_license_warning', 10, 3);
  19.     }
  20.  
  21. }
  22.  
  23. edd_check_license($license_key) {
  24.    
  25.     $status = get_transient( 'wpf_license_check' );
  26.  
  27.     if( false === $status ) {
  28.  
  29.         $api_params = array(
  30.             'edd_action'=> 'check_license',
  31.             'license'   => $license_key,
  32.             'item_name' => urlencode( 'WP Fusion' ),
  33.             'url'       => home_url()
  34.         );
  35.  
  36.         $response = wp_remote_post( WPF_STORE_URL, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );
  37.  
  38.         if ( is_wp_error( $response ) )
  39.             return false;
  40.  
  41.         $license_data = json_decode( wp_remote_retrieve_body( $response ) );
  42.  
  43.         $this->set('license_status', $license_data->license);
  44.  
  45.         set_transient( 'wpf_license_check', true, 60*60*24*3 );
  46.  
  47.         return $license_data->license;
  48.  
  49.     } else {
  50.  
  51.         return $this->get('license_status');
  52.  
  53.     }
  54.  
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement