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