diff --git a/src/js/_enqueues/admin/tags.js b/src/js/_enqueues/admin/tags.js index 0f195c777e..a36b2ebb4f 100644 --- a/src/js/_enqueues/admin/tags.js +++ b/src/js/_enqueues/admin/tags.js @@ -11,6 +11,8 @@ jQuery(document).ready(function($) { + var addingTerm = false; + /** * Adds an event handler to the delete term link on the term overview page. * @@ -102,6 +104,14 @@ jQuery(document).ready(function($) { if ( ! validateForm( form ) ) return false; + if ( addingTerm ) { + // If we're adding a term, noop the button to avoid duplicate requests. + return false; + } + + addingTerm = true; + form.find( '.submit .spinner' ).addClass( 'is-active' ); + /** * Does a request to the server to add a new term to the database * @@ -112,6 +122,9 @@ jQuery(document).ready(function($) { $.post(ajaxurl, $('#addtag').serialize(), function(r){ var res, parent, term, indent, i; + addingTerm = false; + form.find( '.submit .spinner' ).removeClass( 'is-active' ); + $('#ajax-response').empty(); res = wpAjax.parseAjaxResponse( r, 'ajax-response' ); if ( ! res || res.errors ) diff --git a/src/wp-admin/css/edit.css b/src/wp-admin/css/edit.css index e186e488ad..4b03870f22 100644 --- a/src/wp-admin/css/edit.css +++ b/src/wp-admin/css/edit.css @@ -1163,6 +1163,11 @@ p.popular-tags a { text-decoration: underline; } +#addtag .spinner { + float: none; + vertical-align: top; +} + #edittag { max-width: 800px; } diff --git a/src/wp-admin/edit-tags.php b/src/wp-admin/edit-tags.php index eb6b52a1b0..cc5f118997 100644 --- a/src/wp-admin/edit-tags.php +++ b/src/wp-admin/edit-tags.php @@ -515,9 +515,12 @@ if ( $can_edit_terms ) { * @param string $taxonomy The taxonomy slug. */ do_action( "{$taxonomy}_add_form_fields", $taxonomy ); - - submit_button( $tax->labels->add_new_item ); - + ?> +

+ labels->add_new_item, 'primary', 'submit', false ); ?> + +

+