calderawpcfeddfieldsfieldslicense

The Caldera Forms EDD calderawp cfeddfields fields license class.

Defined (1)

The class is defined in the following location(s).

/vendor/calderawp/cf-edd-fields/src/fields/license.php  
  1. class license { 
  2.  
  3. /** 
  4. * Get all licensed add-ons for a user 
  5. * @param null|int $user_id Optional. User ID, current user ID if mull 
  6. * @param bool $include_expired Optional. If false the default, expired licenses will be skipped. 
  7. * @return bool|array Array of download_id => download title or false if none found. 
  8. */ 
  9. public static function get_downloads_by_licensed_user( $user_id = null, $include_expired = false ) { 
  10. if ( is_null( $user_id ) ) { 
  11. $user_id = get_current_user_id(); 
  12.  
  13. $licensed_downloads = false; 
  14. if ( 0 < absint( $user_id ) ) { 
  15. global $wpdb; 
  16. $query = $wpdb->prepare( 'SELECT `post_id` FROM `%2s` WHERE `meta_value` = %d AND `meta_key` = "_edd_sl_user_id"', $wpdb->postmeta, $user_id ); 
  17. $licenses = $wpdb->get_results( $query, ARRAY_A ); 
  18.  
  19. if ( ! empty( $licenses ) ) { 
  20. foreach( $licenses as $license ) { 
  21. if ( ! $include_expired ) { 
  22. $status = get_post_meta( $license[ 'post_id' ], '_edd_sl_status', true ); 
  23. if ( false == $status ) { 
  24. continue; 
  25.  
  26. $id = get_post_meta( $license[ 'post_id'], '_edd_sl_download_id', true ); 
  27. if ( $id ) { 
  28. $licensed_downloads[$id] = get_the_title( $id ); 
  29.  
  30.  
  31.  
  32.  
  33. return $licensed_downloads; 
  34.  
  35.  
  36.  
  37.