1 | <?php |
||
50 | class WP_PHP_Console_Loader { |
||
51 | |||
52 | |||
53 | /** minimum PHP version required by this plugin */ |
||
54 | const MINIMUM_PHP_VERSION = '5.6.0'; |
||
55 | |||
56 | /** minimum WordPress version required by this plugin */ |
||
57 | const MINIMUM_WP_VERSION = '3.6.0'; |
||
58 | |||
59 | /** the plugin name, for displaying notices */ |
||
60 | const PLUGIN_NAME = 'WP PHP Console'; |
||
61 | |||
62 | |||
63 | /** @var \WP_PHP_Console_Loader single instance of this class */ |
||
64 | protected static $instance; |
||
65 | |||
66 | /** @var array the admin notices to add */ |
||
67 | protected $notices = array(); |
||
68 | |||
69 | |||
70 | /** |
||
71 | * Loads WP PHP Console after performing compatibility checks. |
||
72 | * |
||
73 | * @since 1.5.4 |
||
74 | */ |
||
75 | protected function __construct() { |
||
88 | |||
89 | |||
90 | /** |
||
91 | * Cloning instances is forbidden due to singleton pattern. |
||
92 | * |
||
93 | * @since 1.5.4 |
||
94 | */ |
||
95 | public function __clone() { |
||
99 | |||
100 | |||
101 | /** |
||
102 | * Unserializing instances is forbidden due to singleton pattern. |
||
103 | * |
||
104 | * @since 1.5.4 |
||
105 | */ |
||
106 | public function __wakeup() { |
||
110 | |||
111 | |||
112 | /** |
||
113 | * Initializes the plugin. |
||
114 | * |
||
115 | * @internal |
||
116 | * |
||
117 | * @since 1.5.4 |
||
118 | */ |
||
119 | private function init_plugin() { |
||
131 | |||
132 | |||
133 | /** |
||
134 | * Checks the server environment and other factors and deactivates plugins as necessary. |
||
135 | * |
||
136 | * Based on http://wptavern.com/how-to-prevent-wordpress-plugins-from-activating-on-sites-with-incompatible-hosting-environments |
||
137 | * |
||
138 | * @internal |
||
139 | * |
||
140 | * @since 1.5.4 |
||
141 | */ |
||
142 | public function activation_check() { |
||
151 | |||
152 | |||
153 | /** |
||
154 | * Checks the environment on loading WordPress, just in case the environment changes after activation. |
||
155 | * |
||
156 | * @internal |
||
157 | * |
||
158 | * @since 1.5.4 |
||
159 | */ |
||
160 | public function check_environment() { |
||
169 | |||
170 | |||
171 | /** |
||
172 | * Adds notices for out-of-date WordPress and/or WooCommerce versions. |
||
173 | * |
||
174 | * @internal |
||
175 | * |
||
176 | * @since 1.5.4 |
||
177 | */ |
||
178 | public function add_plugin_notices() { |
||
190 | |||
191 | |||
192 | /** |
||
193 | * Determines if the plugin is WordPress compatible. |
||
194 | * |
||
195 | * @since 1.5.4 |
||
196 | * |
||
197 | * @return bool |
||
198 | */ |
||
199 | private function is_wp_compatible() { |
||
204 | |||
205 | |||
206 | /** |
||
207 | * Deactivates the plugin. |
||
208 | * |
||
209 | * @since 1.5.4 |
||
210 | */ |
||
211 | private function deactivate_plugin() { |
||
219 | |||
220 | |||
221 | /** |
||
222 | * Adds an admin notice to be displayed. |
||
223 | * |
||
224 | * @since 1.5.4 |
||
225 | * |
||
226 | * @param string $slug notice ID |
||
227 | * @param string $class CSS class |
||
228 | * @param string $message message content |
||
229 | */ |
||
230 | private function add_admin_notice( $slug, $class, $message ) { |
||
237 | |||
238 | |||
239 | /** |
||
240 | * Displays admin notices. |
||
241 | * |
||
242 | * @internal |
||
243 | * |
||
244 | * @since 1.5.4 |
||
245 | */ |
||
246 | public function admin_notices() { |
||
258 | |||
259 | |||
260 | /** |
||
261 | * Determines if the server environment is compatible with this plugin. |
||
262 | * |
||
263 | * @since 1.5.4 |
||
264 | * |
||
265 | * @return bool |
||
266 | */ |
||
267 | private function is_environment_compatible() { |
||
271 | |||
272 | |||
273 | /** |
||
274 | * Returns the message for display when the environment is incompatible with this plugin. |
||
275 | * |
||
276 | * @since 1.5.4 |
||
277 | * |
||
278 | * @return string |
||
279 | */ |
||
280 | private function get_environment_message() { |
||
284 | |||
285 | |||
286 | /** |
||
287 | * Returns the main \WP_PHP_Console_Loader instance. |
||
288 | * |
||
289 | * Ensures only one instance can be loaded at any given time. |
||
290 | * |
||
291 | * @since 1.5.4 |
||
292 | * |
||
293 | * @return \WP_PHP_Console_Loader |
||
294 | */ |
||
295 | public static function instance() { |
||
303 | |||
304 | |||
305 | } |
||
306 | |||
309 |