PluginProbe
QuadMenu – Mega Menu / 2.0.0
QuadMenu – Mega Menu v2.0.0
3.3.7 3.3.6 trunk 1.8.4 1.8.5 1.8.7 1.8.8 1.8.9 1.9.0 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 All 87 releases
quadmenu / includes / panel / system.php

system.php in QuadMenu – Mega Menu 2.0.0, at includes/panel/system.php

433 lines 15.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if (!defined('ABSPATH')) {
3 die('-1');
4 }
5
6 class QuadMenu_System extends QuadMenu_Panel {
7
8 static $status = array();
9
10 function __construct() {
11 add_action('admin_menu', array($this, 'add_menu'));
12 }
13
14 function add_menu() {
15 add_submenu_page(self::$panel_slug, esc_html__('System', 'quadmenu'), sprintf('%s', esc_html__('System', 'quadmenu')), 'edit_posts', self::$panel_slug . '_system', array($this, 'add_panel'));
16 }
17
18 function add_panel() {
19 global $submenu;
20 $system = $this;
21 include (QUADMENU_PLUGIN_DIR . '/includes/panel/pages/parts/header.php');
22 include (QUADMENU_PLUGIN_DIR . '/includes/panel/pages/system.php');
23 }
24
25 function add($section, $status_array) {
26 self::$status[$section][] = $status_array;
27 }
28
29 function tables() {
30
31 $this->system();
32
33 foreach (self::$status as $section_name => $section_statuses) {
34 ?>
35 <table class="widefat quadmenu-system-table" cellspacing="0">
36 <thead>
37 <tr>
38 <th colspan="4"><?php echo esc_html($section_name); ?></th>
39 </tr>
40 </thead>
41 <tbody>
42 <?php
43 foreach ($section_statuses as $status_params) {
44 ?>
45 <tr>
46 <td class="quadmenu-system-name"><?php echo esc_html($status_params['check_name']); ?></td>
47 <!--<td class="quadmenu-system-help"></td>-->
48 <td class="quadmenu-system-status">
49 <?php
50 switch ($status_params['status']) {
51 case 'green':
52 echo '<div class="quadmenu-system-led success" title="' . esc_html__('Green status: this check passed our system status test!', 'quadmenu') . '"></div>';
53 break;
54 case 'yellow':
55 echo '<div class="quadmenu-system-led warning" title="' . esc_html__('Yellow status: this setting may affect the backend of the site. The frontend should still run as expected. We recommend that you fix this.', 'quadmenu') . '"></div>';
56 break;
57 case 'red' :
58 echo '<div class="quadmenu-system-led critical" title="' . esc_html__('Red status: the site may not work as expected with this option.', 'quadmenu') . '"></div>';
59 break;
60 case 'info':
61 echo '<div class="quadmenu-system-led info title="' . esc_html__('Info status: this is just for information purposes and easier debug if a problem appears', 'quadmenu') . '">i</div>';
62 break;
63 }
64 ?>
65 </td>
66 <td class="quadmenu-system-value"><?php
67 echo wp_kses($status_params['value'], array(
68 'a' => array(
69 'href' => array(),
70 'title' => array()
71 ),
72 'br' => array(),
73 'em' => array(),
74 'strong' => array(),
75 'span' => array(),
76 ));
77 ?></td>
78 </tr>
79 <?php
80 }
81 ?>
82 </tbody>
83 </table>
84 <?php
85 }
86 }
87
88 function system() {
89
90 global $quadmenu_active_locations, $_wp_registered_nav_menus;
91
92 // Plugin name
93 $this->add('Plugin config', array(
94 'check_name' => 'Plugin name',
95 'tooltip' => '',
96 'value' => QUADMENU_PLUGIN_NAME,
97 'status' => 'info'
98 ));
99
100 // Plugin version
101 $this->add('Plugin config', array(
102 'check_name' => 'Plugin version',
103 'tooltip' => '',
104 'value' => QUADMENU_PLUGIN_VERSION,
105 'status' => 'info'
106 ));
107
108 // Redux version
109 if (class_exists('ReduxFramework')) {
110 if (version_compare(ReduxFramework::$_version, '3.6.5') < 0) {
111 $this->add('Plugin config', array(
112 'check_name' => 'Redux version',
113 'tooltip' => '',
114 'value' => sprintf('%1$s - <span class="quadmenu-status-small-text">%2$s <a href="%3$s" target="_blank">%4$s</a></span>', ReduxFramework::$_version, esc_html__('Your Redux version is outdated: ', 'quadmenu'), 'https://es.wordpress.org/plugins/redux-framework/', esc_html__('Please install it as a plugin', 'quadmenu')),
115 'status' => 'red',
116 ));
117 } else {
118 $this->add('Plugin config', array(
119 'check_name' => 'Redux version',
120 'tooltip' => '',
121 'value' => ReduxFramework::$_version,
122 'status' => 'green'
123 ));
124 }
125 } else {
126 $this->add('Plugin config', array(
127 'check_name' => 'Redux version',
128 'tooltip' => '',
129 'value' => esc_html__('Activate ReduxFramework', 'quadmenu'),
130 'status' => 'red',
131 ));
132 }
133
134 // Menu Locations
135 if (is_array($quadmenu_active_locations)) {
136 $this->add('Plugin config', array(
137 'check_name' => 'Active Locations',
138 'tooltip' => '',
139 'value' => sprintf(esc_html__('You have %s active menu locations', 'quadmenu'), count($quadmenu_active_locations)),
140 'status' => count($quadmenu_active_locations) ? 'green' : 'info'
141 ));
142 }
143
144 // Server status
145 // -----------------------------------------------------------------
146 // server info
147 $this->add('php.ini configuration', array(
148 'check_name' => 'Server software',
149 'tooltip' => '',
150 'value' => esc_html($_SERVER['SERVER_SOFTWARE']),
151 'status' => 'info'
152 ));
153
154 // php version
155 $this->add('php.ini configuration', array(
156 'check_name' => 'PHP Version',
157 'tooltip' => '',
158 'value' => phpversion(),
159 'status' => 'info'
160 ));
161
162 // post_max_size
163 $this->add('php.ini configuration', array(
164 'check_name' => 'post_max_size',
165 'tooltip' => '',
166 'value' => sprintf('%1$s - <span class="quadmenu-status-small-text">%2$s</span>', ini_get('post_max_size'), esc_html__('You cannot upload images, themes and plugins that have a size bigger than this value', 'quadmenu')),
167 'status' => 'info'
168 ));
169
170 // php time limit
171 $max_execution_time = ini_get('max_execution_time');
172 if ($max_execution_time == 0 or $max_execution_time >= 300) {
173 $this->add('php.ini configuration', array(
174 'check_name' => 'max_execution_time',
175 'tooltip' => '',
176 'value' => esc_html($max_execution_time),
177 'status' => 'green'
178 ));
179 } else {
180 $this->add('php.ini configuration', array(
181 'check_name' => 'max_execution_time',
182 'tooltip' => '',
183 'value' => sprintf('%1$s - <span class="quadmenu-status-small-text">%2$s <a href="%3$s" target="_blank">%4$s</a></span>', $max_execution_time, esc_html__('To import the demo content 300 seconds of max execution time is required. See: ', 'quadmenu'), 'http://codex.wordpress.org/Common_WordPress_Errors#Maximum_execution_time_exceeded', esc_html__('Increasing max execution to PHP', 'quadmenu')),
184 'status' => 'red'
185 ));
186 }
187
188 // php max input vars
189 $max_input_vars = ini_get('max_input_vars');
190 if ($max_input_vars == 0 or $max_input_vars >= 2000) {
191 $this->add('php.ini configuration', array(
192 'check_name' => 'max_input_vars',
193 'tooltip' => '',
194 'value' => esc_html($max_input_vars),
195 'status' => 'green'
196 ));
197 } else {
198 $this->add('php.ini configuration', array(
199 'check_name' => 'max_input_vars',
200 'tooltip' => '',
201 'value' => esc_html($max_input_vars),
202 'status' => 'yellow'
203 ));
204 }
205
206 // suhosin
207 if (extension_loaded('suhosin') !== true) {
208 $this->add('php.ini configuration', array(
209 'check_name' => 'SUHOSIN Installed',
210 'tooltip' => '',
211 'value' => 'False',
212 'status' => 'green'
213 ));
214 } else {
215 $this->add('php.ini configuration', array(
216 'check_name' => 'SUHOSIN Installed',
217 'tooltip' => '',
218 'value' => sprintf('%1$s - <span class="quadmenu-status-small-text">%2$s</span>', esc_html__('SUHOSIN is installed', 'quadmenu'), esc_html__('It may cause problems with saving the plugin panel if it\'s not properly configured', 'quadmenu')),
219 'status' => 'yellow'
220 ));
221 }
222
223 $response_code = wp_remote_retrieve_response_code(wp_remote_get(QUADMENU_PLUGIN_URL . 'assets/frontend/less/quadmenu-locations.less', array(
224 'timeout' => 20,
225 'user-agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:20.0) Gecko/20100101 Firefox/20.0'
226 )));
227 // mime types
228 if ($response_code == 200) {
229 $this->add('Compiler', array(
230 'check_name' => esc_html__('LESS files allowed', 'quadmenu'),
231 'tooltip' => '',
232 'value' => $response_code,
233 'status' => 'green'
234 ));
235 } else {
236 $this->add('Compiler', array(
237 'check_name' => esc_html__('Can\'t compile stylesheets', 'quadmenu'),
238 'tooltip' => '',
239 'value' => sprintf('%1$s error - <span class="quadmenu-status-small-text">%2$s</span>', $response_code, esc_html__('Can\'t download LESS mime types', 'quadmenu')),
240 'status' => 'red'
241 ));
242 }
243
244 // mime types
245 if (wp_is_writable(QUADMENU_PLUGIN_DIR_CSS)) {
246 $this->add('Compiler', array(
247 'check_name' => esc_html__('Folder is writable', 'quadmenu'),
248 'tooltip' => '',
249 'value' => QUADMENU_PLUGIN_DIR_CSS,
250 'status' => 'green'
251 ));
252 } else {
253 $this->add('Compiler', array(
254 'check_name' => esc_html__('Can\'t write uploads folder', 'quadmenu'),
255 'tooltip' => '',
256 'value' => QUADMENU_PLUGIN_DIR_CSS,
257 'status' => 'red'
258 ));
259 }
260
261
262 // WordPress
263 // -----------------------------------------------------------------
264 // home url
265 $this->add('WordPress and plugins', array(
266 'check_name' => 'WP Home URL',
267 'tooltip' => 'test tooltip',
268 'value' => home_url(),
269 'status' => 'info'
270 ));
271
272 // site url
273 $this->add('WordPress and plugins', array(
274 'check_name' => 'WP Site URL',
275 'tooltip' => 'test tooltip',
276 'value' => site_url(),
277 'status' => 'info'
278 ));
279
280 // home_url == site_url
281 if (home_url() != site_url()) {
282 $this->add('WordPress and plugins', array(
283 'check_name' => 'Home URL - Site URL',
284 'tooltip' => 'Home URL not equal to Site URL, this may indicate a problem with your WordPress configuration.',
285 'value' => sprintf('%1$s - <span class="quadmenu-status-small-text">%2$s</span>', esc_html__('Home URL != Site URL', 'quadmenu'), esc_html__('Home URL not equal to Site URL, this may indicate a problem with your WordPress configuration.', 'quadmenu')),
286 'status' => 'red'
287 ));
288 }
289
290 // version
291 $this->add('WordPress and plugins', array(
292 'check_name' => 'WP version',
293 'tooltip' => '',
294 'value' => get_bloginfo('version'),
295 'status' => 'info'
296 ));
297
298
299 // is_multisite
300 $this->add('WordPress and plugins', array(
301 'check_name' => 'WP multisite enabled',
302 'tooltip' => '',
303 'value' => is_multisite() ? 'Yes' : 'No',
304 'status' => 'info'
305 ));
306
307
308 // language
309 $this->add('WordPress and plugins', array(
310 'check_name' => 'WP Language',
311 'tooltip' => '',
312 'value' => get_locale(),
313 'status' => 'info'
314 ));
315
316 // theme locations
317 if (!is_array($_wp_registered_nav_menus) || !count($_wp_registered_nav_menus)) {
318 $this->add('WordPress and plugins', array(
319 'check_name' => 'WP Menu Locations',
320 'tooltip' => '',
321 'value' => esc_html__('Your theme doesn\'t natively support menus'),
322 'status' => 'red'
323 ));
324 } else {
325 $this->add('WordPress and plugins', array(
326 'check_name' => 'WP Menu Locations',
327 'tooltip' => '',
328 'value' => count($_wp_registered_nav_menus),
329 'status' => 'green'
330 ));
331 }
332
333 // memory limit
334 $memory_limit = $this->wp_memory_notation_to_number(WP_MEMORY_LIMIT);
335 if ($memory_limit < 67108864) {
336 $this->add('WordPress and plugins', array(
337 'check_name' => 'WP Memory Limit',
338 'tooltip' => '',
339 'value' => sprintf('%1$s - <span class="quadmenu-status-small-text">%2$s <a href="%3$s" target="_blank">%4$s</a></span>', size_format($memory_limit) . '/request', esc_html__('We recommend setting memory to at least 64MB. The Plugin is well tested with a 40MB/request limit, but if you are using multiple plugins that may not be enough. See: ', 'quadmenu'), 'http://codex.wordpress.org/Editing_wp-config.php#Increasing_memory_allocated_to_PHP', esc_html__('Increasing memory allocated to PHP', 'quadmenu')),
340 'status' => 'red'
341 ));
342 } else {
343 $this->add('WordPress and plugins', array(
344 'check_name' => 'WP Memory Limit',
345 'tooltip' => '',
346 'value' => size_format($memory_limit) . '/request',
347 'status' => 'green'
348 ));
349 }
350
351
352 // wp debug
353 if (defined('WP_DEBUG') and WP_DEBUG === true) {
354 $this->add('WordPress and plugins', array(
355 'check_name' => 'WP_DEBUG',
356 'tooltip' => '',
357 'value' => esc_html__('WP_DEBUG is enabled', 'quadmenu'),
358 'status' => 'yellow'
359 ));
360 } else {
361 $this->add('WordPress and plugins', array(
362 'check_name' => 'WP_DEBUG',
363 'tooltip' => '',
364 'value' => 'False',
365 'status' => 'green'
366 ));
367 }
368
369 // caching
370 $caching_plugin_list = array(
371 'wp-super-cache/wp-cache.php' => array(
372 'name' => 'WP super cache',
373 'status' => 'green',
374 ),
375 'w3-total-cache/w3-total-cache.php' => array(
376 'name' => 'W3 total cache',
377 'status' => 'green',
378 ),
379 'wp-fastest-cache/wpFastestCache.php' => array(
380 'name' => 'WP Fastest Cache (We haven\'t tested this plugin.)',
381 'status' => 'yellow',
382 ),
383 'wp-rocket/wp-rocket.php' => array(
384 'name' => 'WP Rocket (We haven\'t tested this plugin.)',
385 'status' => 'yellow',
386 ),
387 );
388
389 $active_plugins = get_plugins();
390
391 $caching_plugin = esc_html__('No caching plugin detected', 'quadmenu');
392
393 $caching_plugin_status = 'yellow';
394
395 foreach (array_keys($active_plugins) as $active_plugin) {
396
397 if (isset($caching_plugin_list[$active_plugin])) {
398
399 $caching_plugin = $caching_plugin_list[$active_plugin]['name'];
400 $caching_plugin_status = $caching_plugin_list[$active_plugin]['status'];
401 break;
402 }
403 }
404 $this->add('WordPress and plugins', array(
405 'check_name' => 'Caching plugin',
406 'tooltip' => '',
407 'value' => $caching_plugin,
408 'status' => $caching_plugin_status
409 ));
410 }
411
412 function wp_memory_notation_to_number($size) {
413 $l = substr($size, -1);
414 $ret = substr($size, 0, -1);
415 switch (strtoupper($l)) {
416 case 'P':
417 $ret *= 1024;
418 case 'T':
419 $ret *= 1024;
420 case 'G':
421 $ret *= 1024;
422 case 'M':
423 $ret *= 1024;
424 case 'K':
425 $ret *= 1024;
426 }
427 return $ret;
428 }
429
430 }
431
432 new QuadMenu_System();
433