mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-12 13:44:21 +01:00
Administration: Remove term page check from ajax-response.js
.
Replace hard coded check for the term creation page in `_enqueues/lib/ajax-response.js` with a check for a notification to display in the AJAX response data. Follow up to [52170], [52672]. Props SergeyBiryukov, ryokuhi, johnregan3, sabernhardt, joedolson. Fixes #55078. See #54955. Built from https://develop.svn.wordpress.org/trunk@53123 git-svn-id: http://core.svn.wordpress.org/trunk@52712 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
bdd42a3e74
commit
ce1dd08c07
@ -1121,7 +1121,11 @@ function wp_ajax_add_tag() {
|
|||||||
array(
|
array(
|
||||||
'what' => 'taxonomy',
|
'what' => 'taxonomy',
|
||||||
'data' => $message,
|
'data' => $message,
|
||||||
'supplemental' => compact( 'parents', 'noparents' ),
|
'supplemental' => array(
|
||||||
|
'parents' => $parents,
|
||||||
|
'noparents' => $noparents,
|
||||||
|
'notice' => $message,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ window.wpAjax = jQuery.extend( {
|
|||||||
return r;
|
return r;
|
||||||
},
|
},
|
||||||
parseAjaxResponse: function( x, r, e ) { // 1 = good, 0 = strange (bad data?), -1 = you lack permission.
|
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') ) {
|
if ( x && typeof x === 'object' && x.getElementsByTagName('wp_ajax') ) {
|
||||||
parsed.responses = [];
|
parsed.responses = [];
|
||||||
@ -27,11 +27,14 @@ window.wpAjax = jQuery.extend( {
|
|||||||
var th = jQuery(this), child = jQuery(this.firstChild), response;
|
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 = { 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();
|
response.data = jQuery( 'response_data', child ).text();
|
||||||
if ( jQuery( 'body' ).hasClass( 'edit-tags-php' ) ) {
|
|
||||||
successmsg += response.data;
|
|
||||||
}
|
|
||||||
response.supplemental = {};
|
response.supplemental = {};
|
||||||
if ( !jQuery( 'supplemental', child ).children().each( function() {
|
if ( !jQuery( 'supplemental', child ).children().each( function() {
|
||||||
|
|
||||||
|
if ( this.nodeName === 'notice' ) {
|
||||||
|
noticeMessage += jQuery(this).text();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
response.supplemental[this.nodeName] = jQuery(this).text();
|
response.supplemental[this.nodeName] = jQuery(this).text();
|
||||||
} ).length ) { response.supplemental = false; }
|
} ).length ) { response.supplemental = false; }
|
||||||
response.errors = [];
|
response.errors = [];
|
||||||
@ -52,10 +55,10 @@ window.wpAjax = jQuery.extend( {
|
|||||||
if ( err.length ) {
|
if ( err.length ) {
|
||||||
re.html( '<div class="error">' + err + '</div>' );
|
re.html( '<div class="error">' + err + '</div>' );
|
||||||
wp.a11y.speak( err );
|
wp.a11y.speak( err );
|
||||||
} else if ( successmsg.length ) {
|
} else if ( noticeMessage.length ) {
|
||||||
re.html( '<div class="updated notice is-dismissible"><p>' + successmsg + '</p></div>');
|
re.html( '<div class="updated notice is-dismissible"><p>' + noticeMessage + '</p></div>');
|
||||||
jQuery(document).trigger( 'wp-updates-notice-added' );
|
jQuery(document).trigger( 'wp-updates-notice-added' );
|
||||||
wp.a11y.speak( successmsg );
|
wp.a11y.speak( noticeMessage );
|
||||||
}
|
}
|
||||||
return parsed;
|
return parsed;
|
||||||
}
|
}
|
||||||
|
2
wp-includes/js/wp-ajax-response.min.js
vendored
2
wp-includes/js/wp-ajax-response.min.js
vendored
@ -1,2 +1,2 @@
|
|||||||
/*! This file is auto-generated */
|
/*! This file is auto-generated */
|
||||||
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(),jQuery("body").hasClass("edit-tags-php")&&(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+="<p>"+r.message+"</p>",a.errors.push(r),o.errors=!0}).length||(a.errors=!1),o.responses.push(a)}),s.length?(e.html('<div class="error">'+s+"</div>"),wp.a11y.speak(s)):t.length&&(e.html('<div class="updated notice is-dismissible"><p>'+t+"</p></div>"),jQuery(document).trigger("wp-updates-notice-added"),wp.a11y.speak(t)),o):isNaN(i)?!e.html('<div class="error"><p>'+i+"</p></div>"):-1===(i=parseInt(i,10))?!e.html('<div class="error"><p>'+wpAjax.noPerm+"</p></div>"):0!==i||!e.html('<div class="error"><p>'+wpAjax.broken+"</p></div>")},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))})});
|
window.wpAjax=jQuery.extend({unserialize:function(e){var r,t,i,a,n={};if(!e)return n;for(i in t=(e=(r=e.split("?"))[1]?r[1]:e).split("&"))"function"==typeof t.hasOwnProperty&&!t.hasOwnProperty(i)||(n[(a=t[i].split("="))[0]]=a[1]);return n},parseAjaxResponse:function(a,e,n){var o={},e=jQuery("#"+e).empty(),s="",t="";return a&&"object"==typeof a&&a.getElementsByTagName("wp_ajax")?(o.responses=[],o.errors=!1,jQuery("response",a).each(function(){var e=jQuery(this),r=jQuery(this.firstChild),i={action:e.attr("action"),what:r.get(0).nodeName,id:r.attr("id"),oldId:r.attr("old_id"),position:r.attr("position")};i.data=jQuery("response_data",r).text(),i.supplemental={},jQuery("supplemental",r).children().each(function(){"notice"===this.nodeName?t+=jQuery(this).text():i.supplemental[this.nodeName]=jQuery(this).text()}).length||(i.supplemental=!1),i.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+'"]',a);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+="<p>"+r.message+"</p>",i.errors.push(r),o.errors=!0}).length||(i.errors=!1),o.responses.push(i)}),s.length?(e.html('<div class="error">'+s+"</div>"),wp.a11y.speak(s)):t.length&&(e.html('<div class="updated notice is-dismissible"><p>'+t+"</p></div>"),jQuery(document).trigger("wp-updates-notice-added"),wp.a11y.speak(t)),o):isNaN(a)?!e.html('<div class="error"><p>'+a+"</p></div>"):-1===(a=parseInt(a,10))?!e.html('<div class="error"><p>'+wpAjax.noPerm+"</p></div>"):0!==a||!e.html('<div class="error"><p>'+wpAjax.broken+"</p></div>")},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))})});
|
@ -16,7 +16,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '6.0-alpha-53122';
|
$wp_version = '6.0-alpha-53123';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
Loading…
Reference in New Issue
Block a user