| 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 ( ! is_super_admin() ) { |
| 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 | $info = array( |
| 23 | 'WordPress' => array( |
| 24 | 'fields' => array( |
| 25 | array( |
| 26 | 'label' => 'Version', |
| 27 | 'value' => get_bloginfo( 'version' ) |
| 28 | ), |
| 29 | array( |
| 30 | 'label' => 'Debug mode', |
| 31 | 'value' => ( defined( 'WP_DEBUG' ) && WP_DEBUG ? __( 'Enabled' ) : __( 'Disabled' ) ) |
| 32 | ), |
| 33 | array( |
| 34 | 'label' => 'Language', |
| 35 | 'value' => get_locale() |
| 36 | ), |
| 37 | array( |
| 38 | 'label' => 'Home URL', |
| 39 | 'value' => get_bloginfo( 'url' ), |
| 40 | 'private' => true |
| 41 | ), |
| 42 | array( |
| 43 | 'label' => 'Site URL', |
| 44 | 'value' => get_bloginfo( 'wpurl' ), |
| 45 | 'private' => true |
| 46 | ), |
| 47 | array( |
| 48 | 'label' => 'Home path', |
| 49 | 'value' => get_home_path(), |
| 50 | 'private' => true |
| 51 | ), |
| 52 | array( |
| 53 | 'label' => 'HTTPS', |
| 54 | 'value' => ( is_ssl() ? 'Enabled' : 'Disabled' ) |
| 55 | ), |
| 56 | array( |
| 57 | 'label' => 'Theme directory is writable', |
| 58 | 'value' => ( wp_is_writable( TEMPLATEPATH . '/..' ) ? __( 'Yes' ) : __( 'No' ) ) |
| 59 | ), |
| 60 | array( |
| 61 | 'label' => 'Plugin directory is writable', |
| 62 | 'value' => ( wp_is_writable( WP_PLUGIN_DIR ) ? __( 'Yes' ) : __( 'No' ) ) |
| 63 | ), |
| 64 | array( |
| 65 | 'label' => 'WordPress memory limit', |
| 66 | 'value' => WP_MAX_MEMORY_LIMIT |
| 67 | ), |
| 68 | array( |
| 69 | 'label' => 'Multisite', |
| 70 | 'value' => ( is_multisite() ? __( 'Yes' ) : __( 'No' ) ) |
| 71 | ) |
| 72 | ), |
| 73 | ), |
| 74 | 'Active theme' => array( |
| 75 | 'fields' => array() |
| 76 | ), |
| 77 | 'Available themes' => array( |
| 78 | 'fields' => array(), |
| 79 | 'show_count' => true |
| 80 | ), |
| 81 | 'Must Use Plugins' => array( |
| 82 | 'fields' => array(), |
| 83 | 'show_count' => true |
| 84 | ), |
| 85 | 'Active plugins' => array( |
| 86 | 'fields' => array(), |
| 87 | 'show_count' => true |
| 88 | ), |
| 89 | 'Inactive plugins' => array( |
| 90 | 'fields' => array(), |
| 91 | 'show_count' => true |
| 92 | ), |
| 93 | 'Server' => array( |
| 94 | 'description' => __( 'The options shown below are relating to your server setup, and may require the help of your host if changes are required.' ), |
| 95 | 'fields' => array() |
| 96 | ), |
| 97 | 'Database' => array( |
| 98 | 'fields' => array() |
| 99 | ) |
| 100 | ); |
| 101 | |
| 102 | if ( is_multisite() ) { |
| 103 | $network_query = new WP_Network_Query(); |
| 104 | $network_ids = $network_query->query( array( |
| 105 | 'fields' => 'ids', |
| 106 | 'number' => 100, |
| 107 | 'no_found_rows' => false, |
| 108 | ) ); |
| 109 | |
| 110 | $site_count = 0; |
| 111 | foreach ( $network_ids as $network_id ) { |
| 112 | $site_count += get_blog_count( $network_id ); |
| 113 | } |
| 114 | |
| 115 | $info['WordPress']['fields'][] = array( |
| 116 | 'label' => 'User Count', |
| 117 | 'value' => get_user_count() |
| 118 | ); |
| 119 | $info['WordPress']['fields'][] = array( |
| 120 | 'label' => 'Site Count', |
| 121 | 'value' => $site_count |
| 122 | ); |
| 123 | $info['WordPress']['fields'][] = array( |
| 124 | 'label' => 'Network Count', |
| 125 | 'value' => $network_query->found_networks |
| 126 | ); |
| 127 | } else { |
| 128 | $user_count = count_users(); |
| 129 | |
| 130 | $info['WordPress']['fields'][] = array( |
| 131 | 'label' => 'User Count', |
| 132 | 'value' => $user_count['total_users'] |
| 133 | ); |
| 134 | } |
| 135 | |
| 136 | // Populate the server debug fields |
| 137 | $info['Server']['fields'][] = array( |
| 138 | 'label' => 'PHP Version', |
| 139 | 'value' => phpversion() |
| 140 | ); |
| 141 | $info['Server']['fields'][] = array( |
| 142 | 'label' => 'PHP SAPI', |
| 143 | 'value' => php_sapi_name() |
| 144 | ); |
| 145 | $info['Server']['fields'][] = array( |
| 146 | 'label' => 'PHP post max size', |
| 147 | 'value' => ini_get( 'post_max_size' ) |
| 148 | ); |
| 149 | $info['Server']['fields'][] = array( |
| 150 | 'label' => 'PHP time limit', |
| 151 | 'value' => ini_get( 'max_execution_time' ) |
| 152 | ); |
| 153 | $info['Server']['fields'][] = array( |
| 154 | 'label' => 'PHP memory limit', |
| 155 | 'value' => ini_get( 'memory_limit' ) |
| 156 | ); |
| 157 | |
| 158 | $cURL = curl_version(); |
| 159 | $info['Server']['fields'][] = array( |
| 160 | 'label' => 'cURL Version', |
| 161 | 'value' => sprintf( '%s %s', $cURL['version'], $cURL['ssl_version'] ) |
| 162 | ); |
| 163 | |
| 164 | $info['Server']['fields'][] = array( |
| 165 | 'label' => 'SUHOSIN installed', |
| 166 | 'value' => ( ( extension_loaded('suhosin') || ( defined( 'SUHOSIN_PATCH' ) && constant( 'SUHOSIN_PATCH' ) ) ) ? __( 'Yes' ) : __( 'No' ) ) |
| 167 | ); |
| 168 | |
| 169 | |
| 170 | // Populate the database debug fields. |
| 171 | if ( is_resource( $wpdb->dbh ) ) { |
| 172 | # Old mysql extension |
| 173 | $extension = 'mysql'; |
| 174 | } else if ( is_object( $wpdb->dbh ) ) { |
| 175 | # mysqli or PDO |
| 176 | $extension = get_class( $wpdb->dbh ); |
| 177 | } else { |
| 178 | # Who knows? |
| 179 | $extension = null; |
| 180 | } |
| 181 | |
| 182 | if ( method_exists( $wpdb, 'db_version' ) ) { |
| 183 | $server = $wpdb->db_version(); |
| 184 | } else { |
| 185 | $server = null; |
| 186 | } |
| 187 | |
| 188 | if ( isset( $wpdb->use_mysqli ) && $wpdb->use_mysqli ) { |
| 189 | $client_version = mysqli_get_client_version(); |
| 190 | } else { |
| 191 | if ( preg_match( '|[0-9]{1,2}\.[0-9]{1,2}\.[0-9]{1,2}|', mysql_get_client_info(), $matches ) ) { |
| 192 | $client_version = $matches[0]; |
| 193 | } else { |
| 194 | $client_version = null; |
| 195 | } |
| 196 | } |
| 197 | |
| 198 | $info['Database']['fields'][] = array( |
| 199 | 'label' => 'Extension', |
| 200 | 'value' => $extension |
| 201 | ); |
| 202 | $info['Database']['fields'][] = array( |
| 203 | 'label' => 'Server version', |
| 204 | 'value' => $server |
| 205 | ); |
| 206 | $info['Database']['fields'][] = array( |
| 207 | 'label' => 'Client version', |
| 208 | 'value' => $client_version |
| 209 | ); |
| 210 | $info['Database']['fields'][] = array( |
| 211 | 'label' => 'Database user', |
| 212 | 'value' => $wpdb->dbuser, |
| 213 | 'private' => true |
| 214 | ); |
| 215 | $info['Database']['fields'][] = array( |
| 216 | 'label' => 'Database host', |
| 217 | 'value' => $wpdb->dbhost, |
| 218 | 'private' => true |
| 219 | ); |
| 220 | $info['Database']['fields'][] = array( |
| 221 | 'label' => 'Database table', |
| 222 | 'value' => $wpdb->dbname, |
| 223 | 'private' => true |
| 224 | ); |
| 225 | $info['Database']['fields'][] = array( |
| 226 | 'label' => 'Database prefix', |
| 227 | 'value' => $wpdb->prefix |
| 228 | ); |
| 229 | |
| 230 | |
| 231 | // List must use plugins if there are any |
| 232 | $mu_plugins = get_mu_plugins(); |
| 233 | |
| 234 | foreach ( $mu_plugins AS $plugin_path => $plugin ) { |
| 235 | $info['Must Use Plugins']['fields'][] = array( |
| 236 | 'label' => $plugin['Name'], |
| 237 | 'value' => sprintf( 'Version %s by %s', $plugin['Version'], $plugin['Author'] ) |
| 238 | ); |
| 239 | } |
| 240 | |
| 241 | |
| 242 | // List active- and inactive plugins |
| 243 | $plugins = get_plugins(); |
| 244 | |
| 245 | foreach ( $plugins AS $plugin_path => $plugin ) { |
| 246 | |
| 247 | $key = ( is_plugin_active( $plugin_path ) ) ? 'Active plugins' : 'Inactive plugins'; |
| 248 | |
| 249 | $info[$key]['fields'][] = array( |
| 250 | 'label' => $plugin['Name'], |
| 251 | 'value' => sprintf( 'Version %s by %s', $plugin['Version'], $plugin['Author'] ) |
| 252 | ); |
| 253 | } |
| 254 | |
| 255 | |
| 256 | // Populate the section for the currently active theme |
| 257 | $theme = wp_get_theme(); |
| 258 | |
| 259 | $info['Active theme']['fields'] = array( |
| 260 | array( |
| 261 | 'label' => 'Name', |
| 262 | 'value' => $theme->Name |
| 263 | ), |
| 264 | array( |
| 265 | 'label' => 'Version', |
| 266 | 'value' => $theme->Version |
| 267 | ), |
| 268 | array( |
| 269 | 'label' => 'Author', |
| 270 | 'value' => wp_kses( $theme->Author, array() ) |
| 271 | ), |
| 272 | array( |
| 273 | 'label' => 'Author URL', |
| 274 | 'value' => $theme->AuthorURI |
| 275 | ), |
| 276 | array( |
| 277 | 'label' => 'Parent theme', |
| 278 | 'value' => ( $theme->parent_Theme ?: 'Not a child theme' ) |
| 279 | ) |
| 280 | ); |
| 281 | |
| 282 | |
| 283 | // Populate a list of all themes available in the install |
| 284 | $all_themes = wp_get_themes(); |
| 285 | |
| 286 | foreach ( $all_themes AS $theme_slug => $theme ) { |
| 287 | $info['Available themes']['fields'][] = array( |
| 288 | 'label' => sprintf( '%s (%s)', $theme->Name, $theme_slug ), |
| 289 | 'value' => sprintf( 'Version %s by %s', $theme->Version, wp_kses( $theme->Author, array() ) ) |
| 290 | ); |
| 291 | } |
| 292 | |
| 293 | |
| 294 | /** |
| 295 | * Add or modify new debug sections. |
| 296 | * |
| 297 | * Plugin or themes may wish to introduce their own debug information without creating additional admin pages for this |
| 298 | * kind of information as it is rarely needed, they can then utilize this filter to introduce their own sections. |
| 299 | * |
| 300 | * This filter intentionally does not include the fields introduced by core as those should always be un-modified |
| 301 | * and reliable for support related scenarios. |
| 302 | * |
| 303 | * @since 4.9.0 |
| 304 | * |
| 305 | * @param array $args { |
| 306 | * The debug information to be added to the core information page. |
| 307 | * |
| 308 | * @type string $description Optional. A description for your information section which may contain basic HTML |
| 309 | * markup: `em`, `strong` and `a` for linking to documentation or putting emphasis. |
| 310 | * @type array $fields { |
| 311 | * An associative array containing the data to be displayed. |
| 312 | * |
| 313 | * @type string $label The label for this piece of information. |
| 314 | * @type string $value The output that is of interest for this field. |
| 315 | * @type boolean $private Optional. If set to `true` the field will not be included in the copy-paste text area |
| 316 | * on top of the page, allowing you to show, for example, API keys here. |
| 317 | * } |
| 318 | * } |
| 319 | */ |
| 320 | $external_info = apply_filters( 'debug_information', array() ); |
| 321 | |
| 322 | // Merge the core and external debug fields |
| 323 | $info = array_merge( $external_info, $info ); |
| 324 | ?> |
| 325 | |
| 326 | <div class="wrap"> |
| 327 | <h1 class="wp-heading-inline"> |
| 328 | <?php echo esc_html( $title ); ?> |
| 329 | </h1> |
| 330 | |
| 331 | <label for="info-copy-paste-field"> |
| 332 | <?php esc_html_e( 'Copy and paste' ); ?> |
| 333 | </label> |
| 334 | <textarea id="info-copy-paste-field" class="widefat">` |
| 335 | <?php |
| 336 | foreach( $info as $section => $details ) { |
| 337 | |
| 338 | if( isset( $details['show_count'] ) && true === $details['show_count'] ) { |
| 339 | printf( |
| 340 | "%s (%d)\n", |
| 341 | $section, |
| 342 | count( $details['fields'] ) |
| 343 | ); |
| 344 | } else { |
| 345 | printf( |
| 346 | "%s\n", |
| 347 | $section |
| 348 | ); |
| 349 | } |
| 350 | |
| 351 | foreach( $details['fields'] as $field ) { |
| 352 | |
| 353 | if ( isset( $field['private'] ) && true === $field['private'] ) { |
| 354 | continue; |
| 355 | } |
| 356 | |
| 357 | printf( |
| 358 | "%s: %s\n", |
| 359 | $field['label'], |
| 360 | $field['value'] |
| 361 | ); |
| 362 | } |
| 363 | echo "\n"; |
| 364 | } |
| 365 | ?> |
| 366 | `</textarea> |
| 367 | |
| 368 | <?php |
| 369 | foreach ( $info AS $section => $details ) { |
| 370 | |
| 371 | if ( ! isset( $details['fields'] ) || empty( $details['fields'] ) ) { |
| 372 | continue; |
| 373 | } |
| 374 | |
| 375 | if( isset( $details['show_count'] ) && true === $details['show_count'] ) { |
| 376 | printf( |
| 377 | '<h2>%s (%d)</h2>', |
| 378 | esc_html( $section ), |
| 379 | count( $details['fields'] ) |
| 380 | ); |
| 381 | } else { |
| 382 | printf( |
| 383 | '<h2>%s</h2>', |
| 384 | esc_html( $section ) |
| 385 | ); |
| 386 | } |
| 387 | |
| 388 | if ( isset( $details['description'] ) && ! empty( $details['description'] ) ) { |
| 389 | printf( |
| 390 | '<p>%s</p>', |
| 391 | wp_kses( $details['description'], array( |
| 392 | 'a' => array( |
| 393 | 'href' => true |
| 394 | ), |
| 395 | 'strong' => true, |
| 396 | 'em' => true, |
| 397 | ) ) |
| 398 | ); |
| 399 | } |
| 400 | ?> |
| 401 | <table class="widefat"> |
| 402 | <tbody> |
| 403 | <?php |
| 404 | foreach ( $details['fields'] as $field ) { |
| 405 | printf( |
| 406 | '<tr><td>%s</td><td>%s</td></tr>', |
| 407 | esc_html( $field['label'] ), |
| 408 | esc_html( $field['value'] ) |
| 409 | ); |
| 410 | } |
| 411 | ?> |
| 412 | </tbody> |
| 413 | </table> |
| 414 | <?php |
| 415 | } |
| 416 | |
| 417 | include( ABSPATH . 'wp-admin/admin-footer.php' ); |