summaryrefslogtreecommitdiffstatshomepage
path: root/src/js/_enqueues/lib/ajax-response.js
diff options
context:
space:
mode:
authorJoe Dolson <joedolson@git.wordpress.org>2022-07-16 01:06:40 +0000
committerJoe Dolson <joedolson@git.wordpress.org>2022-07-16 01:06:40 +0000
commitb977f5b18f8445c7e26c60b4ba506d5fdbaa817d (patch)
treece7ffa6e30bb79c89f84bdfa8dfcecb3e59699b1 /src/js/_enqueues/lib/ajax-response.js
parent93414818116bf1da608af7d6f21e345825398d32 (diff)
downloadwordpress-b977f5b18f8445c7e26c60b4ba506d5fdbaa817d.tar.gz
wordpress-b977f5b18f8445c7e26c60b4ba506d5fdbaa817d.zip
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
Diffstat (limited to 'src/js/_enqueues/lib/ajax-response.js')
-rw-r--r--src/js/_enqueues/lib/ajax-response.js20
1 files 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( '<div class="error">' + err + '</div>' );
+ re.html( '<div class="notice notice-error">' + err + '</div>' );
wp.a11y.speak( err );
} else if ( noticeMessage.length ) {
- re.html( '<div class="updated notice is-dismissible"><p>' + noticeMessage + '</p></div>');
+ re.html( '<div class="notice notice-success is-dismissible"><p>' + noticeMessage + '</p></div>');
jQuery(document).trigger( 'wp-updates-notice-added' );
wp.a11y.speak( noticeMessage );
}
return parsed;
}
- if ( isNaN(x) ) { return !re.html('<div class="error"><p>' + x + '</p></div>'); }
- x = parseInt(x,10);
- if ( -1 === x ) { return !re.html('<div class="error"><p>' + wpAjax.noPerm + '</p></div>'); }
- else if ( 0 === x ) { return !re.html('<div class="error"><p>' + wpAjax.broken + '</p></div>'); }
+ if ( isNaN( x ) ) {
+ wp.a11y.speak( x );
+ return ! re.html( '<div class="notice notice-error"><p>' + x + '</p></div>' );
+ }
+ x = parseInt( x, 10 );
+ if ( -1 === x ) {
+ wp.a11y.speak( wpAjax.noPerm );
+ return ! re.html( '<div class="notice notice-error"><p>' + wpAjax.noPerm + '</p></div>' );
+ } else if ( 0 === x ) {
+ wp.a11y.speak( wpAjax.broken );
+ return ! re.html( '<div class="notice notice-error"><p>' + wpAjax.broken + '</p></div>' );
+ }
return true;
},
invalidateForm: function ( selector ) {