site-health-info.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <?php
  2. /**
  3. * Tools Administration Screen.
  4. *
  5. * @package WordPress
  6. * @subpackage Administration
  7. */
  8. if ( ! defined( 'ABSPATH' ) ) {
  9. die();
  10. }
  11. if ( ! class_exists( 'WP_Debug_Data' ) ) {
  12. require_once ABSPATH . 'wp-admin/includes/class-wp-debug-data.php';
  13. }
  14. if ( ! class_exists( 'WP_Site_Health' ) ) {
  15. require_once ABSPATH . 'wp-admin/includes/class-wp-site-health.php';
  16. }
  17. $health_check_site_status = WP_Site_Health::get_instance();
  18. ?>
  19. <div class="notice notice-error hide-if-js">
  20. <p><?php _e( 'The Site Health check requires JavaScript.' ); ?></p>
  21. </div>
  22. <div class="health-check-body health-check-debug-tab hide-if-no-js">
  23. <?php
  24. WP_Debug_Data::check_for_updates();
  25. $info = WP_Debug_Data::debug_data();
  26. ?>
  27. <h2>
  28. <?php _e( 'Site Health Info' ); ?>
  29. </h2>
  30. <p>
  31. <?php
  32. /* translators: %s: URL to Site Health Status page. */
  33. printf( __( 'This page can show you every detail about the configuration of your WordPress website. For any improvements that could be made, see the <a href="%s">Site Health Status</a> page.' ), esc_url( admin_url( 'site-health.php' ) ) );
  34. ?>
  35. </p>
  36. <p>
  37. <?php _e( 'If you want to export a handy list of all the information on this page, you can use the button below to copy it to the clipboard. You can then paste it in a text file and save it to your device, or paste it in an email exchange with a support engineer or theme/plugin developer for example.' ); ?>
  38. </p>
  39. <div class="site-health-copy-buttons">
  40. <div class="copy-button-wrapper">
  41. <button type="button" class="button copy-button" data-clipboard-text="<?php echo esc_attr( WP_Debug_Data::format( $info, 'debug' ) ); ?>">
  42. <?php _e( 'Copy site info to clipboard' ); ?>
  43. </button>
  44. <span class="success hidden" aria-hidden="true"><?php _e( 'Copied!' ); ?></span>
  45. </div>
  46. </div>
  47. <div id="health-check-debug" class="health-check-accordion">
  48. <?php
  49. $sizes_fields = array( 'uploads_size', 'themes_size', 'plugins_size', 'wordpress_size', 'database_size', 'total_size' );
  50. foreach ( $info as $section => $details ) {
  51. if ( ! isset( $details['fields'] ) || empty( $details['fields'] ) ) {
  52. continue;
  53. }
  54. ?>
  55. <h3 class="health-check-accordion-heading">
  56. <button aria-expanded="false" class="health-check-accordion-trigger" aria-controls="health-check-accordion-block-<?php echo esc_attr( $section ); ?>" type="button">
  57. <span class="title">
  58. <?php echo esc_html( $details['label'] ); ?>
  59. <?php
  60. if ( isset( $details['show_count'] ) && $details['show_count'] ) {
  61. printf(
  62. '(%s)',
  63. number_format_i18n( count( $details['fields'] ) )
  64. );
  65. }
  66. ?>
  67. </span>
  68. <?php
  69. if ( 'wp-paths-sizes' === $section ) {
  70. ?>
  71. <span class="health-check-wp-paths-sizes spinner"></span>
  72. <?php
  73. }
  74. ?>
  75. <span class="icon"></span>
  76. </button>
  77. </h3>
  78. <div id="health-check-accordion-block-<?php echo esc_attr( $section ); ?>" class="health-check-accordion-panel" hidden="hidden">
  79. <?php
  80. if ( isset( $details['description'] ) && ! empty( $details['description'] ) ) {
  81. printf( '<p>%s</p>', $details['description'] );
  82. }
  83. ?>
  84. <table class="widefat striped health-check-table" role="presentation">
  85. <tbody>
  86. <?php
  87. foreach ( $details['fields'] as $field_name => $field ) {
  88. if ( is_array( $field['value'] ) ) {
  89. $values = '<ul>';
  90. foreach ( $field['value'] as $name => $value ) {
  91. $values .= sprintf( '<li>%s: %s</li>', esc_html( $name ), esc_html( $value ) );
  92. }
  93. $values .= '</ul>';
  94. } else {
  95. $values = esc_html( $field['value'] );
  96. }
  97. if ( in_array( $field_name, $sizes_fields, true ) ) {
  98. printf( '<tr><td>%s</td><td class="%s">%s</td></tr>', esc_html( $field['label'] ), esc_attr( $field_name ), $values );
  99. } else {
  100. printf( '<tr><td>%s</td><td>%s</td></tr>', esc_html( $field['label'] ), $values );
  101. }
  102. }
  103. ?>
  104. </tbody>
  105. </table>
  106. </div>
  107. <?php } ?>
  108. </div>
  109. </div>