ru-se.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

site-health-info.php (3978B)


      1 <?php
      2 /**
      3  * Tools Administration Screen.
      4  *
      5  * @package WordPress
      6  * @subpackage Administration
      7  */
      8 
      9 if ( ! defined( 'ABSPATH' ) ) {
     10 	die();
     11 }
     12 
     13 if ( ! class_exists( 'WP_Debug_Data' ) ) {
     14 	require_once ABSPATH . 'wp-admin/includes/class-wp-debug-data.php';
     15 }
     16 if ( ! class_exists( 'WP_Site_Health' ) ) {
     17 	require_once ABSPATH . 'wp-admin/includes/class-wp-site-health.php';
     18 }
     19 
     20 $health_check_site_status = WP_Site_Health::get_instance();
     21 ?>
     22 
     23 <div class="notice notice-error hide-if-js">
     24 	<p><?php _e( 'The Site Health check requires JavaScript.' ); ?></p>
     25 </div>
     26 
     27 <div class="health-check-body health-check-debug-tab hide-if-no-js">
     28 	<?php
     29 
     30 	WP_Debug_Data::check_for_updates();
     31 
     32 	$info = WP_Debug_Data::debug_data();
     33 
     34 	?>
     35 
     36 	<h2>
     37 		<?php _e( 'Site Health Info' ); ?>
     38 	</h2>
     39 
     40 	<p>
     41 		<?php
     42 			/* translators: %s: URL to Site Health Status page. */
     43 			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' ) ) );
     44 		?>
     45 	</p>
     46 	<p>
     47 		<?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.' ); ?>
     48 	</p>
     49 
     50 	<div class="site-health-copy-buttons">
     51 		<div class="copy-button-wrapper">
     52 			<button type="button" class="button copy-button" data-clipboard-text="<?php echo esc_attr( WP_Debug_Data::format( $info, 'debug' ) ); ?>">
     53 				<?php _e( 'Copy site info to clipboard' ); ?>
     54 			</button>
     55 			<span class="success hidden" aria-hidden="true"><?php _e( 'Copied!' ); ?></span>
     56 		</div>
     57 	</div>
     58 
     59 	<div id="health-check-debug" class="health-check-accordion">
     60 
     61 		<?php
     62 
     63 		$sizes_fields = array( 'uploads_size', 'themes_size', 'plugins_size', 'wordpress_size', 'database_size', 'total_size' );
     64 
     65 		foreach ( $info as $section => $details ) {
     66 			if ( ! isset( $details['fields'] ) || empty( $details['fields'] ) ) {
     67 				continue;
     68 			}
     69 
     70 			?>
     71 			<h3 class="health-check-accordion-heading">
     72 				<button aria-expanded="false" class="health-check-accordion-trigger" aria-controls="health-check-accordion-block-<?php echo esc_attr( $section ); ?>" type="button">
     73 					<span class="title">
     74 						<?php echo esc_html( $details['label'] ); ?>
     75 						<?php
     76 
     77 						if ( isset( $details['show_count'] ) && $details['show_count'] ) {
     78 							printf( '(%d)', count( $details['fields'] ) );
     79 						}
     80 
     81 						?>
     82 					</span>
     83 					<?php
     84 
     85 					if ( 'wp-paths-sizes' === $section ) {
     86 						?>
     87 						<span class="health-check-wp-paths-sizes spinner"></span>
     88 						<?php
     89 					}
     90 
     91 					?>
     92 					<span class="icon"></span>
     93 				</button>
     94 			</h3>
     95 
     96 			<div id="health-check-accordion-block-<?php echo esc_attr( $section ); ?>" class="health-check-accordion-panel" hidden="hidden">
     97 				<?php
     98 
     99 				if ( isset( $details['description'] ) && ! empty( $details['description'] ) ) {
    100 					printf( '<p>%s</p>', $details['description'] );
    101 				}
    102 
    103 				?>
    104 				<table class="widefat striped health-check-table" role="presentation">
    105 					<tbody>
    106 					<?php
    107 
    108 					foreach ( $details['fields'] as $field_name => $field ) {
    109 						if ( is_array( $field['value'] ) ) {
    110 							$values = '<ul>';
    111 
    112 							foreach ( $field['value'] as $name => $value ) {
    113 								$values .= sprintf( '<li>%s: %s</li>', esc_html( $name ), esc_html( $value ) );
    114 							}
    115 
    116 							$values .= '</ul>';
    117 						} else {
    118 							$values = esc_html( $field['value'] );
    119 						}
    120 
    121 						if ( in_array( $field_name, $sizes_fields, true ) ) {
    122 							printf( '<tr><td>%s</td><td class="%s">%s</td></tr>', esc_html( $field['label'] ), esc_attr( $field_name ), $values );
    123 						} else {
    124 							printf( '<tr><td>%s</td><td>%s</td></tr>', esc_html( $field['label'] ), $values );
    125 						}
    126 					}
    127 
    128 					?>
    129 					</tbody>
    130 				</table>
    131 			</div>
    132 		<?php } ?>
    133 	</div>
    134 </div>