diff --git a/wp-admin/edit-form-advanced.php b/wp-admin/edit-form-advanced.php index 52381b7507..e5e244c40d 100644 --- a/wp-admin/edit-form-advanced.php +++ b/wp-admin/edit-form-advanced.php @@ -365,6 +365,9 @@ if ( isset( $post_new_file ) && current_user_can( $post_type_object->cap->create

+
> diff --git a/wp-includes/js/autosave.js b/wp-includes/js/autosave.js index e185a60224..6bab0e402e 100644 --- a/wp-includes/js/autosave.js +++ b/wp-includes/js/autosave.js @@ -128,6 +128,15 @@ jQuery(document).ready( function($) { delayed_autosave(); }); } + + // When connection is lost, keep user from submitting changes. + $(document).on('heartbeat-connection-lost.autosave', function() { + autosave_disable_buttons(); + $('#lost-connection-notice').show(); + }).on('heartbeat-connection-restored.autosave', function() { + autosave_enable_buttons(); + $('#lost-connection-notice').hide(); + }); }); function autosave_parse_response( response ) { @@ -218,17 +227,20 @@ function autosave_loading() { } function autosave_enable_buttons() { - // delay that a bit to avoid some rare collisions while the DOM is being updated. - setTimeout(function(){ - jQuery(':button, :submit', '#submitpost').removeAttr('disabled'); - jQuery('.spinner', '#submitpost').hide(); - }, 500); + if ( ! wp.heartbeat.connectionLost ) { + // delay that a bit to avoid some rare collisions while the DOM is being updated. + setTimeout(function(){ + var parent = jQuery('#submitpost'); + parent.find(':button, :submit').removeAttr('disabled'); + parent.find('.spinner').hide(); + }, 500); + } } function autosave_disable_buttons() { - jQuery(':button, :submit', '#submitpost').prop('disabled', true); + jQuery('#submitpost').find(':button, :submit').prop('disabled', true); // Re-enable 5 sec later. Just gives autosave a head start to avoid collisions. - setTimeout(autosave_enable_buttons, 5000); + setTimeout( autosave_enable_buttons, 5000 ); } function delayed_autosave() { @@ -245,6 +257,7 @@ autosave = function() { var rich = (typeof tinymce != "undefined") && tinymce.activeEditor && !tinymce.activeEditor.isHidden(), post_data, doAutoSave, ed, origStatus, successCallback; + // Disable buttons until we know the save completed. autosave_disable_buttons(); post_data = wp.autosave.getPostData(); diff --git a/wp-includes/js/heartbeat.js b/wp-includes/js/heartbeat.js index 600dfa0f0c..7f923eabc5 100644 --- a/wp-includes/js/heartbeat.js +++ b/wp-includes/js/heartbeat.js @@ -383,6 +383,8 @@ window.wp = window.wp || {}; if ( self.xhr && self.xhr.readyState != 4 ) self.xhr.abort(); + // Reset the error state + errorstate(); running = false; return true; }