pmpro_license_isValid

Check license.

Description

pmpro_license_isValid( (constant) $key = NULL, (constant) $type = NULL, (constant) $force = false ); 

Parameters (3)

0. $key — Optional. (constant) => NULL
The key.
1. $type — Optional. (constant) => NULL
The type.
2. $force — Optional. (constant) => false
The force.

Usage

  1. if ( !function_exists( 'pmpro_license_isValid' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'paid-memberships-pro/includes/license.php'; 
  3.  
  4. // The key. 
  5. $key = NULL; 
  6.  
  7. // The type. 
  8. $type = NULL; 
  9.  
  10. // The force. 
  11. $force = false; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = pmpro_license_isValid($key, $type, $force); 
  15.  

Defined (1)

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

/includes/license.php  
  1. function pmpro_license_isValid($key = NULL, $type = NULL, $force = false) {  
  2. //check cache first 
  3. $pmpro_license_check = get_option('pmpro_license_check', false); 
  4. if(empty($force) && $pmpro_license_check !== false && $pmpro_license_check['enddate'] > current_time('timestamp')) 
  5. if(empty($type)) 
  6. return true; 
  7. elseif($type == $pmpro_license_check['license']) 
  8. return true; 
  9. else 
  10. return false; 
  11.  
  12. //get key and site url 
  13. if(empty($key)) 
  14. $key = get_option("pmpro_license_key", ""); 
  15.  
  16. //no key 
  17. if(!empty($key))  
  18. return pmpro_license_check_key($key); 
  19. else 
  20. //no key 
  21. delete_option('pmpro_license_check'); 
  22. add_option('pmpro_license_check', array('license'=>false, 'enddate'=>0), NULL, 'no'); 
  23.  
  24. return false;