Skip to content

Commit b977f5b

Browse files
committed
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
1 parent 9341481 commit b977f5b

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/js/_enqueues/lib/ajax-response.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,19 +53,27 @@ window.wpAjax = jQuery.extend( {
5353
parsed.responses.push( response );
5454
} );
5555
if ( err.length ) {
56-
re.html( '<div class="error">' + err + '</div>' );
56+
re.html( '<div class="notice notice-error">' + err + '</div>' );
5757
wp.a11y.speak( err );
5858
} else if ( noticeMessage.length ) {
59-
re.html( '<div class="updated notice is-dismissible"><p>' + noticeMessage + '</p></div>');
59+
re.html( '<div class="notice notice-success is-dismissible"><p>' + noticeMessage + '</p></div>');
6060
jQuery(document).trigger( 'wp-updates-notice-added' );
6161
wp.a11y.speak( noticeMessage );
6262
}
6363
return parsed;
6464
}
65-
if ( isNaN(x) ) { return !re.html('<div class="error"><p>' + x + '</p></div>'); }
66-
x = parseInt(x,10);
67-
if ( -1 === x ) { return !re.html('<div class="error"><p>' + wpAjax.noPerm + '</p></div>'); }
68-
else if ( 0 === x ) { return !re.html('<div class="error"><p>' + wpAjax.broken + '</p></div>'); }
65+
if ( isNaN( x ) ) {
66+
wp.a11y.speak( x );
67+
return ! re.html( '<div class="notice notice-error"><p>' + x + '</p></div>' );
68+
}
69+
x = parseInt( x, 10 );
70+
if ( -1 === x ) {
71+
wp.a11y.speak( wpAjax.noPerm );
72+
return ! re.html( '<div class="notice notice-error"><p>' + wpAjax.noPerm + '</p></div>' );
73+
} else if ( 0 === x ) {
74+
wp.a11y.speak( wpAjax.broken );
75+
return ! re.html( '<div class="notice notice-error"><p>' + wpAjax.broken + '</p></div>' );
76+
}
6977
return true;
7078
},
7179
invalidateForm: function ( selector ) {

0 commit comments

Comments
 (0)