| 1 |
<?php |
| 2 |
if (!defined('ABSPATH')) { |
| 3 |
die('-1'); |
| 4 |
} |
| 5 |
|
| 6 |
class QuadMenu_System extends QuadMenu_Panel { |
| 7 |
|
| 8 |
function __construct() { |
| 9 |
add_action('admin_menu', array($this, 'panel'), 10); |
| 10 |
} |
| 11 |
|
| 12 |
function panel() { |
| 13 |
add_submenu_page('quadmenu_welcome', 'System', 'System', 'edit_posts', 'quadmenu_system_status', array($this, 'system')); |
| 14 |
} |
| 15 |
|
| 16 |
function system() { |
| 17 |
$this->header(); |
| 18 |
?> |
| 19 |
<div class="about-wrap quadmenu-admin-wrap"> |
| 20 |
<h1><?php esc_html_e('System Status', 'quadmenu'); ?></h1> |
| 21 |
<div class="about-text"> |
| 22 |
<?php esc_html_e('Here you can check the system status. Yellow status means that the site will work as expected on the front end but it may cause problems in your admin dashboard.', 'quadmenu'); ?> |
| 23 |
</div> |
| 24 |
|
| 25 |
<?php |
| 26 |
global $quadmenu_active_locations, $_wp_registered_nav_menus; |
| 27 |
|
| 28 |
// Plugin name |
| 29 |
$this->add('Plugin config', array( |
| 30 |
'check_name' => 'Plugin name', |
| 31 |
'tooltip' => '', |
| 32 |
'value' => QUADMENU_NAME, |
| 33 |
'status' => 'info' |
| 34 |
)); |
| 35 |
|
| 36 |
// Plugin version |
| 37 |
$this->add('Plugin config', array( |
| 38 |
'check_name' => 'Plugin version', |
| 39 |
'tooltip' => '', |
| 40 |
'value' => QUADMENU_VERSION, |
| 41 |
'status' => 'info' |
| 42 |
)); |
| 43 |
|
| 44 |
// Redux version |
| 45 |
if (class_exists('ReduxFramework')) { |
| 46 |
if (version_compare(ReduxFramework::$_version, '3.6.5') < 0) { |
| 47 |
$this->add('Plugin config', array( |
| 48 |
'check_name' => 'Redux version', |
| 49 |
'tooltip' => '', |
| 50 |
'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')), |
| 51 |
'status' => 'red', |
| 52 |
)); |
| 53 |
} else { |
| 54 |
$this->add('Plugin config', array( |
| 55 |
'check_name' => 'Redux version', |
| 56 |
'tooltip' => '', |
| 57 |
'value' => ReduxFramework::$_version, |
| 58 |
'status' => 'green' |
| 59 |
)); |
| 60 |
} |
| 61 |
} else { |
| 62 |
$this->add('Plugin config', array( |
| 63 |
'check_name' => 'Redux version', |
| 64 |
'tooltip' => '', |
| 65 |
'value' => esc_html__('Activate ReduxFramework', 'quadmenu'), |
| 66 |
'status' => 'red', |
| 67 |
)); |
| 68 |
} |
| 69 |
|
| 70 |
// Menu Locations |
| 71 |
if (is_array($quadmenu_active_locations)) { |
| 72 |
$this->add('Plugin config', array( |
| 73 |
'check_name' => 'Active Locations', |
| 74 |
'tooltip' => '', |
| 75 |
'value' => sprintf(esc_html__('You have %s active menu locations', 'quadmenu'), count($quadmenu_active_locations)), |
| 76 |
'status' => count($quadmenu_active_locations) ? 'green' : 'info' |
| 77 |
)); |
| 78 |
} |
| 79 |
|
| 80 |
// Server status |
| 81 |
// ----------------------------------------------------------------- |
| 82 |
// server info |
| 83 |
$this->add('php.ini configuration', array( |
| 84 |
'check_name' => 'Server software', |
| 85 |
'tooltip' => '', |
| 86 |
'value' => esc_html($_SERVER['SERVER_SOFTWARE']), |
| 87 |
'status' => 'info' |
| 88 |
)); |
| 89 |
|
| 90 |
// php version |
| 91 |
$this->add('php.ini configuration', array( |
| 92 |
'check_name' => 'PHP Version', |
| 93 |
'tooltip' => '', |
| 94 |
'value' => phpversion(), |
| 95 |
'status' => 'info' |
| 96 |
)); |
| 97 |
|
| 98 |
// post_max_size |
| 99 |
$this->add('php.ini configuration', array( |
| 100 |
'check_name' => 'post_max_size', |
| 101 |
'tooltip' => '', |
| 102 |
'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')), |
| 103 |
'status' => 'info' |
| 104 |
)); |
| 105 |
|
| 106 |
// php time limit |
| 107 |
$max_execution_time = ini_get('max_execution_time'); |
| 108 |
if ($max_execution_time == 0 or $max_execution_time >= 300) { |
| 109 |
$this->add('php.ini configuration', array( |
| 110 |
'check_name' => 'max_execution_time', |
| 111 |
'tooltip' => '', |
| 112 |
'value' => esc_html($max_execution_time), |
| 113 |
'status' => 'green' |
| 114 |
)); |
| 115 |
} else { |
| 116 |
$this->add('php.ini configuration', array( |
| 117 |
'check_name' => 'max_execution_time', |
| 118 |
'tooltip' => '', |
| 119 |
'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')), |
| 120 |
'status' => 'red' |
| 121 |
)); |
| 122 |
} |
| 123 |
|
| 124 |
// php max input vars |
| 125 |
$max_input_vars = ini_get('max_input_vars'); |
| 126 |
if ($max_input_vars == 0 or $max_input_vars >= 2000) { |
| 127 |
$this->add('php.ini configuration', array( |
| 128 |
'check_name' => 'max_input_vars', |
| 129 |
'tooltip' => '', |
| 130 |
'value' => esc_html($max_input_vars), |
| 131 |
'status' => 'green' |
| 132 |
)); |
| 133 |
} else { |
| 134 |
$this->add('php.ini configuration', array( |
| 135 |
'check_name' => 'max_input_vars', |
| 136 |
'tooltip' => '', |
| 137 |
'value' => esc_html($max_input_vars), |
| 138 |
'status' => 'yellow' |
| 139 |
)); |
| 140 |
} |
| 141 |
|
| 142 |
// suhosin |
| 143 |
if (extension_loaded('suhosin') !== true) { |
| 144 |
$this->add('php.ini configuration', array( |
| 145 |
'check_name' => 'SUHOSIN Installed', |
| 146 |
'tooltip' => '', |
| 147 |
'value' => 'False', |
| 148 |
'status' => 'green' |
| 149 |
)); |
| 150 |
} else { |
| 151 |
$this->add('php.ini configuration', array( |
| 152 |
'check_name' => 'SUHOSIN Installed', |
| 153 |
'tooltip' => '', |
| 154 |
'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')), |
| 155 |
'status' => 'yellow' |
| 156 |
)); |
| 157 |
} |
| 158 |
|
| 159 |
$response_code = wp_remote_retrieve_response_code(wp_remote_get(QUADMENU_URL_ASSETS . 'frontend/less/quadmenu-locations.less', array( |
| 160 |
'timeout' => 20, |
| 161 |
'user-agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:20.0) Gecko/20100101 Firefox/20.0' |
| 162 |
))); |
| 163 |
// mime types |
| 164 |
if ($response_code == 200) { |
| 165 |
$this->add('Compiler', array( |
| 166 |
'check_name' => esc_html__('LESS files allowed', 'quadmenu'), |
| 167 |
'tooltip' => '', |
| 168 |
'value' => $response_code, |
| 169 |
'status' => 'green' |
| 170 |
)); |
| 171 |
} else { |
| 172 |
$this->add('Compiler', array( |
| 173 |
'check_name' => esc_html__('Can\'t compile stylesheets', 'quadmenu'), |
| 174 |
'tooltip' => '', |
| 175 |
'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')), |
| 176 |
'status' => 'red' |
| 177 |
)); |
| 178 |
} |
| 179 |
|
| 180 |
// mime types |
| 181 |
if (wp_is_writable(QUADMENU_PATH_CSS)) { |
| 182 |
$this->add('Compiler', array( |
| 183 |
'check_name' => esc_html__('Folder is writable', 'quadmenu'), |
| 184 |
'tooltip' => '', |
| 185 |
'value' => QUADMENU_PATH_CSS, |
| 186 |
'status' => 'green' |
| 187 |
)); |
| 188 |
} else { |
| 189 |
$this->add('Compiler', array( |
| 190 |
'check_name' => esc_html__('Can\'t write uploads folder', 'quadmenu'), |
| 191 |
'tooltip' => '', |
| 192 |
'value' => QUADMENU_PATH_CSS, |
| 193 |
'status' => 'red' |
| 194 |
)); |
| 195 |
} |
| 196 |
|
| 197 |
|
| 198 |
// WordPress |
| 199 |
// ----------------------------------------------------------------- |
| 200 |
// home url |
| 201 |
$this->add('WordPress and plugins', array( |
| 202 |
'check_name' => 'WP Home URL', |
| 203 |
'tooltip' => 'test tooltip', |
| 204 |
'value' => home_url(), |
| 205 |
'status' => 'info' |
| 206 |
)); |
| 207 |
|
| 208 |
// site url |
| 209 |
$this->add('WordPress and plugins', array( |
| 210 |
'check_name' => 'WP Site URL', |
| 211 |
'tooltip' => 'test tooltip', |
| 212 |
'value' => site_url(), |
| 213 |
'status' => 'info' |
| 214 |
)); |
| 215 |
|
| 216 |
// home_url == site_url |
| 217 |
if (home_url() != site_url()) { |
| 218 |
$this->add('WordPress and plugins', array( |
| 219 |
'check_name' => 'Home URL - Site URL', |
| 220 |
'tooltip' => 'Home URL not equal to Site URL, this may indicate a problem with your WordPress configuration.', |
| 221 |
'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')), |
| 222 |
'status' => 'red' |
| 223 |
)); |
| 224 |
} |
| 225 |
|
| 226 |
// version |
| 227 |
$this->add('WordPress and plugins', array( |
| 228 |
'check_name' => 'WP version', |
| 229 |
'tooltip' => '', |
| 230 |
'value' => get_bloginfo('version'), |
| 231 |
'status' => 'info' |
| 232 |
)); |
| 233 |
|
| 234 |
|
| 235 |
// is_multisite |
| 236 |
$this->add('WordPress and plugins', array( |
| 237 |
'check_name' => 'WP multisite enabled', |
| 238 |
'tooltip' => '', |
| 239 |
'value' => is_multisite() ? 'Yes' : 'No', |
| 240 |
'status' => 'info' |
| 241 |
)); |
| 242 |
|
| 243 |
|
| 244 |
// language |
| 245 |
$this->add('WordPress and plugins', array( |
| 246 |
'check_name' => 'WP Language', |
| 247 |
'tooltip' => '', |
| 248 |
'value' => get_locale(), |
| 249 |
'status' => 'info' |
| 250 |
)); |
| 251 |
|
| 252 |
// theme locations |
| 253 |
if (!is_array($_wp_registered_nav_menus) || !count($_wp_registered_nav_menus)) { |
| 254 |
$this->add('WordPress and plugins', array( |
| 255 |
'check_name' => 'WP Menu Locations', |
| 256 |
'tooltip' => '', |
| 257 |
'value' => esc_html__('Your theme doesn\'t natively support menus'), |
| 258 |
'status' => 'red' |
| 259 |
)); |
| 260 |
} else { |
| 261 |
$this->add('WordPress and plugins', array( |
| 262 |
'check_name' => 'WP Menu Locations', |
| 263 |
'tooltip' => '', |
| 264 |
'value' => count($_wp_registered_nav_menus), |
| 265 |
'status' => 'green' |
| 266 |
)); |
| 267 |
} |
| 268 |
|
| 269 |
// memory limit |
| 270 |
$memory_limit = $this->wp_memory_notation_to_number(WP_MEMORY_LIMIT); |
| 271 |
if ($memory_limit < 67108864) { |
| 272 |
$this->add('WordPress and plugins', array( |
| 273 |
'check_name' => 'WP Memory Limit', |
| 274 |
'tooltip' => '', |
| 275 |
'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')), |
| 276 |
'status' => 'red' |
| 277 |
)); |
| 278 |
} else { |
| 279 |
$this->add('WordPress and plugins', array( |
| 280 |
'check_name' => 'WP Memory Limit', |
| 281 |
'tooltip' => '', |
| 282 |
'value' => size_format($memory_limit) . '/request', |
| 283 |
'status' => 'green' |
| 284 |
)); |
| 285 |
} |
| 286 |
|
| 287 |
|
| 288 |
// wp debug |
| 289 |
if (defined('WP_DEBUG') and WP_DEBUG === true) { |
| 290 |
$this->add('WordPress and plugins', array( |
| 291 |
'check_name' => 'WP_DEBUG', |
| 292 |
'tooltip' => '', |
| 293 |
'value' => esc_html__('WP_DEBUG is enabled', 'quadmenu'), |
| 294 |
'status' => 'yellow' |
| 295 |
)); |
| 296 |
} else { |
| 297 |
$this->add('WordPress and plugins', array( |
| 298 |
'check_name' => 'WP_DEBUG', |
| 299 |
'tooltip' => '', |
| 300 |
'value' => 'False', |
| 301 |
'status' => 'green' |
| 302 |
)); |
| 303 |
} |
| 304 |
|
| 305 |
// caching |
| 306 |
$caching_plugin_list = array( |
| 307 |
'wp-super-cache/wp-cache.php' => array( |
| 308 |
'name' => 'WP super cache', |
| 309 |
'status' => 'green', |
| 310 |
), |
| 311 |
'w3-total-cache/w3-total-cache.php' => array( |
| 312 |
'name' => 'W3 total cache', |
| 313 |
'status' => 'green', |
| 314 |
), |
| 315 |
'wp-fastest-cache/wpFastestCache.php' => array( |
| 316 |
'name' => 'WP Fastest Cache (We haven\'t tested this plugin.)', |
| 317 |
'status' => 'yellow', |
| 318 |
), |
| 319 |
'wp-rocket/wp-rocket.php' => array( |
| 320 |
'name' => 'WP Rocket (We haven\'t tested this plugin.)', |
| 321 |
'status' => 'yellow', |
| 322 |
), |
| 323 |
); |
| 324 |
|
| 325 |
$active_plugins = get_plugins(); |
| 326 |
|
| 327 |
$caching_plugin = esc_html__('No caching plugin detected', 'quadmenu'); |
| 328 |
|
| 329 |
$caching_plugin_status = 'yellow'; |
| 330 |
|
| 331 |
foreach (array_keys($active_plugins) as $active_plugin) { |
| 332 |
|
| 333 |
if (isset($caching_plugin_list[$active_plugin])) { |
| 334 |
|
| 335 |
$caching_plugin = $caching_plugin_list[$active_plugin]['name']; |
| 336 |
$caching_plugin_status = $caching_plugin_list[$active_plugin]['status']; |
| 337 |
break; |
| 338 |
} |
| 339 |
} |
| 340 |
$this->add('WordPress and plugins', array( |
| 341 |
'check_name' => 'Caching plugin', |
| 342 |
'tooltip' => '', |
| 343 |
'value' => $caching_plugin, |
| 344 |
'status' => $caching_plugin_status |
| 345 |
)); |
| 346 |
|
| 347 |
$this->tables(); |
| 348 |
?> |
| 349 |
|
| 350 |
</div> |
| 351 |
<?php |
| 352 |
} |
| 353 |
|
| 354 |
function wp_memory_notation_to_number($size) { |
| 355 |
$l = substr($size, -1); |
| 356 |
$ret = substr($size, 0, -1); |
| 357 |
switch (strtoupper($l)) { |
| 358 |
case 'P': |
| 359 |
$ret *= 1024; |
| 360 |
case 'T': |
| 361 |
$ret *= 1024; |
| 362 |
case 'G': |
| 363 |
$ret *= 1024; |
| 364 |
case 'M': |
| 365 |
$ret *= 1024; |
| 366 |
case 'K': |
| 367 |
$ret *= 1024; |
| 368 |
} |
| 369 |
return $ret; |
| 370 |
} |
| 371 |
|
| 372 |
} |
| 373 |
|
| 374 |
new QuadMenu_System(); |
| 375 |
|