316 'COMPRESS_CSS' => array( |
314 'COMPRESS_CSS' => array( |
317 'label' => 'COMPRESS_CSS', |
315 'label' => 'COMPRESS_CSS', |
318 'value' => $compress_css, |
316 'value' => $compress_css, |
319 'debug' => $compress_css_debug, |
317 'debug' => $compress_css_debug, |
320 ), |
318 ), |
321 'WP_LOCAL_DEV' => array( |
319 'WP_ENVIRONMENT_TYPE' => array( |
322 'label' => 'WP_LOCAL_DEV', |
320 'label' => 'WP_ENVIRONMENT_TYPE', |
323 'value' => $wp_local_dev, |
321 'value' => $wp_environment_type, |
324 'debug' => $wp_local_dev_debug, |
322 'debug' => $wp_environment_type, |
325 ), |
323 ), |
326 'DB_CHARSET' => array( |
324 'DB_CHARSET' => array( |
327 'label' => 'DB_CHARSET', |
325 'label' => 'DB_CHARSET', |
328 'value' => ( defined( 'DB_CHARSET' ) ? DB_CHARSET : __( 'Undefined' ) ), |
326 'value' => ( defined( 'DB_CHARSET' ) ? DB_CHARSET : __( 'Undefined' ) ), |
329 'debug' => ( defined( 'DB_CHARSET' ) ? DB_CHARSET : 'undefined' ), |
327 'debug' => ( defined( 'DB_CHARSET' ) ? DB_CHARSET : 'undefined' ), |
388 $site_count = 0; |
386 $site_count = 0; |
389 foreach ( $network_ids as $network_id ) { |
387 foreach ( $network_ids as $network_id ) { |
390 $site_count += get_blog_count( $network_id ); |
388 $site_count += get_blog_count( $network_id ); |
391 } |
389 } |
392 |
390 |
393 $info['wp-core']['fields']['user_count'] = array( |
|
394 'label' => __( 'User count' ), |
|
395 'value' => get_user_count(), |
|
396 ); |
|
397 |
|
398 $info['wp-core']['fields']['site_count'] = array( |
391 $info['wp-core']['fields']['site_count'] = array( |
399 'label' => __( 'Site count' ), |
392 'label' => __( 'Site count' ), |
400 'value' => $site_count, |
393 'value' => $site_count, |
401 ); |
394 ); |
402 |
395 |
403 $info['wp-core']['fields']['network_count'] = array( |
396 $info['wp-core']['fields']['network_count'] = array( |
404 'label' => __( 'Network count' ), |
397 'label' => __( 'Network count' ), |
405 'value' => $network_query->found_networks, |
398 'value' => $network_query->found_networks, |
406 ); |
399 ); |
407 } else { |
400 } |
408 $user_count = count_users(); |
401 |
409 |
402 $info['wp-core']['fields']['user_count'] = array( |
410 $info['wp-core']['fields']['user_count'] = array( |
403 'label' => __( 'User count' ), |
411 'label' => __( 'User count' ), |
404 'value' => get_user_count(), |
412 'value' => $user_count['total_users'], |
405 ); |
413 ); |
|
414 } |
|
415 |
406 |
416 // WordPress features requiring processing. |
407 // WordPress features requiring processing. |
417 $wp_dotorg = wp_remote_get( 'https://wordpress.org', array( 'timeout' => 10 ) ); |
408 $wp_dotorg = wp_remote_get( 'https://wordpress.org', array( 'timeout' => 10 ) ); |
418 |
409 |
419 if ( ! is_wp_error( $wp_dotorg ) ) { |
410 if ( ! is_wp_error( $wp_dotorg ) ) { |
1396 'debug' => ( $is_writable_wpmu_plugin_dir ? 'writable' : 'not writable' ), |
1397 'debug' => ( $is_writable_wpmu_plugin_dir ? 'writable' : 'not writable' ), |
1397 ); |
1398 ); |
1398 } |
1399 } |
1399 |
1400 |
1400 /** |
1401 /** |
1401 * Add or modify the debug information. |
1402 * Add to or modify the debug information shown on the Tools -> Site Health -> Info screen. |
1402 * |
1403 * |
1403 * Plugin or themes may wish to introduce their own debug information without creating additional admin pages |
1404 * Plugin or themes may wish to introduce their own debug information without creating |
1404 * they can utilize this filter to introduce their own sections or add more data to existing sections. |
1405 * additional admin pages. They can utilize this filter to introduce their own sections |
|
1406 * or add more data to existing sections. |
1405 * |
1407 * |
1406 * Array keys for sections added by core are all prefixed with `wp-`, plugins and themes should use their own slug as |
1408 * Array keys for sections added by core are all prefixed with `wp-`. Plugins and themes |
1407 * a prefix, both for consistency as well as avoiding key collisions. Note that the array keys are used as labels |
1409 * should use their own slug as a prefix, both for consistency as well as avoiding |
1408 * for the copied data. |
1410 * key collisions. Note that the array keys are used as labels for the copied data. |
1409 * |
1411 * |
1410 * All strings are expected to be plain text except $description that can contain inline HTML tags (see below). |
1412 * All strings are expected to be plain text except `$description` that can contain |
|
1413 * inline HTML tags (see below). |
1411 * |
1414 * |
1412 * @since 5.2.0 |
1415 * @since 5.2.0 |
1413 * |
1416 * |
1414 * @param array $args { |
1417 * @param array $args { |
1415 * The debug information to be added to the core information page. |
1418 * The debug information to be added to the core information page. |
1416 * |
1419 * |
1417 * This is an associative multi-dimensional array, up to three levels deep. The topmost array holds the sections. |
1420 * This is an associative multi-dimensional array, up to three levels deep. |
1418 * Each section has a `$fields` associative array (see below), and each `$value` in `$fields` can be |
1421 * The topmost array holds the sections, keyed by section ID. |
1419 * another associative array of name/value pairs when there is more structured data to display. |
|
1420 * |
1422 * |
1421 * @type string $label The title for this section of the debug output. |
1423 * @type array ...$0 { |
1422 * @type string $description Optional. A description for your information section which may contain basic HTML |
1424 * Each section has a `$fields` associative array (see below), and each `$value` in `$fields` |
1423 * markup, inline tags only as it is outputted in a paragraph. |
1425 * can be another associative array of name/value pairs when there is more structured data |
1424 * @type boolean $show_count Optional. If set to `true` the amount of fields will be included in the title for |
1426 * to display. |
1425 * this section. |
|
1426 * @type boolean $private Optional. If set to `true` the section and all associated fields will be excluded |
|
1427 * from the copied data. |
|
1428 * @type array $fields { |
|
1429 * An associative array containing the data to be displayed. |
|
1430 * |
1427 * |
1431 * @type string $label The label for this piece of information. |
1428 * @type string $label Required. The title for this section of the debug output. |
1432 * @type string $value The output that is displayed for this field. Text should be translated. Can be |
1429 * @type string $description Optional. A description for your information section which |
1433 * an associative array that is displayed as name/value pairs. |
1430 * may contain basic HTML markup, inline tags only as it is |
1434 * @type string $debug Optional. The output that is used for this field when the user copies the data. |
1431 * outputted in a paragraph. |
1435 * It should be more concise and not translated. If not set, the content of `$value` is used. |
1432 * @type bool $show_count Optional. If set to `true`, the amount of fields will be included |
1436 * Note that the array keys are used as labels for the copied data. |
1433 * in the title for this section. Default false. |
1437 * @type boolean $private Optional. If set to `true` the field will not be included in the copied data |
1434 * @type bool $private Optional. If set to `true`, the section and all associated fields |
1438 * allowing you to show, for example, API keys here. |
1435 * will be excluded from the copied data. Default false. |
|
1436 * @type array $fields { |
|
1437 * Required. An associative array containing the fields to be displayed in the section, |
|
1438 * keyed by field ID. |
|
1439 * |
|
1440 * @type array ...$0 { |
|
1441 * An associative array containing the data to be displayed for the field. |
|
1442 * |
|
1443 * @type string $label Required. The label for this piece of information. |
|
1444 * @type mixed $value Required. The output that is displayed for this field. |
|
1445 * Text should be translated. Can be an associative array |
|
1446 * that is displayed as name/value pairs. |
|
1447 * Accepted types: `string|int|float|(string|int|float)[]`. |
|
1448 * @type string $debug Optional. The output that is used for this field when |
|
1449 * the user copies the data. It should be more concise and |
|
1450 * not translated. If not set, the content of `$value` |
|
1451 * is used. Note that the array keys are used as labels |
|
1452 * for the copied data. |
|
1453 * @type bool $private Optional. If set to `true`, the field will be excluded |
|
1454 * from the copied data, allowing you to show, for example, |
|
1455 * API keys here. Default false. |
|
1456 * } |
|
1457 * } |
1439 * } |
1458 * } |
1440 * } |
1459 * } |
1441 */ |
1460 */ |
1442 $info = apply_filters( 'debug_information', $info ); |
1461 $info = apply_filters( 'debug_information', $info ); |
1443 |
1462 |
1444 return $info; |
1463 return $info; |
|
1464 } |
|
1465 |
|
1466 /** |
|
1467 * Returns the value of a MySQL system variable. |
|
1468 * |
|
1469 * @since 5.9.0 |
|
1470 * |
|
1471 * @global wpdb $wpdb WordPress database abstraction object. |
|
1472 * |
|
1473 * @param string $mysql_var Name of the MySQL system variable. |
|
1474 * @return string|null The variable value on success. Null if the variable does not exist. |
|
1475 */ |
|
1476 public static function get_mysql_var( $mysql_var ) { |
|
1477 global $wpdb; |
|
1478 |
|
1479 $result = $wpdb->get_row( |
|
1480 $wpdb->prepare( 'SHOW VARIABLES LIKE %s', $mysql_var ), |
|
1481 ARRAY_A |
|
1482 ); |
|
1483 |
|
1484 if ( ! empty( $result ) && array_key_exists( 'Value', $result ) ) { |
|
1485 return $result['Value']; |
|
1486 } |
|
1487 |
|
1488 return null; |
1445 } |
1489 } |
1446 |
1490 |
1447 /** |
1491 /** |
1448 * Format the information gathered for debugging, in a manner suitable for copying to a forum or support ticket. |
1492 * Format the information gathered for debugging, in a manner suitable for copying to a forum or support ticket. |
1449 * |
1493 * |
1450 * @since 5.2.0 |
1494 * @since 5.2.0 |
1451 * |
1495 * |
1452 * @param array $info_array Information gathered from the `WP_Debug_Data::debug_data` function. |
1496 * @param array $info_array Information gathered from the `WP_Debug_Data::debug_data()` function. |
1453 * @param string $type The data type to return, either 'info' or 'debug'. |
1497 * @param string $data_type The data type to return, either 'info' or 'debug'. |
1454 * @return string The formatted data. |
1498 * @return string The formatted data. |
1455 */ |
1499 */ |
1456 public static function format( $info_array, $type ) { |
1500 public static function format( $info_array, $data_type ) { |
1457 $return = "`\n"; |
1501 $return = "`\n"; |
1458 |
1502 |
1459 foreach ( $info_array as $section => $details ) { |
1503 foreach ( $info_array as $section => $details ) { |
1460 // Skip this section if there are no fields, or the section has been declared as private. |
1504 // Skip this section if there are no fields, or the section has been declared as private. |
1461 if ( empty( $details['fields'] ) || ( isset( $details['private'] ) && $details['private'] ) ) { |
1505 if ( empty( $details['fields'] ) || ( isset( $details['private'] ) && $details['private'] ) ) { |
1462 continue; |
1506 continue; |
1463 } |
1507 } |
1464 |
1508 |
1465 $section_label = 'debug' === $type ? $section : $details['label']; |
1509 $section_label = 'debug' === $data_type ? $section : $details['label']; |
1466 |
1510 |
1467 $return .= sprintf( |
1511 $return .= sprintf( |
1468 "### %s%s ###\n\n", |
1512 "### %s%s ###\n\n", |
1469 $section_label, |
1513 $section_label, |
1470 ( isset( $details['show_count'] ) && $details['show_count'] ? sprintf( ' (%d)', count( $details['fields'] ) ) : '' ) |
1514 ( isset( $details['show_count'] ) && $details['show_count'] ? sprintf( ' (%d)', count( $details['fields'] ) ) : '' ) |