<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[18796] trunk: Release a user's post lock when the user leaves a post.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg > ul, #logmsg > ol { margin-left: 0; margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://core.trac.wordpress.org/changeset/18796">18796</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2011-09-27 20:52:07 +0000 (Tue, 27 Sep 2011)</dd>
</dl>
<h3>Log Message</h3>
<pre>Release a user's post lock when the user leaves a post. see <a href="http://core.trac.wordpress.org/ticket/18515">#18515</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminadminajaxphp">trunk/wp-admin/admin-ajax.php</a></li>
<li><a href="#trunkwpadmineditformadvancedphp">trunk/wp-admin/edit-form-advanced.php</a></li>
<li><a href="#trunkwpadminincludespostphp">trunk/wp-admin/includes/post.php</a></li>
<li><a href="#trunkwpadminpostphp">trunk/wp-admin/post.php</a></li>
<li><a href="#trunkwpincludesjsautosavedevjs">trunk/wp-includes/js/autosave.dev.js</a></li>
<li><a href="#trunkwpincludesjsautosavejs">trunk/wp-includes/js/autosave.js</a></li>
<li><a href="#trunkwpincludesscriptloaderphp">trunk/wp-includes/script-loader.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminadminajaxphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/admin-ajax.php (18795 => 18796)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/admin-ajax.php        2011-09-27 19:50:15 UTC (rev 18795)
+++ trunk/wp-admin/admin-ajax.php        2011-09-27 20:52:07 UTC (rev 18796)
</span><span class="lines">@@ -988,8 +988,10 @@
</span><span class="cx">                         $id = $post->ID;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        if ( $do_lock && empty( $_POST['auto_draft'] ) && $id && is_numeric( $id ) )
-                wp_set_post_lock( $id );
</del><ins>+        if ( $do_lock && empty( $_POST['auto_draft'] ) && $id && is_numeric( $id ) ) {
+                $lock_result = wp_set_post_lock( $id );
+                $supplemental['active-post-lock'] = implode( ':', $lock_result );
+        }
</ins><span class="cx">
</span><span class="cx">         if ( $nonce_age == 2 ) {
</span><span class="cx">                 $supplemental['replace-autosavenonce'] = wp_create_nonce('autosave');
</span><span class="lines">@@ -1551,6 +1553,26 @@
</span><span class="cx">         echo json_encode( array( 'message' => $message, 'last_edited' => $last_edited ) );
</span><span class="cx">         die();
</span><span class="cx">         break;
</span><ins>+case 'wp-remove-post-lock' :
+        if ( empty( $_POST['post_ID'] ) || empty( $_POST['active_post_lock'] ) )
+                die( '0' );
+        $post_id = (int) $_POST['post_ID'];
+        if ( ! $post = get_post( $post_id ) )
+                die( '0' );
+
+        check_ajax_referer( 'update-' . $post->post_type . '_' . $post_id );
+
+        if ( ! current_user_can( 'edit_post', $post_id ) )
+                die( '-1' );
+
+        $active_lock = array_map( 'absint', explode( ':', $_POST['active_post_lock'] ) );
+        if ( $active_lock[1] != get_current_user_id() )
+                die( '0' );
+
+        $new_lock = ( time() - apply_filters( 'wp_check_post_lock_window', AUTOSAVE_INTERVAL * 2 ) + 5 ) . ':' . $active_lock[1];
+        update_post_meta( $post_id, '_edit_lock', $new_lock, implode( ':', $active_lock ) );
+        die( '1' );
+
</ins><span class="cx"> default :
</span><span class="cx">         do_action( 'wp_ajax_' . $_POST['action'] );
</span><span class="cx">         die('0');
</span></span></pre></div>
<a id="trunkwpadmineditformadvancedphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/edit-form-advanced.php (18795 => 18796)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/edit-form-advanced.php        2011-09-27 19:50:15 UTC (rev 18795)
+++ trunk/wp-admin/edit-form-advanced.php        2011-09-27 20:52:07 UTC (rev 18796)
</span><span class="lines">@@ -231,7 +231,10 @@
</span><span class="cx"> <input type="hidden" id="post_type" name="post_type" value="<?php echo esc_attr( $post_type ) ?>" />
</span><span class="cx"> <input type="hidden" id="original_post_status" name="original_post_status" value="<?php echo esc_attr( $post->post_status) ?>" />
</span><span class="cx"> <input type="hidden" id="referredby" name="referredby" value="<?php echo esc_url(stripslashes(wp_get_referer())); ?>" />
</span><ins>+<?php if ( ! empty( $active_post_lock ) ) { ?>
+<input type="hidden" id="active_post_lock" value="<?php echo esc_attr( implode( ':', $active_post_lock ) ); ?>" />
</ins><span class="cx"> <?php
</span><ins>+}
</ins><span class="cx"> if ( 'draft' != $post->post_status )
</span><span class="cx">         wp_original_referer_field(true, 'previous');
</span><span class="cx">
</span></span></pre></div>
<a id="trunkwpadminincludespostphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/post.php (18795 => 18796)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/post.php        2011-09-27 19:50:15 UTC (rev 18795)
+++ trunk/wp-admin/includes/post.php        2011-09-27 20:52:07 UTC (rev 18796)
</span><span class="lines">@@ -1239,7 +1239,8 @@
</span><span class="cx"> * @since 2.5.0
</span><span class="cx"> *
</span><span class="cx"> * @param int $post_id ID of the post to being edited
</span><del>- * @return bool Returns false if the post doesn't exist of there is no current user
</del><ins>+ * @return bool|array Returns false if the post doesn't exist of there is no current user, or
+ *         an array of the lock time and the user ID.
</ins><span class="cx"> */
</span><span class="cx"> function wp_set_post_lock( $post_id ) {
</span><span class="cx">         if ( !$post = get_post( $post_id ) )
</span><span class="lines">@@ -1251,6 +1252,7 @@
</span><span class="cx">         $lock = "$now:$user_id";
</span><span class="cx">
</span><span class="cx">         update_post_meta( $post->ID, '_edit_lock', $lock );
</span><ins>+        return array( $now, $user_id );
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span></span></pre></div>
<a id="trunkwpadminpostphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/post.php (18795 => 18796)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/post.php        2011-09-27 19:50:15 UTC (rev 18795)
+++ trunk/wp-admin/post.php        2011-09-27 20:52:07 UTC (rev 18796)
</span><span class="lines">@@ -174,7 +174,7 @@
</span><span class="cx">         if ( $last = wp_check_post_lock( $post->ID ) ) {
</span><span class="cx">                 add_action('admin_notices', '_admin_notice_post_locked' );
</span><span class="cx">         } else {
</span><del>-                wp_set_post_lock( $post->ID );
</del><ins>+                $active_post_lock = wp_set_post_lock( $post->ID );
</ins><span class="cx">                 wp_enqueue_script('autosave');
</span><span class="cx">         }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkwpincludesjsautosavedevjs"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/js/autosave.dev.js (18795 => 18796)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/js/autosave.dev.js        2011-09-27 19:50:15 UTC (rev 18795)
+++ trunk/wp-includes/js/autosave.dev.js        2011-09-27 20:52:07 UTC (rev 18796)
</span><span class="lines">@@ -1,4 +1,4 @@
</span><del>-var autosave, autosaveLast = '', autosavePeriodical, autosaveOldMessage = '', autosaveDelayPreview = false, notSaved = true, blockSave = false, fullscreen;
</del><ins>+var autosave, autosaveLast = '', autosavePeriodical, autosaveOldMessage = '', autosaveDelayPreview = false, notSaved = true, blockSave = false, fullscreen, autosaveLockRelease = true;
</ins><span class="cx">
</span><span class="cx"> jQuery(document).ready( function($) {
</span><span class="cx">         var dotabkey = true;
</span><span class="lines">@@ -9,6 +9,7 @@
</span><span class="cx">         //Disable autosave after the form has been submitted
</span><span class="cx">         $("#post").submit(function() {
</span><span class="cx">                 $.cancel(autosavePeriodical);
</span><ins>+                autosaveLockRelease = false;
</ins><span class="cx">         });
</span><span class="cx">
</span><span class="cx">         $('input[type="submit"], a.submitdelete', '#submitpost').click(function(){
</span><span class="lines">@@ -47,6 +48,22 @@
</span><span class="cx">                 }
</span><span class="cx">         };
</span><span class="cx">
</span><ins>+        $(window).unload( function() {
+                if ( ! autosaveLockRelease )
+                        return;
+                $.ajax({
+                        type: 'POST',
+                        url: ajaxurl,
+                        async: false,
+                        data: {
+                                action: 'wp-remove-post-lock',
+                                _wpnonce: $('#_wpnonce').val(),
+                                post_ID: $('#post_ID').val(),
+                                active_post_lock: $('#active_post_lock').val()
+                        },
+                });
+        } );
+
</ins><span class="cx">         // preview
</span><span class="cx">         $('#post-preview').click(function(){
</span><span class="cx">                 if ( $('#auto_draft').val() == '1' && notSaved ) {
</span><span class="lines">@@ -99,9 +116,14 @@
</span><span class="cx">                         sup = res.responses[0].supplemental;
</span><span class="cx">                         if ( 'disable' == sup['disable_autosave'] ) {
</span><span class="cx">                                 autosave = function() {};
</span><ins>+                                autosaveLockRelease = false;
</ins><span class="cx">                                 res = { errors: true };
</span><span class="cx">                         }
</span><span class="cx">
</span><ins>+                        if ( sup['active-post-lock'] ) {
+                                jQuery('#active_post_lock').val( sup['active-post-lock'] );
+                        }
+
</ins><span class="cx">                         if ( sup['alert'] ) {
</span><span class="cx">                                 jQuery('#autosave-alert').remove();
</span><span class="cx">                                 jQuery('#titlediv').after('<div id="autosave-alert" class="error below-h2"><p>' + sup['alert'] + '</p></div>');
</span></span></pre></div>
<a id="trunkwpincludesjsautosavejs"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/js/autosave.js (18795 => 18796)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/js/autosave.js        2011-09-27 19:50:15 UTC (rev 18795)
+++ trunk/wp-includes/js/autosave.js        2011-09-27 20:52:07 UTC (rev 18796)
</span><span class="lines">@@ -1 +1 @@
</span><del>-var autosave,autosaveLast="",autosavePeriodical,autosaveOldMessage="",autosaveDelayPreview=false,notSaved=true,blockSave=false,fullscreen;jQuery(document).ready(function(b){var a=true;autosaveLast=b("#post #title").val()+b("#post #content").val();autosavePeriodical=b.schedule({time:autosaveL10n.autosaveInterval*1000,func:function(){autosave()},repeat:true,protect:true});b("#post").submit(function(){b.cancel(autosavePeriodical)});b('input[type="submit"], a.submitdelete',"#submitpost").click(function(){blockSave=true;window.onbeforeunload=null;b(":button, :submit","#submitpost").each(function(){var c=b(this);if(c.hasClass("button-primary")){c.addClass("button-primary-disabled")}else{c.addClass("button-disabled")}});if(b(this).attr("id")=="publish"){b("#ajax-loading").css("visibility","visible")}els
e{b("#draft-ajax-loading").css("visibility","visible")}});window.onbeforeunload=function(){var c=typeof(tinyMCE)!="undefined"?tinyMCE.activeEditor:false,e,d;if(c&&!c.isHidden()){if(c.isDirty()){return autosaveL10n.saveAlert}}else{if(fullscreen&&fullscreen.settings.visible){e=b("#wp-fullscreen-title").val();d=b("#wp_mce_fullscreen").val()}else{e=b("#post #title").val();d=b("#post #content").val()}if((e||d)&&e+d!=autosaveLast){return autosaveL10n.saveAlert}}};b("#post-preview").click(function(){if(b("#auto_draft").val()=="1"&&notSaved){autosaveDelayPreview=true;autosave();return false}doPreview();return false});doPreview=function(){b("input#wp-preview").val("dopreview");b("form#post").attr("target","wp-preview").submit().attr("target","");b("input#wp-preview"
).val("")};if(typeof tinyMCE!="undefined"){b("#title")[b.browser.opera?"keypress":"keydown"](function(c){if(c.which==9&&!c.shiftKey&&!c.controlKey&&!c.altKey){if((b("#auto_draft").val()=="1")&&(b("#title").val().length>0)){autosave()}if(tinyMCE.activeEditor&&!tinyMCE.activeEditor.isHidden()&&a){c.preventDefault();a=false;tinyMCE.activeEditor.focus();return false}}})}if("1"==b("#auto_draft").val()){b("#title").blur(function(){if(!this.value||b("#auto_draft").val()!="1"){return}delayed_autosave()})}});function autosave_parse_response(c){var d=wpAjax.parseAjaxResponse(c,"autosave"),e="",a,b;if(d&&d.responses&&d.responses.length){e=d.responses[0].data;if(d.responses[0].supplemental){b=d.responses[0].supplemental;if("disable"==b.disable_autosave){autosave=f
unction(){};d={errors:true}}if(b.alert){jQuery("#autosave-alert").remove();jQuery("#titlediv").after('<div id="autosave-alert" class="error below-h2"><p>'+b.alert+"</p></div>")}jQuery.each(b,function(f,g){if(f.match(/^replace-/)){jQuery("#"+f.replace("replace-","")).val(g)}})}if(!d.errors){a=parseInt(d.responses[0].id,10);if(!isNaN(a)&&a>0){autosave_update_slug(a)}}}if(e){jQuery(".autosave-message").html(e)}else{if(autosaveOldMessage&&d){jQuery(".autosave-message").html(autosaveOldMessage)}}return d}function autosave_saved(a){blockSave=false;autosave_parse_response(a);autosave_enable_buttons()}function autosave_saved_new(b){blockSave=false;var c=autosave_parse_response(b),a;if(c&&c.responses.length&&!c.errors){a=parseInt(c.responses[0].id,10);if(!isNaN(a)&&a>0){notSaved=false;jQuery("#auto_draft").
val("0")}autosave_enable_buttons();if(autosaveDelayPreview){autosaveDelayPreview=false;doPreview()}}else{autosave_enable_buttons()}}function autosave_update_slug(a){if("undefined"!=makeSlugeditClickable&&jQuery.isFunction(makeSlugeditClickable)&&!jQuery("#edit-slug-box > *").size()){jQuery.post(ajaxurl,{action:"sample-permalink",post_id:a,new_title:fullscreen&&fullscreen.settings.visible?jQuery("#wp-fullscreen-title").val():jQuery("#title").val(),samplepermalinknonce:jQuery("#samplepermalinknonce").val()},function(b){if(b!=="-1"){jQuery("#edit-slug-box").html(b);makeSlugeditClickable()}})}}function autosave_loading(){jQuery(".autosave-message").html(autosaveL10n.savingText)}function autosave_enable_buttons(){setTimeout(function(){jQuery(":button, :submit","#submitpost").removeAttr("disabled");jQuery(".ajax-loading&q
uot;).css("visibility","hidden")},500)}function autosave_disable_buttons(){jQuery(":button, :submit","#submitpost").prop("disabled",true);setTimeout(autosave_enable_buttons,5000)}function delayed_autosave(){setTimeout(function(){if(blockSave){return}autosave()},200)}autosave=function(){blockSave=true;var c=(typeof tinyMCE!="undefined")&&tinyMCE.activeEditor&&!tinyMCE.activeEditor.isHidden(),d,f,b,e,a;autosave_disable_buttons();d={action:"autosave",post_ID:jQuery("#post_ID").val()||0,autosavenonce:jQuery("#autosavenonce").val(),post_type:jQuery("#post_type").val()||"",autosave:1};jQuery(".tags-input").each(function(){d[this.name]=this.value});f=true;if(jQuery("#TB_window").css("display")=="block"){f=false}if(c&&f){b=tinyMCE.activeEditor;if(b.plugins.spellchecker&&b.plugins.spellchecker.active){f=f
alse}else{if("mce_fullscreen"==b.id||"wp_mce_fullscreen"==b.id){tinyMCE.get("content").setContent(b.getContent({format:"raw"}),{format:"raw"})}tinyMCE.triggerSave()}}if(fullscreen&&fullscreen.settings.visible){d.post_title=jQuery("#wp-fullscreen-title").val();d.content=jQuery("#wp_mce_fullscreen").val()}else{d.post_title=jQuery("#title").val();d.content=jQuery("#content").val()}if(jQuery("#post_name").val()){d.post_name=jQuery("#post_name").val()}if((d.post_title.length==0&&d.content.length==0)||d.post_title+d.content==autosaveLast){f=false}e=jQuery("#original_post_status").val();goodcats=([]);jQuery("[name='post_category[]']:checked").each(function(g){goodcats.push(this.value)});d.catslist=goodcats.join(",");if(jQuery("#comment_status").prop("checked")){d.comment_status="open"}if(jQuery(&quo
t;#ping_status").prop("checked")){d.ping_status="open"}if(jQuery("#excerpt").size()){d.excerpt=jQuery("#excerpt").val()}if(jQuery("#post_author").size()){d.post_author=jQuery("#post_author").val()}if(jQuery("#parent_id").val()){d.parent_id=jQuery("#parent_id").val()}d.user_ID=jQuery("#user-id").val();if(jQuery("#auto_draft").val()=="1"){d.auto_draft="1"}if(f){autosaveLast=d.post_title+d.content;jQuery(document).triggerHandler("wpcountwords",[d.content])}else{d.autosave=0}if(d.auto_draft=="1"){a=autosave_saved_new}else{a=autosave_saved}autosaveOldMessage=jQuery("#autosave").html();jQuery.ajax({data:d,beforeSend:f?autosave_loading:null,type:"POST",url:ajaxurl,success:a})};
</del><span class="cx">\ No newline at end of file
</span><ins>+var autosave,autosaveLast="",autosavePeriodical,autosaveOldMessage="",autosaveDelayPreview=false,notSaved=true,blockSave=false,fullscreen,autosaveLockRelease=true;jQuery(document).ready(function(b){var a=true;autosaveLast=b("#post #title").val()+b("#post #content").val();autosavePeriodical=b.schedule({time:autosaveL10n.autosaveInterval*1000,func:function(){autosave()},repeat:true,protect:true});b("#post").submit(function(){b.cancel(autosavePeriodical);autosaveLockRelease=false});b('input[type="submit"], a.submitdelete',"#submitpost").click(function(){blockSave=true;window.onbeforeunload=null;b(":button, :submit","#submitpost").each(function(){var c=b(this);if(c.hasClass("button-primary")){c.addClass("button-primary-disabled")}else{c.addClass("button-disabled")}});if(b(this).attr("id")=="publish"){b("#ajax-loading").
css("visibility","visible")}else{b("#draft-ajax-loading").css("visibility","visible")}});window.onbeforeunload=function(){var c=typeof(tinyMCE)!="undefined"?tinyMCE.activeEditor:false,e,d;if(c&&!c.isHidden()){if(c.isDirty()){return autosaveL10n.saveAlert}}else{if(fullscreen&&fullscreen.settings.visible){e=b("#wp-fullscreen-title").val();d=b("#wp_mce_fullscreen").val()}else{e=b("#post #title").val();d=b("#post #content").val()}if((e||d)&&e+d!=autosaveLast){return autosaveL10n.saveAlert}}};b(window).unload(function(){if(!autosaveLockRelease){return}b.ajax({type:"POST",url:ajaxurl,async:false,data:{action:"wp-remove-post-lock",_wpnonce:b("#_wpnonce").val(),post_ID:b("#post_ID").val(),active_post_lock:b("#active_post_lock").val()},})});b("#post-preview").click(function(){if(b("#auto_draft"
;).val()=="1"&&notSaved){autosaveDelayPreview=true;autosave();return false}doPreview();return false});doPreview=function(){b("input#wp-preview").val("dopreview");b("form#post").attr("target","wp-preview").submit().attr("target","");b("input#wp-preview").val("")};if(typeof tinyMCE!="undefined"){b("#title")[b.browser.opera?"keypress":"keydown"](function(c){if(c.which==9&&!c.shiftKey&&!c.controlKey&&!c.altKey){if((b("#auto_draft").val()=="1")&&(b("#title").val().length>0)){autosave()}if(tinyMCE.activeEditor&&!tinyMCE.activeEditor.isHidden()&&a){c.preventDefault();a=false;tinyMCE.activeEditor.focus();return false}}})}if("1"==b("#auto_draft").val()){b("#title").blur(function(){if(!this.value||b("#auto_draft").val()!
="1"){return}delayed_autosave()})}});function autosave_parse_response(c){var d=wpAjax.parseAjaxResponse(c,"autosave"),e="",a,b;if(d&&d.responses&&d.responses.length){e=d.responses[0].data;if(d.responses[0].supplemental){b=d.responses[0].supplemental;if("disable"==b.disable_autosave){autosave=function(){};autosaveLockRelease=false;d={errors:true}}if(b["active-post-lock"]){jQuery("#active_post_lock").val(b["active-post-lock"])}if(b.alert){jQuery("#autosave-alert").remove();jQuery("#titlediv").after('<div id="autosave-alert" class="error below-h2"><p>'+b.alert+"</p></div>")}jQuery.each(b,function(f,g){if(f.match(/^replace-/)){jQuery("#"+f.replace("replace-","")).val(g)}})}if(!d.errors){a=parseInt(d.responses[0].id,10);if(!isNaN(a)&&a>0){autosave_update_slug(a)}}}if(e){jQuery("
;.autosave-message").html(e)}else{if(autosaveOldMessage&&d){jQuery(".autosave-message").html(autosaveOldMessage)}}return d}function autosave_saved(a){blockSave=false;autosave_parse_response(a);autosave_enable_buttons()}function autosave_saved_new(b){blockSave=false;var c=autosave_parse_response(b),a;if(c&&c.responses.length&&!c.errors){a=parseInt(c.responses[0].id,10);if(!isNaN(a)&&a>0){notSaved=false;jQuery("#auto_draft").val("0")}autosave_enable_buttons();if(autosaveDelayPreview){autosaveDelayPreview=false;doPreview()}}else{autosave_enable_buttons()}}function autosave_update_slug(a){if("undefined"!=makeSlugeditClickable&&jQuery.isFunction(makeSlugeditClickable)&&!jQuery("#edit-slug-box > *").size()){jQuery.post(ajaxurl,{action:"sample-permalink",post_id:a,new_title:fullscreen&&fullscreen.settings.visible?jQuery("#wp-fullscreen-title").val
():jQuery("#title").val(),samplepermalinknonce:jQuery("#samplepermalinknonce").val()},function(b){if(b!=="-1"){jQuery("#edit-slug-box").html(b);makeSlugeditClickable()}})}}function autosave_loading(){jQuery(".autosave-message").html(autosaveL10n.savingText)}function autosave_enable_buttons(){setTimeout(function(){jQuery(":button, :submit","#submitpost").removeAttr("disabled");jQuery(".ajax-loading").css("visibility","hidden")},500)}function autosave_disable_buttons(){jQuery(":button, :submit","#submitpost").prop("disabled",true);setTimeout(autosave_enable_buttons,5000)}function delayed_autosave(){setTimeout(function(){if(blockSave){return}autosave()},200)}autosave=function(){blockSave=true;var c=(typeof tinyMCE!="undefined")&&tinyMCE.activeEditor&&!tinyMCE.activeEditor.isHidden(),d,f,b,e,a;autosave_disable_butto
ns();d={action:"autosave",post_ID:jQuery("#post_ID").val()||0,autosavenonce:jQuery("#autosavenonce").val(),post_type:jQuery("#post_type").val()||"",autosave:1};jQuery(".tags-input").each(function(){d[this.name]=this.value});f=true;if(jQuery("#TB_window").css("display")=="block"){f=false}if(c&&f){b=tinyMCE.activeEditor;if(b.plugins.spellchecker&&b.plugins.spellchecker.active){f=false}else{if("mce_fullscreen"==b.id||"wp_mce_fullscreen"==b.id){tinyMCE.get("content").setContent(b.getContent({format:"raw"}),{format:"raw"})}tinyMCE.triggerSave()}}if(fullscreen&&fullscreen.settings.visible){d.post_title=jQuery("#wp-fullscreen-title").val();d.content=jQuery("#wp_mce_fullscreen").val()}else{d.post_title=jQuery("#title").val();d.content=jQuery("#content").val()}if(jQuery("#post_n
ame").val()){d.post_name=jQuery("#post_name").val()}if((d.post_title.length==0&&d.content.length==0)||d.post_title+d.content==autosaveLast){f=false}e=jQuery("#original_post_status").val();goodcats=([]);jQuery("[name='post_category[]']:checked").each(function(g){goodcats.push(this.value)});d.catslist=goodcats.join(",");if(jQuery("#comment_status").prop("checked")){d.comment_status="open"}if(jQuery("#ping_status").prop("checked")){d.ping_status="open"}if(jQuery("#excerpt").size()){d.excerpt=jQuery("#excerpt").val()}if(jQuery("#post_author").size()){d.post_author=jQuery("#post_author").val()}if(jQuery("#parent_id").val()){d.parent_id=jQuery("#parent_id").val()}d.user_ID=jQuery("#user-id").val();if(jQuery("#auto_draft").val()=="1"){d.auto_draft="1"}if(f){autosaveLast=d.
post_title+d.content;jQuery(document).triggerHandler("wpcountwords",[d.content])}else{d.autosave=0}if(d.auto_draft=="1"){a=autosave_saved_new}else{a=autosave_saved}autosaveOldMessage=jQuery("#autosave").html();jQuery.ajax({data:d,beforeSend:f?autosave_loading:null,type:"POST",url:ajaxurl,success:a})};
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkwpincludesscriptloaderphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/script-loader.php (18795 => 18796)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/script-loader.php        2011-09-27 19:50:15 UTC (rev 18795)
+++ trunk/wp-includes/script-loader.php        2011-09-27 20:52:07 UTC (rev 18796)
</span><span class="lines">@@ -101,7 +101,7 @@
</span><span class="cx">                 'close' => __('Close'),
</span><span class="cx">         ) );
</span><span class="cx">
</span><del>-        $scripts->add( 'autosave', "/wp-includes/js/autosave$suffix.js", array('schedule', 'wp-ajax-response'), '20110524', 1 );
</del><ins>+        $scripts->add( 'autosave', "/wp-includes/js/autosave$suffix.js", array('schedule', 'wp-ajax-response'), '20110927', 1 );
</ins><span class="cx">
</span><span class="cx">         $scripts->add( 'wp-lists', "/wp-includes/js/wp-lists$suffix.js", array('wp-ajax-response'), '20110521', 1 );
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>