diff --git a/wp-admin/includes/ajax-actions.php b/wp-admin/includes/ajax-actions.php
index 964aba357f..a6ba2b678c 100644
--- a/wp-admin/includes/ajax-actions.php
+++ b/wp-admin/includes/ajax-actions.php
@@ -1071,16 +1071,21 @@ function wp_ajax_add_tag() {
}
if ( ! $tag || is_wp_error( $tag ) ) {
- $message = __( 'An error has occurred. Please reload the page and try again.' );
+ $message = __( 'An error has occurred. Please reload the page and try again.' );
+ $error_code = 'error';
if ( is_wp_error( $tag ) && $tag->get_error_message() ) {
$message = $tag->get_error_message();
}
+ if ( is_wp_error( $tag ) && $tag->get_error_code() ) {
+ $error_code = $tag->get_error_code();
+ }
+
$x->add(
array(
'what' => 'taxonomy',
- 'data' => new WP_Error( 'error', $message ),
+ 'data' => new WP_Error( $error_code, $message ),
)
);
$x->send();
diff --git a/wp-admin/js/tags.js b/wp-admin/js/tags.js
index 4ff7aaa440..474088646e 100644
--- a/wp-admin/js/tags.js
+++ b/wp-admin/js/tags.js
@@ -101,9 +101,6 @@ jQuery( function($) {
$('#submit').on( 'click', function(){
var form = $(this).parents('form');
- if ( ! validateForm( form ) )
- return false;
-
if ( addingTerm ) {
// If we're adding a term, noop the button to avoid duplicate requests.
return false;
@@ -127,8 +124,14 @@ jQuery( function($) {
$('#ajax-response').empty();
res = wpAjax.parseAjaxResponse( r, 'ajax-response' );
- if ( ! res || res.errors )
+
+ if ( res.errors && res.responses[0].errors[0].code === 'empty_term_name' ) {
+ validateForm( form );
+ }
+
+ if ( ! res || res.errors ) {
return;
+ }
parent = form.find( 'select#parent' ).val();
diff --git a/wp-admin/js/tags.min.js b/wp-admin/js/tags.min.js
index 5a6e81befc..2f25616baf 100644
--- a/wp-admin/js/tags.min.js
+++ b/wp-admin/js/tags.min.js
@@ -1,2 +1,2 @@
/*! This file is auto-generated */
-jQuery(function(o){var r=!1;o("#the-list").on("click",".delete-tag",function(){var t,e=o(this),n=e.parents("tr"),a=!0;return(a="undefined"!=showNotice?showNotice.warn():a)&&(t=e.attr("href").replace(/[^?]*\?/,"").replace(/action=delete/,"action=delete-tag"),o.post(ajaxurl,t,function(e){"1"==e?(o("#ajax-response").empty(),n.fadeOut("normal",function(){n.remove()}),o('select#parent option[value="'+t.match(/tag_ID=(\d+)/)[1]+'"]').remove(),o("a.tag-link-"+t.match(/tag_ID=(\d+)/)[1]).remove()):("-1"==e?o("#ajax-response").empty().append('
'+wp.i18n.__("Sorry, you are not allowed to do that.")+"
"):o("#ajax-response").empty().append(''+wp.i18n.__("Something went wrong.")+"
"),n.children().css("backgroundColor",""))}),n.children().css("backgroundColor","#f33")),!1}),o("#edittag").on("click",".delete",function(e){return"undefined"==typeof showNotice||void(showNotice.warn()||e.preventDefault())}),o("#submit").on("click",function(){var s=o(this).parents("form");return validateForm(s)&&(r||(r=!0,s.find(".submit .spinner").addClass("is-active"),o.post(ajaxurl,o("#addtag").serialize(),function(e){var t,n,a;if(r=!1,s.find(".submit .spinner").removeClass("is-active"),o("#ajax-response").empty(),(t=wpAjax.parseAjaxResponse(e,"ajax-response"))&&!t.errors){if(0<(e=s.find("select#parent").val())&&0'+n+e.name+"")}o('input:not([type="checkbox"]):not([type="radio"]):visible, textarea:visible',s).val("")}}))),!1})});
\ No newline at end of file
+jQuery(function(s){var o=!1;s("#the-list").on("click",".delete-tag",function(){var t,e=s(this),n=e.parents("tr"),a=!0;return(a="undefined"!=showNotice?showNotice.warn():a)&&(t=e.attr("href").replace(/[^?]*\?/,"").replace(/action=delete/,"action=delete-tag"),s.post(ajaxurl,t,function(e){"1"==e?(s("#ajax-response").empty(),n.fadeOut("normal",function(){n.remove()}),s('select#parent option[value="'+t.match(/tag_ID=(\d+)/)[1]+'"]').remove(),s("a.tag-link-"+t.match(/tag_ID=(\d+)/)[1]).remove()):("-1"==e?s("#ajax-response").empty().append(''+wp.i18n.__("Sorry, you are not allowed to do that.")+"
"):s("#ajax-response").empty().append(''+wp.i18n.__("Something went wrong.")+"
"),n.children().css("backgroundColor",""))}),n.children().css("backgroundColor","#f33")),!1}),s("#edittag").on("click",".delete",function(e){return"undefined"==typeof showNotice||void(showNotice.warn()||e.preventDefault())}),s("#submit").on("click",function(){var r=s(this).parents("form");return o||(o=!0,r.find(".submit .spinner").addClass("is-active"),s.post(ajaxurl,s("#addtag").serialize(),function(e){var t,n,a;if(o=!1,r.find(".submit .spinner").removeClass("is-active"),s("#ajax-response").empty(),(t=wpAjax.parseAjaxResponse(e,"ajax-response")).errors&&"empty_term_name"===t.responses[0].errors[0].code&&validateForm(r),t&&!t.errors){if(0<(e=r.find("select#parent").val())&&0'+n+e.name+"")}s('input:not([type="checkbox"]):not([type="radio"]):visible, textarea:visible',r).val("")}})),!1})});
\ No newline at end of file
diff --git a/wp-includes/version.php b/wp-includes/version.php
index bcebe3bda4..8c616f04f5 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
-$wp_version = '6.0-alpha-53087';
+$wp_version = '6.0-alpha-53088';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.