[ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[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 $action = ! empty( $_REQUEST['action'] ) ? sanitize_text_field( $_REQUEST['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 * Filters the 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/documentation/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 wp_admin_notice( 109 __( 'Site URLs switched to HTTPS.' ), 110 array( 111 'type' => 'success', 112 'id' => 'message', 113 'dismissible' => true, 114 ) 115 ); 116 } else { 117 wp_admin_notice( 118 __( 'Site URLs could not be switched to HTTPS.' ), 119 array( 120 'type' => 'error', 121 'id' => 'message', 122 'dismissible' => true, 123 ) 124 ); 125 } 126 } 127 ?> 128 129 <div class="health-check-title-section site-health-progress-wrapper loading hide-if-no-js"> 130 <div class="site-health-progress"> 131 <svg aria-hidden="true" focusable="false" width="100%" height="100%" viewBox="0 0 200 200" version="1.1" xmlns="http://www.w3.org/2000/svg"> 132 <circle r="90" cx="100" cy="100" fill="transparent" stroke-dasharray="565.48" stroke-dashoffset="0"></circle> 133 <circle id="bar" r="90" cx="100" cy="100" fill="transparent" stroke-dasharray="565.48" stroke-dashoffset="0"></circle> 134 </svg> 135 </div> 136 <div class="site-health-progress-label"> 137 <?php _e( 'Results are still loading…' ); ?> 138 </div> 139 </div> 140 141 <nav class="<?php echo implode( ' ', $wrapper_classes ); ?>" aria-label="<?php esc_attr_e( 'Secondary menu' ); ?>"> 142 <?php 143 $tabs_slice = $tabs; 144 145 /* 146 * If there are more than 4 tabs, only output the first 3 inline, 147 * the remaining links will be added to a sub-navigation. 148 */ 149 if ( count( $tabs ) > 4 ) { 150 $tabs_slice = array_slice( $tabs, 0, 3 ); 151 } 152 153 foreach ( $tabs_slice as $slug => $label ) { 154 printf( 155 '<a href="%s" class="health-check-tab %s">%s</a>', 156 esc_url( 157 add_query_arg( 158 array( 159 'tab' => $slug, 160 ), 161 admin_url( 'site-health.php' ) 162 ) 163 ), 164 ( $current_tab === $slug ? 'active' : '' ), 165 esc_html( $label ) 166 ); 167 } 168 ?> 169 170 <?php if ( count( $tabs ) > 4 ) : ?> 171 <button type="button" class="health-check-tab health-check-offscreen-nav-wrapper" aria-haspopup="true"> 172 <span class="dashicons dashicons-ellipsis"></span> 173 <span class="screen-reader-text"> 174 <?php 175 /* translators: Hidden accessibility text. */ 176 _e( 'Toggle extra menu items' ); 177 ?> 178 </span> 179 180 <div class="health-check-offscreen-nav"> 181 <?php 182 // Remove the first few entries from the array as being already output. 183 $tabs_slice = array_slice( $tabs, 3 ); 184 foreach ( $tabs_slice as $slug => $label ) { 185 printf( 186 '<a href="%s" class="health-check-tab %s">%s</a>', 187 esc_url( 188 add_query_arg( 189 array( 190 'tab' => $slug, 191 ), 192 admin_url( 'site-health.php' ) 193 ) 194 ), 195 ( isset( $_GET['tab'] ) && $_GET['tab'] === $slug ? 'active' : '' ), 196 esc_html( $label ) 197 ); 198 } 199 ?> 200 </div> 201 </button> 202 <?php endif; ?> 203 </nav> 204 </div> 205 206 <hr class="wp-header-end"> 207 208 <?php 209 if ( isset( $_GET['tab'] ) && ! empty( $_GET['tab'] ) ) { 210 /** 211 * Fires when outputting the content of a custom Site Health tab. 212 * 213 * This action fires right after the Site Health header, and users are still subject to 214 * the capability checks for the Site Health page to view any custom tabs and their contents. 215 * 216 * @since 5.8.0 217 * 218 * @param string $tab The slug of the tab that was requested. 219 */ 220 do_action( 'site_health_tab_content', $_GET['tab'] ); 221 222 require_once ABSPATH . 'wp-admin/admin-footer.php'; 223 return; 224 } else { 225 wp_admin_notice( 226 __( 'The Site Health check requires JavaScript.' ), 227 array( 228 'type' => 'error', 229 'additional_classes' => array( 'hide-if-js' ), 230 ) 231 ); 232 ?> 233 234 <div class="health-check-body health-check-status-tab hide-if-no-js"> 235 <div class="site-status-all-clear hide"> 236 <p class="icon"> 237 <span class="dashicons dashicons-smiley" aria-hidden="true"></span> 238 </p> 239 240 <p class="encouragement"> 241 <?php _e( 'Great job!' ); ?> 242 </p> 243 244 <p> 245 <?php _e( 'Everything is running smoothly here.' ); ?> 246 </p> 247 </div> 248 249 <div class="site-status-has-issues"> 250 <h2> 251 <?php _e( 'Site Health Status' ); ?> 252 </h2> 253 254 <p><?php _e( 'The site health check shows information about your WordPress configuration and items that may need your attention.' ); ?></p> 255 256 <div class="site-health-issues-wrapper hidden" id="health-check-issues-critical"> 257 <h3 class="site-health-issue-count-title"> 258 <?php 259 /* translators: %s: Number of critical issues found. */ 260 printf( _n( '%s critical issue', '%s critical issues', 0 ), '<span class="issue-count">0</span>' ); 261 ?> 262 </h3> 263 264 <p><?php _e( 'Critical issues are items that may have a high impact on your sites performance or security, and resolving these issues should be prioritized.' ); ?></p> 265 266 <div id="health-check-site-status-critical" class="health-check-accordion issues"></div> 267 </div> 268 269 <div class="site-health-issues-wrapper hidden" id="health-check-issues-recommended"> 270 <h3 class="site-health-issue-count-title"> 271 <?php 272 /* translators: %s: Number of recommended improvements. */ 273 printf( _n( '%s recommended improvement', '%s recommended improvements', 0 ), '<span class="issue-count">0</span>' ); 274 ?> 275 </h3> 276 277 <p><?php _e( 'Recommended items are considered beneficial to your site, although not as important to prioritize as a critical issue, they may include improvements to things such as; Performance, user experience, and more.' ); ?></p> 278 279 <div id="health-check-site-status-recommended" class="health-check-accordion issues"></div> 280 </div> 281 </div> 282 283 <div class="site-health-view-more"> 284 <button type="button" class="button site-health-view-passed" aria-expanded="false" aria-controls="health-check-issues-good"> 285 <?php _e( 'Passed tests' ); ?> 286 <span class="icon"></span> 287 </button> 288 </div> 289 290 <div class="site-health-issues-wrapper hidden" id="health-check-issues-good"> 291 <h3 class="site-health-issue-count-title"> 292 <?php 293 /* translators: %s: Number of items with no issues. */ 294 printf( _n( '%s item with no issues detected', '%s items with no issues detected', 0 ), '<span class="issue-count">0</span>' ); 295 ?> 296 </h3> 297 298 <div id="health-check-site-status-good" class="health-check-accordion issues"></div> 299 </div> 300 </div> 301 302 <script id="tmpl-health-check-issue" type="text/template"> 303 <h4 class="health-check-accordion-heading"> 304 <button aria-expanded="false" class="health-check-accordion-trigger" aria-controls="health-check-accordion-block-{{ data.test }}" type="button"> 305 <span class="title">{{ data.label }}</span> 306 <# if ( data.badge ) { #> 307 <span class="badge {{ data.badge.color }}">{{ data.badge.label }}</span> 308 <# } #> 309 <span class="icon"></span> 310 </button> 311 </h4> 312 <div id="health-check-accordion-block-{{ data.test }}" class="health-check-accordion-panel" hidden="hidden"> 313 {{{ data.description }}} 314 <# if ( data.actions ) { #> 315 <div class="actions"> 316 {{{ data.actions }}} 317 </div> 318 <# } #> 319 </div> 320 </script> 321 322 <?php 323 } 324 require_once ABSPATH . 'wp-admin/admin-footer.php';
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated : Sat Dec 21 08:20:01 2024 | Cross-referenced by PHPXref |