PluginProbe ʕ •ᴥ•ʔ
Image Widget / 4.2
Image Widget v4.2
trunk 1.0 2.0 2.1 2.2 2.2.1 2.2.2 3.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.2 3.2.1 3.2.10 3.2.11 3.2.2 3.2.3 3.2.4 3.2.5 3.2.7 3.2.8 3.2.9 3.3 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 4.0 4.0.1 4.0.2 4.0.3 4.0.4 4.0.5 4.0.6 4.0.7 4.0.8 4.0.9 4.1 4.1.1 4.1.2 4.2 4.2.1 4.2.2 4.3 4.3.1 4.4 4.4.1 4.4.11 4.4.12 4.4.2 4.4.3 4.4.4 4.4.5 4.4.6 4.4.7 4.4.8 4.4.9
image-widget / freemius / includes / managers / class-fs-plan-manager.php
image-widget / freemius / includes / managers Last commit date
class-fs-admin-menu-manager.php 10 years ago class-fs-admin-notice-manager.php 10 years ago class-fs-key-value-storage.php 10 years ago class-fs-license-manager.php 10 years ago class-fs-option-manager.php 10 years ago class-fs-plan-manager.php 10 years ago class-fs-plugin-manager.php 10 years ago
class-fs-plan-manager.php
147 lines
1 <?php
2 /**
3 * @package Freemius
4 * @copyright Copyright (c) 2015, Freemius, Inc.
5 * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6 * @since 1.0.6
7 */
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit;
11 }
12
13 class FS_Plan_Manager {
14 /**
15 * @var FS_Plan_Manager
16 */
17 private static $_instance;
18
19 /**
20 * @return FS_Plan_Manager
21 */
22 static function instance() {
23 if ( ! isset( self::$_instance ) ) {
24 self::$_instance = new FS_Plan_Manager();
25 }
26
27 return self::$_instance;
28 }
29
30 private function __construct() {
31 }
32
33 /**
34 * @param FS_Plugin_License[] $licenses
35 *
36 * @return bool
37 */
38 function has_premium_license( $licenses ) {
39 if ( is_array( $licenses ) ) {
40 foreach ( $licenses as $license ) {
41 if ( ! $license->is_utilized() && $license->is_features_enabled() ) {
42 return true;
43 }
44 }
45 }
46
47 return false;
48 }
49
50 /**
51 * Check if plugin has any paid plans.
52 *
53 * @author Vova Feldman (@svovaf)
54 * @since 1.0.7
55 *
56 * @param FS_Plugin_Plan[] $plans
57 *
58 * @return bool
59 */
60 function has_paid_plan( $plans ) {
61 if ( ! is_array( $plans ) || 0 === count( $plans ) ) {
62 return false;
63 }
64
65 for ( $i = 0, $len = count( $plans ); $i < $len; $i ++ ) {
66 if ( ! $plans[ $i ]->is_free() ) {
67 return true;
68 }
69 }
70
71 return false;
72 }
73
74 /**
75 * Check if plugin has any free plan, or is it premium only.
76 *
77 * Note: If no plans configured, assume plugin is free.
78 *
79 * @author Vova Feldman (@svovaf)
80 * @since 1.0.7
81 *
82 * @param FS_Plugin_Plan[] $plans
83 *
84 * @return bool
85 */
86 function has_free_plan( $plans ) {
87 if ( ! is_array( $plans ) || 0 === count( $plans ) ) {
88 return true;
89 }
90
91 for ( $i = 0, $len = count( $plans ); $i < $len; $i ++ ) {
92 if ( $plans[ $i ]->is_free() ) {
93 return true;
94 }
95 }
96
97 return false;
98 }
99
100 /**
101 * Find all plans that have trial.
102 *
103 * @author Vova Feldman (@svovaf)
104 * @since 1.0.9
105 *
106 * @param FS_Plugin_Plan[] $plans
107 *
108 * @return FS_Plugin_Plan[]
109 */
110 function get_trial_plans( $plans ) {
111 $trial_plans = array();
112
113 if ( is_array( $plans ) && 0 < count( $plans ) ) {
114 for ( $i = 0, $len = count( $plans ); $i < $len; $i ++ ) {
115 if ( $plans[ $i ]->has_trial() ) {
116 $trial_plans[] = $plans[ $i ];
117 }
118 }
119 }
120
121 return $trial_plans;
122 }
123
124 /**
125 * Check if plugin has any trial plan.
126 *
127 * @author Vova Feldman (@svovaf)
128 * @since 1.0.9
129 *
130 * @param FS_Plugin_Plan[] $plans
131 *
132 * @return bool
133 */
134 function has_trial_plan( $plans ) {
135 if ( ! is_array( $plans ) || 0 === count( $plans ) ) {
136 return true;
137 }
138
139 for ( $i = 0, $len = count( $plans ); $i < $len; $i ++ ) {
140 if ( $plans[ $i ]->has_trial() ) {
141 return true;
142 }
143 }
144
145 return false;
146 }
147 }