| 1 | <?php |
| 2 | /** |
| 3 | * Get system status for debugging and support. |
| 4 | * |
| 5 | * @package WordPress |
| 6 | * @subpackage Administration |
| 7 | */ |
| 8 | |
| 9 | /** WordPress Administration Bootstrap */ |
| 10 | require_once( dirname( __FILE__ ) . '/admin.php' ); |
| 11 | |
| 12 | if ( ! current_user_can( 'update_core' ) ) { |
| 13 | wp_die( __( 'Sorry, you do not have permission to access this page.' ) ); |
| 14 | } |
| 15 | |
| 16 | global $wpdb; |
| 17 | |
| 18 | $title = __( 'System information' ); |
| 19 | |
| 20 | require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
| 21 | ?> |
| 22 | <div class="wrap"> |
| 23 | <h1 class="wp-heading-inline"> |
| 24 | <?php echo esc_html( $title ); ?> |
| 25 | |
| 26 | <?php if ( function_exists( 'phpinfo' ) &&! isset( $_GET['phpinfo'] ) ) : ?> |
| 27 | <a href="<?php echo esc_url( admin_url( 'info.php?phpinfo' ) ); ?>" class="page-title-action"><?php esc_html_e( 'PHP Information' ); ?></a> |
| 28 | <?php endif; ?> |
| 29 | <?php if ( ! isset( $_GET['crons'] ) ) : ?> |
| 30 | <a href="<?php echo esc_url( admin_url( 'info.php?crons' ) ); ?>" class="page-title-action"><?php esc_html_e( 'Cron jobs' ); ?></a> |
| 31 | <?php else : ?> |
| 32 | <a href="<?php echo esc_url( admin_url( 'info.php' ) ); ?>" class="page-title-action"><?php esc_html_e( 'Debug Information' ); ?></a> |
| 33 | <?php endif; ?> |
| 34 | </h1> |
| 35 | |
| 36 | <hr class="wp-header-end"> |
| 37 | |
| 38 | <?php |
| 39 | if ( isset( $_GET['crons'] ) ) { |
| 40 | $crons = _get_cron_array(); |
| 41 | $html = ''; |
| 42 | foreach ( $crons as $cron ) { |
| 43 | foreach ( $cron as $action => $schedules ) { |
| 44 | foreach ( $schedules as $schedule ) { |
| 45 | $html .= sprintf( |
| 46 | '<tr><td>%s</td><td>%s</td><td>%s</td></tr>', |
| 47 | esc_html( $action ), |
| 48 | esc_html( $schedule['schedule'] ), |
| 49 | esc_html( $schedule['interval'] ) |
| 50 | ); |
| 51 | } |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | echo '<table class="widefat striped"> |
| 56 | <tr> |
| 57 | <th>Action</th> |
| 58 | <th>Schedule</th> |
| 59 | <th>Interval (seconds)</th> |
| 60 | </tr> |
| 61 | ' . $html . ' |
| 62 | </html>'; |
| 63 | } elseif ( ! isset( $_GET['phpinfo'] ) ) { |
| 64 | |
| 65 | $upload_dir = wp_upload_dir(); |
| 66 | if ( file_exists( ABSPATH . 'wp-config.php') ) { |
| 67 | $wp_config_path = ABSPATH . 'wp-config.php'; |
| 68 | } else if ( @file_exists( dirname( ABSPATH ) . '/wp-config.php' ) && ! @file_exists( dirname( ABSPATH ) . '/wp-settings.php' ) ) { |
| 69 | $wp_config_path = dirname( ABSPATH ) . '/wp-config.php'; |
| 70 | } |
| 71 | |
| 72 | $info = array( |
| 73 | 'wp-core' => array( |
| 74 | 'label' => __( 'WordPress' ), |
| 75 | 'fields' => array( |
| 76 | array( |
| 77 | 'label' => __( 'Version' ), |
| 78 | 'value' => get_bloginfo( 'version' ) |
| 79 | ), |
| 80 | array( |
| 81 | 'label' => __( 'Language' ), |
| 82 | 'value' => get_locale() |
| 83 | ), |
| 84 | array( |
| 85 | 'label' => __( 'Home URL' ), |
| 86 | 'value' => get_bloginfo( 'url' ), |
| 87 | 'private' => true |
| 88 | ), |
| 89 | array( |
| 90 | 'label' => __( 'Site URL' ), |
| 91 | 'value' => get_bloginfo( 'wpurl' ), |
| 92 | 'private' => true |
| 93 | ), |
| 94 | array( |
| 95 | 'label' => __( 'Permalink structure' ), |
| 96 | 'value' => get_option( 'permalink_structure' ) |
| 97 | ), |
| 98 | array( |
| 99 | 'label' => __( 'Is this site using HTTPS' ), |
| 100 | 'value' => ( is_ssl() ? __( 'Yes' ) : __( 'No' ) ) |
| 101 | ), |
| 102 | array( |
| 103 | 'label' => __( 'Can anyone register on this site' ), |
| 104 | 'value' => ( get_option( 'users_can_register' ) ? __( 'Yes' ) : __( 'No' ) ) |
| 105 | ), |
| 106 | array( |
| 107 | 'label' => __( 'Default comment status' ), |
| 108 | 'value' => get_option( 'default_comment_status' ) |
| 109 | ), |
| 110 | array( |
| 111 | 'label' => __( 'Is this a multisite' ), |
| 112 | 'value' => ( is_multisite() ? __( 'Yes' ) : __( 'No' ) ) |
| 113 | ) |
| 114 | ), |
| 115 | ), |
| 116 | 'wp-dropins' => array( |
| 117 | 'label' => __( 'Drop-ins' ), |
| 118 | 'description' => __( 'Drop-ins are single files that replace or enhance WordPress features in ways that are not possible for traditional plugins' ), |
| 119 | 'fields' => array() |
| 120 | ), |
| 121 | 'wp-active-theme' => array( |
| 122 | 'label' => __( 'Active theme' ), |
| 123 | 'fields' => array() |
| 124 | ), |
| 125 | 'wp-themes' => array( |
| 126 | 'label' => __( 'Other themes' ), |
| 127 | 'show_count' => true, |
| 128 | 'fields' => array() |
| 129 | ), |
| 130 | 'wp-mu-plugins' => array( |
| 131 | 'label' => __( 'Must User Plugins' ), |
| 132 | 'show_count' => true, |
| 133 | 'fields' => array() |
| 134 | ), |
| 135 | 'wp-plugins-active' => array( |
| 136 | 'label' => __( 'Active Plugins' ), |
| 137 | 'show_count' => true, |
| 138 | 'fields' => array() |
| 139 | ), |
| 140 | 'wp-plugins-inactive' => array( |
| 141 | 'label' => __( 'Inactive Plugins' ), |
| 142 | 'show_count' => true, |
| 143 | 'fields' => array() |
| 144 | ), |
| 145 | 'wp-server' => array( |
| 146 | 'label' => 'Server', |
| 147 | 'description' => __( 'The options shown below relate to your server setup. If changes are required, you may need your web host\'s assistance.' ), |
| 148 | 'fields' => array() |
| 149 | ), |
| 150 | 'wp-database' => array( |
| 151 | 'label' => __( 'Database' ), |
| 152 | 'fields' => array() |
| 153 | ), |
| 154 | 'wp-constants' => array( |
| 155 | 'label' => __( 'WordPress constants' ), |
| 156 | 'description' => __( 'These values represent values set in your websites code which affect WordPress in various ways that may be of importance when seeking help with your site.' ), |
| 157 | 'fields' => array( |
| 158 | array( |
| 159 | 'label' => 'ABSPATH', |
| 160 | 'value' => ! defined( 'ABSPATH' ) ? __( 'Undefined' ) : ABSPATH |
| 161 | ), |
| 162 | array( |
| 163 | 'label' => 'WP_HOME', |
| 164 | 'value' => ! defined( 'WP_HOME' ) ? __( 'Undefined' ) : WP_HOME |
| 165 | ), |
| 166 | array( |
| 167 | 'label' => 'WP_SITEURL', |
| 168 | 'value' => ! defined( 'WP_SITEURL' ) ? __( 'Undefined' ) : WP_SITEURL |
| 169 | ), |
| 170 | array( |
| 171 | 'label' => 'EMPTY_TRASH_DAYS', |
| 172 | 'value' => ! defined( 'EMPTY_TRASH_DAYS' ) ? __( 'Undefined' ) : EMPTY_TRASH_DAYS |
| 173 | ), |
| 174 | array( |
| 175 | 'label' => 'WP_DEBUG', |
| 176 | 'value' => ( ! defined( 'WP_DEBUG' ) ? __( 'Undefined' ) : ( WP_DEBUG ? __( 'Enabled' ) : __( 'Disabled' ) ) ) |
| 177 | ), |
| 178 | array( |
| 179 | 'label' => 'WP_MAX_MEMORY_LIMIT', |
| 180 | 'value' => ( ! defined( 'WP_MAX_MEMORY_LIMIT' ) ? __( 'Undefined' ) : WP_MAX_MEMORY_LIMIT ) |
| 181 | ), |
| 182 | array( |
| 183 | 'label' => 'WP_DEBUG_DISPLAY', |
| 184 | 'value' => ( ! defined( 'WP_DEBUG_DISPLAY' ) ? __( 'Undefined' ) : ( WP_DEBUG_DISPLAY ? __( 'Enabled' ) : __( 'Disabled' ) ) ) |
| 185 | ), |
| 186 | array( |
| 187 | 'label' => 'WP_DEBUG_LOG', |
| 188 | 'value' => ( ! defined( 'WP_DEBUG_LOG' ) ? __( 'Undefined' ) : ( WP_DEBUG_LOG ? __( 'Enabled' ) : __( 'Disabled' ) ) ) |
| 189 | ), |
| 190 | array( |
| 191 | 'label' => 'SCRIPT_DEBUG', |
| 192 | 'value' => ( ! defined( 'SCRIPT_DEBUG' ) ? __( 'Undefined' ) : ( SCRIPT_DEBUG ? __( 'Enabled' ) : __( 'Disabled' ) ) ) |
| 193 | ), |
| 194 | array( |
| 195 | 'label' => 'WP_CACHE', |
| 196 | 'value' => ( ! defined( 'WP_CACHE' ) ? __( 'Undefined' ) : ( WP_CACHE ? __( 'Enabled' ) : __( 'Disabled' ) ) ) |
| 197 | ), |
| 198 | array( |
| 199 | 'label' => 'CONCATENATE_SCRIPTS', |
| 200 | 'value' => ( ! defined( 'CONCATENATE_SCRIPTS' ) ? __( 'Undefined' ) : ( CONCATENATE_SCRIPTS ? __( 'Enabled' ) : __( 'Disabled' ) ) ) |
| 201 | ), |
| 202 | array( |
| 203 | 'label' => 'COMPRESS_SCRIPTS', |
| 204 | 'value' => ( ! defined( 'COMPRESS_SCRIPTS' ) ? __( 'Undefined' ) : ( COMPRESS_SCRIPTS ? __( 'Enabled' ) : __( 'Disabled' ) ) ) |
| 205 | ), |
| 206 | array( |
| 207 | 'label' => 'COMPRESS_CSS', |
| 208 | 'value' => ( ! defined( 'COMPRESS_CSS' ) ? __( 'Undefined' ) : ( COMPRESS_CSS ? __( 'Enabled' ) : __( 'Disabled' ) ) ) |
| 209 | ), |
| 210 | array( |
| 211 | 'label' => 'WP_LOCAL_DEV', |
| 212 | 'value' => ( ! defined( 'WP_LOCAL_DEV' ) ? __( 'Undefined' ) : ( WP_LOCAL_DEV ? __( 'Enabled' ) : __( 'Disabled' ) ) ) |
| 213 | ), |
| 214 | ) |
| 215 | ), |
| 216 | 'wp-filesystem' => array( |
| 217 | 'label' => __( 'Filesystem permissions' ), |
| 218 | 'description' => __( 'The status of various locations WordPress needs to write files in various scenarios.' ), |
| 219 | 'fields' => array( |
| 220 | array( |
| 221 | 'label' => __( 'The main WordPress directory' ), |
| 222 | 'value' => ( wp_is_writable( ABSPATH ) ? __( 'Writable' ) : __( 'Not writable' ) ) |
| 223 | ), |
| 224 | array( |
| 225 | 'label' => __( 'The wp-content directory' ), |
| 226 | 'value' => ( wp_is_writable( WP_CONTENT_DIR ) ? __( 'Writable' ) : __( 'Not writable' ) ) |
| 227 | ), |
| 228 | array( |
| 229 | 'label' => __( 'The uploads directory' ), |
| 230 | 'value' => ( wp_is_writable( $upload_dir['basedir'] ) ? __( 'Writable' ) : __( 'Not writable' ) ) |
| 231 | ), |
| 232 | array( |
| 233 | 'label' => __( 'The plugins directory' ), |
| 234 | 'value' => ( wp_is_writable( WP_PLUGIN_DIR ) ? __( 'Writable' ) : __( 'Not writable' ) ) |
| 235 | ), |
| 236 | array( |
| 237 | 'label' => __( 'The themes directory' ), |
| 238 | 'value' => ( wp_is_writable( get_template_directory() . '/..' ) ? __( 'Writable' ) : __( 'Not writable' ) ) |
| 239 | ), |
| 240 | array( |
| 241 | 'label' => __( 'The Must User Plugins directory' ), |
| 242 | 'value' => ( wp_is_writable( WPMU_PLUGIN_DIR ) ? __( 'Writable' ) : __( 'Not writable' ) ) |
| 243 | ) |
| 244 | ) |
| 245 | ), |
| 246 | ); |
| 247 | |
| 248 | if ( is_multisite() ) { |
| 249 | $network_query = new WP_Network_Query(); |
| 250 | $network_ids = $network_query->query( array( |
| 251 | 'fields' => 'ids', |
| 252 | 'number' => 100, |
| 253 | 'no_found_rows' => false, |
| 254 | ) ); |
| 255 | |
| 256 | $site_count = 0; |
| 257 | foreach ( $network_ids AS $network_id ) { |
| 258 | $site_count += get_blog_count( $network_id ); |
| 259 | } |
| 260 | |
| 261 | $info['wp-core']['fields'][] = array( |
| 262 | 'label' => __( 'User Count' ), |
| 263 | 'value' => get_user_count() |
| 264 | ); |
| 265 | $info['wp-core']['fields'][] = array( |
| 266 | 'label' => __( 'Site Count' ), |
| 267 | 'value' => $site_count |
| 268 | ); |
| 269 | $info['wp-core']['fields'][] = array( |
| 270 | 'label' => __( 'Network Count' ), |
| 271 | 'value' => $network_query->found_networks |
| 272 | ); |
| 273 | } else { |
| 274 | $user_count = count_users(); |
| 275 | |
| 276 | $info['wp-core']['fields'][] = array( |
| 277 | 'label' => __( 'User Count' ), |
| 278 | 'value' => $user_count['total_users'] |
| 279 | ); |
| 280 | } |
| 281 | |
| 282 | // WordPress features requiring processing. |
| 283 | $wp_dotorg = wp_remote_get( 'https://wordpress.org', array( 'timeout' => 10 ) ); |
| 284 | if ( ! is_wp_error( $wp_dotorg ) ) { |
| 285 | $info['wp-core']['fields'][] = array( |
| 286 | 'label' => __( 'Communication with WordPress.org' ), |
| 287 | 'value' => sprintf( |
| 288 | __( 'WordPress.org is reachable' ) |
| 289 | ) |
| 290 | ); |
| 291 | } else { |
| 292 | $info['wp-core']['fields'][] = array( |
| 293 | 'label' => __( 'Communication with WordPress.org' ), |
| 294 | 'value' => sprintf( |
| 295 | // translators: %1$s: The IP address WordPress.org resolves to. %2$s: The error returned by the lookup. |
| 296 | __( 'Unable to reach WordPress.org at %1$s: %2$s' ), |
| 297 | gethostbyname( 'wordpress.org' ), |
| 298 | $wp_dotorg->get_error_message() |
| 299 | ) |
| 300 | ); |
| 301 | } |
| 302 | |
| 303 | // Get drop-ins. |
| 304 | $dropins = get_dropins(); |
| 305 | $dropin_description = _get_dropins(); |
| 306 | foreach ( $dropins AS $dropin_key => $dropin ) { |
| 307 | $info['wp-dropins']['fields'][] = array( |
| 308 | 'label' => $dropin_key, |
| 309 | 'value' => $dropin_description[ $dropin_key ][0] |
| 310 | ); |
| 311 | } |
| 312 | |
| 313 | // Populate the server debug fields. |
| 314 | $info['wp-server']['fields'][] = array( |
| 315 | 'label' => _( 'Server architecture' ), |
| 316 | 'value' => ( ! function_exists( 'php_uname' ) ? __( 'Unable to determine server architecture' ) : sprintf( '%s %s %s', php_uname( 's' ), php_uname( 'r' ), php_uname( 'm' ) ) ) |
| 317 | ); |
| 318 | $info['wp-server']['fields'][] = array( |
| 319 | 'label' => __( 'PHP Version' ), |
| 320 | 'value' => ( ! function_exists( 'phpversion' ) ? __( 'Unable to determine PHP version' ) : phpversion() ) |
| 321 | ); |
| 322 | $info['wp-server']['fields'][] = array( |
| 323 | 'label' => __( 'PHP SAPI' ), |
| 324 | 'value' => ( ! function_exists( 'php_sapi_name' ) ? __( 'Unable to determine PHP SAPI' ) : php_sapi_name() ) |
| 325 | ); |
| 326 | |
| 327 | if ( ! function_exists( 'ini_get' ) ) { |
| 328 | $info['wp-server']['fields'][] = array( |
| 329 | 'label' => __( 'Server settings' ), |
| 330 | 'value' => __( 'Unable to determine some settings as the ini_get() function has been disabled' ) |
| 331 | ); |
| 332 | } else { |
| 333 | $info['wp-server']['fields'][] = array( |
| 334 | 'label' => __( 'PHP max input variables' ), |
| 335 | 'value' => ini_get( 'max_input_vars' ) |
| 336 | ); |
| 337 | $info['wp-server']['fields'][] = array( |
| 338 | 'label' => __( 'PHP time limit' ), |
| 339 | 'value' => ini_get( 'max_execution_time' ) |
| 340 | ); |
| 341 | $info['wp-server']['fields'][] = array( |
| 342 | 'label' => __( 'PHP memory limit' ), |
| 343 | 'value' => ini_get( 'memory_limit' ) |
| 344 | ); |
| 345 | $info['wp-server']['fields'][] = array( |
| 346 | 'label' => __( 'Upload max filesize' ), |
| 347 | 'value' => ini_get( 'upload_max_filesize' ) |
| 348 | ); |
| 349 | $info['wp-server']['fields'][] = array( |
| 350 | 'label' => __( 'PHP post max size' ), |
| 351 | 'value' => ini_get( 'post_max_size' ) |
| 352 | ); |
| 353 | } |
| 354 | |
| 355 | if ( function_exists( 'curl_version' ) ) { |
| 356 | $cURL = curl_version(); |
| 357 | $info['wp-server']['fields'][] = array( |
| 358 | 'label' => __( 'cURL Version' ), |
| 359 | 'value' => sprintf( '%s %s', $cURL['version'], $cURL['ssl_version'] ) |
| 360 | ); |
| 361 | } else { |
| 362 | $info['wp-server']['fields'][] = array( |
| 363 | 'label' => __( 'cURL Version' ), |
| 364 | 'value' => __( 'Your server does not support cURL' ) |
| 365 | ); |
| 366 | } |
| 367 | |
| 368 | $info['wp-server']['fields'][] = array( |
| 369 | 'label' => __( 'SUHOSIN installed' ), |
| 370 | 'value' => ( ( extension_loaded( 'suhosin' ) || ( defined( 'SUHOSIN_PATCH' ) && constant( 'SUHOSIN_PATCH' ) ) ) ? __( 'Yes' ) : __( 'No' ) ) |
| 371 | ); |
| 372 | |
| 373 | $info['wp-server']['fields'][] = array( |
| 374 | 'label' => __( 'Is the Imagick library available' ), |
| 375 | 'value' => ( extension_loaded( 'imagick' ) ? __( 'Yes' ) : __( 'No' ) ) |
| 376 | ); |
| 377 | |
| 378 | |
| 379 | // Populate the database debug fields. |
| 380 | if ( is_resource( $wpdb->dbh ) ) { |
| 381 | // Old mysql extension. |
| 382 | $extension = 'mysql'; |
| 383 | } else if ( is_object( $wpdb->dbh ) ) { |
| 384 | // mysqli or PDO. |
| 385 | $extension = get_class( $wpdb->dbh ); |
| 386 | } else { |
| 387 | // Unknown sql extension. |
| 388 | $extension = null; |
| 389 | } |
| 390 | |
| 391 | if ( method_exists( $wpdb, 'db_version' ) ) { |
| 392 | if ( $wpdb->use_mysqli ) { |
| 393 | $server = mysqli_get_server_info( $wpdb->dbh ); |
| 394 | } else { |
| 395 | $server = mysql_get_server_info( $wpdb->dbh ); |
| 396 | } |
| 397 | } else { |
| 398 | $server = null; |
| 399 | } |
| 400 | |
| 401 | if ( isset( $wpdb->use_mysqli ) && $wpdb->use_mysqli ) { |
| 402 | $client_version = $wpdb->dbh->client_info; |
| 403 | } else { |
| 404 | if ( preg_match( '|[0-9]{1,2}\.[0-9]{1,2}\.[0-9]{1,2}|', mysql_get_client_info(), $matches ) ) { |
| 405 | $client_version = $matches[0]; |
| 406 | } else { |
| 407 | $client_version = null; |
| 408 | } |
| 409 | } |
| 410 | |
| 411 | $info['wp-database']['fields'][] = array( |
| 412 | 'label' => __( 'Extension' ), |
| 413 | 'value' => $extension |
| 414 | ); |
| 415 | $info['wp-database']['fields'][] = array( |
| 416 | 'label' => __( 'Server version' ), |
| 417 | 'value' => $server |
| 418 | ); |
| 419 | $info['wp-database']['fields'][] = array( |
| 420 | 'label' => __( 'Client version' ), |
| 421 | 'value' => $client_version |
| 422 | ); |
| 423 | $info['wp-database']['fields'][] = array( |
| 424 | 'label' => __( 'Database user' ), |
| 425 | 'value' => $wpdb->dbuser, |
| 426 | 'private' => true |
| 427 | ); |
| 428 | $info['wp-database']['fields'][] = array( |
| 429 | 'label' => __( 'Database host' ), |
| 430 | 'value' => $wpdb->dbhost, |
| 431 | 'private' => true |
| 432 | ); |
| 433 | $info['wp-database']['fields'][] = array( |
| 434 | 'label' => __( 'Database table' ), |
| 435 | 'value' => $wpdb->dbname, |
| 436 | 'private' => true |
| 437 | ); |
| 438 | $info['wp-database']['fields'][] = array( |
| 439 | 'label' => __( 'Database prefix' ), |
| 440 | 'value' => $wpdb->prefix |
| 441 | ); |
| 442 | |
| 443 | |
| 444 | // List must use plugins if there are any. |
| 445 | $mu_plugins = get_mu_plugins(); |
| 446 | |
| 447 | foreach ( $mu_plugins AS $plugin_path => $plugin ) { |
| 448 | $info['wp-mu-plugins']['fields'][] = array( |
| 449 | 'label' => $plugin['Name'], |
| 450 | // translators: %1$s: Plugin version number. %2$s: Plugin author name. |
| 451 | 'value' => sprintf( __( 'version %1$s by %2$s' ), $plugin['Version'], $plugin['Author'] ) |
| 452 | ); |
| 453 | } |
| 454 | |
| 455 | |
| 456 | // List all available plugins. |
| 457 | $plugins = get_plugins(); |
| 458 | |
| 459 | foreach ( $plugins AS $plugin_path => $plugin ) { |
| 460 | $plugin_part = ( is_plugin_active( $plugin_path ) ) ? 'wp-plugins-active' : 'wp-plugins-inactive'; |
| 461 | |
| 462 | $info[ $plugin_part ]['fields'][] = array( |
| 463 | 'label' => $plugin['Name'], |
| 464 | // translators: %1$s: Plugin version number. %2$s: Plugin author name. |
| 465 | 'value' => sprintf( __( 'version %1$s by %2$s' ), $plugin['Version'], $plugin['Author'] ) |
| 466 | ); |
| 467 | } |
| 468 | |
| 469 | |
| 470 | // Populate the section for the currently active theme. |
| 471 | global $_wp_theme_features; |
| 472 | $theme_features = array(); |
| 473 | foreach ( $_wp_theme_features AS $feature => $options ) { |
| 474 | $theme_features[] = $feature; |
| 475 | } |
| 476 | |
| 477 | $active_theme = wp_get_theme(); |
| 478 | $info['wp-active-theme']['fields'] = array( |
| 479 | array( |
| 480 | 'label' => __( 'Name' ), |
| 481 | 'value' => $active_theme->Name |
| 482 | ), |
| 483 | array( |
| 484 | 'label' => __( 'Version' ), |
| 485 | 'value' => $active_theme->Version |
| 486 | ), |
| 487 | array( |
| 488 | 'label' => __( 'Author' ), |
| 489 | 'value' => wp_kses( $active_theme->Author, array() ) |
| 490 | ), |
| 491 | array( |
| 492 | 'label' => __( 'Author website' ), |
| 493 | 'value' => ( $active_theme->offsetGet( 'Author URI' ) ?: __( 'Undefined' ) ) |
| 494 | ), |
| 495 | array( |
| 496 | 'label' => __( 'Parent theme' ), |
| 497 | 'value' => ( $active_theme->parent_theme ?: __( 'Not a child theme' ) ) |
| 498 | ), |
| 499 | array( |
| 500 | 'label' => __( 'Supported theme features' ), |
| 501 | 'value' => implode( ', ', $theme_features ) |
| 502 | ) |
| 503 | ); |
| 504 | |
| 505 | // Populate a list of all themes available in the install. |
| 506 | $all_themes = wp_get_themes(); |
| 507 | |
| 508 | foreach ( $all_themes AS $theme_slug => $theme ) { |
| 509 | // Ignore the currently active theme from the list of all themes. |
| 510 | if ( $active_theme->stylesheet == $theme_slug ) { |
| 511 | continue; |
| 512 | } |
| 513 | |
| 514 | $info['wp-themes']['fields'][] = array( |
| 515 | // translators: %1$s: Theme name. %2$s: Theme slug. |
| 516 | 'label' => sprintf( __( '%1$s (%2$s)' ), $theme->Name, $theme_slug ), |
| 517 | // translators: %1$s Theme version number. %2$s: Theme author name. |
| 518 | 'value' => sprintf( __( 'version %1$s by %2$s ' ), $theme->Version, wp_kses( $theme->Author, array() ) ) |
| 519 | ); |
| 520 | } |
| 521 | |
| 522 | |
| 523 | /** |
| 524 | * Add or modify new debug sections. |
| 525 | * |
| 526 | * Plugin or themes may wish to introduce their own debug information without creating additional admin pages for this |
| 527 | * kind of information as it is rarely needed, they can then utilize this filter to introduce their own sections. |
| 528 | * |
| 529 | * This filter intentionally does not include the fields introduced by core as those should always be un-modified |
| 530 | * and reliable for support related scenarios, take note that the core fields will take priority if a filtered value |
| 531 | * is trying to use the same array keys. |
| 532 | * |
| 533 | * Array keys added by core are all prefixed with `wp-`, plugins and themes are encouraged to use their own slug as |
| 534 | * a prefix, both for consistency as well as avoiding key collisions. |
| 535 | * |
| 536 | * @since 4.9.0 |
| 537 | * |
| 538 | * @param array $args { |
| 539 | * The debug information to be added to the core information page. |
| 540 | * |
| 541 | * @type string $label The title for this section of the debug output. |
| 542 | * @type string $description Optional. A description for your information section which may contain basic HTML |
| 543 | * markup: `em`, `strong` and `a` for linking to documentation or putting emphasis. |
| 544 | * @type boolean $show_count Optional. If set to `true` the amount of fields will be included in the title for |
| 545 | * this section. |
| 546 | * @type boolean $private Optional. If set to `true` the section and all associated fields will be excluded |
| 547 | * from the copy-paste text area. |
| 548 | * @type array $fields { |
| 549 | * An associative array containing the data to be displayed. |
| 550 | * |
| 551 | * @type string $label The label for this piece of information. |
| 552 | * @type string $value The output that is of interest for this field. |
| 553 | * @type boolean $private Optional. If set to `true` the field will not be included in the copy-paste text area |
| 554 | * on top of the page, allowing you to show, for example, API keys here. |
| 555 | * } |
| 556 | * } |
| 557 | */ |
| 558 | $external_info = apply_filters( 'debug_information', array() ); |
| 559 | |
| 560 | // Merge the core and external debug fields. |
| 561 | $info = array_replace_recursive( $info, array_replace_recursive( $external_info, $info ) ); |
| 562 | ?> |
| 563 | |
| 564 | |
| 565 | <div class="notice notice-info"> |
| 566 | <p> |
| 567 | <?php esc_html_e( 'The system information shown below can also be copied and pasted into support requests such as on the WordPress.org forums, or to your theme and plugin developers.' ); ?> |
| 568 | </p> |
| 569 | <p> |
| 570 | <button type="button" class="button button-primary" onclick="document.getElementById('system-information-copy-wrapper').style.display = 'block'; this.style.display = 'none';"><?php esc_html_e( 'Show copy and paste field' ); ?></button> |
| 571 | </p> |
| 572 | |
| 573 | <div id="system-information-copy-wrapper" style="display: none;"> |
| 574 | <textarea id="system-information-copy-field" class="widefat" rows="10">` |
| 575 | <?php |
| 576 | foreach ( $info AS $section => $details ) { |
| 577 | // Skip this section if there are no fields, or the section has been declared as private. |
| 578 | if ( empty( $details['fields'] ) || ( isset( $details['private'] ) && $details['private'] ) ) { |
| 579 | continue; |
| 580 | } |
| 581 | |
| 582 | printf( |
| 583 | "### %s%s ###\n\n", |
| 584 | $details['label'], |
| 585 | ( isset( $details['show_count'] ) && $details['show_count'] ? sprintf( ' (%d)', count( $details['fields'] ) ) : '' ) |
| 586 | ); |
| 587 | |
| 588 | foreach ( $details['fields'] AS $field ) { |
| 589 | if ( isset( $field['private'] ) && true === $field['private'] ) { |
| 590 | continue; |
| 591 | } |
| 592 | |
| 593 | printf( |
| 594 | "%s: %s\n", |
| 595 | $field['label'], |
| 596 | $field['value'] |
| 597 | ); |
| 598 | } |
| 599 | echo "\n"; |
| 600 | } |
| 601 | ?> |
| 602 | `</textarea> |
| 603 | <p> |
| 604 | <?php esc_html_e( 'Some information may be filtered out from the list you are about to copy, this is information that may be considers private, and is not meant to be shared in a public forum.' ); ?> |
| 605 | <br> |
| 606 | <button type="button" class="button button-primary" onclick="document.getElementById('system-information-copy-field').select();"><?php esc_html_e( 'Mark field for copying' ); ?></button> |
| 607 | </p> |
| 608 | </div> |
| 609 | </div> |
| 610 | |
| 611 | <div id="system-information-table-of-contents"> |
| 612 | <?php |
| 613 | $toc = array(); |
| 614 | |
| 615 | foreach ( $info AS $section => $details ) { |
| 616 | if ( empty( $details['fields'] ) ) { |
| 617 | continue; |
| 618 | } |
| 619 | |
| 620 | $toc[] = sprintf( |
| 621 | '<a href="#%s">%s</a>', |
| 622 | esc_attr( $section ), |
| 623 | esc_html( $details['label'] ) |
| 624 | ); |
| 625 | } |
| 626 | |
| 627 | echo implode( ' | ', $toc ); |
| 628 | ?> |
| 629 | </div> |
| 630 | |
| 631 | <?php |
| 632 | foreach ( $info as $section => $details ) { |
| 633 | if ( ! isset( $details['fields'] ) || empty( $details['fields'] ) ) { |
| 634 | continue; |
| 635 | } |
| 636 | |
| 637 | printf( |
| 638 | '<h2 id="%s">%s%s</h2>', |
| 639 | esc_attr( $section ), |
| 640 | esc_html( $details['label'] ), |
| 641 | ( isset( $details['show_count'] ) && $details['show_count'] ? sprintf( ' (%d)', count( $details['fields'] ) ) : '' ) |
| 642 | ); |
| 643 | |
| 644 | if ( isset( $details['description'] ) && ! empty( $details['description'] ) ) { |
| 645 | printf( |
| 646 | '<p>%s</p>', |
| 647 | wp_kses( $details['description'], array( |
| 648 | 'a' => array( |
| 649 | 'href' => true |
| 650 | ), |
| 651 | 'strong' => true, |
| 652 | 'em' => true, |
| 653 | ) ) |
| 654 | ); |
| 655 | } |
| 656 | ?> |
| 657 | <table class="widefat striped"> |
| 658 | <tbody> |
| 659 | <?php |
| 660 | foreach ( $details['fields'] as $field ) { |
| 661 | printf( |
| 662 | '<tr><td>%s</td><td>%s</td></tr>', |
| 663 | esc_html( $field['label'] ), |
| 664 | esc_html( $field['value'] ) |
| 665 | ); |
| 666 | } |
| 667 | ?> |
| 668 | </tbody> |
| 669 | </table> |
| 670 | <span style="display: block; width: 100%; text-align: <?php echo ( is_rtl() ? 'left' : 'right' ); ?>"> |
| 671 | <a href="#system-information-table-of-contents"><?php esc_html_e( 'Return to table of contents' ); ?></a> |
| 672 | </span> |
| 673 | <?php |
| 674 | } |
| 675 | } else { |
| 676 | if ( ! function_exists( 'phpinfo' ) ) { |
| 677 | ?> |
| 678 | |
| 679 | <div class="notice notice-error"> |
| 680 | <p> |
| 681 | <?php esc_html_e( 'The phpinfo() function has been disabled by your host. Please contact the host if you need more information about your setup.' ); ?> |
| 682 | </p> |
| 683 | </div> |
| 684 | |
| 685 | <?php } else { ?> |
| 686 | |
| 687 | <div class="notice notice-warning"> |
| 688 | <p> |
| 689 | <?php esc_html_e( 'Some scenarios require you to look up more detailed server configurations than what is normally required. This page allows you to view all available configuration options for your PHP setup. Please be advised that WordPress does not guarantee that any information shown on this page may not be considered private.' ); ?> |
| 690 | </p> |
| 691 | </div> |
| 692 | |
| 693 | <?php |
| 694 | ob_start(); |
| 695 | phpinfo(); |
| 696 | $phpinfo_raw = ob_get_clean(); |
| 697 | |
| 698 | // Extract the body of the `phpinfo()` call, to avoid all the styles they introduce. |
| 699 | preg_match_all("/<body[^>]*>(.*)<\/body>/siU", $phpinfo_raw, $phpinfo ); |
| 700 | |
| 701 | // Extract the styles `phpinfo()` creates for this page. |
| 702 | preg_match_all( "/<style[^>]*>(.*)<\/style>/siU", $phpinfo_raw, $styles ); |
| 703 | |
| 704 | // We remove various styles that break the visual flow of wp-admin. |
| 705 | $remove_patterns = array( |
| 706 | "/a:.+?\n/si", |
| 707 | "/body.+?\n/si" |
| 708 | ); |
| 709 | |
| 710 | // Output the styles as an inline style block. |
| 711 | if ( isset( $styles[1][0] ) ) { |
| 712 | $styles = preg_replace( $remove_patterns, "", $styles[1][0] ); |
| 713 | |
| 714 | echo '<style type="text/css">' . $styles . '</style>'; |
| 715 | } |
| 716 | |
| 717 | // Output the actual phpinfo data. |
| 718 | if ( isset( $phpinfo[1][0] ) ) { |
| 719 | echo $phpinfo[1][0]; |
| 720 | } |
| 721 | ?> |
| 722 | |
| 723 | <?php } ?> |
| 724 | |
| 725 | <?php } ?> |
| 726 | </div> |
| 727 | |
| 728 | <?php |
| 729 | include( ABSPATH . 'wp-admin/admin-footer.php' ); |