<!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" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { 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 #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#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>
<title>[12987] trunk: Create post_status=auto-draft when creating a new post item.</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/12987">12987</a></dd>
<dt>Author</dt> <dd>markjaquith</dd>
<dt>Date</dt> <dd>2010-02-06 10:07:57 +0000 (Sat, 06 Feb 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>Create post_status=auto-draft when creating a new post item. status changes to draft on first auto-save. now we always have a real post ID to work with. see <a href="http://trac.wordpress.org/ticket/11889">#11889</a>. fixes <a href="http://trac.wordpress.org/ticket/11145">#11145</a>. fixes <a href="http://trac.wordpress.org/ticket/11990">#11990</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="#trunkwpadminincludesmetaboxesphp">trunk/wp-admin/includes/meta-boxes.php</a></li>
<li><a href="#trunkwpadminincludespostphp">trunk/wp-admin/includes/post.php</a></li>
<li><a href="#trunkwpadminpostnewphp">trunk/wp-admin/post-new.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="#trunkwpincludeslinktemplatephp">trunk/wp-includes/link-template.php</a></li>
<li><a href="#trunkwpincludespostphp">trunk/wp-includes/post.php</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 (12986 => 12987)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/admin-ajax.php        2010-02-06 07:31:38 UTC (rev 12986)
+++ trunk/wp-admin/admin-ajax.php        2010-02-06 10:07:57 UTC (rev 12987)
</span><span class="lines">@@ -887,57 +887,54 @@
</span><span class="cx">                 $supplemental['session_expired'] = add_query_arg( 'interim-login', 1, wp_login_url() );
</span><span class="cx"> 
</span><span class="cx">         $id = $revision_id = 0;
</span><del>-        if ( $_POST['post_ID'] &lt; 0 ) {
</del><ins>+
+        $post_ID = (int) $_POST['post_ID'];
+        $_POST['ID'] = $post_ID;
+        $post = get_post($post_ID);
+        if ( 'auto-draft' == $post-&gt;post_status )
</ins><span class="cx">                 $_POST['post_status'] = 'draft';
</span><del>-                $_POST['temp_ID'] = $_POST['post_ID'];
-                if ( $do_autosave ) {
-                        $id = wp_write_post();
-                        $data = $message;
-                }
-        } else {
-                $post_ID = (int) $_POST['post_ID'];
-                $_POST['ID'] = $post_ID;
-                $post = get_post($post_ID);
</del><span class="cx"> 
</span><del>-                if ( $last = wp_check_post_lock( $post-&gt;ID ) ) {
-                        $do_autosave = $do_lock = false;
</del><ins>+        if ( $last = wp_check_post_lock( $post-&gt;ID ) ) {
+                $do_autosave = $do_lock = false;
</ins><span class="cx"> 
</span><del>-                        $last_user = get_userdata( $last );
-                        $last_user_name = $last_user ? $last_user-&gt;display_name : __( 'Someone' );
-                        $data = new WP_Error( 'locked', sprintf(
-                                $_POST['post_type'] == 'page' ? __( 'Autosave disabled: %s is currently editing this page.' ) : __( 'Autosave disabled: %s is currently editing this post.' ),
-                                esc_html( $last_user_name )
-                        ) );
</del><ins>+                $last_user = get_userdata( $last );
+                $last_user_name = $last_user ? $last_user-&gt;display_name : __( 'Someone' );
+                $data = new WP_Error( 'locked', sprintf(
+                        $_POST['post_type'] == 'page' ? __( 'Autosave disabled: %s is currently editing this page.' ) : __( 'Autosave disabled: %s is currently editing this post.' ),
+                        esc_html( $last_user_name )
+                ) );
</ins><span class="cx"> 
</span><del>-                        $supplemental['disable_autosave'] = 'disable';
-                }
</del><ins>+                $supplemental['disable_autosave'] = 'disable';
+        }
</ins><span class="cx"> 
</span><del>-                if ( 'page' == $post-&gt;post_type ) {
-                        if ( !current_user_can('edit_page', $post_ID) )
-                                die(__('You are not allowed to edit this page.'));
-                } else {
-                        if ( !current_user_can('edit_post', $post_ID) )
-                                die(__('You are not allowed to edit this post.'));
-                }
</del><ins>+        if ( 'page' == $post-&gt;post_type ) {
+                if ( !current_user_can('edit_page', $post_ID) )
+                        die(__('You are not allowed to edit this page.'));
+        } else {
+                if ( !current_user_can('edit_post', $post_ID) )
+                        die(__('You are not allowed to edit this post.'));
+        }
</ins><span class="cx"> 
</span><del>-                if ( $do_autosave ) {
-                        // Drafts are just overwritten by autosave
-                        if ( 'draft' == $post-&gt;post_status ) {
-                                $id = edit_post();
-                        } else { // Non drafts are not overwritten.  The autosave is stored in a special post revision.
-                                $revision_id = wp_create_post_autosave( $post-&gt;ID );
-                                if ( is_wp_error($revision_id) )
-                                        $id = $revision_id;
-                                else
-                                        $id = $post-&gt;ID;
-                        }
-                        $data = $message;
-                } else {
-                        $id = $post-&gt;ID;
</del><ins>+        if ( $do_autosave ) {
+                // Drafts and auto-drafts are just overwritten by autosave
+                if ( 'auto-draft' == $post-&gt;post_status || 'draft' == $post-&gt;post_status ) {
+                        $id = edit_post();
+                } else { // Non drafts are not overwritten.  The autosave is stored in a special post revision.
+                        $revision_id = wp_create_post_autosave( $post-&gt;ID );
+                        if ( is_wp_error($revision_id) )
+                                $id = $revision_id;
+                        else
+                                $id = $post-&gt;ID;
</ins><span class="cx">                 }
</span><ins>+                $data = $message;
+        } else {
+                if ( '1' == $_POST['auto_draft'] )
+                        $id = 0; // This tells us it didn't actually save
+                else
+                        $id = $post-&gt;ID;
</ins><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if ( $do_lock &amp;&amp; $id &amp;&amp; is_numeric($id) )
</del><ins>+        if ( $do_lock &amp;&amp; $_POST['auto_draft'] != '1' &amp;&amp; $id &amp;&amp; is_numeric($id) )
</ins><span class="cx">                 wp_set_post_lock( $id );
</span><span class="cx"> 
</span><span class="cx">         if ( $nonce_age == 2 ) {
</span><span class="lines">@@ -961,18 +958,6 @@
</span><span class="cx">         ) );
</span><span class="cx">         $x-&gt;send();
</span><span class="cx">         break;
</span><del>-case 'autosave-generate-nonces' :
-        check_ajax_referer( 'autosave', 'autosavenonce' );
-        $ID = (int) $_POST['post_ID'];
-        $post_type = $_POST['post_type'];
-        $post_type_object = get_post_type_object($post_type);
-        if ( !$post_type_object )
-                die('0');
-        if ( current_user_can( $post_type_object-&gt;edit_cap, $ID ) )
-                die( json_encode( array( 'updateNonce' =&gt; wp_create_nonce( &quot;update-{$post_type}_{$ID}&quot; ), 'deleteURL' =&gt; str_replace( '&amp;amp;', '&amp;', wp_nonce_url( admin_url( $post_type . '.php?action=trash&amp;post=' . $ID ), &quot;trash-{$post_type}_{$ID}&quot; ) ) ) ) );
-        do_action('autosave_generate_nonces');
-        die('0');
-break;
</del><span class="cx"> case 'closed-postboxes' :
</span><span class="cx">         check_ajax_referer( 'closedpostboxes', 'closedpostboxesnonce' );
</span><span class="cx">         $closed = isset( $_POST['closed'] ) ? $_POST['closed'] : '';
</span></span></pre></div>
<a id="trunkwpadmineditformadvancedphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/edit-form-advanced.php (12986 => 12987)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/edit-form-advanced.php        2010-02-06 07:31:38 UTC (rev 12986)
+++ trunk/wp-admin/edit-form-advanced.php        2010-02-06 10:07:57 UTC (rev 12987)
</span><span class="lines">@@ -60,28 +60,29 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> $notice = false;
</span><del>-if ( 0 == $post_ID ) {
-        $form_action = 'post';
-        $nonce_action = 'add-' . $post_type;
-        $temp_ID = -1 * time(); // don't change this formula without looking at wp_write_post()
-        $form_extra = &quot;&lt;input type='hidden' id='post_ID' name='temp_ID' value='&quot; . esc_attr($temp_ID) . &quot;' /&gt;&quot;;
</del><ins>+$form_extra = '';
+if ( 'auto-draft' == $post-&gt;post_status ) {
+        if ( 'edit' == $action )
+                $post-&gt;post_title = '';
</ins><span class="cx">         $autosave = false;
</span><ins>+        $form_extra .= &quot;&lt;input type='hidden' id='auto_draft' name='auto_draft' value='1' /&gt;&quot;;
</ins><span class="cx"> } else {
</span><del>-        $form_action = 'editpost';
-        $nonce_action = 'update-' . $post_type . '_' . $post_ID;
-        $form_extra = &quot;&lt;input type='hidden' id='post_ID' name='post_ID' value='&quot; . esc_attr($post_ID) . &quot;' /&gt;&quot;;
</del><span class="cx">         $autosave = wp_get_post_autosave( $post_ID );
</span><ins>+}
</ins><span class="cx"> 
</span><del>-        // Detect if there exists an autosave newer than the post and if that autosave is different than the post
-        if ( $autosave &amp;&amp; mysql2date( 'U', $autosave-&gt;post_modified_gmt, false ) &gt; mysql2date( 'U', $post-&gt;post_modified_gmt, false ) ) {
-                foreach ( _wp_post_revision_fields() as $autosave_field =&gt; $_autosave_field ) {
-                        if ( normalize_whitespace( $autosave-&gt;$autosave_field ) != normalize_whitespace( $post-&gt;$autosave_field ) ) {
-                                $notice = sprintf( __( 'There is an autosave of this post that is more recent than the version below.  &lt;a href=&quot;%s&quot;&gt;View the autosave&lt;/a&gt;' ), get_edit_post_link( $autosave-&gt;ID ) );
-                                break;
-                        }
</del><ins>+$form_action = 'editpost';
+$nonce_action = 'update-' . $post_type . '_' . $post_ID;
+$form_extra .= &quot;&lt;input type='hidden' id='post_ID' name='post_ID' value='&quot; . esc_attr($post_ID) . &quot;' /&gt;&quot;;
+
+// Detect if there exists an autosave newer than the post and if that autosave is different than the post
+if ( $autosave &amp;&amp; mysql2date( 'U', $autosave-&gt;post_modified_gmt, false ) &gt; mysql2date( 'U', $post-&gt;post_modified_gmt, false ) ) {
+        foreach ( _wp_post_revision_fields() as $autosave_field =&gt; $_autosave_field ) {
+                if ( normalize_whitespace( $autosave-&gt;$autosave_field ) != normalize_whitespace( $post-&gt;$autosave_field ) ) {
+                        $notice = sprintf( __( 'There is an autosave of this post that is more recent than the version below.  &lt;a href=&quot;%s&quot;&gt;View the autosave&lt;/a&gt;' ), get_edit_post_link( $autosave-&gt;ID ) );
+                        break;
</ins><span class="cx">                 }
</span><del>-                unset($autosave_field, $_autosave_field);
</del><span class="cx">         }
</span><ins>+        unset($autosave_field, $_autosave_field);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> $post_type_object = get_post_type_object($post_type);
</span><span class="lines">@@ -197,7 +198,7 @@
</span><span class="cx"> if ( !( 'pending' == $post-&gt;post_status &amp;&amp; !current_user_can( $post_type_object-&gt;publish_cap ) ) ) { ?&gt;
</span><span class="cx">         &lt;div id=&quot;edit-slug-box&quot;&gt;
</span><span class="cx"> &lt;?php
</span><del>-        if ( ! empty($post-&gt;ID) &amp;&amp; ! empty($sample_permalink_html) ) :
</del><ins>+        if ( ! empty($post-&gt;ID) &amp;&amp; ! empty($sample_permalink_html) &amp;&amp; 'auto-draft' != $post-&gt;post_status ) :
</ins><span class="cx">                 echo $sample_permalink_html;
</span><span class="cx"> endif; ?&gt;
</span><span class="cx">         &lt;/div&gt;
</span><span class="lines">@@ -215,7 +216,7 @@
</span><span class="cx">         &lt;td class=&quot;autosave-info&quot;&gt;
</span><span class="cx">         &lt;span id=&quot;autosave&quot;&gt;&amp;nbsp;&lt;/span&gt;
</span><span class="cx"> &lt;?php
</span><del>-        if ( $post_ID ) {
</del><ins>+        if ( 'auto-draft' != $post-&gt;post_status ) {
</ins><span class="cx">                 echo '&lt;span id=&quot;last-edit&quot;&gt;';
</span><span class="cx">                 if ( $last_id = get_post_meta($post_ID, '_edit_last', true) ) {
</span><span class="cx">                         $last_user = get_userdata($last_id);
</span></span></pre></div>
<a id="trunkwpadminincludesmetaboxesphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/meta-boxes.php (12986 => 12987)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/meta-boxes.php        2010-02-06 07:31:38 UTC (rev 12986)
+++ trunk/wp-admin/includes/meta-boxes.php        2010-02-06 10:07:57 UTC (rev 12987)
</span><span class="lines">@@ -71,8 +71,12 @@
</span><span class="cx">                 _e('Pending Review');
</span><span class="cx">                 break;
</span><span class="cx">         case 'draft':
</span><ins>+        case 'auto-draft':
</ins><span class="cx">                 _e('Draft');
</span><span class="cx">                 break;
</span><ins>+        case 'auto-draft':
+                _e('Unsaved');
+                break;
</ins><span class="cx"> }
</span><span class="cx"> ?&gt;
</span><span class="cx"> &lt;/span&gt;
</span><span class="lines">@@ -80,7 +84,7 @@
</span><span class="cx"> &lt;a href=&quot;#post_status&quot; &lt;?php if ( 'private' == $post-&gt;post_status ) { ?&gt;style=&quot;display:none;&quot; &lt;?php } ?&gt;class=&quot;edit-post-status hide-if-no-js&quot; tabindex='4'&gt;&lt;?php _e('Edit') ?&gt;&lt;/a&gt;
</span><span class="cx"> 
</span><span class="cx"> &lt;div id=&quot;post-status-select&quot; class=&quot;hide-if-js&quot;&gt;
</span><del>-&lt;input type=&quot;hidden&quot; name=&quot;hidden_post_status&quot; id=&quot;hidden_post_status&quot; value=&quot;&lt;?php echo esc_attr($post-&gt;post_status); ?&gt;&quot; /&gt;
</del><ins>+&lt;input type=&quot;hidden&quot; name=&quot;hidden_post_status&quot; id=&quot;hidden_post_status&quot; value=&quot;&lt;?php echo esc_attr( ('auto-draft' == $post-&gt;post_status ) ? 'draft' : $post-&gt;post_status); ?&gt;&quot; /&gt;
</ins><span class="cx"> &lt;select name='post_status' id='post_status' tabindex='4'&gt;
</span><span class="cx"> &lt;?php if ( 'publish' == $post-&gt;post_status ) : ?&gt;
</span><span class="cx"> &lt;option&lt;?php selected( $post-&gt;post_status, 'publish' ); ?&gt; value='publish'&gt;&lt;?php _e('Published') ?&gt;&lt;/option&gt;
</span><span class="lines">@@ -90,7 +94,11 @@
</span><span class="cx"> &lt;option&lt;?php selected( $post-&gt;post_status, 'future' ); ?&gt; value='future'&gt;&lt;?php _e('Scheduled') ?&gt;&lt;/option&gt;
</span><span class="cx"> &lt;?php endif; ?&gt;
</span><span class="cx"> &lt;option&lt;?php selected( $post-&gt;post_status, 'pending' ); ?&gt; value='pending'&gt;&lt;?php _e('Pending Review') ?&gt;&lt;/option&gt;
</span><ins>+&lt;?php if ( 'auto-draft' == $post-&gt;post_status ) : ?&gt;
+&lt;option&lt;?php selected( $post-&gt;post_status, 'auto-draft' ); ?&gt; value='draft'&gt;&lt;?php _e('Draft') ?&gt;&lt;/option&gt;
+&lt;?php else : ?&gt;
</ins><span class="cx"> &lt;option&lt;?php selected( $post-&gt;post_status, 'draft' ); ?&gt; value='draft'&gt;&lt;?php _e('Draft') ?&gt;&lt;/option&gt;
</span><ins>+&lt;?php endif; ?&gt;
</ins><span class="cx"> &lt;/select&gt;
</span><span class="cx">  &lt;a href=&quot;#post_status&quot; class=&quot;save-post-status hide-if-no-js button&quot;&gt;&lt;?php _e('OK'); ?&gt;&lt;/a&gt;
</span><span class="cx">  &lt;a href=&quot;#post_status&quot; class=&quot;cancel-post-status hide-if-no-js&quot;&gt;&lt;?php _e('Cancel'); ?&gt;&lt;/a&gt;
</span></span></pre></div>
<a id="trunkwpadminincludespostphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/post.php (12986 => 12987)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/post.php        2010-02-06 07:31:38 UTC (rev 12986)
+++ trunk/wp-admin/includes/post.php        2010-02-06 10:07:57 UTC (rev 12987)
</span><span class="lines">@@ -76,8 +76,6 @@
</span><span class="cx"> 
</span><span class="cx">         if ( isset( $post_data['ID'] ) )
</span><span class="cx">                 $post_id = $post_data['ID'];
</span><del>-        elseif ( isset( $post_data['temp_ID'] ) )
-                $post_id = $post_data['temp_ID'];
</del><span class="cx">         else
</span><span class="cx">                 $post_id = false;
</span><span class="cx">         $previous_status = $post_id ? get_post_field( 'post_status', $post_id ) : false;
</span><span class="lines">@@ -336,7 +334,8 @@
</span><span class="cx">  *@param string A post type string, defaults to 'post'.
</span><span class="cx">  * @return object stdClass object containing all the default post data as attributes
</span><span class="cx">  */
</span><del>-function get_default_post_to_edit( $post_type = 'post' ) {
</del><ins>+function get_default_post_to_edit( $post_type = 'post', $create_in_db = false ) {
+        global $wpdb;
</ins><span class="cx"> 
</span><span class="cx">         $post_title = '';
</span><span class="cx">         if ( !empty( $_REQUEST['post_title'] ) )
</span><span class="lines">@@ -350,26 +349,35 @@
</span><span class="cx">         if ( !empty( $_REQUEST['excerpt'] ) )
</span><span class="cx">                 $post_excerpt = esc_html( stripslashes( $_REQUEST['excerpt'] ));
</span><span class="cx"> 
</span><del>-        $post-&gt;ID = 0;
</del><ins>+        if ( $create_in_db ) {
+                // Cleanup old auto-drafts more than 7 days old
+                $old_posts = $wpdb-&gt;get_col( &quot;SELECT ID FROM $wpdb-&gt;posts WHERE post_status = 'auto-draft' AND DATE_SUB( NOW(), INTERVAL 7 DAY ) &gt; post_date&quot; );
+                foreach ( (array) $old_posts as $delete )
+                        wp_delete_post( $delete, true ); // Force delete
+                $post = get_post( wp_insert_post( array( 'post_title' =&gt; __( 'Auto Draft' ), 'post_type' =&gt; $post_type, 'post_status' =&gt; 'auto-draft' ) ) );
+        } else {
+                $post-&gt;ID = 0;
+                $post-&gt;post_author = '';
+                $post-&gt;post_date = '';
+                $post-&gt;post_date_gmt = '';
+                $post-&gt;post_password = '';
+                $post-&gt;post_type = $post_type;
+                $post-&gt;post_status = 'draft';
+                $post-&gt;to_ping = '';
+                $post-&gt;pinged = '';
+                $post-&gt;comment_status = get_option( 'default_comment_status' );
+                $post-&gt;ping_status = get_option( 'default_ping_status' );
+                $post-&gt;post_pingback = get_option( 'default_pingback_flag' );
+                $post-&gt;post_category = get_option( 'default_category' );
+                $post-&gt;page_template = 'default';
+                $post-&gt;post_parent = 0;
+                $post-&gt;menu_order = 0;
+        }
+
+        $post-&gt;post_content = apply_filters( 'default_content', $post_content );
+        $post-&gt;post_title   = apply_filters( 'default_title',   $post_title   );
+        $post-&gt;post_excerpt = apply_filters( 'default_excerpt', $post_excerpt );
</ins><span class="cx">         $post-&gt;post_name = '';
</span><del>-        $post-&gt;post_author = '';
-        $post-&gt;post_date = '';
-        $post-&gt;post_date_gmt = '';
-        $post-&gt;post_password = '';
-        $post-&gt;post_status = 'draft';
-        $post-&gt;post_type = $post_type;
-        $post-&gt;to_ping = '';
-        $post-&gt;pinged = '';
-        $post-&gt;comment_status = get_option( 'default_comment_status' );
-        $post-&gt;ping_status = get_option( 'default_ping_status' );
-        $post-&gt;post_pingback = get_option( 'default_pingback_flag' );
-        $post-&gt;post_category = get_option( 'default_category' );
-        $post-&gt;post_content = apply_filters( 'default_content', $post_content);
-        $post-&gt;post_title = apply_filters( 'default_title', $post_title );
-        $post-&gt;post_excerpt = apply_filters( 'default_excerpt', $post_excerpt);
-        $post-&gt;page_template = 'default';
-        $post-&gt;post_parent = 0;
-        $post-&gt;menu_order = 0;
</del><span class="cx"> 
</span><span class="cx">         return $post;
</span><span class="cx"> }
</span><span class="lines">@@ -465,6 +473,7 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         // Check for autosave collisions
</span><ins>+        // Does this need to be updated? ~ Mark
</ins><span class="cx">         $temp_id = false;
</span><span class="cx">         if ( isset($_POST['temp_ID']) ) {
</span><span class="cx">                 $temp_id = (int) $_POST['temp_ID'];
</span><span class="lines">@@ -473,7 +482,7 @@
</span><span class="cx">                 foreach ( $draft_ids as $temp =&gt; $real )
</span><span class="cx">                         if ( time() + $temp &gt; 86400 ) // 1 day: $temp is equal to -1 * time( then )
</span><span class="cx">                                 unset($draft_ids[$temp]);
</span><del>-
</del><ins>+        
</ins><span class="cx">                 if ( isset($draft_ids[$temp_id]) ) { // Edit, don't write
</span><span class="cx">                         $_POST['post_ID'] = $draft_ids[$temp_id];
</span><span class="cx">                         unset($_POST['temp_ID']);
</span><span class="lines">@@ -513,6 +522,7 @@
</span><span class="cx">         add_meta( $post_ID );
</span><span class="cx"> 
</span><span class="cx">         // Reunite any orphaned attachments with their parent
</span><ins>+        // Does this need to be udpated? ~ Mark
</ins><span class="cx">         if ( !$draft_ids = get_user_option( 'autosave_draft_ids' ) )
</span><span class="cx">                 $draft_ids = array();
</span><span class="cx">         if ( $draft_temp_id = (int) array_search( $post_ID, $draft_ids ) )
</span></span></pre></div>
<a id="trunkwpadminpostnewphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/post-new.php (12986 => 12987)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/post-new.php        2010-02-06 07:31:38 UTC (rev 12986)
+++ trunk/wp-admin/post-new.php        2010-02-06 10:07:57 UTC (rev 12987)
</span><span class="lines">@@ -50,7 +50,8 @@
</span><span class="cx"> 
</span><span class="cx"> // Show post form.
</span><span class="cx"> if ( current_user_can($post_type_object-&gt;edit_type_cap) ) {
</span><del>-        $post = get_default_post_to_edit( $post_type );
</del><ins>+        $post = get_default_post_to_edit( $post_type, true );
+        $post_ID = $post-&gt;ID;
</ins><span class="cx">         include('edit-form-advanced.php');
</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 (12986 => 12987)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/js/autosave.dev.js        2010-02-06 07:31:38 UTC (rev 12986)
+++ trunk/wp-includes/js/autosave.dev.js        2010-02-06 10:07:57 UTC (rev 12987)
</span><span class="lines">@@ -39,7 +39,7 @@
</span><span class="cx"> 
</span><span class="cx">         // preview
</span><span class="cx">         $('#post-preview').click(function(){
</span><del>-                if ( 1 &gt; $('#post_ID').val() &amp;&amp; notSaved ) {
</del><ins>+                if ( $('#auto_draft').val() == '1' &amp;&amp; notSaved ) {
</ins><span class="cx">                         autosaveDelayPreview = true;
</span><span class="cx">                         autosave();
</span><span class="cx">                         return false;
</span><span class="lines">@@ -58,7 +58,7 @@
</span><span class="cx">         if ( typeof tinyMCE != 'undefined' ) {
</span><span class="cx">                 $('#title')[$.browser.opera ? 'keypress' : 'keydown'](function (e) {
</span><span class="cx">                         if ( e.which == 9 &amp;&amp; !e.shiftKey &amp;&amp; !e.controlKey &amp;&amp; !e.altKey ) {
</span><del>-                                if ( ($(&quot;#post_ID&quot;).val() &lt; 1) &amp;&amp; ($(&quot;#title&quot;).val().length &gt; 0) ) { autosave(); }
</del><ins>+                                if ( ($('#auto_draft').val() == '1') &amp;&amp; ($(&quot;#title&quot;).val().length &gt; 0) ) { autosave(); }
</ins><span class="cx">                                 if ( tinyMCE.activeEditor &amp;&amp; ! tinyMCE.activeEditor.isHidden() &amp;&amp; dotabkey ) {
</span><span class="cx">                                         e.preventDefault();
</span><span class="cx">                                         dotabkey = false;
</span><span class="lines">@@ -70,11 +70,10 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         // autosave new posts after a title is typed but not if Publish or Save Draft is clicked
</span><del>-        if ( 0 &gt; $('#post_ID').val() ) {
</del><ins>+        if ( '1' == $('#auto_draft').val() ) {
</ins><span class="cx">                 $('#title').blur( function() {
</span><del>-                        if ( !this.value || 0 &lt; $('#post_ID').val() )
</del><ins>+                        if ( !this.value || $('#auto_draft').val() != '1' )
</ins><span class="cx">                                 return;
</span><del>-
</del><span class="cx">                         delayed_autosave();
</span><span class="cx">                 });
</span><span class="cx">         }
</span><span class="lines">@@ -121,24 +120,19 @@
</span><span class="cx"> 
</span><span class="cx"> // called when autosaving pre-existing post
</span><span class="cx"> function autosave_saved(response) {
</span><ins>+        blockSave = false;
</ins><span class="cx">         autosave_parse_response(response); // parse the ajax response
</span><span class="cx">         autosave_enable_buttons(); // re-enable disabled form buttons
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> // called when autosaving new post
</span><span class="cx"> function autosave_saved_new(response) {
</span><ins>+        blockSave = false;
</ins><span class="cx">         var res = autosave_parse_response(response), tempID, postID;
</span><del>-        // if no errors: update post_ID from the temporary value, grab new save-nonce for that new ID
</del><span class="cx">         if ( res &amp;&amp; res.responses.length &amp;&amp; !res.errors ) {
</span><del>-                tempID = jQuery('#post_ID').val();
</del><ins>+                // An ID is sent only for real auto-saves, not for autosave=0 &quot;keepalive&quot; saves
</ins><span class="cx">                 postID = parseInt( res.responses[0].id, 10 );
</span><span class="cx">                 autosave_update_post_ID( postID ); // disabled form buttons are re-enabled here
</span><del>-                if ( tempID &lt; 0 &amp;&amp; postID &gt; 0 ) { // update media buttons
-                        notSaved = false;
-                        jQuery('#media-buttons a').each(function(){
-                                this.href = this.href.replace(tempID, postID);
-                        });
-                }
</del><span class="cx">                 if ( autosaveDelayPreview ) {
</span><span class="cx">                         autosaveDelayPreview = false;
</span><span class="cx">                         doPreview();
</span><span class="lines">@@ -151,22 +145,11 @@
</span><span class="cx"> function autosave_update_post_ID( postID ) {
</span><span class="cx">         if ( !isNaN(postID) &amp;&amp; postID &gt; 0 ) {
</span><span class="cx">                 if ( postID == parseInt(jQuery('#post_ID').val(), 10) ) { return; } // no need to do this more than once
</span><del>-                jQuery('#post_ID').attr({name: &quot;post_ID&quot;});
-                jQuery('#post_ID').val(postID);
-                // We need new nonces
-                jQuery.post(autosaveL10n.requestFile, {
-                        action: &quot;autosave-generate-nonces&quot;,
-                        post_ID: postID,
-                        autosavenonce: jQuery('#autosavenonce').val(),
-                        post_type: jQuery('#post_type').val()
-                }, function(html) {
-                        jQuery('#_wpnonce').val(html.updateNonce);
-                        jQuery('#delete-action a.submitdelete').attr('href', html.deleteURL);
-                        autosave_enable_buttons(); // re-enable disabled form buttons
-                        jQuery('#delete-action a.submitdelete').fadeIn();
-                },
-                'json');
</del><ins>+                notSaved = false;
+                autosave_enable_buttons();
+                jQuery('#delete-action a.submitdelete').fadeIn();
</ins><span class="cx">                 jQuery('#hiddenaction').val('editpost');
</span><ins>+                jQuery('#auto_draft').val('0'); // No longer an auto-draft
</ins><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -217,6 +200,7 @@
</span><span class="cx"> 
</span><span class="cx"> autosave = function() {
</span><span class="cx">         // (bool) is rich editor enabled and active
</span><ins>+        blockSave = true;
</ins><span class="cx">         var rich = (typeof tinyMCE != &quot;undefined&quot;) &amp;&amp; tinyMCE.activeEditor &amp;&amp; !tinyMCE.activeEditor.isHidden(), post_data, doAutoSave, ed, origStatus, successCallback;
</span><span class="cx"> 
</span><span class="cx">         autosave_disable_buttons();
</span><span class="lines">@@ -281,6 +265,8 @@
</span><span class="cx">         if ( jQuery(&quot;#post_author&quot;).size() )
</span><span class="cx">                 post_data[&quot;post_author&quot;] = jQuery(&quot;#post_author&quot;).val();
</span><span class="cx">         post_data[&quot;user_ID&quot;] = jQuery(&quot;#user-id&quot;).val();
</span><ins>+        if ( jQuery('#auto_draft').val() == '1' )
+                post_data[&quot;auto_draft&quot;] = '1';
</ins><span class="cx"> 
</span><span class="cx">         if ( doAutoSave ) {
</span><span class="cx">                 autosaveLast = jQuery(&quot;#title&quot;).val()+jQuery(&quot;#content&quot;).val();
</span><span class="lines">@@ -288,15 +274,13 @@
</span><span class="cx">                 post_data['autosave'] = 0;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if ( parseInt(post_data[&quot;post_ID&quot;], 10) &lt; 1 ) {
-                post_data[&quot;temp_ID&quot;] = post_data[&quot;post_ID&quot;];
</del><ins>+        if ( post_data[&quot;auto_draft&quot;] == '1' ) {
</ins><span class="cx">                 successCallback = autosave_saved_new; // new post
</span><span class="cx">         } else {
</span><span class="cx">                 successCallback = autosave_saved; // pre-existing post
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         autosaveOldMessage = jQuery('#autosave').html();
</span><del>-
</del><span class="cx">         jQuery.ajax({
</span><span class="cx">                 data: post_data,
</span><span class="cx">                 beforeSend: doAutoSave ? autosave_loading : null,
</span></span></pre></div>
<a id="trunkwpincludesjsautosavejs"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/js/autosave.js (12986 => 12987)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/js/autosave.js        2010-02-06 07:31:38 UTC (rev 12986)
+++ trunk/wp-includes/js/autosave.js        2010-02-06 10:07:57 UTC (rev 12987)
</span><span class="lines">@@ -1 +1 @@
</span><del>-var autosave,autosaveLast=&quot;&quot;,autosavePeriodical,autosaveOldMessage=&quot;&quot;,autosaveDelayPreview=false,notSaved=true,blockSave=false,interimLogin=false;jQuery(document).ready(function(b){var a=true;autosaveLast=b(&quot;#post #title&quot;).val()+b(&quot;#post #content&quot;).val();autosavePeriodical=b.schedule({time:autosaveL10n.autosaveInterval*1000,func:function(){autosave()},repeat:true,protect:true});b(&quot;#post&quot;).submit(function(){b.cancel(autosavePeriodical)});b('input[type=&quot;submit&quot;], a.submitdelete',&quot;#submitpost&quot;).click(function(){blockSave=true;window.onbeforeunload=null;b(&quot;:button, :submit&quot;,&quot;#submitpost&quot;).each(function(){var c=b(this);if(c.hasClass(&quot;button-primary&quot;)){c.addClass(&quot;button-primary-disabled&quot;)}else{c.addClass(&quot;button-disabled&quot;)}});b(&quot;#ajax-loading&quot;).css(&quot;visibility&quot;,&quot;visible&quot;)});window.onbeforeunload=function(){var c=typeof(tinyMCE)!=&quot;undefined&quot;?tinyMCE.activeEditor:false,e,d;if(c&amp;&amp;!c.isHidden()){if(c.isDirty()){return autosaveL10n.saveAlert}}else{e=b(&quot;#post #title&quot;).val(),d=b(&quot;#post #content&quot;).val();if((e||d)&amp;&amp;e+d!=autosaveLast){return autosaveL10n.saveAlert}}};b(&quot;#post-preview&quot;).click(function(){if(1&gt;b(&quot;#post_ID&quot;).val()&amp;&amp;notSaved){autosaveDelayPreview=true;autosave();return false}doPreview();return false});doPreview=function(){b(&quot;input#wp-preview&quot;).val(&quot;dopreview&quot;);b(&quot;form#post&quot;).attr(&quot;target&quot;,&quot;wp-preview&quot;).submit().attr(&quot;target&quot;,&quot;&quot;);b(&quot;input#wp-preview&quot;).val(&quot;&quot;)};if(typeof tinyMCE!=&quot;undefined&quot;){b(&quot;#title&quot;)[b.browser.opera?&quot;keypress&quot;:&quot;keydown&quot;](function(c){if(c.which==9&amp;&amp;!c.shiftKey&amp;&amp;!c.controlKey&amp;&amp;!c.altKey){if((b(&quot;#post_ID&quot;).val()&lt;1)&amp;&amp;(b(&quot;#title&quot;).val().length&gt;0)){autosave()}if(tinyMCE.activeEditor&amp;&amp;!tinyMCE.activeEditor.isHidden()&amp;&amp;a){c.preventDefault();a=false;tinyMCE.activeEditor.focus();return false}}})}if(0&gt;b(&quot;#post_ID&quot;).val()){b(&quot;#title&quot;).blur(function(){if(!this.value||0&lt;b(&quot;#post_ID&quot;).val()){return}delayed_autosave()})}});function autosave_parse_response(c){var e=wpAjax.parseAjaxResponse(c,&quot;autosave&quot;),f=&quot;&quot;,a,b,d;if(e&amp;&amp;e.responses&amp;&amp;e.responses.length){f=e.responses[0].data;if(e.responses[0].supplemental){b=e.responses[0].supplemental;if(&quot;disable&quot;==b.disable_autosave){autosave=function(){};e={errors:true}}if(b.session_expired&amp;&amp;(d=b.session_expired)){if(!interimLogin||interimLogin.closed){interimLogin=window.open(d,&quot;login&quot;,&quot;width=600,height=450,resizable=yes,scrollbars=yes,status=yes&quot;);interimLogin.focus()}delete b.session_expired}jQuery.each(b,function(g,h){if(g.match(/^replace-/)){jQuery(&quot;#&quot;+g.replace(&quot;replace-&quot;,&quot;&quot;)).val(h)}})}if(!e.errors){a=parseInt(e.responses[0].id,10);if(!isNaN(a)&amp;&amp;a&gt;0){autosave_update_slug(a)}}}if(f){jQuery(&quot;#autosave&quot;).html(f)}else{if(autosaveOldMessage&amp;&amp;e){jQuery(&quot;#autosave&quot;).html(autosaveOldMessage)}}return e}function autosave_saved(a){autosave_parse_response(a);autosave_enable_buttons()}function autosave_saved_new(b){var d=autosave_parse_response(b),c,a;if(d&amp;&amp;d.responses.length&amp;&amp;!d.errors){c=jQuery(&quot;#post_ID&quot;).val();a=parseInt(d.responses[0].id,10);autosave_update_post_ID(a);if(c&lt;0&amp;&amp;a&gt;0){notSaved=false;jQuery(&quot;#media-buttons a&quot;).each(function(){this.href=this.href.replace(c,a)})}if(autosaveDelayPreview){autosaveDelayPreview=false;doPreview()}}else{autosave_enable_buttons()}}function autosave_update_post_ID(a){if(!isNaN(a)&amp;&amp;a&gt;0){if(a==parseInt(jQuery(&quot;#post_ID&quot;).val(),10)){return}jQuery(&quot;#post_ID&quot;).attr({name:&quot;post_ID&quot;});jQuery(&quot;#post_ID&quot;).val(a);jQuery.post(autosaveL10n.requestFile,{action:&quot;autosave-generate-nonces&quot;,post_ID:a,autosavenonce:jQuery(&quot;#autosavenonce&quot;).val(),post_type:jQuery(&quot;#post_type&quot;).val()},function(b){jQuery(&quot;#_wpnonce&quot;).val(b.updateNonce);jQuery(&quot;#delete-action a.submitdelete&quot;).attr(&quot;href&quot;,b.deleteURL);autosave_enable_buttons();jQuery(&quot;#delete-action a.submitdelete&quot;).fadeIn()},&quot;json&quot;);jQuery(&quot;#hiddenaction&quot;).val(&quot;editpost&quot;)}}function autosave_update_slug(a){if(&quot;undefined&quot;!=makeSlugeditClickable&amp;&amp;jQuery.isFunction(makeSlugeditClickable)&amp;&amp;!jQuery(&quot;#edit-slug-box &gt; *&quot;).size()){jQuery.post(ajaxurl,{action:&quot;sample-permalink&quot;,post_id:a,new_title:jQuery(&quot;#title&quot;).val(),samplepermalinknonce:jQuery(&quot;#samplepermalinknonce&quot;).val()},function(b){jQuery(&quot;#edit-slug-box&quot;).html(b);makeSlugeditClickable()})}}function autosave_loading(){jQuery(&quot;#autosave&quot;).html(autosaveL10n.savingText)}function autosave_enable_buttons(){setTimeout(function(){jQuery(&quot;:button, :submit&quot;,&quot;#submitpost&quot;).removeAttr(&quot;disabled&quot;);jQuery(&quot;#ajax-loading&quot;).css(&quot;visibility&quot;,&quot;hidden&quot;)},500)}function autosave_disable_buttons(){jQuery(&quot;:button, :submit&quot;,&quot;#submitpost&quot;).attr(&quot;disabled&quot;,&quot;disabled&quot;);setTimeout(autosave_enable_buttons,5000)}function delayed_autosave(){setTimeout(function(){if(blockSave){return}autosave()},200)}autosave=function(){var c=(typeof tinyMCE!=&quot;undefined&quot;)&amp;&amp;tinyMCE.activeEditor&amp;&amp;!tinyMCE.activeEditor.isHidden(),d,f,b,e,a;autosave_disable_buttons();d={action:&quot;autosave&quot;,post_ID:jQuery(&quot;#post_ID&quot;).val()||0,post_title:jQuery(&quot;#title&quot;).val()||&quot;&quot;,autosavenonce:jQuery(&quot;#autosavenonce&quot;).val(),post_type:jQuery(&quot;#post_type&quot;).val()||&quot;&quot;,autosave:1};jQuery(&quot;.tags-input&quot;).each(function(){d[this.name]=this.value});f=true;if(jQuery(&quot;#TB_window&quot;).css(&quot;display&quot;)==&quot;block&quot;){f=false}if(c&amp;&amp;f){b=tinyMCE.activeEditor;if(b.plugins.spellchecker&amp;&amp;b.plugins.spellchecker.active){f=false}else{if(&quot;mce_fullscreen&quot;==b.id){tinyMCE.get(&quot;content&quot;).setContent(b.getContent({format:&quot;raw&quot;}),{format:&quot;raw&quot;})}tinyMCE.get(&quot;content&quot;).save()}}d.content=jQuery(&quot;#content&quot;).val();if(jQuery(&quot;#post_name&quot;).val()){d.post_name=jQuery(&quot;#post_name&quot;).val()}if((d.post_title.length==0&amp;&amp;d.content.length==0)||d.post_title+d.content==autosaveLast){f=false}e=jQuery(&quot;#original_post_status&quot;).val();goodcats=([]);jQuery(&quot;[name='post_category[]']:checked&quot;).each(function(g){goodcats.push(this.value)});d.catslist=goodcats.join(&quot;,&quot;);if(jQuery(&quot;#comment_status&quot;).attr(&quot;checked&quot;)){d.comment_status=&quot;open&quot;}if(jQuery(&quot;#ping_status&quot;).attr(&quot;checked&quot;)){d.ping_status=&quot;open&quot;}if(jQuery(&quot;#excerpt&quot;).size()){d.excerpt=jQuery(&quot;#excerpt&quot;).val()}if(jQuery(&quot;#post_author&quot;).size()){d.post_author=jQuery(&quot;#post_author&quot;).val()}d.user_ID=jQuery(&quot;#user-id&quot;).val();if(f){autosaveLast=jQuery(&quot;#title&quot;).val()+jQuery(&quot;#content&quot;).val()}else{d.autosave=0}if(parseInt(d.post_ID,10)&lt;1){d.temp_ID=d.post_ID;a=autosave_saved_new}else{a=autosave_saved}autosaveOldMessage=jQuery(&quot;#autosave&quot;).html();jQuery.ajax({data:d,beforeSend:f?autosave_loading:null,type:&quot;POST&quot;,url:autosaveL10n.requestFile,success:a})};
</del><span class="cx">\ No newline at end of file
</span><ins>+var autosave,autosaveLast=&quot;&quot;,autosavePeriodical,autosaveOldMessage=&quot;&quot;,autosaveDelayPreview=false,notSaved=true,blockSave=false,interimLogin=false;jQuery(document).ready(function($){var dotabkey=true;autosaveLast=$(&quot;#post #title&quot;).val()+$(&quot;#post #content&quot;).val();autosavePeriodical=$.schedule({time:autosaveL10n.autosaveInterval*1000,func:function(){autosave()},repeat:true,protect:true});$(&quot;#post&quot;).submit(function(){$.cancel(autosavePeriodical)});$('input[type=&quot;submit&quot;], a.submitdelete',&quot;#submitpost&quot;).click(function(){blockSave=true;window.onbeforeunload=null;$(&quot;:button, :submit&quot;,&quot;#submitpost&quot;).each(function(){var t=$(this);if(t.hasClass(&quot;button-primary&quot;)){t.addClass(&quot;button-primary-disabled&quot;)}else{t.addClass(&quot;button-disabled&quot;)}});$(&quot;#ajax-loading&quot;).css(&quot;visibility&quot;,&quot;visible&quot;)});window.onbeforeunload=function(){var mce=typeof(tinyMCE)!=&quot;undefined&quot;?tinyMCE.activeEditor:false,title,content;if(mce&amp;&amp;!mce.isHidden()){if(mce.isDirty()){return autosaveL10n.saveAlert}}else{title=$(&quot;#post #title&quot;).val(),content=$(&quot;#post #content&quot;).val();if((title||content)&amp;&amp;title+content!=autosaveLast){return autosaveL10n.saveAlert}}};$(&quot;#post-preview&quot;).click(function(){if($(&quot;#auto_draft&quot;).val()==&quot;1&quot;&amp;&amp;notSaved){autosaveDelayPreview=true;autosave();return false}doPreview();return false});doPreview=function(){$(&quot;input#wp-preview&quot;).val(&quot;dopreview&quot;);$(&quot;form#post&quot;).attr(&quot;target&quot;,&quot;wp-preview&quot;).submit().attr(&quot;target&quot;,&quot;&quot;);$(&quot;input#wp-preview&quot;).val(&quot;&quot;)};if(typeof tinyMCE!=&quot;undefined&quot;){$(&quot;#title&quot;)[$.browser.opera?&quot;keypress&quot;:&quot;keydown&quot;](function(e){if(e.which==9&amp;&amp;!e.shiftKey&amp;&amp;!e.controlKey&amp;&amp;!e.altKey){if(($(&quot;#auto_draft&quot;).val()==&quot;1&quot;)&amp;&amp;($(&quot;#title&quot;).val().length&gt;0)){autosave()}if(tinyMCE.activeEditor&amp;&amp;!tinyMCE.activeEditor.isHidden()&amp;&amp;dotabkey){e.preventDefault();dotabkey=false;tinyMCE.activeEditor.focus();return false}}})}if(&quot;1&quot;==$(&quot;#auto_draft&quot;).val()){$(&quot;#title&quot;).blur(function(){if(!this.value||$(&quot;#auto_draft&quot;).val()!=&quot;1&quot;){return}delayed_autosave()})}});function autosave_parse_response(response){var res=wpAjax.parseAjaxResponse(response,&quot;autosave&quot;),message=&quot;&quot;,postID,sup,url;if(res&amp;&amp;res.responses&amp;&amp;res.responses.length){message=res.responses[0].data;if(res.responses[0].supplemental){sup=res.responses[0].supplemental;if(&quot;disable&quot;==sup.disable_autosave){autosave=function(){};res={errors:true}}if(sup.session_expired&amp;&amp;(url=sup.session_expired)){if(!interimLogin||interimLogin.closed){interimLogin=window.open(url,&quot;login&quot;,&quot;width=600,height=450,resizable=yes,scrollbars=yes,status=yes&quot;);interimLogin.focus()}delete sup.session_expired}jQuery.each(sup,function(selector,value){if(selector.match(/^replace-/)){jQuery(&quot;#&quot;+selector.replace(&quot;replace-&quot;,&quot;&quot;)).val(value)}})}if(!res.errors){postID=parseInt(res.responses[0].id,10);if(!isNaN(postID)&amp;&amp;postID&gt;0){autosave_update_slug(postID)}}}if(message){jQuery(&quot;#autosave&quot;).html(message)}else{if(autosaveOldMessage&amp;&amp;res){jQuery(&quot;#autosave&quot;).html(autosaveOldMessage)}}return res}function autosave_saved(response){blockSave=false;autosave_parse_response(response);autosave_enable_buttons()}function autosave_saved_new(response){blockSave=false;var res=autosave_parse_response(response),tempID,postID;if(res&amp;&amp;res.responses.length&amp;&amp;!res.errors){postID=parseInt(res.responses[0].id,10);autosave_update_post_ID(postID);if(autosaveDelayPreview){autosaveDelayPreview=false;doPreview()}}else{autosave_enable_buttons()}}function autosave_update_post_ID(postID){if(!isNaN(postID)&amp;&amp;postID&gt;0){if(postID==parseInt(jQuery(&quot;#post_ID&quot;).val(),10)){return}notSaved=false;autosave_enable_buttons();jQuery(&quot;#delete-action a.submitdelete&quot;).fadeIn();jQuery(&quot;#hiddenaction&quot;).val(&quot;editpost&quot;);jQuery(&quot;#auto_draft&quot;).val(&quot;0&quot;)}}function autosave_update_slug(post_id){if(&quot;undefined&quot;!=makeSlugeditClickable&amp;&amp;jQuery.isFunction(makeSlugeditClickable)&amp;&amp;!jQuery(&quot;#edit-slug-box &gt; *&quot;).size()){jQuery.post(ajaxurl,{action:&quot;sample-permalink&quot;,post_id:post_id,new_title:jQuery(&quot;#title&quot;).val(),samplepermalinknonce:jQuery(&quot;#samplepermalinknonce&quot;).val()},function(data){jQuery(&quot;#edit-slug-box&quot;).html(data);makeSlugeditClickable()})}}function autosave_loading(){jQuery(&quot;#autosave&quot;).html(autosaveL10n.savingText)}function autosave_enable_buttons(){setTimeout(function(){jQuery(&quot;:button, :submit&quot;,&quot;#submitpost&quot;).removeAttr(&quot;disabled&quot;);jQuery(&quot;#ajax-loading&quot;).css(&quot;visibility&quot;,&quot;hidden&quot;)},500)}function autosave_disable_buttons(){jQuery(&quot;:button, :submit&quot;,&quot;#submitpost&quot;).attr(&quot;disabled&quot;,&quot;disabled&quot;);setTimeout(autosave_enable_buttons,5000)}function delayed_autosave(){setTimeout(function(){if(blockSave){return}autosave()},200)}autosave=function(){blockSave=true;var rich=(typeof tinyMCE!=&quot;undefined&quot;)&amp;&amp;tinyMCE.activeEditor&amp;&amp;!tinyMCE.activeEditor.isHidden(),post_data,doAutoSave,ed,origStatus,successCallback;autosave_disable_buttons();post_data={action:&quot;autosave&quot;,post_ID:jQuery(&quot;#post_ID&quot;).val()||0,post_title:jQuery(&quot;#title&quot;).val()||&quot;&quot;,autosavenonce:jQuery(&quot;#autosavenonce&quot;).val(),post_type:jQuery(&quot;#post_type&quot;).val()||&quot;&quot;,autosave:1};jQuery(&quot;.tags-input&quot;).each(function(){post_data[this.name]=this.value});doAutoSave=true;if(jQuery(&quot;#TB_window&quot;).css(&quot;display&quot;)==&quot;block&quot;){doAutoSave=false}if(rich&amp;&amp;doAutoSave){ed=tinyMCE.activeEditor;if(ed.plugins.spellchecker&amp;&amp;ed.plugins.spellchecker.active){doAutoSave=false}else{if(&quot;mce_fullscreen&quot;==ed.id){tinyMCE.get(&quot;content&quot;).setContent(ed.getContent({format:&quot;raw&quot;}),{format:&quot;raw&quot;})}tinyMCE.get(&quot;content&quot;).save()}}post_data.content=jQuery(&quot;#content&quot;).val();if(jQuery(&quot;#post_name&quot;).val()){post_data.post_name=jQuery(&quot;#post_name&quot;).val()}if((post_data.post_title.length==0&amp;&amp;post_data.content.length==0)||post_data.post_title+post_data.content==autosaveLast){doAutoSave=false}origStatus=jQuery(&quot;#original_post_status&quot;).val();goodcats=([]);jQuery(&quot;[name='post_category[]']:checked&quot;).each(function(i){goodcats.push(this.value)});post_data.catslist=goodcats.join(&quot;,&quot;);if(jQuery(&quot;#comment_status&quot;).attr(&quot;checked&quot;)){post_data.comment_status=&quot;open&quot;}if(jQuery(&quot;#ping_status&quot;).attr(&quot;checked&quot;)){post_data.ping_status=&quot;open&quot;}if(jQuery(&quot;#excerpt&quot;).size()){post_data.excerpt=jQuery(&quot;#excerpt&quot;).val()}if(jQuery(&quot;#post_author&quot;).size()){post_data.post_author=jQuery(&quot;#post_author&quot;).val()}post_data.user_ID=jQuery(&quot;#user-id&quot;).val();if(jQuery(&quot;#auto_draft&quot;).val()==&quot;1&quot;){post_data.auto_draft=&quot;1&quot;}if(doAutoSave){autosaveLast=jQuery(&quot;#title&quot;).val()+jQuery(&quot;#content&quot;).val()}else{post_data.autosave=0}if(post_data.auto_draft==&quot;1&quot;){successCallback=autosave_saved_new}else{successCallback=autosave_saved}autosaveOldMessage=jQuery(&quot;#autosave&quot;).html();jQuery.ajax({data:post_data,beforeSend:doAutoSave?autosave_loading:null,type:&quot;POST&quot;,url:autosaveL10n.requestFile,success:successCallback})};
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkwpincludeslinktemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/link-template.php (12986 => 12987)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/link-template.php        2010-02-06 07:31:38 UTC (rev 12986)
+++ trunk/wp-includes/link-template.php        2010-02-06 10:07:57 UTC (rev 12987)
</span><span class="lines">@@ -111,7 +111,7 @@
</span><span class="cx"> 
</span><span class="cx">         $permalink = get_option('permalink_structure');
</span><span class="cx"> 
</span><del>-        if ( '' != $permalink &amp;&amp; !in_array($post-&gt;post_status, array('draft', 'pending')) ) {
</del><ins>+        if ( '' != $permalink &amp;&amp; !in_array($post-&gt;post_status, array('draft', 'pending', 'auto-draft')) ) {
</ins><span class="cx">                 $unixtime = strtotime($post-&gt;post_date);
</span><span class="cx"> 
</span><span class="cx">                 $category = '';
</span></span></pre></div>
<a id="trunkwpincludespostphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/post.php (12986 => 12987)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/post.php        2010-02-06 07:31:38 UTC (rev 12986)
+++ trunk/wp-includes/post.php        2010-02-06 10:07:57 UTC (rev 12987)
</span><span class="lines">@@ -1976,7 +1976,7 @@
</span><span class="cx">         // Create a valid post name.  Drafts and pending posts are allowed to have an empty
</span><span class="cx">         // post name.
</span><span class="cx">         if ( !isset($post_name) || empty($post_name) ) {
</span><del>-                if ( !in_array( $post_status, array( 'draft', 'pending' ) ) )
</del><ins>+                if ( !in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ) ) )
</ins><span class="cx">                         $post_name = sanitize_title($post_title);
</span><span class="cx">                 else
</span><span class="cx">                         $post_name = '';
</span><span class="lines">@@ -1989,7 +1989,7 @@
</span><span class="cx">                 $post_date = current_time('mysql');
</span><span class="cx"> 
</span><span class="cx">         if ( empty($post_date_gmt) || '0000-00-00 00:00:00' == $post_date_gmt ) {
</span><del>-                if ( !in_array( $post_status, array( 'draft', 'pending' ) ) )
</del><ins>+                if ( !in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ) ) )
</ins><span class="cx">                         $post_date_gmt = get_gmt_from_date($post_date);
</span><span class="cx">                 else
</span><span class="cx">                         $post_date_gmt = '0000-00-00 00:00:00';
</span><span class="lines">@@ -2089,7 +2089,7 @@
</span><span class="cx">                 $where = array( 'ID' =&gt; $post_ID );
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if ( empty($data['post_name']) &amp;&amp; !in_array( $data['post_status'], array( 'draft', 'pending' ) ) ) {
</del><ins>+        if ( empty($data['post_name']) &amp;&amp; !in_array( $data['post_status'], array( 'draft', 'pending', 'auto-draft' ) ) ) {
</ins><span class="cx">                 $data['post_name'] = sanitize_title($data['post_title'], $post_ID);
</span><span class="cx">                 $wpdb-&gt;update( $wpdb-&gt;posts, array( 'post_name' =&gt; $data['post_name'] ), $where );
</span><span class="cx">         }
</span><span class="lines">@@ -2172,7 +2172,7 @@
</span><span class="cx">                 $post_cats = $post['post_category'];
</span><span class="cx"> 
</span><span class="cx">         // Drafts shouldn't be assigned a date unless explicitly done so by the user
</span><del>-        if ( in_array($post['post_status'], array('draft', 'pending')) &amp;&amp; empty($postarr['edit_date']) &amp;&amp;
</del><ins>+        if ( in_array($post['post_status'], array('draft', 'pending', 'auto-draft')) &amp;&amp; empty($postarr['edit_date']) &amp;&amp;
</ins><span class="cx">                          ('0000-00-00 00:00:00' == $post['post_date_gmt']) )
</span><span class="cx">                 $clear_date = true;
</span><span class="cx">         else
</span><span class="lines">@@ -2276,7 +2276,7 @@
</span><span class="cx">  * @return string unique slug for the post, based on $post_name (with a -1, -2, etc. suffix)
</span><span class="cx">  */
</span><span class="cx"> function wp_unique_post_slug($slug, $post_ID, $post_status, $post_type, $post_parent) {
</span><del>-        if ( in_array( $post_status, array( 'draft', 'pending' ) ) )
</del><ins>+        if ( in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ) ) )
</ins><span class="cx">                 return $slug;
</span><span class="cx"> 
</span><span class="cx">         global $wpdb, $wp_rewrite;
</span></span></pre></div>
<a id="trunkwpincludesscriptloaderphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/script-loader.php (12986 => 12987)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/script-loader.php        2010-02-06 07:31:38 UTC (rev 12986)
+++ trunk/wp-includes/script-loader.php        2010-02-06 10:07:57 UTC (rev 12987)
</span><span class="lines">@@ -99,7 +99,7 @@
</span><span class="cx">                 'l10n_print_after' =&gt; 'try{convertEntities(wpAjax);}catch(e){};'
</span><span class="cx">         ) );
</span><span class="cx"> 
</span><del>-        $scripts-&gt;add( 'autosave', &quot;/wp-includes/js/autosave$suffix.js&quot;, array('schedule', 'wp-ajax-response'), '20091012' );
</del><ins>+        $scripts-&gt;add( 'autosave', &quot;/wp-includes/js/autosave$suffix.js&quot;, array('schedule', 'wp-ajax-response'), '20100205' );
</ins><span class="cx">         $scripts-&gt;add_data( 'autosave', 'group', 1 );
</span><span class="cx"> 
</span><span class="cx">         $scripts-&gt;add( 'wp-lists', &quot;/wp-includes/js/wp-lists$suffix.js&quot;, array('wp-ajax-response'), '20091128' );
</span></span></pre>
</div>
</div>

</body>
</html>