1 | <?php |
||
17 | final class Plugin { |
||
18 | /** |
||
19 | * @var string The plugin version. |
||
20 | * |
||
21 | * @api |
||
22 | * @since future |
||
23 | */ |
||
24 | public $version = 'future'; |
||
25 | |||
26 | /** |
||
27 | * @var string Minimum WordPress version. |
||
28 | * |
||
29 | * GravityView requires at least this version of WordPress to function properly. |
||
30 | */ |
||
31 | private static $min_wp_version = '4.0'; |
||
32 | |||
33 | /** |
||
34 | * @var string Minimum Gravity Forms version. |
||
35 | * |
||
36 | * GravityView requires at least this version of Gravity Forms to function properly. |
||
37 | */ |
||
38 | private static $min_gf_version = '1.9.14'; |
||
39 | |||
40 | /** |
||
41 | * @var string Minimum PHP version. |
||
42 | * |
||
43 | * GravityView requires at least this version of PHP to function properly. |
||
44 | */ |
||
45 | private static $min_php_version = '5.3.0'; |
||
46 | |||
47 | /** |
||
48 | * @var string|bool Minimum future PHP version. |
||
49 | * |
||
50 | * GravityView will require this version of PHP soon. False if no future PHP version changes are planned. |
||
51 | */ |
||
52 | private static $future_min_php_version = false; |
||
53 | |||
54 | /** |
||
55 | * @var string|bool Minimum future Gravity Forms version. |
||
56 | * |
||
57 | * GravityView will require this version of Gravity Forms soon. False if no future Gravity Forms version changes are planned. |
||
58 | */ |
||
59 | private static $future_min_gf_version = false; |
||
60 | |||
61 | /** |
||
62 | * @var \GV\Plugin The \GV\Plugin static instance. |
||
63 | */ |
||
64 | private static $__instance = null; |
||
65 | |||
66 | /** |
||
67 | * Get the global instance of \GV\Plugin. |
||
68 | * |
||
69 | * @return \GV\Plugin The global instance of GravityView Plugin. |
||
70 | */ |
||
71 | public static function get() { |
||
77 | |||
78 | /** |
||
79 | * Register hooks that are fired when the plugin is activated and deactivated. |
||
80 | * |
||
81 | * @return void |
||
82 | */ |
||
83 | public function register_activation_hooks() { |
||
87 | |||
88 | /** |
||
89 | * Plugin activation function. |
||
90 | * |
||
91 | * @internal |
||
92 | * @return void |
||
93 | */ |
||
94 | 1 | public function activate() { |
|
108 | |||
109 | /** |
||
110 | * Plugin deactivation function. |
||
111 | * |
||
112 | * @internal |
||
113 | * @return void |
||
114 | */ |
||
115 | public function deactivate() { |
||
118 | |||
119 | /** |
||
120 | * Retrieve an absolute path within the Gravity Forms plugin directory. |
||
121 | * |
||
122 | * @api |
||
123 | * @since future |
||
124 | * |
||
125 | * @param string $path Optional. Append this extra path component. |
||
126 | * @return string The absolute path to the plugin directory. |
||
127 | */ |
||
128 | 1 | public function dir( $path = '' ) { |
|
131 | |||
132 | /** |
||
133 | * Retrieve a URL within the Gravity Forms plugin directory. |
||
134 | * |
||
135 | * @api |
||
136 | * @since future |
||
137 | * |
||
138 | * @param string $path Optional. Extra path appended to the URL. |
||
139 | * @return The URL to this plugin, with trailing slash. |
||
140 | */ |
||
141 | 1 | public function url( $path = '/' ) { |
|
144 | |||
145 | /** |
||
146 | * Is everything compatible with this version of GravityView? |
||
147 | * |
||
148 | * @api |
||
149 | * @since future |
||
150 | * |
||
151 | * @return bool |
||
152 | */ |
||
153 | 1 | public function is_compatible() { |
|
159 | |||
160 | /** |
||
161 | * Is this version of GravityView compatible with the current version of PHP? |
||
162 | * |
||
163 | * @api |
||
164 | * @since future |
||
165 | * |
||
166 | * @return bool true if compatible, false otherwise. |
||
167 | */ |
||
168 | 1 | public function is_compatible_php() { |
|
171 | |||
172 | /** |
||
173 | * Is this version of GravityView compatible with the current version of WordPress? |
||
174 | * |
||
175 | * @api |
||
176 | * @since future |
||
177 | * |
||
178 | * @return bool true if compatible, false otherwise. |
||
179 | */ |
||
180 | 1 | public function is_compatible_wordpress() { |
|
183 | |||
184 | /** |
||
185 | * Is this version of GravityView compatible with the current version of Gravity Forms? |
||
186 | * |
||
187 | * @api |
||
188 | * @since future |
||
189 | * |
||
190 | * @return bool true if compatible, false otherwise (or not active/installed). |
||
191 | */ |
||
192 | 1 | public function is_compatible_gravityforms() { |
|
199 | |||
200 | /** |
||
201 | * Retrieve the current PHP version. |
||
202 | * |
||
203 | * Overridable with GRAVITYVIEW_TESTS_PHP_VERSION_OVERRIDE during testing. |
||
204 | * |
||
205 | * @return string The version of PHP. |
||
206 | */ |
||
207 | private function get_php_version() { |
||
211 | |||
212 | /** |
||
213 | * Retrieve the current WordPress version. |
||
214 | * |
||
215 | * Overridable with GRAVITYVIEW_TESTS_WP_VERSION_OVERRIDE during testing. |
||
216 | * |
||
217 | * @return string The version of WordPress. |
||
218 | */ |
||
219 | private function get_wordpress_version() { |
||
223 | |||
224 | /** |
||
225 | * Retrieve the current Gravity Forms version. |
||
226 | * |
||
227 | * Overridable with GRAVITYVIEW_TESTS_GF_VERSION_OVERRIDE during testing. |
||
228 | * |
||
229 | * @throws \ErrorException If the Gravity Forms plugin is not active or installed (E_ERROR severity) |
||
230 | * @return string The version of Gravity Forms. |
||
231 | */ |
||
232 | private function get_gravityforms_version() { |
||
240 | |||
241 | private function __clone() { } |
||
242 | |||
243 | private function __wakeup() { } |
||
244 | } |
||
245 |
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.