FS_Plugin_License

The NextGEN Gallery FS Plugin License class.

Defined (1)

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

/freemius/includes/entities/class-fs-plugin-license.php  
  1. class FS_Plugin_License extends FS_Entity { 
  2.  
  3. #region Properties 
  4.  
  5. /** 
  6. * @var number 
  7. */ 
  8. public $plugin_id; 
  9. /** 
  10. * @var number 
  11. */ 
  12. public $user_id; 
  13. /** 
  14. * @var number 
  15. */ 
  16. public $plan_id; 
  17. /** 
  18. * @var number 
  19. */ 
  20. public $pricing_id; 
  21. /** 
  22. * @var int|null 
  23. */ 
  24. public $quota; 
  25. /** 
  26. * @var int 
  27. */ 
  28. public $activated; 
  29. /** 
  30. * @var int 
  31. */ 
  32. public $activated_local; 
  33. /** 
  34. * @var string 
  35. */ 
  36. public $expiration; 
  37. /** 
  38. * @var string 
  39. */ 
  40. public $secret_key; 
  41. /** 
  42. * @var bool $is_free_localhost Defaults to true. If true, allow unlimited localhost installs with the same 
  43. * license. 
  44. */ 
  45. public $is_free_localhost; 
  46. /** 
  47. * @var bool $is_block_features Defaults to true. If false, don't block features after license expiry - only 
  48. * block updates and support. 
  49. */ 
  50. public $is_block_features; 
  51. /** 
  52. * @var bool 
  53. */ 
  54. public $is_cancelled; 
  55.  
  56. #endregion Properties 
  57.  
  58. /** 
  59. * @param stdClass|bool $license 
  60. */ 
  61. function __construct( $license = false ) { 
  62. parent::__construct( $license ); 
  63.  
  64. static function get_type() { 
  65. return 'license'; 
  66.  
  67. /** 
  68. * Check how many site activations left. 
  69. * @author Vova Feldman (@svovaf) 
  70. * @since 1.0.5 
  71. * @return int 
  72. */ 
  73. function left() { 
  74. if ( ! $this->is_active() || $this->is_expired() ) { 
  75. return 0; 
  76.  
  77. if ( $this->is_unlimited() ) { 
  78. return 999; 
  79.  
  80. return ( $this->quota - $this->activated - ( $this->is_free_localhost ? 0 : $this->activated_local ) ); 
  81.  
  82. /** 
  83. * Check if single site license. 
  84. * @author Vova Feldman (@svovaf) 
  85. * @since 1.1.8.1 
  86. * @return bool 
  87. */ 
  88. function is_single_site() { 
  89. return ( is_numeric( $this->quota ) && 1 == $this->quota ); 
  90.  
  91. /** 
  92. * @author Vova Feldman (@svovaf) 
  93. * @since 1.0.5 
  94. * @return bool 
  95. */ 
  96. function is_expired() { 
  97. return ! $this->is_lifetime() && ( strtotime( $this->expiration ) < WP_FS__SCRIPT_START_TIME ); 
  98.  
  99. /** 
  100. * Check if license is not expired. 
  101. * @author Vova Feldman (@svovaf) 
  102. * @since 1.2.1 
  103. * @return bool 
  104. */ 
  105. function is_valid() { 
  106. return ! $this->is_expired(); 
  107.  
  108. /** 
  109. * @author Vova Feldman (@svovaf) 
  110. * @since 1.0.6 
  111. * @return bool 
  112. */ 
  113. function is_lifetime() { 
  114. return is_null( $this->expiration ); 
  115.  
  116. /** 
  117. * @author Vova Feldman (@svovaf) 
  118. * @since 1.2.0 
  119. * @return bool 
  120. */ 
  121. function is_unlimited() { 
  122. return is_null( $this->quota ); 
  123.  
  124. /** 
  125. * Check if license is fully utilized. 
  126. * @author Vova Feldman (@svovaf) 
  127. * @since 1.0.6 
  128. * @param bool $is_localhost 
  129. * @return bool 
  130. */ 
  131. function is_utilized( $is_localhost = null ) { 
  132. if ( is_null( $is_localhost ) ) { 
  133. $is_localhost = WP_FS__IS_LOCALHOST_FOR_SERVER; 
  134.  
  135. if ( $this->is_unlimited() ) { 
  136. return false; 
  137.  
  138. return ! ( $this->is_free_localhost && $is_localhost ) && 
  139. ( $this->quota <= $this->activated + ( $this->is_free_localhost ? 0 : $this->activated_local ) ); 
  140.  
  141. /** 
  142. * @author Vova Feldman (@svovaf) 
  143. * @since 1.2.1 
  144. * @return bool 
  145. */ 
  146. function is_active() { 
  147. return ( ! $this->is_cancelled ); 
  148.  
  149. /** 
  150. * Check if license's plan features are enabled. 
  151. * - Either if plan not expired 
  152. * - If expired, based on the configuration to block features or not. 
  153. * @author Vova Feldman (@svovaf) 
  154. * @since 1.0.6 
  155. * @return bool 
  156. */ 
  157. function is_features_enabled() { 
  158. return $this->is_active() && ( ! $this->is_block_features || ! $this->is_expired() ); 
  159.  
  160. /** 
  161. * Subscription considered to be new without any payments 
  162. * if the license expires in less than 24 hours 
  163. * from the license creation. 
  164. * @author Vova Feldman (@svovaf) 
  165. * @since 1.0.9 
  166. * @return bool 
  167. */ 
  168. function is_first_payment_pending() { 
  169. return ( WP_FS__TIME_24_HOURS_IN_SEC >= strtotime( $this->expiration ) - strtotime( $this->created ) );