author | ymh <ymh.work@gmail.com> |
Mon, 08 Sep 2025 19:44:41 +0200 | |
changeset 23 | 417f20492bf7 |
parent 21 | 48c4eec2b7e6 |
permissions | -rw-r--r-- |
9 | 1 |
<?php |
2 |
/** |
|
3 |
* Tools Administration Screen. |
|
4 |
* |
|
5 |
* @package WordPress |
|
6 |
* @subpackage Administration |
|
7 |
*/ |
|
8 |
||
9 |
/** WordPress Administration Bootstrap */ |
|
16 | 10 |
require_once __DIR__ . '/admin.php'; |
9 | 11 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
12 |
$action = ! empty( $_REQUEST['action'] ) ? sanitize_text_field( $_REQUEST['action'] ) : ''; |
18 | 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 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
22 |
* Filters the extra tabs for the Site Health navigation bar. |
18 | 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 |
* |
|
19 | 29 |
* @param string[] $tabs An associative array of tab labels keyed by their slug. |
18 | 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 |
); |
|
9 | 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' ) ) { |
|
16 | 55 |
require_once ABSPATH . 'wp-admin/includes/class-wp-site-health.php'; |
9 | 56 |
} |
57 |
||
18 | 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 |
||
16 | 75 |
$health_check_site_status = WP_Site_Health::get_instance(); |
9 | 76 |
|
19 | 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>' . |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
90 |
'<p>' . __( '<a href="https://wordpress.org/documentation/article/site-health-screen/">Documentation on Site Health tool</a>' ) . '</p>' |
19 | 91 |
); |
92 |
||
9 | 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 |
||
16 | 96 |
require_once ABSPATH . 'wp-admin/admin-header.php'; |
9 | 97 |
?> |
98 |
<div class="health-check-header"> |
|
99 |
<div class="health-check-title-section"> |
|
100 |
<h1> |
|
101 |
<?php _e( 'Site Health' ); ?> |
|
102 |
</h1> |
|
16 | 103 |
</div> |
9 | 104 |
|
18 | 105 |
<?php |
106 |
if ( isset( $_GET['https_updated'] ) ) { |
|
107 |
if ( $_GET['https_updated'] ) { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
108 |
wp_admin_notice( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
109 |
__( 'Site URLs switched to HTTPS.' ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
110 |
array( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
111 |
'type' => 'success', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
112 |
'id' => 'message', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
113 |
'dismissible' => true, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
114 |
) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
115 |
); |
18 | 116 |
} else { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
117 |
wp_admin_notice( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
118 |
__( 'Site URLs could not be switched to HTTPS.' ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
119 |
array( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
120 |
'type' => 'error', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
121 |
'id' => 'message', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
122 |
'dismissible' => true, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
123 |
) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
124 |
); |
18 | 125 |
} |
126 |
} |
|
127 |
?> |
|
128 |
||
16 | 129 |
<div class="health-check-title-section site-health-progress-wrapper loading hide-if-no-js"> |
130 |
<div class="site-health-progress"> |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
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"> |
9 | 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> |
|
16 | 135 |
</div> |
136 |
<div class="site-health-progress-label"> |
|
137 |
<?php _e( 'Results are still loading…' ); ?> |
|
9 | 138 |
</div> |
139 |
</div> |
|
140 |
||
18 | 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 |
?> |
|
9 | 169 |
|
18 | 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> |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
173 |
<span class="screen-reader-text"> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
174 |
<?php |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
175 |
/* translators: Hidden accessibility text. */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
176 |
_e( 'Toggle extra menu items' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
177 |
?> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
178 |
</span> |
18 | 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; ?> |
|
9 | 203 |
</nav> |
204 |
</div> |
|
205 |
||
206 |
<hr class="wp-header-end"> |
|
207 |
||
18 | 208 |
<?php |
209 |
if ( isset( $_GET['tab'] ) && ! empty( $_GET['tab'] ) ) { |
|
210 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
211 |
* Fires when outputting the content of a custom Site Health tab. |
18 | 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 { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
225 |
wp_admin_notice( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
226 |
__( 'The Site Health check requires JavaScript.' ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
227 |
array( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
228 |
'type' => 'error', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
229 |
'additional_classes' => array( 'hide-if-js' ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
230 |
) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
231 |
); |
18 | 232 |
?> |
233 |
||
234 |
<div class="health-check-body health-check-status-tab hide-if-no-js"> |
|
9 | 235 |
<div class="site-status-all-clear hide"> |
236 |
<p class="icon"> |
|
19 | 237 |
<span class="dashicons dashicons-smiley" aria-hidden="true"></span> |
9 | 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 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
254 |
<p><?php _e( 'The site health check shows information about your WordPress configuration and items that may need your attention.' ); ?></p> |
9 | 255 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
256 |
<div class="site-health-issues-wrapper hidden" id="health-check-issues-critical"> |
9 | 257 |
<h3 class="site-health-issue-count-title"> |
258 |
<?php |
|
16 | 259 |
/* translators: %s: Number of critical issues found. */ |
260 |
printf( _n( '%s critical issue', '%s critical issues', 0 ), '<span class="issue-count">0</span>' ); |
|
9 | 261 |
?> |
262 |
</h3> |
|
263 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
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> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
265 |
|
9 | 266 |
<div id="health-check-site-status-critical" class="health-check-accordion issues"></div> |
267 |
</div> |
|
268 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
269 |
<div class="site-health-issues-wrapper hidden" id="health-check-issues-recommended"> |
9 | 270 |
<h3 class="site-health-issue-count-title"> |
271 |
<?php |
|
16 | 272 |
/* translators: %s: Number of recommended improvements. */ |
273 |
printf( _n( '%s recommended improvement', '%s recommended improvements', 0 ), '<span class="issue-count">0</span>' ); |
|
9 | 274 |
?> |
275 |
</h3> |
|
276 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
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> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
278 |
|
9 | 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 |
|
16 | 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>' ); |
|
9 | 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> |
|
18 | 306 |
<# if ( data.badge ) { #> |
307 |
<span class="badge {{ data.badge.color }}">{{ data.badge.label }}</span> |
|
308 |
<# } #> |
|
9 | 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 }}} |
|
16 | 314 |
<# if ( data.actions ) { #> |
315 |
<div class="actions"> |
|
316 |
{{{ data.actions }}} |
|
317 |
</div> |
|
318 |
<# } #> |
|
9 | 319 |
</div> |
320 |
</script> |
|
321 |
||
18 | 322 |
<?php |
323 |
} |
|
16 | 324 |
require_once ABSPATH . 'wp-admin/admin-footer.php'; |