From dbc8d76a9f0fb15bd5546ce5d4dd78a8f497ae2f Mon Sep 17 00:00:00 2001 From: joedolson Date: Mon, 15 Nov 2021 22:24:01 +0000 Subject: [PATCH] Taxonomy: Display update notices when adding terms. Display notice and announce to screen readers when a new term is added. Props manishamakhija, birgire, dilipbheda, afercia, hellofromTonya. Fixes #42937. Built from https://develop.svn.wordpress.org/trunk@52170 git-svn-id: http://core.svn.wordpress.org/trunk@51762 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/ajax-actions.php | 10 ++++++++++ wp-includes/js/wp-ajax-response.js | 12 ++++++++++-- wp-includes/js/wp-ajax-response.min.js | 2 +- wp-includes/version.php | 2 +- 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/wp-admin/includes/ajax-actions.php b/wp-admin/includes/ajax-actions.php index 1ba480f2f1..191e5b54dd 100644 --- a/wp-admin/includes/ajax-actions.php +++ b/wp-admin/includes/ajax-actions.php @@ -1102,9 +1102,19 @@ function wp_ajax_add_tag() { $wp_list_table->single_row( $tag ); $parents = ob_get_clean(); + require ABSPATH . 'wp-admin/includes/edit-tag-messages.php'; + + $message = ''; + if ( isset( $messages[ $tax->name ][1] ) ) { + $message = $messages[ $tax->name ][1]; + } elseif ( isset( $messages['_item'][1] ) ) { + $message = $messages['_item'][1]; + } + $x->add( array( 'what' => 'taxonomy', + 'data' => $message, 'supplemental' => compact( 'parents', 'noparents' ), ) ); diff --git a/wp-includes/js/wp-ajax-response.js b/wp-includes/js/wp-ajax-response.js index 38816f3c38..659b91e023 100644 --- a/wp-includes/js/wp-ajax-response.js +++ b/wp-includes/js/wp-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 = ''; + var parsed = {}, re = jQuery('#' + r).empty(), err = '', successmsg = ''; if ( x && typeof x === 'object' && x.getElementsByTagName('wp_ajax') ) { parsed.responses = []; @@ -27,6 +27,7 @@ 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(); + successmsg += response.data; response.supplemental = {}; if ( !jQuery( 'supplemental', child ).children().each( function() { response.supplemental[this.nodeName] = jQuery(this).text(); @@ -46,7 +47,14 @@ window.wpAjax = jQuery.extend( { } ).length ) { response.errors = false; } parsed.responses.push( response ); } ); - if ( err.length ) { re.html( '
' + err + '
' ); } + if ( err.length ) { + re.html( '
' + err + '
' ); + wp.a11y.speak( err ); + } else { + re.html( '

' + successmsg + '

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

' + x + '

'); } diff --git a/wp-includes/js/wp-ajax-response.min.js b/wp-includes/js/wp-ajax-response.min.js index 7b3a1eda22..985293277a 100644 --- a/wp-includes/js/wp-ajax-response.min.js +++ b/wp-includes/js/wp-ajax-response.min.js @@ -1,2 +1,2 @@ /*! This file is auto-generated */ -window.wpAjax=jQuery.extend({unserialize:function(e){var r,t,n,i,a={};if(!e)return a;for(n in t=(e=(r=e.split("?"))[1]?r[1]:e).split("&"))"function"==typeof t.hasOwnProperty&&!t.hasOwnProperty(n)||(a[(i=t[n].split("="))[0]]=i[1]);return a},parseAjaxResponse:function(i,e,a){var o={},e=jQuery("#"+e).empty(),s="";return i&&"object"==typeof i&&i.getElementsByTagName("wp_ajax")?(o.responses=[],o.errors=!1,jQuery("response",i).each(function(){var e=jQuery(this),r=jQuery(this.firstChild),n={action:e.attr("action"),what:r.get(0).nodeName,id:r.attr("id"),oldId:r.attr("old_id"),position:r.attr("position")};n.data=jQuery("response_data",r).text(),n.supplemental={},jQuery("supplemental",r).children().each(function(){n.supplemental[this.nodeName]=jQuery(this).text()}).length||(n.supplemental=!1),n.errors=[],jQuery("wp_error",r).each(function(){var e=jQuery(this).attr("code"),r={code:e,message:this.firstChild.nodeValue,data:!1},t=jQuery('wp_error_data[code="'+e+'"]',i);t&&(r.data=t.get()),(t=jQuery("form-field",t).text())&&(e=t),a&&wpAjax.invalidateForm(jQuery("#"+a+' :input[name="'+e+'"]').parents(".form-field:first")),s+="

