| 1 |
<?php |
| 2 |
|
| 3 |
namespace QuadLayers\QuadMenu\Panel; |
| 4 |
|
| 5 |
use QuadLayers\QuadMenu\Panel; |
| 6 |
|
| 7 |
if ( ! defined( 'ABSPATH' ) ) { |
| 8 |
die( '-1' ); |
| 9 |
} |
| 10 |
|
| 11 |
/** |
| 12 |
* System Class ex QuadMenu_System |
| 13 |
*/ |
| 14 |
class System extends Panel { |
| 15 |
|
| 16 |
private static $instance; |
| 17 |
|
| 18 |
public static $status = array(); |
| 19 |
|
| 20 |
function __construct() { |
| 21 |
add_action( 'admin_menu', array( $this, 'add_menu' ) ); |
| 22 |
} |
| 23 |
|
| 24 |
function add_menu() { |
| 25 |
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' ) ); |
| 26 |
} |
| 27 |
|
| 28 |
function add_panel() { |
| 29 |
global $submenu; |
| 30 |
$system = $this; |
| 31 |
include QUADMENU_PLUGIN_DIR . '/lib/panel/pages/parts/header.php'; |
| 32 |
include QUADMENU_PLUGIN_DIR . '/lib/panel/pages/system.php'; |
| 33 |
} |
| 34 |
|
| 35 |
function add( $section, $status_array ) { |
| 36 |
self::$status[ $section ][] = $status_array; |
| 37 |
} |
| 38 |
|
| 39 |
function tables() { |
| 40 |
|
| 41 |
$this->system(); |
| 42 |
|
| 43 |
foreach ( self::$status as $section_name => $section_statuses ) { |
| 44 |
?> |
| 45 |
<table class="widefat quadmenu-system-table" cellspacing="0"> |
| 46 |
<thead> |
| 47 |
<tr> |
| 48 |
<th colspan="4"><?php echo esc_html( $section_name ); ?></th> |
| 49 |
</tr> |
| 50 |
</thead> |
| 51 |
<tbody> |
| 52 |
<?php |
| 53 |
foreach ( $section_statuses as $status_params ) { |
| 54 |
?> |
| 55 |
<tr> |
| 56 |
<td class="quadmenu-system-name"><?php echo esc_html( $status_params['check_name'] ); ?></td> |
| 57 |
<!--<td class="quadmenu-system-help"></td>--> |
| 58 |
<td class="quadmenu-system-status"> |
| 59 |
<?php |
| 60 |
switch ( $status_params['status'] ) { |
| 61 |
case 'green': |
| 62 |
echo '<div class="quadmenu-system-led success" title="' . esc_html__( 'Green status: this check passed our system status test!', 'quadmenu' ) . '"></div>'; |
| 63 |
break; |
| 64 |
case 'yellow': |
| 65 |
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>'; |
| 66 |
break; |
| 67 |
case 'red': |
| 68 |
echo '<div class="quadmenu-system-led critical" title="' . esc_html__( 'Red status: the site may not work as expected with this option.', 'quadmenu' ) . '"></div>'; |
| 69 |
break; |
| 70 |
case 'info': |
| 71 |
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>'; |
| 72 |
break; |
| 73 |
} |
| 74 |
?> |
| 75 |
</td> |
| 76 |
<td class="quadmenu-system-value"> |
| 77 |
<?php |
| 78 |
echo wp_kses( |
| 79 |
$status_params['value'], |
| 80 |
array( |
| 81 |
'a' => array( |
| 82 |
'href' => array(), |
| 83 |
'title' => array(), |
| 84 |
), |
| 85 |
'br' => array(), |
| 86 |
'em' => array(), |
| 87 |
'strong' => array(), |
| 88 |
'span' => array(), |
| 89 |
) |
| 90 |
); |
| 91 |
?> |
| 92 |
</td> |
| 93 |
</tr> |
| 94 |
<?php |
| 95 |
} |
| 96 |
?> |
| 97 |
</tbody> |
| 98 |
</table> |
| 99 |
<?php |
| 100 |
} |
| 101 |
} |
| 102 |
|
| 103 |
function system() { |
| 104 |
|
| 105 |
global $quadmenu_active_locations, $_wp_registered_nav_menus; |
| 106 |
|
| 107 |
// Plugin name |
| 108 |
$this->add( |
| 109 |
'Plugin config', |
| 110 |
array( |
| 111 |
'check_name' => 'Plugin name', |
| 112 |
'tooltip' => '', |
| 113 |
'value' => QUADMENU_PLUGIN_NAME, |
| 114 |
'status' => 'info', |
| 115 |
) |
| 116 |
); |
| 117 |
|
| 118 |
// Plugin version |
| 119 |
$this->add( |
| 120 |
'Plugin config', |
| 121 |
array( |
| 122 |
'check_name' => 'Plugin version', |
| 123 |
'tooltip' => '', |
| 124 |
'value' => QUADMENU_PLUGIN_VERSION, |
| 125 |
'status' => 'info', |
| 126 |
) |
| 127 |
); |
| 128 |
|
| 129 |
// Redux version |
| 130 |
if ( class_exists( 'ReduxFramework' ) ) { |
| 131 |
if ( version_compare( \ReduxFrameworkLegacy::$_version, '3.6.5' ) < 0 ) { |
| 132 |
$this->add( |
| 133 |
'Plugin config', |
| 134 |
array( |
| 135 |
'check_name' => 'Redux version', |
| 136 |
'tooltip' => '', |
| 137 |
'value' => sprintf( '%1$s - <span class="quadmenu-status-small-text">%2$s <a href="%3$s" target="_blank">%4$s</a></span>', \ReduxFrameworkLegacy::$_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' ) ), |
| 138 |
'status' => 'red', |
| 139 |
) |
| 140 |
); |
| 141 |
} else { |
| 142 |
$this->add( |
| 143 |
'Plugin config', |
| 144 |
array( |
| 145 |
'check_name' => 'Redux version', |
| 146 |
'tooltip' => '', |
| 147 |
'value' => \ReduxFrameworkLegacy::$_version, |
| 148 |
'status' => 'green', |
| 149 |
) |
| 150 |
); |
| 151 |
} |
| 152 |
} else { |
| 153 |
$this->add( |
| 154 |
'Plugin config', |
| 155 |
array( |
| 156 |
'check_name' => 'Redux version', |
| 157 |
'tooltip' => '', |
| 158 |
'value' => esc_html__( 'Activate ReduxFramework', 'quadmenu' ), |
| 159 |
'status' => 'red', |
| 160 |
) |
| 161 |
); |
| 162 |
} |
| 163 |
|
| 164 |
// Menu Locations |
| 165 |
if ( is_array( $quadmenu_active_locations ) ) { |
| 166 |
$this->add( |
| 167 |
'Plugin config', |
| 168 |
array( |
| 169 |
'check_name' => 'Active Locations', |
| 170 |
'tooltip' => '', |
| 171 |
'value' => sprintf( esc_html__( 'You have %s active menu locations', 'quadmenu' ), count( $quadmenu_active_locations ) ), |
| 172 |
'status' => count( $quadmenu_active_locations ) ? 'green' : 'info', |
| 173 |
) |
| 174 |
); |
| 175 |
} |
| 176 |
|
| 177 |
// Server status |
| 178 |
// ----------------------------------------------------------------- |
| 179 |
// server info |
| 180 |
$this->add( |
| 181 |
'php.ini configuration', |
| 182 |
array( |
| 183 |
'check_name' => 'Server software', |
| 184 |
'tooltip' => '', |
| 185 |
'value' => esc_html( $_SERVER['SERVER_SOFTWARE'] ), |
| 186 |
'status' => 'info', |
| 187 |
) |
| 188 |
); |
| 189 |
|
| 190 |
// php version |
| 191 |
$this->add( |
| 192 |
'php.ini configuration', |
| 193 |
array( |
| 194 |
'check_name' => 'PHP Version', |
| 195 |
'tooltip' => '', |
| 196 |
'value' => phpversion(), |
| 197 |
'status' => 'info', |
| 198 |
) |
| 199 |
); |
| 200 |
|
| 201 |
// post_max_size |
| 202 |
$this->add( |
| 203 |
'php.ini configuration', |
| 204 |
array( |
| 205 |
'check_name' => 'post_max_size', |
| 206 |
'tooltip' => '', |
| 207 |
'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' ) ), |
| 208 |
'status' => 'info', |
| 209 |
) |
| 210 |
); |
| 211 |
|
| 212 |
// php time limit |
| 213 |
$max_execution_time = ini_get( 'max_execution_time' ); |
| 214 |
if ( $max_execution_time == 0 or $max_execution_time >= 300 ) { |
| 215 |
$this->add( |
| 216 |
'php.ini configuration', |
| 217 |
array( |
| 218 |
'check_name' => 'max_execution_time', |
| 219 |
'tooltip' => '', |
| 220 |
'value' => esc_html( $max_execution_time ), |
| 221 |
'status' => 'green', |
| 222 |
) |
| 223 |
); |
| 224 |
} else { |
| 225 |
$this->add( |
| 226 |
'php.ini configuration', |
| 227 |
array( |
| 228 |
'check_name' => 'max_execution_time', |
| 229 |
'tooltip' => '', |
| 230 |
'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' ) ), |
| 231 |
'status' => 'red', |
| 232 |
) |
| 233 |
); |
| 234 |
} |
| 235 |
|
| 236 |
// php max input vars |
| 237 |
$max_input_vars = ini_get( 'max_input_vars' ); |
| 238 |
if ( $max_input_vars == 0 or $max_input_vars >= 2000 ) { |
| 239 |
$this->add( |
| 240 |
'php.ini configuration', |
| 241 |
array( |
| 242 |
'check_name' => 'max_input_vars', |
| 243 |
'tooltip' => '', |
| 244 |
'value' => esc_html( $max_input_vars ), |
| 245 |
'status' => 'green', |
| 246 |
) |
| 247 |
); |
| 248 |
} else { |
| 249 |
$this->add( |
| 250 |
'php.ini configuration', |
| 251 |
array( |
| 252 |
'check_name' => 'max_input_vars', |
| 253 |
'tooltip' => '', |
| 254 |
'value' => esc_html( $max_input_vars ), |
| 255 |
'status' => 'yellow', |
| 256 |
) |
| 257 |
); |
| 258 |
} |
| 259 |
|
| 260 |
// suhosin |
| 261 |
if ( extension_loaded( 'suhosin' ) !== true ) { |
| 262 |
$this->add( |
| 263 |
'php.ini configuration', |
| 264 |
array( |
| 265 |
'check_name' => 'SUHOSIN Installed', |
| 266 |
'tooltip' => '', |
| 267 |
'value' => 'False', |
| 268 |
'status' => 'green', |
| 269 |
) |
| 270 |
); |
| 271 |
} else { |
| 272 |
$this->add( |
| 273 |
'php.ini configuration', |
| 274 |
array( |
| 275 |
'check_name' => 'SUHOSIN Installed', |
| 276 |
'tooltip' => '', |
| 277 |
'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' ) ), |
| 278 |
'status' => 'yellow', |
| 279 |
) |
| 280 |
); |
| 281 |
} |
| 282 |
|
| 283 |
$response_code = wp_remote_retrieve_response_code( |
| 284 |
wp_remote_get( |
| 285 |
QUADMENU_PLUGIN_URL . 'assets/frontend/less/quadmenu-locations.less', |
| 286 |
array( |
| 287 |
'timeout' => 20, |
| 288 |
'user-agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:20.0) Gecko/20100101 Firefox/20.0', |
| 289 |
) |
| 290 |
) |
| 291 |
); |
| 292 |
// mime types |
| 293 |
if ( $response_code == 200 ) { |
| 294 |
$this->add( |
| 295 |
'Compiler', |
| 296 |
array( |
| 297 |
'check_name' => esc_html__( 'LESS files allowed', 'quadmenu' ), |
| 298 |
'tooltip' => '', |
| 299 |
'value' => $response_code, |
| 300 |
'status' => 'green', |
| 301 |
) |
| 302 |
); |
| 303 |
} else { |
| 304 |
$this->add( |
| 305 |
'Compiler', |
| 306 |
array( |
| 307 |
'check_name' => esc_html__( 'Can\'t compile stylesheets', 'quadmenu' ), |
| 308 |
'tooltip' => '', |
| 309 |
'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' ) ), |
| 310 |
'status' => 'red', |
| 311 |
) |
| 312 |
); |
| 313 |
} |
| 314 |
|
| 315 |
// mime types |
| 316 |
if ( wp_is_writable( QUADMENU_UPLOAD_DIR ) ) { |
| 317 |
$this->add( |
| 318 |
'Compiler', |
| 319 |
array( |
| 320 |
'check_name' => esc_html__( 'Folder is writable', 'quadmenu' ), |
| 321 |
'tooltip' => '', |
| 322 |
'value' => QUADMENU_UPLOAD_DIR, |
| 323 |
'status' => 'green', |
| 324 |
) |
| 325 |
); |
| 326 |
} else { |
| 327 |
$this->add( |
| 328 |
'Compiler', |
| 329 |
array( |
| 330 |
'check_name' => esc_html__( 'Can\'t write uploads folder', 'quadmenu' ), |
| 331 |
'tooltip' => '', |
| 332 |
'value' => QUADMENU_UPLOAD_DIR, |
| 333 |
'status' => 'red', |
| 334 |
) |
| 335 |
); |
| 336 |
} |
| 337 |
|
| 338 |
// WordPress |
| 339 |
// ----------------------------------------------------------------- |
| 340 |
// home url |
| 341 |
$this->add( |
| 342 |
'WordPress and plugins', |
| 343 |
array( |
| 344 |
'check_name' => 'WP Home URL', |
| 345 |
'tooltip' => 'test tooltip', |
| 346 |
'value' => home_url(), |
| 347 |
'status' => 'info', |
| 348 |
) |
| 349 |
); |
| 350 |
|
| 351 |
// site url |
| 352 |
$this->add( |
| 353 |
'WordPress and plugins', |
| 354 |
array( |
| 355 |
'check_name' => 'WP Site URL', |
| 356 |
'tooltip' => 'test tooltip', |
| 357 |
'value' => site_url(), |
| 358 |
'status' => 'info', |
| 359 |
) |
| 360 |
); |
| 361 |
|
| 362 |
// home_url == site_url |
| 363 |
if ( home_url() != site_url() ) { |
| 364 |
$this->add( |
| 365 |
'WordPress and plugins', |
| 366 |
array( |
| 367 |
'check_name' => 'Home URL - Site URL', |
| 368 |
'tooltip' => 'Home URL not equal to Site URL, this may indicate a problem with your WordPress configuration.', |
| 369 |
'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' ) ), |
| 370 |
'status' => 'red', |
| 371 |
) |
| 372 |
); |
| 373 |
} |
| 374 |
|
| 375 |
// version |
| 376 |
$this->add( |
| 377 |
'WordPress and plugins', |
| 378 |
array( |
| 379 |
'check_name' => 'WP version', |
| 380 |
'tooltip' => '', |
| 381 |
'value' => get_bloginfo( 'version' ), |
| 382 |
'status' => 'info', |
| 383 |
) |
| 384 |
); |
| 385 |
|
| 386 |
// is_multisite |
| 387 |
$this->add( |
| 388 |
'WordPress and plugins', |
| 389 |
array( |
| 390 |
'check_name' => 'WP multisite enabled', |
| 391 |
'tooltip' => '', |
| 392 |
'value' => is_multisite() ? 'Yes' : 'No', |
| 393 |
'status' => 'info', |
| 394 |
) |
| 395 |
); |
| 396 |
|
| 397 |
// language |
| 398 |
$this->add( |
| 399 |
'WordPress and plugins', |
| 400 |
array( |
| 401 |
'check_name' => 'WP Language', |
| 402 |
'tooltip' => '', |
| 403 |
'value' => get_locale(), |
| 404 |
'status' => 'info', |
| 405 |
) |
| 406 |
); |
| 407 |
|
| 408 |
// theme locations |
| 409 |
if ( ! is_array( $_wp_registered_nav_menus ) || ! count( $_wp_registered_nav_menus ) ) { |
| 410 |
$this->add( |
| 411 |
'WordPress and plugins', |
| 412 |
array( |
| 413 |
'check_name' => 'WP Menu Locations', |
| 414 |
'tooltip' => '', |
| 415 |
'value' => esc_html__( 'Your theme doesn\'t natively support menus' ), |
| 416 |
'status' => 'red', |
| 417 |
) |
| 418 |
); |
| 419 |
} else { |
| 420 |
$this->add( |
| 421 |
'WordPress and plugins', |
| 422 |
array( |
| 423 |
'check_name' => 'WP Menu Locations', |
| 424 |
'tooltip' => '', |
| 425 |
'value' => count( $_wp_registered_nav_menus ), |
| 426 |
'status' => 'green', |
| 427 |
) |
| 428 |
); |
| 429 |
} |
| 430 |
|
| 431 |
// memory limit |
| 432 |
$memory_limit = $this->wp_memory_notation_to_number( WP_MEMORY_LIMIT ); |
| 433 |
if ( $memory_limit < 67108864 ) { |
| 434 |
$this->add( |
| 435 |
'WordPress and plugins', |
| 436 |
array( |
| 437 |
'check_name' => 'WP Memory Limit', |
| 438 |
'tooltip' => '', |
| 439 |
'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' ) ), |
| 440 |
'status' => 'red', |
| 441 |
) |
| 442 |
); |
| 443 |
} else { |
| 444 |
$this->add( |
| 445 |
'WordPress and plugins', |
| 446 |
array( |
| 447 |
'check_name' => 'WP Memory Limit', |
| 448 |
'tooltip' => '', |
| 449 |
'value' => size_format( $memory_limit ) . '/request', |
| 450 |
'status' => 'green', |
| 451 |
) |
| 452 |
); |
| 453 |
} |
| 454 |
|
| 455 |
// wp debug |
| 456 |
if ( defined( 'WP_DEBUG' ) and WP_DEBUG === true ) { |
| 457 |
$this->add( |
| 458 |
'WordPress and plugins', |
| 459 |
array( |
| 460 |
'check_name' => 'WP_DEBUG', |
| 461 |
'tooltip' => '', |
| 462 |
'value' => esc_html__( 'WP_DEBUG is enabled', 'quadmenu' ), |
| 463 |
'status' => 'yellow', |
| 464 |
) |
| 465 |
); |
| 466 |
} else { |
| 467 |
$this->add( |
| 468 |
'WordPress and plugins', |
| 469 |
array( |
| 470 |
'check_name' => 'WP_DEBUG', |
| 471 |
'tooltip' => '', |
| 472 |
'value' => 'False', |
| 473 |
'status' => 'green', |
| 474 |
) |
| 475 |
); |
| 476 |
} |
| 477 |
|
| 478 |
// caching |
| 479 |
$caching_plugin_list = array( |
| 480 |
'wp-super-cache/wp-cache.php' => array( |
| 481 |
'name' => 'WP super cache', |
| 482 |
'status' => 'green', |
| 483 |
), |
| 484 |
'w3-total-cache/w3-total-cache.php' => array( |
| 485 |
'name' => 'W3 total cache', |
| 486 |
'status' => 'green', |
| 487 |
), |
| 488 |
'wp-fastest-cache/wpFastestCache.php' => array( |
| 489 |
'name' => 'WP Fastest Cache (We haven\'t tested this plugin.)', |
| 490 |
'status' => 'yellow', |
| 491 |
), |
| 492 |
'wp-rocket/wp-rocket.php' => array( |
| 493 |
'name' => 'WP Rocket (We haven\'t tested this plugin.)', |
| 494 |
'status' => 'yellow', |
| 495 |
), |
| 496 |
); |
| 497 |
|
| 498 |
$active_plugins = get_plugins(); |
| 499 |
|
| 500 |
$caching_plugin = esc_html__( 'No caching plugin detected', 'quadmenu' ); |
| 501 |
|
| 502 |
$caching_plugin_status = 'yellow'; |
| 503 |
|
| 504 |
foreach ( array_keys( $active_plugins ) as $active_plugin ) { |
| 505 |
|
| 506 |
if ( isset( $caching_plugin_list[ $active_plugin ] ) ) { |
| 507 |
|
| 508 |
$caching_plugin = $caching_plugin_list[ $active_plugin ]['name']; |
| 509 |
$caching_plugin_status = $caching_plugin_list[ $active_plugin ]['status']; |
| 510 |
break; |
| 511 |
} |
| 512 |
} |
| 513 |
$this->add( |
| 514 |
'WordPress and plugins', |
| 515 |
array( |
| 516 |
'check_name' => 'Caching plugin', |
| 517 |
'tooltip' => '', |
| 518 |
'value' => $caching_plugin, |
| 519 |
'status' => $caching_plugin_status, |
| 520 |
) |
| 521 |
); |
| 522 |
} |
| 523 |
|
| 524 |
function wp_memory_notation_to_number( $size ) { |
| 525 |
$l = substr( $size, -1 ); |
| 526 |
$ret = substr( $size, 0, -1 ); |
| 527 |
switch ( strtoupper( $l ) ) { |
| 528 |
case 'P': |
| 529 |
$ret *= 1024; |
| 530 |
case 'T': |
| 531 |
$ret *= 1024; |
| 532 |
case 'G': |
| 533 |
$ret *= 1024; |
| 534 |
case 'M': |
| 535 |
$ret *= 1024; |
| 536 |
case 'K': |
| 537 |
$ret *= 1024; |
| 538 |
} |
| 539 |
return $ret; |
| 540 |
} |
| 541 |
|
| 542 |
public static function instance() { |
| 543 |
if ( ! isset( self::$instance ) ) { |
| 544 |
self::$instance = new self(); |
| 545 |
} |
| 546 |
return self::$instance; |
| 547 |
} |
| 548 |
} |
| 549 |
|