This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
0 ignored issues
–
show
|
|||
2 | /** |
||
3 | * @package Freemius |
||
4 | * @copyright Copyright (c) 2015, Freemius, Inc. |
||
5 | * @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3 |
||
6 | * @since 1.0.7 |
||
7 | */ |
||
8 | |||
9 | if ( ! defined( 'ABSPATH' ) ) { |
||
10 | exit; |
||
11 | } |
||
12 | |||
13 | |||
14 | /** |
||
15 | * - Each instance of Freemius class represents a single plugin |
||
16 | * install by a single user (the installer of the plugin). |
||
17 | * |
||
18 | * - Each website can only have one install of the same plugin. |
||
19 | * |
||
20 | * - Install entity is only created after a user connects his account with Freemius. |
||
21 | * |
||
22 | * Class Freemius_Abstract |
||
23 | */ |
||
24 | abstract class Freemius_Abstract { |
||
0 ignored issues
–
show
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.
You can fix this by adding a namespace to your class: namespace YourVendor;
class YourClass { }
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries. ![]() |
|||
25 | |||
26 | #---------------------------------------------------------------------------------- |
||
27 | #region Identity |
||
28 | #---------------------------------------------------------------------------------- |
||
29 | |||
30 | /** |
||
31 | * Check if user has connected his account (opted-in). |
||
32 | * |
||
33 | * Note: |
||
34 | * If the user opted-in and opted-out on a later stage, |
||
35 | * this will still return true. If you want to check if the |
||
36 | * user is currently opted-in, use: |
||
37 | * `$fs->is_registered() && $fs->is_tracking_allowed()` |
||
38 | * |
||
39 | * @since 1.0.1 |
||
40 | * @return bool |
||
41 | */ |
||
42 | abstract function is_registered(); |
||
0 ignored issues
–
show
|
|||
43 | |||
44 | /** |
||
45 | * Check if the user skipped connecting the account with Freemius. |
||
46 | * |
||
47 | * @since 1.0.7 |
||
48 | * |
||
49 | * @return bool |
||
50 | */ |
||
51 | abstract function is_anonymous(); |
||
0 ignored issues
–
show
|
|||
52 | |||
53 | /** |
||
54 | * Check if the user currently in activation mode. |
||
55 | * |
||
56 | * @since 1.0.7 |
||
57 | * |
||
58 | * @return bool |
||
59 | */ |
||
60 | abstract function is_activation_mode(); |
||
0 ignored issues
–
show
|
|||
61 | |||
62 | #endregion |
||
63 | |||
64 | #---------------------------------------------------------------------------------- |
||
65 | #region Usage Tracking |
||
66 | #---------------------------------------------------------------------------------- |
||
67 | |||
68 | /** |
||
69 | * Returns TRUE if the user opted-in and didn't disconnect (opt-out). |
||
70 | * |
||
71 | * @author Leo Fajardo (@leorw) |
||
72 | * @since 1.2.1.5 |
||
73 | * |
||
74 | * @return bool |
||
75 | */ |
||
76 | abstract function is_tracking_allowed(); |
||
0 ignored issues
–
show
|
|||
77 | |||
78 | /** |
||
79 | * Returns TRUE if the user never opted-in or manually opted-out. |
||
80 | * |
||
81 | * @author Vova Feldman (@svovaf) |
||
82 | * @since 1.2.1.5 |
||
83 | * |
||
84 | * @return bool |
||
85 | */ |
||
86 | function is_tracking_prohibited() { |
||
0 ignored issues
–
show
|
|||
87 | return ! $this->is_registered() || ! $this->is_tracking_allowed(); |
||
88 | } |
||
89 | |||
90 | /** |
||
91 | * Opt-out from usage tracking. |
||
92 | * |
||
93 | * Note: This will not delete the account information but will stop all tracking. |
||
94 | * |
||
95 | * Returns: |
||
96 | * 1. FALSE - If the user never opted-in. |
||
97 | * 2. TRUE - If successfully opted-out. |
||
98 | * 3. object - API Result on failure. |
||
99 | * |
||
100 | * @author Leo Fajardo (@leorw) |
||
101 | * @since 1.2.1.5 |
||
102 | * |
||
103 | * @return bool|object |
||
104 | */ |
||
105 | abstract function stop_tracking(); |
||
0 ignored issues
–
show
|
|||
106 | |||
107 | /** |
||
108 | * Opt-in back into usage tracking. |
||
109 | * |
||
110 | * Note: This will only work if the user opted-in previously. |
||
111 | * |
||
112 | * Returns: |
||
113 | * 1. FALSE - If the user never opted-in. |
||
114 | * 2. TRUE - If successfully opted-in back to usage tracking. |
||
115 | * 3. object - API result on failure. |
||
116 | * |
||
117 | * @author Leo Fajardo (@leorw) |
||
118 | * @since 1.2.1.5 |
||
119 | * |
||
120 | * @return bool|object |
||
121 | */ |
||
122 | abstract function allow_tracking(); |
||
0 ignored issues
–
show
|
|||
123 | |||
124 | #endregion |
||
125 | |||
126 | #---------------------------------------------------------------------------------- |
||
127 | #region Module Type |
||
128 | #---------------------------------------------------------------------------------- |
||
129 | |||
130 | /** |
||
131 | * Checks if the plugin's type is "plugin". The other type is "theme". |
||
132 | * |
||
133 | * @author Leo Fajardo (@leorw) |
||
134 | * @since 1.2.2 |
||
135 | * |
||
136 | * @return bool |
||
137 | */ |
||
138 | abstract function is_plugin(); |
||
0 ignored issues
–
show
|
|||
139 | |||
140 | /** |
||
141 | * Checks if the module type is "theme". The other type is "plugin". |
||
142 | * |
||
143 | * @author Leo Fajardo (@leorw) |
||
144 | * @since 1.2.2 |
||
145 | * |
||
146 | * @return bool |
||
147 | */ |
||
148 | function is_theme() { |
||
0 ignored issues
–
show
|
|||
149 | return ( ! $this->is_plugin() ); |
||
150 | } |
||
151 | |||
152 | #endregion |
||
153 | |||
154 | #---------------------------------------------------------------------------------- |
||
155 | #region Permissions |
||
156 | #---------------------------------------------------------------------------------- |
||
157 | |||
158 | /** |
||
159 | * Check if plugin must be WordPress.org compliant. |
||
160 | * |
||
161 | * @since 1.0.7 |
||
162 | * |
||
163 | * @return bool |
||
164 | */ |
||
165 | abstract function is_org_repo_compliant(); |
||
0 ignored issues
–
show
|
|||
166 | |||
167 | /** |
||
168 | * Check if plugin is allowed to install executable files. |
||
169 | * |
||
170 | * @author Vova Feldman (@svovaf) |
||
171 | * @since 1.0.5 |
||
172 | * |
||
173 | * @return bool |
||
174 | */ |
||
175 | function is_allowed_to_install() { |
||
0 ignored issues
–
show
|
|||
176 | return ( $this->is_premium() || ! $this->is_org_repo_compliant() ); |
||
177 | } |
||
178 | |||
179 | #endregion |
||
180 | |||
181 | /** |
||
182 | * Check if user in trial or in free plan (not paying). |
||
183 | * |
||
184 | * @author Vova Feldman (@svovaf) |
||
185 | * @since 1.0.4 |
||
186 | * |
||
187 | * @return bool |
||
188 | */ |
||
189 | function is_not_paying() { |
||
0 ignored issues
–
show
|
|||
190 | return ( $this->is_trial() || $this->is_free_plan() ); |
||
191 | } |
||
192 | |||
193 | /** |
||
194 | * Check if the user has an activated and valid paid license on current plugin's install. |
||
195 | * |
||
196 | * @since 1.0.9 |
||
197 | * |
||
198 | * @return bool |
||
199 | */ |
||
200 | abstract function is_paying(); |
||
0 ignored issues
–
show
|
|||
201 | |||
202 | /** |
||
203 | * Check if the user is paying or in trial. |
||
204 | * |
||
205 | * @since 1.0.9 |
||
206 | * |
||
207 | * @return bool |
||
208 | */ |
||
209 | function is_paying_or_trial() { |
||
0 ignored issues
–
show
|
|||
210 | return ( $this->is_paying() || $this->is_trial() ); |
||
211 | } |
||
212 | |||
213 | /** |
||
214 | * Check if user in a trial or have feature enabled license. |
||
215 | * |
||
216 | * @author Vova Feldman (@svovaf) |
||
217 | * @since 1.1.7 |
||
218 | * |
||
219 | * @return bool |
||
220 | */ |
||
221 | abstract function can_use_premium_code(); |
||
0 ignored issues
–
show
|
|||
222 | |||
223 | #---------------------------------------------------------------------------------- |
||
224 | #region Premium Only |
||
225 | #---------------------------------------------------------------------------------- |
||
226 | |||
227 | /** |
||
228 | * All logic wrapped in methods with "__premium_only()" suffix will be only |
||
229 | * included in the premium code. |
||
230 | * |
||
231 | * Example: |
||
232 | * if ( freemius()->is__premium_only() ) { |
||
233 | * ... |
||
234 | * } |
||
235 | */ |
||
236 | |||
237 | /** |
||
238 | * Returns true when running premium plugin code. |
||
239 | * |
||
240 | * @since 1.0.9 |
||
241 | * |
||
242 | * @return bool |
||
243 | */ |
||
244 | function is__premium_only() { |
||
0 ignored issues
–
show
|
|||
245 | return $this->is_premium(); |
||
246 | } |
||
247 | |||
248 | /** |
||
249 | * Check if the user has an activated and valid paid license on current plugin's install. |
||
250 | * |
||
251 | * @since 1.0.9 |
||
252 | * |
||
253 | * @return bool |
||
254 | * |
||
255 | */ |
||
256 | function is_paying__premium_only() { |
||
0 ignored issues
–
show
|
|||
257 | return ( $this->is__premium_only() && $this->is_paying() ); |
||
258 | } |
||
259 | |||
260 | /** |
||
261 | * All code wrapped in this statement will be only included in the premium code. |
||
262 | * |
||
263 | * @since 1.0.9 |
||
264 | * |
||
265 | * @param string $plan Plan name. |
||
266 | * @param bool $exact If true, looks for exact plan. If false, also check "higher" plans. |
||
267 | * |
||
268 | * @return bool |
||
269 | */ |
||
270 | function is_plan__premium_only( $plan, $exact = false ) { |
||
0 ignored issues
–
show
|
|||
271 | return ( $this->is_premium() && $this->is_plan( $plan, $exact ) ); |
||
272 | } |
||
273 | |||
274 | /** |
||
275 | * Check if plan matches active license' plan or active trial license' plan. |
||
276 | * |
||
277 | * All code wrapped in this statement will be only included in the premium code. |
||
278 | * |
||
279 | * @since 1.0.9 |
||
280 | * |
||
281 | * @param string $plan Plan name. |
||
282 | * @param bool $exact If true, looks for exact plan. If false, also check "higher" plans. |
||
283 | * |
||
284 | * @return bool |
||
285 | */ |
||
286 | function is_plan_or_trial__premium_only( $plan, $exact = false ) { |
||
0 ignored issues
–
show
|
|||
287 | return ( $this->is_premium() && $this->is_plan_or_trial( $plan, $exact ) ); |
||
288 | } |
||
289 | |||
290 | /** |
||
291 | * Check if the user is paying or in trial. |
||
292 | * |
||
293 | * All code wrapped in this statement will be only included in the premium code. |
||
294 | * |
||
295 | * @since 1.0.9 |
||
296 | * |
||
297 | * @return bool |
||
298 | */ |
||
299 | function is_paying_or_trial__premium_only() { |
||
0 ignored issues
–
show
|
|||
300 | return $this->is_premium() && $this->is_paying_or_trial(); |
||
301 | } |
||
302 | |||
303 | /** |
||
304 | * Check if the user has an activated and valid paid license on current plugin's install. |
||
305 | * |
||
306 | * @since 1.0.4 |
||
307 | * |
||
308 | * @return bool |
||
309 | * |
||
310 | * @deprecated Method name is confusing since it's not clear from the name the code will be removed. |
||
311 | * @using Alias to is_paying__premium_only() |
||
312 | */ |
||
313 | function is_paying__fs__() { |
||
0 ignored issues
–
show
|
|||
314 | return $this->is_paying__premium_only(); |
||
315 | } |
||
316 | |||
317 | /** |
||
318 | * Check if user in a trial or have feature enabled license. |
||
319 | * |
||
320 | * All code wrapped in this statement will be only included in the premium code. |
||
321 | * |
||
322 | * @author Vova Feldman (@svovaf) |
||
323 | * @since 1.1.9 |
||
324 | * |
||
325 | * @return bool |
||
326 | */ |
||
327 | function can_use_premium_code__premium_only() { |
||
0 ignored issues
–
show
|
|||
328 | return $this->is_premium() && $this->can_use_premium_code(); |
||
329 | } |
||
330 | |||
331 | #endregion |
||
332 | |||
333 | #---------------------------------------------------------------------------------- |
||
334 | #region Trial |
||
335 | #---------------------------------------------------------------------------------- |
||
336 | |||
337 | /** |
||
338 | * Check if the user in a trial. |
||
339 | * |
||
340 | * @since 1.0.3 |
||
341 | * |
||
342 | * @return bool |
||
343 | */ |
||
344 | abstract function is_trial(); |
||
0 ignored issues
–
show
|
|||
345 | |||
346 | /** |
||
347 | * Check if trial already utilized. |
||
348 | * |
||
349 | * @since 1.0.9 |
||
350 | * |
||
351 | * @return bool |
||
352 | */ |
||
353 | abstract function is_trial_utilized(); |
||
0 ignored issues
–
show
|
|||
354 | |||
355 | #endregion |
||
356 | |||
357 | #---------------------------------------------------------------------------------- |
||
358 | #region Plans |
||
359 | #---------------------------------------------------------------------------------- |
||
360 | |||
361 | /** |
||
362 | * Check if the user is on the free plan of the product. |
||
363 | * |
||
364 | * @since 1.0.4 |
||
365 | * |
||
366 | * @return bool |
||
367 | */ |
||
368 | abstract function is_free_plan(); |
||
0 ignored issues
–
show
|
|||
369 | |||
370 | /** |
||
371 | * @since 1.0.2 |
||
372 | * |
||
373 | * @param string $plan Plan name. |
||
374 | * @param bool $exact If true, looks for exact plan. If false, also check "higher" plans. |
||
375 | * |
||
376 | * @return bool |
||
377 | */ |
||
378 | abstract function is_plan( $plan, $exact = false ); |
||
0 ignored issues
–
show
|
|||
379 | |||
380 | /** |
||
381 | * Check if plan based on trial. If not in trial mode, should return false. |
||
382 | * |
||
383 | * @since 1.0.9 |
||
384 | * |
||
385 | * @param string $plan Plan name. |
||
386 | * @param bool $exact If true, looks for exact plan. If false, also check "higher" plans. |
||
387 | * |
||
388 | * @return bool |
||
389 | */ |
||
390 | abstract function is_trial_plan( $plan, $exact = false ); |
||
0 ignored issues
–
show
|
|||
391 | |||
392 | /** |
||
393 | * Check if plan matches active license' plan or active trial license' plan. |
||
394 | * |
||
395 | * @since 1.0.9 |
||
396 | * |
||
397 | * @param string $plan Plan name. |
||
398 | * @param bool $exact If true, looks for exact plan. If false, also check "higher" plans. |
||
399 | * |
||
400 | * @return bool |
||
401 | */ |
||
402 | function is_plan_or_trial( $plan, $exact = false ) { |
||
0 ignored issues
–
show
|
|||
403 | return $this->is_plan( $plan, $exact ) || |
||
404 | $this->is_trial_plan( $plan, $exact ); |
||
405 | } |
||
406 | |||
407 | /** |
||
408 | * Check if plugin has any paid plans. |
||
409 | * |
||
410 | * @author Vova Feldman (@svovaf) |
||
411 | * @since 1.0.7 |
||
412 | * |
||
413 | * @return bool |
||
414 | */ |
||
415 | abstract function has_paid_plan(); |
||
0 ignored issues
–
show
|
|||
416 | |||
417 | /** |
||
418 | * Check if plugin has any free plan, or is it premium only. |
||
419 | * |
||
420 | * Note: If no plans configured, assume plugin is free. |
||
421 | * |
||
422 | * @author Vova Feldman (@svovaf) |
||
423 | * @since 1.0.7 |
||
424 | * |
||
425 | * @return bool |
||
426 | */ |
||
427 | abstract function has_free_plan(); |
||
0 ignored issues
–
show
|
|||
428 | |||
429 | /** |
||
430 | * Check if plugin is premium only (no free plans). |
||
431 | * |
||
432 | * NOTE: is__premium_only() is very different method, don't get confused. |
||
433 | * |
||
434 | * @author Vova Feldman (@svovaf) |
||
435 | * @since 1.1.9 |
||
436 | * |
||
437 | * @return bool |
||
438 | */ |
||
439 | abstract function is_only_premium(); |
||
0 ignored issues
–
show
|
|||
440 | |||
441 | /** |
||
442 | * Check if module has a premium code version. |
||
443 | * |
||
444 | * Serviceware module might be freemium without any |
||
445 | * premium code version, where the paid features |
||
446 | * are all part of the service. |
||
447 | * |
||
448 | * @author Vova Feldman (@svovaf) |
||
449 | * @since 1.2.1.6 |
||
450 | * |
||
451 | * @return bool |
||
452 | */ |
||
453 | abstract function has_premium_version(); |
||
0 ignored issues
–
show
|
|||
454 | |||
455 | /** |
||
456 | * Check if module has any release on Freemius, |
||
457 | * or all plugin's code is on WordPress.org (Serviceware). |
||
458 | * |
||
459 | * @return bool |
||
460 | */ |
||
461 | function has_release_on_freemius() { |
||
0 ignored issues
–
show
|
|||
462 | return ! $this->is_org_repo_compliant() || |
||
463 | $this->has_premium_version(); |
||
464 | } |
||
465 | |||
466 | /** |
||
467 | * Checks if it's a freemium plugin. |
||
468 | * |
||
469 | * @author Vova Feldman (@svovaf) |
||
470 | * @since 1.1.9 |
||
471 | * |
||
472 | * @return bool |
||
473 | */ |
||
474 | function is_freemium() { |
||
0 ignored issues
–
show
|
|||
475 | return $this->has_paid_plan() && |
||
476 | $this->has_free_plan(); |
||
477 | } |
||
478 | |||
479 | /** |
||
480 | * Check if module has only one plan. |
||
481 | * |
||
482 | * @author Vova Feldman (@svovaf) |
||
483 | * @since 1.2.1.7 |
||
484 | * |
||
485 | * @return bool |
||
486 | */ |
||
487 | abstract function is_single_plan(); |
||
0 ignored issues
–
show
|
|||
488 | |||
489 | #endregion |
||
490 | |||
491 | /** |
||
492 | * Check if running payments in sandbox mode. |
||
493 | * |
||
494 | * @since 1.0.4 |
||
495 | * |
||
496 | * @return bool |
||
497 | */ |
||
498 | abstract function is_payments_sandbox(); |
||
0 ignored issues
–
show
|
|||
499 | |||
500 | /** |
||
501 | * Check if running test vs. live plugin. |
||
502 | * |
||
503 | * @since 1.0.5 |
||
504 | * |
||
505 | * @return bool |
||
506 | */ |
||
507 | abstract function is_live(); |
||
0 ignored issues
–
show
|
|||
508 | |||
509 | /** |
||
510 | * Check if running premium plugin code. |
||
511 | * |
||
512 | * @since 1.0.5 |
||
513 | * |
||
514 | * @return bool |
||
515 | */ |
||
516 | abstract function is_premium(); |
||
0 ignored issues
–
show
|
|||
517 | |||
518 | /** |
||
519 | * Get upgrade URL. |
||
520 | * |
||
521 | * @author Vova Feldman (@svovaf) |
||
522 | * @since 1.0.2 |
||
523 | * |
||
524 | * @param string $period Billing cycle. |
||
525 | * |
||
526 | * @return string |
||
527 | */ |
||
528 | abstract function get_upgrade_url( $period = WP_FS__PERIOD_ANNUALLY ); |
||
0 ignored issues
–
show
|
|||
529 | |||
530 | /** |
||
531 | * Check if Freemius was first added in a plugin update. |
||
532 | * |
||
533 | * @author Vova Feldman (@svovaf) |
||
534 | * @since 1.1.5 |
||
535 | * |
||
536 | * @return bool |
||
537 | */ |
||
538 | function is_plugin_update() { |
||
0 ignored issues
–
show
|
|||
539 | return ! $this->is_plugin_new_install(); |
||
540 | } |
||
541 | |||
542 | /** |
||
543 | * Check if Freemius was part of the plugin when the user installed it first. |
||
544 | * |
||
545 | * @author Vova Feldman (@svovaf) |
||
546 | * @since 1.1.5 |
||
547 | * |
||
548 | * @return bool |
||
549 | */ |
||
550 | abstract function is_plugin_new_install(); |
||
0 ignored issues
–
show
|
|||
551 | |||
552 | #---------------------------------------------------------------------------------- |
||
553 | #region Marketing |
||
554 | #---------------------------------------------------------------------------------- |
||
555 | |||
556 | /** |
||
557 | * Check if current user purchased any other plugins before. |
||
558 | * |
||
559 | * @author Vova Feldman (@svovaf) |
||
560 | * @since 1.0.9 |
||
561 | * |
||
562 | * @return bool |
||
563 | */ |
||
564 | abstract function has_purchased_before(); |
||
0 ignored issues
–
show
|
|||
565 | |||
566 | /** |
||
567 | * Check if current user classified as an agency. |
||
568 | * |
||
569 | * @author Vova Feldman (@svovaf) |
||
570 | * @since 1.0.9 |
||
571 | * |
||
572 | * @return bool |
||
573 | */ |
||
574 | abstract function is_agency(); |
||
0 ignored issues
–
show
|
|||
575 | |||
576 | /** |
||
577 | * Check if current user classified as a developer. |
||
578 | * |
||
579 | * @author Vova Feldman (@svovaf) |
||
580 | * @since 1.0.9 |
||
581 | * |
||
582 | * @return bool |
||
583 | */ |
||
584 | abstract function is_developer(); |
||
0 ignored issues
–
show
|
|||
585 | |||
586 | /** |
||
587 | * Check if current user classified as a business. |
||
588 | * |
||
589 | * @author Vova Feldman (@svovaf) |
||
590 | * @since 1.0.9 |
||
591 | * |
||
592 | * @return bool |
||
593 | */ |
||
594 | abstract function is_business(); |
||
0 ignored issues
–
show
|
|||
595 | |||
596 | #endregion |
||
597 | } |
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.