"+r.message+"

",n.errors.push(r),o.errors=!0}).length||(n.errors=!1),o.responses.push(n)}),s.length&&e.html('
'+s+"
"),o):isNaN(i)?!e.html('

'+i+"

"):-1===(i=parseInt(i,10))?!e.html('

'+wpAjax.noPerm+"

"):0!==i||!e.html('

'+wpAjax.broken+"

")},invalidateForm:function(e){return jQuery(e).addClass("form-invalid").find("input").one("change wp-check-valid-field",function(){jQuery(this).closest(".form-invalid").removeClass("form-invalid")})},validateForm:function(e){return e=jQuery(e),!wpAjax.invalidateForm(e.find(".form-required").filter(function(){return""===jQuery("input:visible",this).val()})).length}},wpAjax||{noPerm:"Sorry, you are not allowed to do that.",broken:"Something went wrong."}),jQuery(function(e){e("form.validate").on("submit",function(){return wpAjax.validateForm(e(this))})}); \ No newline at end of file +window.wpAjax=jQuery.extend({unserialize:function(e){var r,t,a,i,n={};if(!e)return n;for(a in t=(e=(r=e.split("?"))[1]?r[1]:e).split("&"))"function"==typeof t.hasOwnProperty&&!t.hasOwnProperty(a)||(n[(i=t[a].split("="))[0]]=i[1]);return n},parseAjaxResponse:function(i,e,n){var o={},e=jQuery("#"+e).empty(),s="",t="";return i&&"object"==typeof i&&i.getElementsByTagName("wp_ajax")?(o.responses=[],o.errors=!1,jQuery("response",i).each(function(){var e=jQuery(this),r=jQuery(this.firstChild),a={action:e.attr("action"),what:r.get(0).nodeName,id:r.attr("id"),oldId:r.attr("old_id"),position:r.attr("position")};a.data=jQuery("response_data",r).text(),t+=a.data,a.supplemental={},jQuery("supplemental",r).children().each(function(){a.supplemental[this.nodeName]=jQuery(this).text()}).length||(a.supplemental=!1),a.errors=[],jQuery("wp_error",r).each(function(){var e=jQuery(this).attr("code"),r={code:e,message:this.firstChild.nodeValue,data:!1},t=jQuery('wp_error_data[code="'+e+'"]',i);t&&(r.data=t.get()),(t=jQuery("form-field",t).text())&&(e=t),n&&wpAjax.invalidateForm(jQuery("#"+n+' :input[name="'+e+'"]').parents(".form-field:first")),s+="

"+r.message+"

",a.errors.push(r),o.errors=!0}).length||(a.errors=!1),o.responses.push(a)}),s.length?(e.html('
'+s+"
"),wp.a11y.speak(s)):(e.html('

'+t+"

"),jQuery(document).trigger("wp-updates-notice-added"),wp.a11y.speak(t)),o):isNaN(i)?!e.html('

'+i+"

"):-1===(i=parseInt(i,10))?!e.html('

'+wpAjax.noPerm+"

"):0!==i||!e.html('

'+wpAjax.broken+"

")},invalidateForm:function(e){return jQuery(e).addClass("form-invalid").find("input").one("change wp-check-valid-field",function(){jQuery(this).closest(".form-invalid").removeClass("form-invalid")})},validateForm:function(e){return e=jQuery(e),!wpAjax.invalidateForm(e.find(".form-required").filter(function(){return""===jQuery("input:visible",this).val()})).length}},wpAjax||{noPerm:"Sorry, you are not allowed to do that.",broken:"Something went wrong."}),jQuery(function(e){e("form.validate").on("submit",function(){return wpAjax.validateForm(e(this))})}); \ No newline at end of file diff --git a/wp-includes/version.php b/wp-includes/version.php index 8660ef48d9..a5b673cda3 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '5.9-alpha-52169'; +$wp_version = '5.9-alpha-52170'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.