4 * |
4 * |
5 * @package WordPress |
5 * @package WordPress |
6 * @subpackage Administration |
6 * @subpackage Administration |
7 */ |
7 */ |
8 |
8 |
9 if ( isset( $_GET['tab'] ) && 'debug' === $_GET['tab'] ) { |
|
10 require_once __DIR__ . '/site-health-info.php'; |
|
11 return; |
|
12 } |
|
13 |
|
14 /** WordPress Administration Bootstrap */ |
9 /** WordPress Administration Bootstrap */ |
15 require_once __DIR__ . '/admin.php'; |
10 require_once __DIR__ . '/admin.php'; |
16 |
11 |
17 $title = __( 'Site Health Status' ); |
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 associated 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 array $tabs An associated array of tab slugs and their label. |
|
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 ); |
18 |
46 |
19 if ( ! current_user_can( 'view_site_health_checks' ) ) { |
47 if ( ! current_user_can( 'view_site_health_checks' ) ) { |
20 wp_die( __( 'Sorry, you are not allowed to access site health information.' ), '', 403 ); |
48 wp_die( __( 'Sorry, you are not allowed to access site health information.' ), '', 403 ); |
21 } |
49 } |
22 |
50 |
23 wp_enqueue_style( 'site-health' ); |
51 wp_enqueue_style( 'site-health' ); |
24 wp_enqueue_script( 'site-health' ); |
52 wp_enqueue_script( 'site-health' ); |
25 |
53 |
26 if ( ! class_exists( 'WP_Site_Health' ) ) { |
54 if ( ! class_exists( 'WP_Site_Health' ) ) { |
27 require_once ABSPATH . 'wp-admin/includes/class-wp-site-health.php'; |
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; |
28 } |
73 } |
29 |
74 |
30 $health_check_site_status = WP_Site_Health::get_instance(); |
75 $health_check_site_status = WP_Site_Health::get_instance(); |
31 |
76 |
32 // Start by checking if this is a special request checking for the existence of certain filters. |
77 // Start by checking if this is a special request checking for the existence of certain filters. |
39 <h1> |
84 <h1> |
40 <?php _e( 'Site Health' ); ?> |
85 <?php _e( 'Site Health' ); ?> |
41 </h1> |
86 </h1> |
42 </div> |
87 </div> |
43 |
88 |
|
89 <?php |
|
90 if ( isset( $_GET['https_updated'] ) ) { |
|
91 if ( $_GET['https_updated'] ) { |
|
92 ?> |
|
93 <div id="message" class="notice notice-success is-dismissible"><p><?php _e( 'Site URLs switched to HTTPS.' ); ?></p></div> |
|
94 <?php |
|
95 } else { |
|
96 ?> |
|
97 <div id="message" class="notice notice-error is-dismissible"><p><?php _e( 'Site URLs could not be switched to HTTPS.' ); ?></p></div> |
|
98 <?php |
|
99 } |
|
100 } |
|
101 ?> |
|
102 |
44 <div class="health-check-title-section site-health-progress-wrapper loading hide-if-no-js"> |
103 <div class="health-check-title-section site-health-progress-wrapper loading hide-if-no-js"> |
45 <div class="site-health-progress"> |
104 <div class="site-health-progress"> |
46 <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"> |
105 <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"> |
47 <circle r="90" cx="100" cy="100" fill="transparent" stroke-dasharray="565.48" stroke-dashoffset="0"></circle> |
106 <circle r="90" cx="100" cy="100" fill="transparent" stroke-dasharray="565.48" stroke-dashoffset="0"></circle> |
48 <circle id="bar" r="90" cx="100" cy="100" fill="transparent" stroke-dasharray="565.48" stroke-dashoffset="0"></circle> |
107 <circle id="bar" r="90" cx="100" cy="100" fill="transparent" stroke-dasharray="565.48" stroke-dashoffset="0"></circle> |
51 <div class="site-health-progress-label"> |
110 <div class="site-health-progress-label"> |
52 <?php _e( 'Results are still loading…' ); ?> |
111 <?php _e( 'Results are still loading…' ); ?> |
53 </div> |
112 </div> |
54 </div> |
113 </div> |
55 |
114 |
56 <nav class="health-check-tabs-wrapper hide-if-no-js" aria-label="<?php esc_attr_e( 'Secondary menu' ); ?>"> |
115 <nav class="<?php echo implode( ' ', $wrapper_classes ); ?>" aria-label="<?php esc_attr_e( 'Secondary menu' ); ?>"> |
57 <a href="<?php echo esc_url( admin_url( 'site-health.php' ) ); ?>" class="health-check-tab active" aria-current="true"> |
116 <?php |
58 <?php |
117 $tabs_slice = $tabs; |
59 /* translators: Tab heading for Site Health Status page. */ |
118 |
60 _ex( 'Status', 'Site Health' ); |
119 /* |
61 ?> |
120 * If there are more than 4 tabs, only output the first 3 inline, |
62 </a> |
121 * the remaining links will be added to a sub-navigation. |
63 |
122 */ |
64 <a href="<?php echo esc_url( admin_url( 'site-health.php?tab=debug' ) ); ?>" class="health-check-tab"> |
123 if ( count( $tabs ) > 4 ) { |
65 <?php |
124 $tabs_slice = array_slice( $tabs, 0, 3 ); |
66 /* translators: Tab heading for Site Health Info page. */ |
125 } |
67 _ex( 'Info', 'Site Health' ); |
126 |
68 ?> |
127 foreach ( $tabs_slice as $slug => $label ) { |
69 </a> |
128 printf( |
|
129 '<a href="%s" class="health-check-tab %s">%s</a>', |
|
130 esc_url( |
|
131 add_query_arg( |
|
132 array( |
|
133 'tab' => $slug, |
|
134 ), |
|
135 admin_url( 'site-health.php' ) |
|
136 ) |
|
137 ), |
|
138 ( $current_tab === $slug ? 'active' : '' ), |
|
139 esc_html( $label ) |
|
140 ); |
|
141 } |
|
142 ?> |
|
143 |
|
144 <?php if ( count( $tabs ) > 4 ) : ?> |
|
145 <button type="button" class="health-check-tab health-check-offscreen-nav-wrapper" aria-haspopup="true"> |
|
146 <span class="dashicons dashicons-ellipsis"></span> |
|
147 <span class="screen-reader-text"><?php _e( 'Toggle extra menu items' ); ?></span> |
|
148 |
|
149 <div class="health-check-offscreen-nav"> |
|
150 <?php |
|
151 // Remove the first few entries from the array as being already output. |
|
152 $tabs_slice = array_slice( $tabs, 3 ); |
|
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 ( isset( $_GET['tab'] ) && $_GET['tab'] === $slug ? 'active' : '' ), |
|
165 esc_html( $label ) |
|
166 ); |
|
167 } |
|
168 ?> |
|
169 </div> |
|
170 </button> |
|
171 <?php endif; ?> |
70 </nav> |
172 </nav> |
71 </div> |
173 </div> |
72 |
174 |
73 <hr class="wp-header-end"> |
175 <hr class="wp-header-end"> |
|
176 |
|
177 <?php |
|
178 if ( isset( $_GET['tab'] ) && ! empty( $_GET['tab'] ) ) { |
|
179 /** |
|
180 * Output content of a custom Site Health tab. |
|
181 * |
|
182 * This action fires right after the Site Health header, and users are still subject to |
|
183 * the capability checks for the Site Health page to view any custom tabs and their contents. |
|
184 * |
|
185 * @since 5.8.0 |
|
186 * |
|
187 * @param string $tab The slug of the tab that was requested. |
|
188 */ |
|
189 do_action( 'site_health_tab_content', $_GET['tab'] ); |
|
190 |
|
191 require_once ABSPATH . 'wp-admin/admin-footer.php'; |
|
192 return; |
|
193 } else { |
|
194 ?> |
74 |
195 |
75 <div class="notice notice-error hide-if-js"> |
196 <div class="notice notice-error hide-if-js"> |
76 <p><?php _e( 'The Site Health check requires JavaScript.' ); ?></p> |
197 <p><?php _e( 'The Site Health check requires JavaScript.' ); ?></p> |
77 </div> |
198 </div> |
78 |
199 |
79 <div class="health-check-body hide-if-no-js"> |
200 <div class="health-check-body health-check-status-tab hide-if-no-js"> |
80 <div class="site-status-all-clear hide"> |
201 <div class="site-status-all-clear hide"> |
81 <p class="icon"> |
202 <p class="icon"> |
82 <span class="dashicons dashicons-yes"></span> |
203 <span class="dashicons dashicons-yes"></span> |
83 </p> |
204 </p> |
84 |
205 |
142 |
263 |
143 <script id="tmpl-health-check-issue" type="text/template"> |
264 <script id="tmpl-health-check-issue" type="text/template"> |
144 <h4 class="health-check-accordion-heading"> |
265 <h4 class="health-check-accordion-heading"> |
145 <button aria-expanded="false" class="health-check-accordion-trigger" aria-controls="health-check-accordion-block-{{ data.test }}" type="button"> |
266 <button aria-expanded="false" class="health-check-accordion-trigger" aria-controls="health-check-accordion-block-{{ data.test }}" type="button"> |
146 <span class="title">{{ data.label }}</span> |
267 <span class="title">{{ data.label }}</span> |
147 <span class="badge {{ data.badge.color }}">{{ data.badge.label }}</span> |
268 <# if ( data.badge ) { #> |
|
269 <span class="badge {{ data.badge.color }}">{{ data.badge.label }}</span> |
|
270 <# } #> |
148 <span class="icon"></span> |
271 <span class="icon"></span> |
149 </button> |
272 </button> |
150 </h4> |
273 </h4> |
151 <div id="health-check-accordion-block-{{ data.test }}" class="health-check-accordion-panel" hidden="hidden"> |
274 <div id="health-check-accordion-block-{{ data.test }}" class="health-check-accordion-panel" hidden="hidden"> |
152 {{{ data.description }}} |
275 {{{ data.description }}} |