diff --git a/src/js/_enqueues/lib/ajax-response.js b/src/js/_enqueues/lib/ajax-response.js index b764823742..f1b0dcd361 100644 --- a/src/js/_enqueues/lib/ajax-response.js +++ b/src/js/_enqueues/lib/ajax-response.js @@ -18,7 +18,7 @@ window.wpAjax = jQuery.extend( { return r; }, parseAjaxResponse: function( x, r, e ) { // 1 = good, 0 = strange (bad data?), -1 = you lack permission. - var parsed = {}, re = jQuery('#' + r).empty(), err = '', successmsg = ''; + var parsed = {}, re = jQuery('#' + r).empty(), err = '', noticeMessage = ''; if ( x && typeof x === 'object' && x.getElementsByTagName('wp_ajax') ) { parsed.responses = []; @@ -27,11 +27,14 @@ window.wpAjax = jQuery.extend( { var th = jQuery(this), child = jQuery(this.firstChild), response; response = { action: th.attr('action'), what: child.get(0).nodeName, id: child.attr('id'), oldId: child.attr('old_id'), position: child.attr('position') }; response.data = jQuery( 'response_data', child ).text(); - if ( jQuery( 'body' ).hasClass( 'edit-tags-php' ) ) { - successmsg += response.data; - } response.supplemental = {}; if ( !jQuery( 'supplemental', child ).children().each( function() { + + if ( this.nodeName === 'notice' ) { + noticeMessage += jQuery(this).text(); + return; + } + response.supplemental[this.nodeName] = jQuery(this).text(); } ).length ) { response.supplemental = false; } response.errors = []; @@ -52,10 +55,10 @@ window.wpAjax = jQuery.extend( { if ( err.length ) { re.html( '
' + err + '
' ); wp.a11y.speak( err ); - } else if ( successmsg.length ) { - re.html( '

' + successmsg + '

'); + } else if ( noticeMessage.length ) { + re.html( '

' + noticeMessage + '

'); jQuery(document).trigger( 'wp-updates-notice-added' ); - wp.a11y.speak( successmsg ); + wp.a11y.speak( noticeMessage ); } return parsed; } diff --git a/src/wp-admin/includes/ajax-actions.php b/src/wp-admin/includes/ajax-actions.php index f600ef3d1b..f3196af31a 100644 --- a/src/wp-admin/includes/ajax-actions.php +++ b/src/wp-admin/includes/ajax-actions.php @@ -1121,7 +1121,11 @@ function wp_ajax_add_tag() { array( 'what' => 'taxonomy', 'data' => $message, - 'supplemental' => compact( 'parents', 'noparents' ), + 'supplemental' => array( + 'parents' => $parents, + 'noparents' => $noparents, + 'notice' => $message, + ), ) );