[ Index ] |
PHP Cross Reference of WordPress |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Tools Administration Screen. 4 * 5 * @package WordPress 6 * @subpackage Administration 7 */ 8 9 /** WordPress Administration Bootstrap */ 10 require_once __DIR__ . '/admin.php'; 11 12 wp_reset_vars( array( 'action' ) ); 13 14 $tabs = array( 15 /* translators: Tab heading for Site Health Status page. */ 16 '' => _x( 'Status', 'Site Health' ), 17 /* translators: Tab heading for Site Health Info page. */ 18 'debug' => _x( 'Info', 'Site Health' ), 19 ); 20 21 /** 22 * An associative array of extra tabs for the Site Health navigation bar. 23 * 24 * Add a custom page to the Site Health screen, based on a tab slug and label. 25 * The label you provide will also be used as part of the site title. 26 * 27 * @since 5.8.0 28 * 29 * @param string[] $tabs An associative array of tab labels keyed by their slug. 30 */ 31 $tabs = apply_filters( 'site_health_navigation_tabs', $tabs ); 32 33 $wrapper_classes = array( 34 'health-check-tabs-wrapper', 35 'hide-if-no-js', 36 'tab-count-' . count( $tabs ), 37 ); 38 39 $current_tab = ( isset( $_GET['tab'] ) ? $_GET['tab'] : '' ); 40 41 $title = sprintf( 42 // translators: %s: The currently displayed tab. 43 __( 'Site Health - %s' ), 44 ( isset( $tabs[ $current_tab ] ) ? esc_html( $tabs[ $current_tab ] ) : esc_html( reset( $tabs ) ) ) 45 ); 46 47 if ( ! current_user_can( 'view_site_health_checks' ) ) { 48 wp_die( __( 'Sorry, you are not allowed to access site health information.' ), '', 403 ); 49 } 50 51 wp_enqueue_style( 'site-health' ); 52 wp_enqueue_script( 'site-health' ); 53 54 if ( ! class_exists( 'WP_Site_Health' ) ) { 55 require_once ABSPATH . 'wp-admin/includes/class-wp-site-health.php'; 56 } 57 58 if ( 'update_https' === $action ) { 59 check_admin_referer( 'wp_update_https' ); 60 61 if ( ! current_user_can( 'update_https' ) ) { 62 wp_die( __( 'Sorry, you are not allowed to update this site to HTTPS.' ), 403 ); 63 } 64 65 if ( ! wp_is_https_supported() ) { 66 wp_die( __( 'It looks like HTTPS is not supported for your website at this point.' ) ); 67 } 68 69 $result = wp_update_urls_to_https(); 70 71 wp_redirect( add_query_arg( 'https_updated', (int) $result, wp_get_referer() ) ); 72 exit; 73 } 74 75 $health_check_site_status = WP_Site_Health::get_instance(); 76 77 get_current_screen()->add_help_tab( 78 array( 79 'id' => 'overview', 80 'title' => __( 'Overview' ), 81 'content' => 82 '<p>' . __( 'This screen allows you to obtain a health diagnosis of your site, and displays an overall rating of the status of your installation.' ) . '</p>' . 83 '<p>' . __( 'In the Status tab, you can see critical information about your WordPress configuration, along with anything else that requires your attention.' ) . '</p>' . 84 '<p>' . __( 'In the Info tab, you will find all the details about the configuration of your WordPress site, server, and database. There is also an export feature that allows you to copy all of the information about your site to the clipboard, to help solve problems on your site when obtaining support.' ) . '</p>', 85 ) 86 ); 87 88 get_current_screen()->set_help_sidebar( 89 '<p><strong>' . __( 'For more information:' ) . '</strong></p>' . 90 '<p>' . __( '<a href="https://wordpress.org/support/article/site-health-screen/">Documentation on Site Health tool</a>' ) . '</p>' 91 ); 92 93 // Start by checking if this is a special request checking for the existence of certain filters. 94 $health_check_site_status->check_wp_version_check_exists(); 95 96 require_once ABSPATH . 'wp-admin/admin-header.php'; 97 ?> 98 <div class="health-check-header"> 99 <div class="health-check-title-section"> 100 <h1> 101 <?php _e( 'Site Health' ); ?> 102 </h1> 103 </div> 104 105 <?php 106 if ( isset( $_GET['https_updated'] ) ) { 107 if ( $_GET['https_updated'] ) { 108 ?> 109 <div id="message" class="notice notice-success is-dismissible"><p><?php _e( 'Site URLs switched to HTTPS.' ); ?></p></div> 110 <?php 111 } else { 112 ?> 113 <div id="message" class="notice notice-error is-dismissible"><p><?php _e( 'Site URLs could not be switched to HTTPS.' ); ?></p></div> 114 <?php 115 } 116 } 117 ?> 118 119 <div class="health-check-title-section site-health-progress-wrapper loading hide-if-no-js"> 120 <div class="site-health-progress"> 121 <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"> 122 <circle r="90" cx="100" cy="100" fill="transparent" stroke-dasharray="565.48" stroke-dashoffset="0"></circle> 123 <circle id="bar" r="90" cx="100" cy="100" fill="transparent" stroke-dasharray="565.48" stroke-dashoffset="0"></circle> 124 </svg> 125 </div> 126 <div class="site-health-progress-label"> 127 <?php _e( 'Results are still loading…' ); ?> 128 </div> 129 </div> 130 131 <nav class="<?php echo implode( ' ', $wrapper_classes ); ?>" aria-label="<?php esc_attr_e( 'Secondary menu' ); ?>"> 132 <?php 133 $tabs_slice = $tabs; 134 135 /* 136 * If there are more than 4 tabs, only output the first 3 inline, 137 * the remaining links will be added to a sub-navigation. 138 */ 139 if ( count( $tabs ) > 4 ) { 140 $tabs_slice = array_slice( $tabs, 0, 3 ); 141 } 142 143 foreach ( $tabs_slice as $slug => $label ) { 144 printf( 145 '<a href="%s" class="health-check-tab %s">%s</a>', 146 esc_url( 147 add_query_arg( 148 array( 149 'tab' => $slug, 150 ), 151 admin_url( 'site-health.php' ) 152 ) 153 ), 154 ( $current_tab === $slug ? 'active' : '' ), 155 esc_html( $label ) 156 ); 157 } 158 ?> 159 160 <?php if ( count( $tabs ) > 4 ) : ?> 161 <button type="button" class="health-check-tab health-check-offscreen-nav-wrapper" aria-haspopup="true"> 162 <span class="dashicons dashicons-ellipsis"></span> 163 <span class="screen-reader-text"><?php _e( 'Toggle extra menu items' ); ?></span> 164 165 <div class="health-check-offscreen-nav"> 166 <?php 167 // Remove the first few entries from the array as being already output. 168 $tabs_slice = array_slice( $tabs, 3 ); 169 foreach ( $tabs_slice as $slug => $label ) { 170 printf( 171 '<a href="%s" class="health-check-tab %s">%s</a>', 172 esc_url( 173 add_query_arg( 174 array( 175 'tab' => $slug, 176 ), 177 admin_url( 'site-health.php' ) 178 ) 179 ), 180 ( isset( $_GET['tab'] ) && $_GET['tab'] === $slug ? 'active' : '' ), 181 esc_html( $label ) 182 ); 183 } 184 ?> 185 </div> 186 </button> 187 <?php endif; ?> 188 </nav> 189 </div> 190 191 <hr class="wp-header-end"> 192 193 <?php 194 if ( isset( $_GET['tab'] ) && ! empty( $_GET['tab'] ) ) { 195 /** 196 * Output content of a custom Site Health tab. 197 * 198 * This action fires right after the Site Health header, and users are still subject to 199 * the capability checks for the Site Health page to view any custom tabs and their contents. 200 * 201 * @since 5.8.0 202 * 203 * @param string $tab The slug of the tab that was requested. 204 */ 205 do_action( 'site_health_tab_content', $_GET['tab'] ); 206 207 require_once ABSPATH . 'wp-admin/admin-footer.php'; 208 return; 209 } else { 210 ?> 211 212 <div class="notice notice-error hide-if-js"> 213 <p><?php _e( 'The Site Health check requires JavaScript.' ); ?></p> 214 </div> 215 216 <div class="health-check-body health-check-status-tab hide-if-no-js"> 217 <div class="site-status-all-clear hide"> 218 <p class="icon"> 219 <span class="dashicons dashicons-smiley" aria-hidden="true"></span> 220 </p> 221 222 <p class="encouragement"> 223 <?php _e( 'Great job!' ); ?> 224 </p> 225 226 <p> 227 <?php _e( 'Everything is running smoothly here.' ); ?> 228 </p> 229 </div> 230 231 <div class="site-status-has-issues"> 232 <h2> 233 <?php _e( 'Site Health Status' ); ?> 234 </h2> 235 236 <p><?php _e( 'The site health check shows critical information about your WordPress configuration and items that require your attention.' ); ?></p> 237 238 <div class="site-health-issues-wrapper" id="health-check-issues-critical"> 239 <h3 class="site-health-issue-count-title"> 240 <?php 241 /* translators: %s: Number of critical issues found. */ 242 printf( _n( '%s critical issue', '%s critical issues', 0 ), '<span class="issue-count">0</span>' ); 243 ?> 244 </h3> 245 246 <div id="health-check-site-status-critical" class="health-check-accordion issues"></div> 247 </div> 248 249 <div class="site-health-issues-wrapper" id="health-check-issues-recommended"> 250 <h3 class="site-health-issue-count-title"> 251 <?php 252 /* translators: %s: Number of recommended improvements. */ 253 printf( _n( '%s recommended improvement', '%s recommended improvements', 0 ), '<span class="issue-count">0</span>' ); 254 ?> 255 </h3> 256 257 <div id="health-check-site-status-recommended" class="health-check-accordion issues"></div> 258 </div> 259 </div> 260 261 <div class="site-health-view-more"> 262 <button type="button" class="button site-health-view-passed" aria-expanded="false" aria-controls="health-check-issues-good"> 263 <?php _e( 'Passed tests' ); ?> 264 <span class="icon"></span> 265 </button> 266 </div> 267 268 <div class="site-health-issues-wrapper hidden" id="health-check-issues-good"> 269 <h3 class="site-health-issue-count-title"> 270 <?php 271 /* translators: %s: Number of items with no issues. */ 272 printf( _n( '%s item with no issues detected', '%s items with no issues detected', 0 ), '<span class="issue-count">0</span>' ); 273 ?> 274 </h3> 275 276 <div id="health-check-site-status-good" class="health-check-accordion issues"></div> 277 </div> 278 </div> 279 280 <script id="tmpl-health-check-issue" type="text/template"> 281 <h4 class="health-check-accordion-heading"> 282 <button aria-expanded="false" class="health-check-accordion-trigger" aria-controls="health-check-accordion-block-{{ data.test }}" type="button"> 283 <span class="title">{{ data.label }}</span> 284 <# if ( data.badge ) { #> 285 <span class="badge {{ data.badge.color }}">{{ data.badge.label }}</span> 286 <# } #> 287 <span class="icon"></span> 288 </button> 289 </h4> 290 <div id="health-check-accordion-block-{{ data.test }}" class="health-check-accordion-panel" hidden="hidden"> 291 {{{ data.description }}} 292 <# if ( data.actions ) { #> 293 <div class="actions"> 294 {{{ data.actions }}} 295 </div> 296 <# } #> 297 </div> 298 </script> 299 300 <?php 301 } 302 require_once ABSPATH . 'wp-admin/admin-footer.php';
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sat Dec 21 01:00:02 2024 | Cross-referenced by PHPXref 0.7.1 |