From 85cf232e23a364e9b49ee9d40d65ec3351369513 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Wed, 24 Jul 2013 05:37:53 +0000 Subject: [PATCH] Autosave: Don't save an autosave unnecessarily when the post editor loads and TinyMCE is the default editor. Delete such useless autosaves when we detect them in edit-form-advanced.php. see #7392. git-svn-id: http://core.svn.wordpress.org/trunk@24787 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/edit-form-advanced.php | 3 +++ wp-includes/js/autosave.js | 10 +++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/wp-admin/edit-form-advanced.php b/wp-admin/edit-form-advanced.php index c574e56199..5f65944163 100644 --- a/wp-admin/edit-form-advanced.php +++ b/wp-admin/edit-form-advanced.php @@ -98,6 +98,9 @@ if ( $autosave && mysql2date( 'U', $autosave->post_modified_gmt, false ) > mysql break; } } + // If this autosave isn't different from the current post, begone. + if ( ! $notice ) + wp_delete_post_revision( $autosave->ID ); unset($autosave_field, $_autosave_field); } diff --git a/wp-includes/js/autosave.js b/wp-includes/js/autosave.js index 33229a324b..fc4a0bc9e8 100644 --- a/wp-includes/js/autosave.js +++ b/wp-includes/js/autosave.js @@ -7,7 +7,15 @@ jQuery(document).ready( function($) { if ( 'content' == editor.id ) { editor.onLoad.add( function() { editor.save(); - autosaveLast = wp.autosave.getCompareString(); + if ( typeof switchEditors != 'undefined' ) { + autosaveLast = wp.autosave.getCompareString({ + post_title : $('#title').val() || '', + content : switchEditors.pre_wpautop( $('#content').val() ) || '', + excerpt : $('#excerpt').val() || '', + }); + } else { + autosaveLast = wp.autosave.getCompareString(); + } }); } });