author | ymh <ymh.work@gmail.com> |
Fri, 05 Sep 2025 18:52:52 +0200 | |
changeset 22 | 8c2e4d02f4ef |
parent 21 | 48c4eec2b7e6 |
permissions | -rw-r--r-- |
9 | 1 |
/** |
2 |
* Interactions used by the Site Health modules in WordPress. |
|
3 |
* |
|
4 |
* @output wp-admin/js/site-health.js |
|
5 |
*/ |
|
6 |
||
7 |
/* global ajaxurl, ClipboardJS, SiteHealth, wp */ |
|
8 |
||
18 | 9 |
jQuery( function( $ ) { |
9 | 10 |
|
11 |
var __ = wp.i18n.__, |
|
12 |
_n = wp.i18n._n, |
|
16 | 13 |
sprintf = wp.i18n.sprintf, |
14 |
clipboard = new ClipboardJS( '.site-health-copy-buttons .copy-button' ), |
|
18 | 15 |
isStatusTab = $( '.health-check-body.health-check-status-tab' ).length, |
16 | 16 |
isDebugTab = $( '.health-check-body.health-check-debug-tab' ).length, |
17 |
pathsSizesSection = $( '#health-check-accordion-block-wp-paths-sizes' ), |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
18 |
menuCounterWrapper = $( '#adminmenu .site-health-counter' ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
19 |
menuCounter = $( '#adminmenu .site-health-counter .count' ), |
16 | 20 |
successTimeout; |
9 | 21 |
|
22 |
// Debug information copy section. |
|
23 |
clipboard.on( 'success', function( e ) { |
|
16 | 24 |
var triggerElement = $( e.trigger ), |
25 |
successElement = $( '.success', triggerElement.closest( 'div' ) ); |
|
26 |
||
27 |
// Clear the selection and move focus back to the trigger. |
|
28 |
e.clearSelection(); |
|
29 |
||
30 |
// Show success visual feedback. |
|
31 |
clearTimeout( successTimeout ); |
|
32 |
successElement.removeClass( 'hidden' ); |
|
9 | 33 |
|
16 | 34 |
// Hide success visual feedback after 3 seconds since last success. |
35 |
successTimeout = setTimeout( function() { |
|
36 |
successElement.addClass( 'hidden' ); |
|
37 |
}, 3000 ); |
|
38 |
||
39 |
// Handle success audible feedback. |
|
40 |
wp.a11y.speak( __( 'Site information has been copied to your clipboard.' ) ); |
|
9 | 41 |
} ); |
42 |
||
43 |
// Accordion handling in various areas. |
|
44 |
$( '.health-check-accordion' ).on( 'click', '.health-check-accordion-trigger', function() { |
|
45 |
var isExpanded = ( 'true' === $( this ).attr( 'aria-expanded' ) ); |
|
46 |
||
47 |
if ( isExpanded ) { |
|
48 |
$( this ).attr( 'aria-expanded', 'false' ); |
|
49 |
$( '#' + $( this ).attr( 'aria-controls' ) ).attr( 'hidden', true ); |
|
50 |
} else { |
|
51 |
$( this ).attr( 'aria-expanded', 'true' ); |
|
52 |
$( '#' + $( this ).attr( 'aria-controls' ) ).attr( 'hidden', false ); |
|
53 |
} |
|
54 |
} ); |
|
55 |
||
56 |
// Site Health test handling. |
|
57 |
||
58 |
$( '.site-health-view-passed' ).on( 'click', function() { |
|
59 |
var goodIssuesWrapper = $( '#health-check-issues-good' ); |
|
60 |
||
61 |
goodIssuesWrapper.toggleClass( 'hidden' ); |
|
62 |
$( this ).attr( 'aria-expanded', ! goodIssuesWrapper.hasClass( 'hidden' ) ); |
|
63 |
} ); |
|
64 |
||
65 |
/** |
|
18 | 66 |
* Validates the Site Health test result format. |
67 |
* |
|
68 |
* @since 5.6.0 |
|
69 |
* |
|
70 |
* @param {Object} issue |
|
71 |
* |
|
72 |
* @return {boolean} |
|
73 |
*/ |
|
74 |
function validateIssueData( issue ) { |
|
75 |
// Expected minimum format of a valid SiteHealth test response. |
|
76 |
var minimumExpected = { |
|
77 |
test: 'string', |
|
78 |
label: 'string', |
|
79 |
description: 'string' |
|
80 |
}, |
|
81 |
passed = true, |
|
82 |
key, value, subKey, subValue; |
|
83 |
||
84 |
// If the issue passed is not an object, return a `false` state early. |
|
85 |
if ( 'object' !== typeof( issue ) ) { |
|
86 |
return false; |
|
87 |
} |
|
88 |
||
89 |
// Loop over expected data and match the data types. |
|
90 |
for ( key in minimumExpected ) { |
|
91 |
value = minimumExpected[ key ]; |
|
92 |
||
93 |
if ( 'object' === typeof( value ) ) { |
|
94 |
for ( subKey in value ) { |
|
95 |
subValue = value[ subKey ]; |
|
96 |
||
97 |
if ( 'undefined' === typeof( issue[ key ] ) || |
|
98 |
'undefined' === typeof( issue[ key ][ subKey ] ) || |
|
99 |
subValue !== typeof( issue[ key ][ subKey ] ) |
|
100 |
) { |
|
101 |
passed = false; |
|
102 |
} |
|
103 |
} |
|
104 |
} else { |
|
105 |
if ( 'undefined' === typeof( issue[ key ] ) || |
|
106 |
value !== typeof( issue[ key ] ) |
|
107 |
) { |
|
108 |
passed = false; |
|
109 |
} |
|
110 |
} |
|
111 |
} |
|
112 |
||
113 |
return passed; |
|
114 |
} |
|
115 |
||
116 |
/** |
|
16 | 117 |
* Appends a new issue to the issue list. |
9 | 118 |
* |
119 |
* @since 5.2.0 |
|
120 |
* |
|
121 |
* @param {Object} issue The issue data. |
|
122 |
*/ |
|
16 | 123 |
function appendIssue( issue ) { |
9 | 124 |
var template = wp.template( 'health-check-issue' ), |
125 |
issueWrapper = $( '#health-check-issues-' + issue.status ), |
|
126 |
heading, |
|
127 |
count; |
|
18 | 128 |
|
129 |
/* |
|
130 |
* Validate the issue data format before using it. |
|
131 |
* If the output is invalid, discard it. |
|
132 |
*/ |
|
133 |
if ( ! validateIssueData( issue ) ) { |
|
134 |
return false; |
|
135 |
} |
|
136 |
||
9 | 137 |
SiteHealth.site_status.issues[ issue.status ]++; |
138 |
||
139 |
count = SiteHealth.site_status.issues[ issue.status ]; |
|
140 |
||
18 | 141 |
// If no test name is supplied, append a placeholder for markup references. |
142 |
if ( typeof issue.test === 'undefined' ) { |
|
143 |
issue.test = issue.status + count; |
|
144 |
} |
|
145 |
||
9 | 146 |
if ( 'critical' === issue.status ) { |
16 | 147 |
heading = sprintf( |
148 |
_n( '%s critical issue', '%s critical issues', count ), |
|
149 |
'<span class="issue-count">' + count + '</span>' |
|
150 |
); |
|
9 | 151 |
} else if ( 'recommended' === issue.status ) { |
16 | 152 |
heading = sprintf( |
153 |
_n( '%s recommended improvement', '%s recommended improvements', count ), |
|
154 |
'<span class="issue-count">' + count + '</span>' |
|
155 |
); |
|
9 | 156 |
} else if ( 'good' === issue.status ) { |
16 | 157 |
heading = sprintf( |
158 |
_n( '%s item with no issues detected', '%s items with no issues detected', count ), |
|
159 |
'<span class="issue-count">' + count + '</span>' |
|
160 |
); |
|
9 | 161 |
} |
162 |
||
163 |
if ( heading ) { |
|
164 |
$( '.site-health-issue-count-title', issueWrapper ).html( heading ); |
|
165 |
} |
|
166 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
167 |
menuCounter.text( SiteHealth.site_status.issues.critical ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
168 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
169 |
if ( 0 < parseInt( SiteHealth.site_status.issues.critical, 0 ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
170 |
$( '#health-check-issues-critical' ).removeClass( 'hidden' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
171 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
172 |
menuCounterWrapper.removeClass( 'count-0' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
173 |
} else { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
174 |
menuCounterWrapper.addClass( 'count-0' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
175 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
176 |
if ( 0 < parseInt( SiteHealth.site_status.issues.recommended, 0 ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
177 |
$( '#health-check-issues-recommended' ).removeClass( 'hidden' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
178 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
179 |
|
9 | 180 |
$( '.issues', '#health-check-issues-' + issue.status ).append( template( issue ) ); |
181 |
} |
|
182 |
||
183 |
/** |
|
16 | 184 |
* Updates site health status indicator as asynchronous tests are run and returned. |
9 | 185 |
* |
186 |
* @since 5.2.0 |
|
187 |
*/ |
|
16 | 188 |
function recalculateProgression() { |
9 | 189 |
var r, c, pct; |
190 |
var $progress = $( '.site-health-progress' ); |
|
16 | 191 |
var $wrapper = $progress.closest( '.site-health-progress-wrapper' ); |
192 |
var $progressLabel = $( '.site-health-progress-label', $wrapper ); |
|
9 | 193 |
var $circle = $( '.site-health-progress svg #bar' ); |
16 | 194 |
var totalTests = parseInt( SiteHealth.site_status.issues.good, 0 ) + |
18 | 195 |
parseInt( SiteHealth.site_status.issues.recommended, 0 ) + |
196 |
( parseInt( SiteHealth.site_status.issues.critical, 0 ) * 1.5 ); |
|
16 | 197 |
var failedTests = ( parseInt( SiteHealth.site_status.issues.recommended, 0 ) * 0.5 ) + |
18 | 198 |
( parseInt( SiteHealth.site_status.issues.critical, 0 ) * 1.5 ); |
9 | 199 |
var val = 100 - Math.ceil( ( failedTests / totalTests ) * 100 ); |
200 |
||
201 |
if ( 0 === totalTests ) { |
|
202 |
$progress.addClass( 'hidden' ); |
|
203 |
return; |
|
204 |
} |
|
205 |
||
16 | 206 |
$wrapper.removeClass( 'loading' ); |
9 | 207 |
|
208 |
r = $circle.attr( 'r' ); |
|
209 |
c = Math.PI * ( r * 2 ); |
|
210 |
||
211 |
if ( 0 > val ) { |
|
212 |
val = 0; |
|
213 |
} |
|
214 |
if ( 100 < val ) { |
|
215 |
val = 100; |
|
216 |
} |
|
217 |
||
18 | 218 |
pct = ( ( 100 - val ) / 100 ) * c + 'px'; |
9 | 219 |
|
220 |
$circle.css( { strokeDashoffset: pct } ); |
|
221 |
||
16 | 222 |
if ( 80 <= val && 0 === parseInt( SiteHealth.site_status.issues.critical, 0 ) ) { |
223 |
$wrapper.addClass( 'green' ).removeClass( 'orange' ); |
|
9 | 224 |
|
16 | 225 |
$progressLabel.text( __( 'Good' ) ); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
226 |
announceTestsProgression( 'good' ); |
16 | 227 |
} else { |
228 |
$wrapper.addClass( 'orange' ).removeClass( 'green' ); |
|
229 |
||
230 |
$progressLabel.text( __( 'Should be improved' ) ); |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
231 |
announceTestsProgression( 'improvable' ); |
9 | 232 |
} |
233 |
||
18 | 234 |
if ( isStatusTab ) { |
9 | 235 |
$.post( |
236 |
ajaxurl, |
|
237 |
{ |
|
238 |
'action': 'health-check-site-status-result', |
|
239 |
'_wpnonce': SiteHealth.nonce.site_status_result, |
|
240 |
'counts': SiteHealth.site_status.issues |
|
241 |
} |
|
242 |
); |
|
243 |
||
16 | 244 |
if ( 100 === val ) { |
245 |
$( '.site-status-all-clear' ).removeClass( 'hide' ); |
|
246 |
$( '.site-status-has-issues' ).addClass( 'hide' ); |
|
247 |
} |
|
9 | 248 |
} |
249 |
} |
|
250 |
||
251 |
/** |
|
16 | 252 |
* Queues the next asynchronous test when we're ready to run it. |
9 | 253 |
* |
254 |
* @since 5.2.0 |
|
255 |
*/ |
|
256 |
function maybeRunNextAsyncTest() { |
|
257 |
var doCalculation = true; |
|
258 |
||
259 |
if ( 1 <= SiteHealth.site_status.async.length ) { |
|
260 |
$.each( SiteHealth.site_status.async, function() { |
|
261 |
var data = { |
|
262 |
'action': 'health-check-' + this.test.replace( '_', '-' ), |
|
263 |
'_wpnonce': SiteHealth.nonce.site_status |
|
264 |
}; |
|
265 |
||
266 |
if ( this.completed ) { |
|
267 |
return true; |
|
268 |
} |
|
269 |
||
270 |
doCalculation = false; |
|
271 |
||
272 |
this.completed = true; |
|
273 |
||
18 | 274 |
if ( 'undefined' !== typeof( this.has_rest ) && this.has_rest ) { |
275 |
wp.apiRequest( { |
|
276 |
url: wp.url.addQueryArgs( this.test, { _locale: 'user' } ), |
|
277 |
headers: this.headers |
|
278 |
} ) |
|
279 |
.done( function( response ) { |
|
280 |
/** This filter is documented in wp-admin/includes/class-wp-site-health.php */ |
|
281 |
appendIssue( wp.hooks.applyFilters( 'site_status_test_result', response ) ); |
|
282 |
} ) |
|
283 |
.fail( function( response ) { |
|
284 |
var description; |
|
285 |
||
286 |
if ( 'undefined' !== typeof( response.responseJSON ) && 'undefined' !== typeof( response.responseJSON.message ) ) { |
|
287 |
description = response.responseJSON.message; |
|
288 |
} else { |
|
289 |
description = __( 'No details available' ); |
|
290 |
} |
|
291 |
||
292 |
addFailedSiteHealthCheckNotice( this.url, description ); |
|
293 |
} ) |
|
294 |
.always( function() { |
|
295 |
maybeRunNextAsyncTest(); |
|
296 |
} ); |
|
297 |
} else { |
|
298 |
$.post( |
|
299 |
ajaxurl, |
|
300 |
data |
|
301 |
).done( function( response ) { |
|
16 | 302 |
/** This filter is documented in wp-admin/includes/class-wp-site-health.php */ |
303 |
appendIssue( wp.hooks.applyFilters( 'site_status_test_result', response.data ) ); |
|
18 | 304 |
} ).fail( function( response ) { |
305 |
var description; |
|
306 |
||
307 |
if ( 'undefined' !== typeof( response.responseJSON ) && 'undefined' !== typeof( response.responseJSON.message ) ) { |
|
308 |
description = response.responseJSON.message; |
|
309 |
} else { |
|
310 |
description = __( 'No details available' ); |
|
311 |
} |
|
312 |
||
313 |
addFailedSiteHealthCheckNotice( this.url, description ); |
|
314 |
} ).always( function() { |
|
9 | 315 |
maybeRunNextAsyncTest(); |
18 | 316 |
} ); |
317 |
} |
|
9 | 318 |
|
319 |
return false; |
|
320 |
} ); |
|
321 |
} |
|
322 |
||
323 |
if ( doCalculation ) { |
|
16 | 324 |
recalculateProgression(); |
9 | 325 |
} |
326 |
} |
|
327 |
||
18 | 328 |
/** |
329 |
* Add the details of a failed asynchronous test to the list of test results. |
|
330 |
* |
|
331 |
* @since 5.6.0 |
|
332 |
*/ |
|
333 |
function addFailedSiteHealthCheckNotice( url, description ) { |
|
334 |
var issue; |
|
335 |
||
336 |
issue = { |
|
337 |
'status': 'recommended', |
|
338 |
'label': __( 'A test is unavailable' ), |
|
339 |
'badge': { |
|
340 |
'color': 'red', |
|
341 |
'label': __( 'Unavailable' ) |
|
342 |
}, |
|
343 |
'description': '<p>' + url + '</p><p>' + description + '</p>', |
|
344 |
'actions': '' |
|
345 |
}; |
|
346 |
||
347 |
/** This filter is documented in wp-admin/includes/class-wp-site-health.php */ |
|
348 |
appendIssue( wp.hooks.applyFilters( 'site_status_test_result', issue ) ); |
|
349 |
} |
|
350 |
||
351 |
if ( 'undefined' !== typeof SiteHealth ) { |
|
9 | 352 |
if ( 0 === SiteHealth.site_status.direct.length && 0 === SiteHealth.site_status.async.length ) { |
16 | 353 |
recalculateProgression(); |
9 | 354 |
} else { |
355 |
SiteHealth.site_status.issues = { |
|
356 |
'good': 0, |
|
357 |
'recommended': 0, |
|
358 |
'critical': 0 |
|
359 |
}; |
|
360 |
} |
|
361 |
||
362 |
if ( 0 < SiteHealth.site_status.direct.length ) { |
|
363 |
$.each( SiteHealth.site_status.direct, function() { |
|
16 | 364 |
appendIssue( this ); |
9 | 365 |
} ); |
366 |
} |
|
367 |
||
368 |
if ( 0 < SiteHealth.site_status.async.length ) { |
|
18 | 369 |
maybeRunNextAsyncTest(); |
9 | 370 |
} else { |
16 | 371 |
recalculateProgression(); |
9 | 372 |
} |
373 |
} |
|
374 |
||
375 |
function getDirectorySizes() { |
|
376 |
var timestamp = ( new Date().getTime() ); |
|
377 |
||
378 |
// After 3 seconds announce that we're still waiting for directory sizes. |
|
379 |
var timeout = window.setTimeout( function() { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
380 |
announceTestsProgression( 'waiting-for-directory-sizes' ); |
9 | 381 |
}, 3000 ); |
382 |
||
18 | 383 |
wp.apiRequest( { |
384 |
path: '/wp-site-health/v1/directory-sizes' |
|
9 | 385 |
} ).done( function( response ) { |
18 | 386 |
updateDirSizes( response || {} ); |
9 | 387 |
} ).always( function() { |
388 |
var delay = ( new Date().getTime() ) - timestamp; |
|
389 |
||
390 |
$( '.health-check-wp-paths-sizes.spinner' ).css( 'visibility', 'hidden' ); |
|
391 |
||
18 | 392 |
if ( delay > 3000 ) { |
16 | 393 |
/* |
394 |
* We have announced that we're waiting. |
|
395 |
* Announce that we're ready after giving at least 3 seconds |
|
396 |
* for the first announcement to be read out, or the two may collide. |
|
397 |
*/ |
|
9 | 398 |
if ( delay > 6000 ) { |
399 |
delay = 0; |
|
400 |
} else { |
|
401 |
delay = 6500 - delay; |
|
402 |
} |
|
403 |
||
404 |
window.setTimeout( function() { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
405 |
recalculateProgression(); |
9 | 406 |
}, delay ); |
407 |
} else { |
|
408 |
// Cancel the announcement. |
|
409 |
window.clearTimeout( timeout ); |
|
410 |
} |
|
411 |
||
412 |
$( document ).trigger( 'site-health-info-dirsizes-done' ); |
|
413 |
} ); |
|
414 |
} |
|
415 |
||
416 |
function updateDirSizes( data ) { |
|
417 |
var copyButton = $( 'button.button.copy-button' ); |
|
16 | 418 |
var clipboardText = copyButton.attr( 'data-clipboard-text' ); |
9 | 419 |
|
420 |
$.each( data, function( name, value ) { |
|
421 |
var text = value.debug || value.size; |
|
422 |
||
423 |
if ( typeof text !== 'undefined' ) { |
|
16 | 424 |
clipboardText = clipboardText.replace( name + ': loading...', name + ': ' + text ); |
9 | 425 |
} |
426 |
} ); |
|
427 |
||
16 | 428 |
copyButton.attr( 'data-clipboard-text', clipboardText ); |
9 | 429 |
|
430 |
pathsSizesSection.find( 'td[class]' ).each( function( i, element ) { |
|
431 |
var td = $( element ); |
|
432 |
var name = td.attr( 'class' ); |
|
433 |
||
434 |
if ( data.hasOwnProperty( name ) && data[ name ].size ) { |
|
435 |
td.text( data[ name ].size ); |
|
436 |
} |
|
437 |
} ); |
|
438 |
} |
|
439 |
||
440 |
if ( isDebugTab ) { |
|
441 |
if ( pathsSizesSection.length ) { |
|
442 |
getDirectorySizes(); |
|
443 |
} else { |
|
16 | 444 |
recalculateProgression(); |
9 | 445 |
} |
446 |
} |
|
18 | 447 |
|
448 |
// Trigger a class toggle when the extended menu button is clicked. |
|
449 |
$( '.health-check-offscreen-nav-wrapper' ).on( 'click', function() { |
|
450 |
$( this ).toggleClass( 'visible' ); |
|
451 |
} ); |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
452 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
453 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
454 |
* Announces to assistive technologies the tests progression status. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
455 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
456 |
* @since 6.4.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
457 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
458 |
* @param {string} type The type of message to be announced. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
459 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
460 |
* @return {void} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
461 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
462 |
function announceTestsProgression( type ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
463 |
// Only announce the messages in the Site Health pages. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
464 |
if ( 'site-health' !== SiteHealth.screen ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
465 |
return; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
466 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
467 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
468 |
switch ( type ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
469 |
case 'good': |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
470 |
wp.a11y.speak( __( 'All site health tests have finished running. Your site is looking good.' ) ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
471 |
break; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
472 |
case 'improvable': |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
473 |
wp.a11y.speak( __( 'All site health tests have finished running. There are items that should be addressed.' ) ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
474 |
break; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
475 |
case 'waiting-for-directory-sizes': |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
476 |
wp.a11y.speak( __( 'Running additional tests... please wait.' ) ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
477 |
break; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
478 |
default: |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
479 |
return; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
480 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
481 |
} |
9 | 482 |
} ); |