FS_Plan_Manager

The NextGEN Gallery FS Plan Manager class.

Defined (1)

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

/freemius/includes/managers/class-fs-plan-manager.php  
  1. class FS_Plan_Manager { 
  2. /** 
  3. * @var FS_Plan_Manager 
  4. */ 
  5. private static $_instance; 
  6.  
  7. /** 
  8. * @return FS_Plan_Manager 
  9. */ 
  10. static function instance() { 
  11. if ( ! isset( self::$_instance ) ) { 
  12. self::$_instance = new FS_Plan_Manager(); 
  13.  
  14. return self::$_instance; 
  15.  
  16. private function __construct() { 
  17.  
  18. /** 
  19. * @param FS_Plugin_License[] $licenses 
  20. * @return bool 
  21. */ 
  22. function has_premium_license( $licenses ) { 
  23. if ( is_array( $licenses ) ) { 
  24. /** 
  25. * @var FS_Plugin_License[] $licenses 
  26. */ 
  27. foreach ( $licenses as $license ) { 
  28. if ( ! $license->is_utilized() && $license->is_features_enabled() ) { 
  29. return true; 
  30.  
  31. return false; 
  32.  
  33. /** 
  34. * Check if plugin has any paid plans. 
  35. * @author Vova Feldman (@svovaf) 
  36. * @since 1.0.7 
  37. * @param FS_Plugin_Plan[] $plans 
  38. * @return bool 
  39. */ 
  40. function has_paid_plan( $plans ) { 
  41. if ( ! is_array( $plans ) || 0 === count( $plans ) ) { 
  42. return false; 
  43.  
  44. /** 
  45. * @var FS_Plugin_Plan[] $plans 
  46. */ 
  47. for ( $i = 0, $len = count( $plans ); $i < $len; $i ++ ) { 
  48. if ( ! $plans[ $i ]->is_free() ) { 
  49. return true; 
  50.  
  51. return false; 
  52.  
  53. /** 
  54. * Check if plugin has any free plan, or is it premium only. 
  55. * Note: If no plans configured, assume plugin is free. 
  56. * @author Vova Feldman (@svovaf) 
  57. * @since 1.0.7 
  58. * @param FS_Plugin_Plan[] $plans 
  59. * @return bool 
  60. */ 
  61. function has_free_plan( $plans ) { 
  62. if ( ! is_array( $plans ) || 0 === count( $plans ) ) { 
  63. return true; 
  64.  
  65. /** 
  66. * @var FS_Plugin_Plan[] $plans 
  67. */ 
  68. for ( $i = 0, $len = count( $plans ); $i < $len; $i ++ ) { 
  69. if ( $plans[ $i ]->is_free() ) { 
  70. return true; 
  71.  
  72. return false; 
  73.  
  74. /** 
  75. * Find all plans that have trial. 
  76. * @author Vova Feldman (@svovaf) 
  77. * @since 1.0.9 
  78. * @param FS_Plugin_Plan[] $plans 
  79. * @return FS_Plugin_Plan[] 
  80. */ 
  81. function get_trial_plans( $plans ) { 
  82. $trial_plans = array(); 
  83.  
  84. if ( is_array( $plans ) && 0 < count( $plans ) ) { 
  85. /** 
  86. * @var FS_Plugin_Plan[] $plans 
  87. */ 
  88. for ( $i = 0, $len = count( $plans ); $i < $len; $i ++ ) { 
  89. if ( $plans[ $i ]->has_trial() ) { 
  90. $trial_plans[] = $plans[ $i ]; 
  91.  
  92. return $trial_plans; 
  93.  
  94. /** 
  95. * Check if plugin has any trial plan. 
  96. * @author Vova Feldman (@svovaf) 
  97. * @since 1.0.9 
  98. * @param FS_Plugin_Plan[] $plans 
  99. * @return bool 
  100. */ 
  101. function has_trial_plan( $plans ) { 
  102. if ( ! is_array( $plans ) || 0 === count( $plans ) ) { 
  103. return true; 
  104.  
  105. /** 
  106. * @var FS_Plugin_Plan[] $plans 
  107. */ 
  108. for ( $i = 0, $len = count( $plans ); $i < $len; $i ++ ) { 
  109. if ( $plans[ $i ]->has_trial() ) { 
  110. return true; 
  111.  
  112. return false;