From b977f5b18f8445c7e26c60b4ba506d5fdbaa817d Mon Sep 17 00:00:00 2001 From: Joe Dolson Date: Sat, 16 Jul 2022 01:06:40 +0000 Subject: [PATCH] Administration: Audible messages on AJAX error cases. Issues appropriate audible messages via `wp.a11y.speak()` when `ajax-response.js` generates an error via `wp_die()`. Props afercia, alexstine. Fixes #54483. git-svn-id: https://develop.svn.wordpress.org/trunk@53709 602fd350-edb4-49c9-b593-d223f7449a82 --- src/js/_enqueues/lib/ajax-response.js | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/js/_enqueues/lib/ajax-response.js b/src/js/_enqueues/lib/ajax-response.js index f1b0dcd361..3fd6ff0314 100644 --- a/src/js/_enqueues/lib/ajax-response.js +++ b/src/js/_enqueues/lib/ajax-response.js @@ -53,19 +53,27 @@ window.wpAjax = jQuery.extend( { parsed.responses.push( response ); } ); if ( err.length ) { - re.html( '
' + err + '
' ); + re.html( '
' + err + '
' ); wp.a11y.speak( err ); } else if ( noticeMessage.length ) { - re.html( '

' + noticeMessage + '

'); + re.html( '

' + noticeMessage + '

'); jQuery(document).trigger( 'wp-updates-notice-added' ); wp.a11y.speak( noticeMessage ); } return parsed; } - if ( isNaN(x) ) { return !re.html('

' + x + '

'); } - x = parseInt(x,10); - if ( -1 === x ) { return !re.html('

' + wpAjax.noPerm + '

'); } - else if ( 0 === x ) { return !re.html('

' + wpAjax.broken + '

'); } + if ( isNaN( x ) ) { + wp.a11y.speak( x ); + return ! re.html( '

' + x + '

' ); + } + x = parseInt( x, 10 ); + if ( -1 === x ) { + wp.a11y.speak( wpAjax.noPerm ); + return ! re.html( '

' + wpAjax.noPerm + '

' ); + } else if ( 0 === x ) { + wp.a11y.speak( wpAjax.broken ); + return ! re.html( '

' + wpAjax.broken + '

' ); + } return true; }, invalidateForm: function ( selector ) {