wp/wp-admin/site-health-info.php
changeset 9 177826044cd9
child 16 a86126ab1dd4
equal deleted inserted replaced
8:c7c34916027a 9:177826044cd9
       
     1 <?php
       
     2 /**
       
     3  * Tools Administration Screen.
       
     4  *
       
     5  * @package WordPress
       
     6  * @subpackage Administration
       
     7  */
       
     8 
       
     9 /** WordPress Administration Bootstrap */
       
    10 require_once( dirname( __FILE__ ) . '/admin.php' );
       
    11 
       
    12 $title = __( 'Site Health Info' );
       
    13 
       
    14 if ( ! current_user_can( 'view_site_health_checks' ) ) {
       
    15 	wp_die( __( 'Sorry, you are not allowed to access the debug data.' ), '', 403 );
       
    16 }
       
    17 
       
    18 wp_enqueue_style( 'site-health' );
       
    19 wp_enqueue_script( 'site-health' );
       
    20 
       
    21 if ( ! class_exists( 'WP_Debug_Data' ) ) {
       
    22 	require_once( ABSPATH . 'wp-admin/includes/class-wp-debug-data.php' );
       
    23 }
       
    24 if ( ! class_exists( 'WP_Site_Health' ) ) {
       
    25 	require_once( ABSPATH . 'wp-admin/includes/class-wp-site-health.php' );
       
    26 }
       
    27 
       
    28 $health_check_site_status = new WP_Site_Health();
       
    29 
       
    30 require_once( ABSPATH . 'wp-admin/admin-header.php' );
       
    31 ?>
       
    32 <div class="health-check-header">
       
    33 	<div class="health-check-title-section">
       
    34 		<h1>
       
    35 			<?php _e( 'Site Health' ); ?>
       
    36 		</h1>
       
    37 
       
    38 		<div class="site-health-progress hide-if-no-js loading">
       
    39 			<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">
       
    40 				<circle r="90" cx="100" cy="100" fill="transparent" stroke-dasharray="565.48" stroke-dashoffset="0"></circle>
       
    41 				<circle id="bar" r="90" cx="100" cy="100" fill="transparent" stroke-dasharray="565.48" stroke-dashoffset="0"></circle>
       
    42 			</svg>
       
    43 			<span class="screen-reader-text"><?php _e( 'Current health score:' ); ?></span>
       
    44 			<span class="site-health-progress-count"></span>
       
    45 		</div>
       
    46 	</div>
       
    47 
       
    48 	<nav class="health-check-tabs-wrapper hide-if-no-js" aria-label="<?php esc_attr_e( 'Secondary menu' ); ?>">
       
    49 		<a href="<?php echo esc_url( admin_url( 'site-health.php' ) ); ?>" class="health-check-tab">
       
    50 			<?php
       
    51 			/* translators: tab heading for Site Health Status page */
       
    52 			_ex( 'Status', 'Site Health' );
       
    53 			?>
       
    54 		</a>
       
    55 
       
    56 		<a href="<?php echo esc_url( admin_url( 'site-health.php?tab=debug' ) ); ?>" class="health-check-tab active" aria-current="true">
       
    57 			<?php
       
    58 			/* translators: tab heading for Site Health Info page */
       
    59 			_ex( 'Info', 'Site Health' );
       
    60 			?>
       
    61 		</a>
       
    62 	</nav>
       
    63 </div>
       
    64 
       
    65 <hr class="wp-header-end">
       
    66 
       
    67 <div class="notice notice-error hide-if-js">
       
    68 	<p><?php _e( 'The Site Health check requires JavaScript.' ); ?></p>
       
    69 </div>
       
    70 
       
    71 <div class="health-check-body health-check-debug-tab hide-if-no-js">
       
    72 	<?php
       
    73 
       
    74 	WP_Debug_Data::check_for_updates();
       
    75 
       
    76 	$info = WP_Debug_Data::debug_data();
       
    77 
       
    78 	?>
       
    79 
       
    80 	<h2>
       
    81 		<?php _e( 'Site Health Info' ); ?>
       
    82 	</h2>
       
    83 
       
    84 	<p>
       
    85 		<?php _e( 'This page can show you every detail about the configuration of your WordPress website. If we see anything here that could be improved, we will let you know on the Site Health Status page.' ); ?>
       
    86 	</p>
       
    87 	<p>
       
    88 		<?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 harddrive, or paste it in an email exchange with a support engineer or theme/plugin developer for example.' ); ?>
       
    89 	</p>
       
    90 
       
    91 	<div class="site-health-copy-buttons">
       
    92 		<div class="copy-button-wrapper">
       
    93 			<button type="button" class="button copy-button" data-clipboard-text="<?php echo esc_attr( WP_Debug_Data::format( $info, 'debug' ) ); ?>">
       
    94 				<?php _e( 'Copy site info to clipboard' ); ?>
       
    95 			</button>
       
    96 			<span class="success" aria-hidden="true"><?php _e( 'Copied!' ); ?></span>
       
    97 		</div>
       
    98 	</div>
       
    99 
       
   100 	<div id="health-check-debug" class="health-check-accordion">
       
   101 
       
   102 		<?php
       
   103 
       
   104 		$sizes_fields = array( 'uploads_size', 'themes_size', 'plugins_size', 'wordpress_size', 'database_size', 'total_size' );
       
   105 
       
   106 		foreach ( $info as $section => $details ) {
       
   107 			if ( ! isset( $details['fields'] ) || empty( $details['fields'] ) ) {
       
   108 				continue;
       
   109 			}
       
   110 
       
   111 			?>
       
   112 			<h3 class="health-check-accordion-heading">
       
   113 				<button aria-expanded="false" class="health-check-accordion-trigger" aria-controls="health-check-accordion-block-<?php echo esc_attr( $section ); ?>" type="button">
       
   114 					<span class="title">
       
   115 						<?php echo esc_html( $details['label'] ); ?>
       
   116 						<?php
       
   117 
       
   118 						if ( isset( $details['show_count'] ) && $details['show_count'] ) {
       
   119 							printf( '(%d)', count( $details['fields'] ) );
       
   120 						}
       
   121 
       
   122 						?>
       
   123 					</span>
       
   124 					<?php
       
   125 
       
   126 					if ( 'wp-paths-sizes' === $section ) {
       
   127 						?>
       
   128 						<span class="health-check-wp-paths-sizes spinner"></span>
       
   129 						<?php
       
   130 					}
       
   131 
       
   132 					?>
       
   133 					<span class="icon"></span>
       
   134 				</button>
       
   135 			</h3>
       
   136 
       
   137 			<div id="health-check-accordion-block-<?php echo esc_attr( $section ); ?>" class="health-check-accordion-panel" hidden="hidden">
       
   138 				<?php
       
   139 
       
   140 				if ( isset( $details['description'] ) && ! empty( $details['description'] ) ) {
       
   141 					printf( '<p>%s</p>', $details['description'] );
       
   142 				}
       
   143 
       
   144 				?>
       
   145 				<table class="widefat striped health-check-table" role="presentation">
       
   146 					<tbody>
       
   147 					<?php
       
   148 
       
   149 					foreach ( $details['fields'] as $field_name => $field ) {
       
   150 						if ( is_array( $field['value'] ) ) {
       
   151 							$values = '<ul>';
       
   152 
       
   153 							foreach ( $field['value'] as $name => $value ) {
       
   154 								$values .= sprintf( '<li>%s: %s</li>', esc_html( $name ), esc_html( $value ) );
       
   155 							}
       
   156 
       
   157 							$values .= '</ul>';
       
   158 						} else {
       
   159 							$values = esc_html( $field['value'] );
       
   160 						}
       
   161 
       
   162 						if ( in_array( $field_name, $sizes_fields, true ) ) {
       
   163 							printf( '<tr><td>%s</td><td class="%s">%s</td></tr>', esc_html( $field['label'] ), esc_attr( $field_name ), $values );
       
   164 						} else {
       
   165 							printf( '<tr><td>%s</td><td>%s</td></tr>', esc_html( $field['label'] ), $values );
       
   166 						}
       
   167 					}
       
   168 
       
   169 					?>
       
   170 					</tbody>
       
   171 				</table>
       
   172 			</div>
       
   173 		<?php } ?>
       
   174 	</div>
       
   175 </div>
       
   176 
       
   177 <?php
       
   178 include( ABSPATH . 'wp-admin/admin-footer.php' );