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 bool $is_free_localhost Defaults to true. If true, allow unlimited localhost installs with the same 
  39. * license. 
  40. */ 
  41. public $is_free_localhost; 
  42. /** 
  43. * @var bool $is_block_features Defaults to true. If false, don't block features after license expiry - only 
  44. * block updates and support. 
  45. */ 
  46. public $is_block_features; 
  47. /** 
  48. * @var bool 
  49. */ 
  50. public $is_cancelled; 
  51.  
  52. #endregion Properties 
  53.  
  54. /** 
  55. * @param stdClass|bool $license 
  56. */ 
  57. function __construct( $license = false ) { 
  58. parent::__construct( $license ); 
  59.  
  60. static function get_type() { 
  61. return 'license'; 
  62.  
  63. /** 
  64. * Check how many site activations left. 
  65. * @author Vova Feldman (@svovaf) 
  66. * @since 1.0.5 
  67. * @return int 
  68. */ 
  69. function left() { 
  70. if ( $this->is_expired() ) { 
  71. return 0; 
  72.  
  73. return ( $this->quota - $this->activated - ( $this->is_free_localhost ? 0 : $this->activated_local ) ); 
  74.  
  75. /** 
  76. * Check if single site license. 
  77. * @author Vova Feldman (@svovaf) 
  78. * @since 1.1.8.1 
  79. * @return bool 
  80. */ 
  81. function is_single_site() { 
  82. return ( is_numeric( $this->quota ) && 1 == $this->quota ); 
  83.  
  84. /** 
  85. * @author Vova Feldman (@svovaf) 
  86. * @since 1.0.5 
  87. * @return bool 
  88. */ 
  89. function is_expired() { 
  90. return ! $this->is_lifetime() && ( strtotime( $this->expiration ) < WP_FS__SCRIPT_START_TIME ); 
  91.  
  92. /** 
  93. * @author Vova Feldman (@svovaf) 
  94. * @since 1.0.6 
  95. * @return bool 
  96. */ 
  97. function is_lifetime() { 
  98. return is_null( $this->expiration ); 
  99.  
  100. /** 
  101. * Check if license is fully utilized. 
  102. * @author Vova Feldman (@svovaf) 
  103. * @since 1.0.6 
  104. * @param bool $is_localhost 
  105. * @return bool 
  106. */ 
  107. function is_utilized( $is_localhost = null ) { 
  108. if ( is_null( $is_localhost ) ) { 
  109. $is_localhost = WP_FS__IS_LOCALHOST_FOR_SERVER; 
  110.  
  111. return ! ( $this->is_free_localhost && $is_localhost ) && 
  112. ( $this->quota <= $this->activated + ( $this->is_free_localhost ? 0 : $this->activated_local ) ); 
  113.  
  114. /** 
  115. * Check if license's plan features are enabled. 
  116. * - Either if plan not expired 
  117. * - If expired, based on the configuration to block features or not. 
  118. * @author Vova Feldman (@svovaf) 
  119. * @since 1.0.6 
  120. * @return bool 
  121. */ 
  122. function is_features_enabled() { 
  123. return ( ! $this->is_block_features || ! $this->is_expired() ); 
  124.  
  125. /** 
  126. * Subscription considered to be new without any payments 
  127. * if the license expires in less than 24 hours 
  128. * from the license creation. 
  129. * @author Vova Feldman (@svovaf) 
  130. * @since 1.0.9 
  131. * @return bool 
  132. */ 
  133. function is_first_payment_pending() { 
  134. return ( WP_FS__TIME_24_HOURS_IN_SEC >= strtotime( $this->expiration ) - strtotime( $this->created ) );