1 | <?php |
||
16 | class FS_Plugin_License extends FS_Entity { |
||
17 | |||
18 | #region Properties |
||
19 | |||
20 | /** |
||
21 | * @var number |
||
22 | */ |
||
23 | public $plugin_id; |
||
24 | /** |
||
25 | * @var number |
||
26 | */ |
||
27 | public $user_id; |
||
28 | /** |
||
29 | * @var number |
||
30 | */ |
||
31 | public $plan_id; |
||
32 | /** |
||
33 | * @var number |
||
34 | */ |
||
35 | public $pricing_id; |
||
36 | /** |
||
37 | * @var int|null |
||
38 | */ |
||
39 | public $quota; |
||
40 | /** |
||
41 | * @var int |
||
42 | */ |
||
43 | public $activated; |
||
44 | /** |
||
45 | * @var int |
||
46 | */ |
||
47 | public $activated_local; |
||
48 | /** |
||
49 | * @var string |
||
50 | */ |
||
51 | public $expiration; |
||
52 | /** |
||
53 | * @var string |
||
54 | */ |
||
55 | public $secret_key; |
||
56 | /** |
||
57 | * @var bool $is_free_localhost Defaults to true. If true, allow unlimited localhost installs with the same |
||
58 | * license. |
||
59 | */ |
||
60 | public $is_free_localhost; |
||
61 | /** |
||
62 | * @var bool $is_block_features Defaults to true. If false, don't block features after license expiry - only |
||
63 | * block updates and support. |
||
64 | */ |
||
65 | public $is_block_features; |
||
66 | /** |
||
67 | * @var bool |
||
68 | */ |
||
69 | public $is_cancelled; |
||
70 | |||
71 | #endregion Properties |
||
72 | |||
73 | /** |
||
74 | * @param stdClass|bool $license |
||
75 | */ |
||
76 | function __construct( $license = false ) { |
||
79 | |||
80 | /** |
||
81 | * Get entity type. |
||
82 | * |
||
83 | * @return string |
||
84 | */ |
||
85 | static function get_type() { |
||
88 | |||
89 | /** |
||
90 | * Check how many site activations left. |
||
91 | * |
||
92 | * @author Vova Feldman (@svovaf) |
||
93 | * @since 1.0.5 |
||
94 | * |
||
95 | * @return int |
||
96 | */ |
||
97 | function left() { |
||
108 | |||
109 | /** |
||
110 | * Check if single site license. |
||
111 | * |
||
112 | * @author Vova Feldman (@svovaf) |
||
113 | * @since 1.1.8.1 |
||
114 | * |
||
115 | * @return bool |
||
116 | */ |
||
117 | function is_single_site() { |
||
120 | |||
121 | /** |
||
122 | * @author Vova Feldman (@svovaf) |
||
123 | * @since 1.0.5 |
||
124 | * |
||
125 | * @return bool |
||
126 | */ |
||
127 | function is_expired() { |
||
130 | |||
131 | /** |
||
132 | * Check if license is not expired. |
||
133 | * |
||
134 | * @author Vova Feldman (@svovaf) |
||
135 | * @since 1.2.1 |
||
136 | * |
||
137 | * @return bool |
||
138 | */ |
||
139 | function is_valid() { |
||
142 | |||
143 | /** |
||
144 | * @author Vova Feldman (@svovaf) |
||
145 | * @since 1.0.6 |
||
146 | * |
||
147 | * @return bool |
||
148 | */ |
||
149 | function is_lifetime() { |
||
152 | |||
153 | /** |
||
154 | * @author Vova Feldman (@svovaf) |
||
155 | * @since 1.2.0 |
||
156 | * |
||
157 | * @return bool |
||
158 | */ |
||
159 | function is_unlimited() { |
||
162 | |||
163 | /** |
||
164 | * Check if license is fully utilized. |
||
165 | * |
||
166 | * @author Vova Feldman (@svovaf) |
||
167 | * @since 1.0.6 |
||
168 | * |
||
169 | * @param bool|null $is_localhost |
||
170 | * |
||
171 | * @return bool |
||
172 | */ |
||
173 | function is_utilized( $is_localhost = null ) { |
||
185 | |||
186 | /** |
||
187 | * Check if license can be activated. |
||
188 | * |
||
189 | * @author Vova Feldman (@svovaf) |
||
190 | * @since 2.0.0 |
||
191 | * |
||
192 | * @param bool|null $is_localhost |
||
193 | * |
||
194 | * @return bool |
||
195 | */ |
||
196 | function can_activate( $is_localhost = null ) { |
||
199 | |||
200 | /** |
||
201 | * Check if license can be activated on a given number of production and localhost sites. |
||
202 | * |
||
203 | * @author Vova Feldman (@svovaf) |
||
204 | * @since 2.0.0 |
||
205 | * |
||
206 | * @param int $production_count |
||
207 | * @param int $localhost_count |
||
208 | * |
||
209 | * @return bool |
||
210 | */ |
||
211 | function can_activate_bulk( $production_count, $localhost_count ) { |
||
223 | |||
224 | /** |
||
225 | * @author Vova Feldman (@svovaf) |
||
226 | * @since 1.2.1 |
||
227 | * |
||
228 | * @return bool |
||
229 | */ |
||
230 | function is_active() { |
||
233 | |||
234 | /** |
||
235 | * Check if license's plan features are enabled. |
||
236 | * |
||
237 | * - Either if plan not expired |
||
238 | * - If expired, based on the configuration to block features or not. |
||
239 | * |
||
240 | * @author Vova Feldman (@svovaf) |
||
241 | * @since 1.0.6 |
||
242 | * |
||
243 | * @return bool |
||
244 | */ |
||
245 | function is_features_enabled() { |
||
248 | |||
249 | /** |
||
250 | * Subscription considered to be new without any payments |
||
251 | * if the license expires in less than 24 hours |
||
252 | * from the license creation. |
||
253 | * |
||
254 | * @author Vova Feldman (@svovaf) |
||
255 | * @since 1.0.9 |
||
256 | * |
||
257 | * @return bool |
||
258 | */ |
||
259 | function is_first_payment_pending() { |
||
262 | |||
263 | /** |
||
264 | * @return int |
||
265 | */ |
||
266 | function total_activations() { |
||
269 | } |
||
270 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.