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.6 |
||
7 | */ |
||
8 | |||
9 | if ( ! defined( 'ABSPATH' ) ) { |
||
10 | exit; |
||
11 | } |
||
12 | |||
13 | class FS_Plan_Manager { |
||
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. ![]() |
|||
14 | /** |
||
15 | * @var FS_Plan_Manager |
||
16 | */ |
||
17 | private static $_instance; |
||
18 | |||
19 | /** |
||
20 | * @return FS_Plan_Manager |
||
21 | */ |
||
22 | static function instance() { |
||
0 ignored issues
–
show
|
|||
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 ) { |
||
0 ignored issues
–
show
|
|||
39 | if ( is_array( $licenses ) ) { |
||
40 | /** |
||
41 | * @var FS_Plugin_License[] $licenses |
||
42 | */ |
||
43 | foreach ( $licenses as $license ) { |
||
44 | if ( ! $license->is_utilized() && $license->is_features_enabled() ) { |
||
45 | return true; |
||
46 | } |
||
47 | } |
||
48 | } |
||
49 | |||
50 | return false; |
||
51 | } |
||
52 | |||
53 | /** |
||
54 | * Check if plugin has any paid plans. |
||
55 | * |
||
56 | * @author Vova Feldman (@svovaf) |
||
57 | * @since 1.0.7 |
||
58 | * |
||
59 | * @param FS_Plugin_Plan[] $plans |
||
60 | * |
||
61 | * @return bool |
||
62 | */ |
||
63 | function has_paid_plan( $plans ) { |
||
0 ignored issues
–
show
|
|||
64 | if ( ! is_array( $plans ) || 0 === count( $plans ) ) { |
||
65 | return false; |
||
66 | } |
||
67 | |||
68 | /** |
||
69 | * @var FS_Plugin_Plan[] $plans |
||
70 | */ |
||
71 | for ( $i = 0, $len = count( $plans ); $i < $len; $i ++ ) { |
||
72 | if ( ! $plans[ $i ]->is_free() ) { |
||
73 | return true; |
||
74 | } |
||
75 | } |
||
76 | |||
77 | return false; |
||
78 | } |
||
79 | |||
80 | /** |
||
81 | * Check if plugin has any free plan, or is it premium only. |
||
82 | * |
||
83 | * Note: If no plans configured, assume plugin is free. |
||
84 | * |
||
85 | * @author Vova Feldman (@svovaf) |
||
86 | * @since 1.0.7 |
||
87 | * |
||
88 | * @param FS_Plugin_Plan[] $plans |
||
89 | * |
||
90 | * @return bool |
||
91 | */ |
||
92 | function has_free_plan( $plans ) { |
||
0 ignored issues
–
show
|
|||
93 | if ( ! is_array( $plans ) || 0 === count( $plans ) ) { |
||
94 | return true; |
||
95 | } |
||
96 | |||
97 | /** |
||
98 | * @var FS_Plugin_Plan[] $plans |
||
99 | */ |
||
100 | for ( $i = 0, $len = count( $plans ); $i < $len; $i ++ ) { |
||
101 | if ( $plans[ $i ]->is_free() ) { |
||
102 | return true; |
||
103 | } |
||
104 | } |
||
105 | |||
106 | return false; |
||
107 | } |
||
108 | |||
109 | /** |
||
110 | * Find all plans that have trial. |
||
111 | * |
||
112 | * @author Vova Feldman (@svovaf) |
||
113 | * @since 1.0.9 |
||
114 | * |
||
115 | * @param FS_Plugin_Plan[] $plans |
||
116 | * |
||
117 | * @return FS_Plugin_Plan[] |
||
118 | */ |
||
119 | function get_trial_plans( $plans ) { |
||
0 ignored issues
–
show
|
|||
120 | $trial_plans = array(); |
||
121 | |||
122 | if ( is_array( $plans ) && 0 < count( $plans ) ) { |
||
123 | /** |
||
124 | * @var FS_Plugin_Plan[] $plans |
||
125 | */ |
||
126 | for ( $i = 0, $len = count( $plans ); $i < $len; $i ++ ) { |
||
127 | if ( $plans[ $i ]->has_trial() ) { |
||
128 | $trial_plans[] = $plans[ $i ]; |
||
129 | } |
||
130 | } |
||
131 | } |
||
132 | |||
133 | return $trial_plans; |
||
134 | } |
||
135 | |||
136 | /** |
||
137 | * Check if plugin has any trial plan. |
||
138 | * |
||
139 | * @author Vova Feldman (@svovaf) |
||
140 | * @since 1.0.9 |
||
141 | * |
||
142 | * @param FS_Plugin_Plan[] $plans |
||
143 | * |
||
144 | * @return bool |
||
145 | */ |
||
146 | function has_trial_plan( $plans ) { |
||
0 ignored issues
–
show
|
|||
147 | if ( ! is_array( $plans ) || 0 === count( $plans ) ) { |
||
148 | return true; |
||
149 | } |
||
150 | |||
151 | /** |
||
152 | * @var FS_Plugin_Plan[] $plans |
||
153 | */ |
||
154 | for ( $i = 0, $len = count( $plans ); $i < $len; $i ++ ) { |
||
155 | if ( $plans[ $i ]->has_trial() ) { |
||
156 | return true; |
||
157 | } |
||
158 | } |
||
159 | |||
160 | return false; |
||
161 | } |
||
162 | } |
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.