site-health-info.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <?php
  2. /**
  3. * Tools Administration Screen.
  4. *
  5. * @package WordPress
  6. * @subpackage Administration
  7. */
  8. /** WordPress Administration Bootstrap */
  9. require_once( dirname( __FILE__ ) . '/admin.php' );
  10. $title = __( 'Site Health Info' );
  11. if ( ! current_user_can( 'view_site_health_checks' ) ) {
  12. wp_die( __( 'Sorry, you are not allowed to access the debug data.' ), '', 403 );
  13. }
  14. wp_enqueue_style( 'site-health' );
  15. wp_enqueue_script( 'site-health' );
  16. if ( ! class_exists( 'WP_Debug_Data' ) ) {
  17. require_once( ABSPATH . 'wp-admin/includes/class-wp-debug-data.php' );
  18. }
  19. if ( ! class_exists( 'WP_Site_Health' ) ) {
  20. require_once( ABSPATH . 'wp-admin/includes/class-wp-site-health.php' );
  21. }
  22. $health_check_site_status = new WP_Site_Health();
  23. require_once( ABSPATH . 'wp-admin/admin-header.php' );
  24. ?>
  25. <div class="health-check-header">
  26. <div class="health-check-title-section">
  27. <h1>
  28. <?php _e( 'Site Health' ); ?>
  29. </h1>
  30. </div>
  31. <div class="health-check-title-section site-health-progress-wrapper loading hide-if-no-js">
  32. <div class="site-health-progress">
  33. <svg role="img" aria-hidden="true" focusable="false" width="100%" height="100%" viewBox="0 0 200 200" version="1.1" xmlns="http://www.w3.org/2000/svg">
  34. <circle r="90" cx="100" cy="100" fill="transparent" stroke-dasharray="565.48" stroke-dashoffset="0"></circle>
  35. <circle id="bar" r="90" cx="100" cy="100" fill="transparent" stroke-dasharray="565.48" stroke-dashoffset="0"></circle>
  36. </svg>
  37. </div>
  38. <div class="site-health-progress-label">
  39. <?php _e( 'Results are still loading&hellip;' ); ?>
  40. </div>
  41. </div>
  42. <nav class="health-check-tabs-wrapper hide-if-no-js" aria-label="<?php esc_attr_e( 'Secondary menu' ); ?>">
  43. <a href="<?php echo esc_url( admin_url( 'site-health.php' ) ); ?>" class="health-check-tab">
  44. <?php
  45. /* translators: Tab heading for Site Health Status page. */
  46. _ex( 'Status', 'Site Health' );
  47. ?>
  48. </a>
  49. <a href="<?php echo esc_url( admin_url( 'site-health.php?tab=debug' ) ); ?>" class="health-check-tab active" aria-current="true">
  50. <?php
  51. /* translators: Tab heading for Site Health Info page. */
  52. _ex( 'Info', 'Site Health' );
  53. ?>
  54. </a>
  55. </nav>
  56. </div>
  57. <hr class="wp-header-end">
  58. <div class="notice notice-error hide-if-js">
  59. <p><?php _e( 'The Site Health check requires JavaScript.' ); ?></p>
  60. </div>
  61. <div class="health-check-body health-check-debug-tab hide-if-no-js">
  62. <?php
  63. WP_Debug_Data::check_for_updates();
  64. $info = WP_Debug_Data::debug_data();
  65. ?>
  66. <h2>
  67. <?php _e( 'Site Health Info' ); ?>
  68. </h2>
  69. <p>
  70. <?php
  71. /* translators: %s: URL to Site Health Status page. */
  72. 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' ) ) );
  73. ?>
  74. </p>
  75. <p>
  76. <?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.' ); ?>
  77. </p>
  78. <div class="site-health-copy-buttons">
  79. <div class="copy-button-wrapper">
  80. <button type="button" class="button copy-button" data-clipboard-text="<?php echo esc_attr( WP_Debug_Data::format( $info, 'debug' ) ); ?>">
  81. <?php _e( 'Copy site info to clipboard' ); ?>
  82. </button>
  83. <span class="success" aria-hidden="true"><?php _e( 'Copied!' ); ?></span>
  84. </div>
  85. </div>
  86. <div id="health-check-debug" class="health-check-accordion">
  87. <?php
  88. $sizes_fields = array( 'uploads_size', 'themes_size', 'plugins_size', 'wordpress_size', 'database_size', 'total_size' );
  89. foreach ( $info as $section => $details ) {
  90. if ( ! isset( $details['fields'] ) || empty( $details['fields'] ) ) {
  91. continue;
  92. }
  93. ?>
  94. <h3 class="health-check-accordion-heading">
  95. <button aria-expanded="false" class="health-check-accordion-trigger" aria-controls="health-check-accordion-block-<?php echo esc_attr( $section ); ?>" type="button">
  96. <span class="title">
  97. <?php echo esc_html( $details['label'] ); ?>
  98. <?php
  99. if ( isset( $details['show_count'] ) && $details['show_count'] ) {
  100. printf( '(%d)', count( $details['fields'] ) );
  101. }
  102. ?>
  103. </span>
  104. <?php
  105. if ( 'wp-paths-sizes' === $section ) {
  106. ?>
  107. <span class="health-check-wp-paths-sizes spinner"></span>
  108. <?php
  109. }
  110. ?>
  111. <span class="icon"></span>
  112. </button>
  113. </h3>
  114. <div id="health-check-accordion-block-<?php echo esc_attr( $section ); ?>" class="health-check-accordion-panel" hidden="hidden">
  115. <?php
  116. if ( isset( $details['description'] ) && ! empty( $details['description'] ) ) {
  117. printf( '<p>%s</p>', $details['description'] );
  118. }
  119. ?>
  120. <table class="widefat striped health-check-table" role="presentation">
  121. <tbody>
  122. <?php
  123. foreach ( $details['fields'] as $field_name => $field ) {
  124. if ( is_array( $field['value'] ) ) {
  125. $values = '<ul>';
  126. foreach ( $field['value'] as $name => $value ) {
  127. $values .= sprintf( '<li>%s: %s</li>', esc_html( $name ), esc_html( $value ) );
  128. }
  129. $values .= '</ul>';
  130. } else {
  131. $values = esc_html( $field['value'] );
  132. }
  133. if ( in_array( $field_name, $sizes_fields, true ) ) {
  134. printf( '<tr><td>%s</td><td class="%s">%s</td></tr>', esc_html( $field['label'] ), esc_attr( $field_name ), $values );
  135. } else {
  136. printf( '<tr><td>%s</td><td>%s</td></tr>', esc_html( $field['label'] ), $values );
  137. }
  138. }
  139. ?>
  140. </tbody>
  141. </table>
  142. </div>
  143. <?php } ?>
  144. </div>
  145. </div>
  146. <?php
  147. include( ABSPATH . 'wp-admin/admin-footer.php' );