Changeset 12987
- Timestamp:
- 02/06/2010 10:07:57 AM (15 years ago)
- Location:
- trunk
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/admin-ajax.php
r12942 r12987 888 888 889 889 $id = $revision_id = 0; 890 if ( $_POST['post_ID'] < 0 ) { 890 891 $post_ID = (int) $_POST['post_ID']; 892 $_POST['ID'] = $post_ID; 893 $post = get_post($post_ID); 894 if ( 'auto-draft' == $post->post_status ) 891 895 $_POST['post_status'] = 'draft'; 892 $_POST['temp_ID'] = $_POST['post_ID']; 893 if ( $do_autosave ) { 894 $id = wp_write_post(); 895 $data = $message; 896 } 896 897 if ( $last = wp_check_post_lock( $post->ID ) ) { 898 $do_autosave = $do_lock = false; 899 900 $last_user = get_userdata( $last ); 901 $last_user_name = $last_user ? $last_user->display_name : __( 'Someone' ); 902 $data = new WP_Error( 'locked', sprintf( 903 $_POST['post_type'] == 'page' ? __( 'Autosave disabled: %s is currently editing this page.' ) : __( 'Autosave disabled: %s is currently editing this post.' ), 904 esc_html( $last_user_name ) 905 ) ); 906 907 $supplemental['disable_autosave'] = 'disable'; 908 } 909 910 if ( 'page' == $post->post_type ) { 911 if ( !current_user_can('edit_page', $post_ID) ) 912 die(__('You are not allowed to edit this page.')); 897 913 } else { 898 $post_ID = (int) $_POST['post_ID']; 899 $_POST['ID'] = $post_ID; 900 $post = get_post($post_ID); 901 902 if ( $last = wp_check_post_lock( $post->ID ) ) { 903 $do_autosave = $do_lock = false; 904 905 $last_user = get_userdata( $last ); 906 $last_user_name = $last_user ? $last_user->display_name : __( 'Someone' ); 907 $data = new WP_Error( 'locked', sprintf( 908 $_POST['post_type'] == 'page' ? __( 'Autosave disabled: %s is currently editing this page.' ) : __( 'Autosave disabled: %s is currently editing this post.' ), 909 esc_html( $last_user_name ) 910 ) ); 911 912 $supplemental['disable_autosave'] = 'disable'; 913 } 914 915 if ( 'page' == $post->post_type ) { 916 if ( !current_user_can('edit_page', $post_ID) ) 917 die(__('You are not allowed to edit this page.')); 918 } else { 919 if ( !current_user_can('edit_post', $post_ID) ) 920 die(__('You are not allowed to edit this post.')); 921 } 922 923 if ( $do_autosave ) { 924 // Drafts are just overwritten by autosave 925 if ( 'draft' == $post->post_status ) { 926 $id = edit_post(); 927 } else { // Non drafts are not overwritten. The autosave is stored in a special post revision. 928 $revision_id = wp_create_post_autosave( $post->ID ); 929 if ( is_wp_error($revision_id) ) 930 $id = $revision_id; 931 else 932 $id = $post->ID; 933 } 934 $data = $message; 935 } else { 914 if ( !current_user_can('edit_post', $post_ID) ) 915 die(__('You are not allowed to edit this post.')); 916 } 917 918 if ( $do_autosave ) { 919 // Drafts and auto-drafts are just overwritten by autosave 920 if ( 'auto-draft' == $post->post_status || 'draft' == $post->post_status ) { 921 $id = edit_post(); 922 } else { // Non drafts are not overwritten. The autosave is stored in a special post revision. 923 $revision_id = wp_create_post_autosave( $post->ID ); 924 if ( is_wp_error($revision_id) ) 925 $id = $revision_id; 926 else 927 $id = $post->ID; 928 } 929 $data = $message; 930 } else { 931 if ( '1' == $_POST['auto_draft'] ) 932 $id = 0; // This tells us it didn't actually save 933 else 936 934 $id = $post->ID; 937 } 938 } 939 940 if ( $do_lock && $id && is_numeric($id) ) 935 } 936 937 if ( $do_lock && $_POST['auto_draft'] != '1' && $id && is_numeric($id) ) 941 938 wp_set_post_lock( $id ); 942 939 … … 962 959 $x->send(); 963 960 break; 964 case 'autosave-generate-nonces' :965 check_ajax_referer( 'autosave', 'autosavenonce' );966 $ID = (int) $_POST['post_ID'];967 $post_type = $_POST['post_type'];968 $post_type_object = get_post_type_object($post_type);969 if ( !$post_type_object )970 die('0');971 if ( current_user_can( $post_type_object->edit_cap, $ID ) )972 die( json_encode( array( 'updateNonce' => wp_create_nonce( "update-{$post_type}_{$ID}" ), 'deleteURL' => str_replace( '&', '&', wp_nonce_url( admin_url( $post_type . '.php?action=trash&post=' . $ID ), "trash-{$post_type}_{$ID}" ) ) ) ) );973 do_action('autosave_generate_nonces');974 die('0');975 break;976 961 case 'closed-postboxes' : 977 962 check_ajax_referer( 'closedpostboxes', 'closedpostboxesnonce' ); -
trunk/wp-admin/edit-form-advanced.php
r12937 r12987 61 61 62 62 $notice = false; 63 if ( 0 == $post_ID ) { 64 $form_action = 'post'; 65 $nonce_action = 'add-' . $post_type; 66 $temp_ID = -1 * time(); // don't change this formula without looking at wp_write_post() 67 $form_extra = "<input type='hidden' id='post_ID' name='temp_ID' value='" . esc_attr($temp_ID) . "' />"; 63 $form_extra = ''; 64 if ( 'auto-draft' == $post->post_status ) { 65 if ( 'edit' == $action ) 66 $post->post_title = ''; 68 67 $autosave = false; 68 $form_extra .= "<input type='hidden' id='auto_draft' name='auto_draft' value='1' />"; 69 69 } else { 70 $form_action = 'editpost';71 $nonce_action = 'update-' . $post_type . '_' . $post_ID;72 $form_extra = "<input type='hidden' id='post_ID' name='post_ID' value='" . esc_attr($post_ID) . "' />";73 70 $autosave = wp_get_post_autosave( $post_ID ); 74 75 // Detect if there exists an autosave newer than the post and if that autosave is different than the post 76 if ( $autosave && mysql2date( 'U', $autosave->post_modified_gmt, false ) > mysql2date( 'U', $post->post_modified_gmt, false ) ) { 77 foreach ( _wp_post_revision_fields() as $autosave_field => $_autosave_field ) { 78 if ( normalize_whitespace( $autosave->$autosave_field ) != normalize_whitespace( $post->$autosave_field ) ) { 79 $notice = sprintf( __( 'There is an autosave of this post that is more recent than the version below. <a href="%s">View the autosave</a>' ), get_edit_post_link( $autosave->ID ) ); 80 break; 81 } 71 } 72 73 $form_action = 'editpost'; 74 $nonce_action = 'update-' . $post_type . '_' . $post_ID; 75 $form_extra .= "<input type='hidden' id='post_ID' name='post_ID' value='" . esc_attr($post_ID) . "' />"; 76 77 // Detect if there exists an autosave newer than the post and if that autosave is different than the post 78 if ( $autosave && mysql2date( 'U', $autosave->post_modified_gmt, false ) > mysql2date( 'U', $post->post_modified_gmt, false ) ) { 79 foreach ( _wp_post_revision_fields() as $autosave_field => $_autosave_field ) { 80 if ( normalize_whitespace( $autosave->$autosave_field ) != normalize_whitespace( $post->$autosave_field ) ) { 81 $notice = sprintf( __( 'There is an autosave of this post that is more recent than the version below. <a href="%s">View the autosave</a>' ), get_edit_post_link( $autosave->ID ) ); 82 break; 82 83 } 83 unset($autosave_field, $_autosave_field);84 84 } 85 unset($autosave_field, $_autosave_field); 85 86 } 86 87 … … 198 199 <div id="edit-slug-box"> 199 200 <?php 200 if ( ! empty($post->ID) && ! empty($sample_permalink_html) ) :201 if ( ! empty($post->ID) && ! empty($sample_permalink_html) && 'auto-draft' != $post->post_status ) : 201 202 echo $sample_permalink_html; 202 203 endif; ?> … … 216 217 <span id="autosave"> </span> 217 218 <?php 218 if ( $post_ID) {219 if ( 'auto-draft' != $post->post_status ) { 219 220 echo '<span id="last-edit">'; 220 221 if ( $last_id = get_post_meta($post_ID, '_edit_last', true) ) { -
trunk/wp-admin/includes/meta-boxes.php
r12967 r12987 72 72 break; 73 73 case 'draft': 74 case 'auto-draft': 74 75 _e('Draft'); 76 break; 77 case 'auto-draft': 78 _e('Unsaved'); 75 79 break; 76 80 } … … 81 85 82 86 <div id="post-status-select" class="hide-if-js"> 83 <input type="hidden" name="hidden_post_status" id="hidden_post_status" value="<?php echo esc_attr( $post->post_status); ?>" />87 <input type="hidden" name="hidden_post_status" id="hidden_post_status" value="<?php echo esc_attr( ('auto-draft' == $post->post_status ) ? 'draft' : $post->post_status); ?>" /> 84 88 <select name='post_status' id='post_status' tabindex='4'> 85 89 <?php if ( 'publish' == $post->post_status ) : ?> … … 91 95 <?php endif; ?> 92 96 <option<?php selected( $post->post_status, 'pending' ); ?> value='pending'><?php _e('Pending Review') ?></option> 97 <?php if ( 'auto-draft' == $post->post_status ) : ?> 98 <option<?php selected( $post->post_status, 'auto-draft' ); ?> value='draft'><?php _e('Draft') ?></option> 99 <?php else : ?> 93 100 <option<?php selected( $post->post_status, 'draft' ); ?> value='draft'><?php _e('Draft') ?></option> 101 <?php endif; ?> 94 102 </select> 95 103 <a href="#post_status" class="save-post-status hide-if-no-js button"><?php _e('OK'); ?></a> -
trunk/wp-admin/includes/post.php
r12954 r12987 77 77 if ( isset( $post_data['ID'] ) ) 78 78 $post_id = $post_data['ID']; 79 elseif ( isset( $post_data['temp_ID'] ) )80 $post_id = $post_data['temp_ID'];81 79 else 82 80 $post_id = false; … … 337 335 * @return object stdClass object containing all the default post data as attributes 338 336 */ 339 function get_default_post_to_edit( $post_type = 'post' ) { 337 function get_default_post_to_edit( $post_type = 'post', $create_in_db = false ) { 338 global $wpdb; 340 339 341 340 $post_title = ''; … … 351 350 $post_excerpt = esc_html( stripslashes( $_REQUEST['excerpt'] )); 352 351 353 $post->ID = 0; 352 if ( $create_in_db ) { 353 // Cleanup old auto-drafts more than 7 days old 354 $old_posts = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_status = 'auto-draft' AND DATE_SUB( NOW(), INTERVAL 7 DAY ) > post_date" ); 355 foreach ( (array) $old_posts as $delete ) 356 wp_delete_post( $delete, true ); // Force delete 357 $post = get_post( wp_insert_post( array( 'post_title' => __( 'Auto Draft' ), 'post_type' => $post_type, 'post_status' => 'auto-draft' ) ) ); 358 } else { 359 $post->ID = 0; 360 $post->post_author = ''; 361 $post->post_date = ''; 362 $post->post_date_gmt = ''; 363 $post->post_password = ''; 364 $post->post_type = $post_type; 365 $post->post_status = 'draft'; 366 $post->to_ping = ''; 367 $post->pinged = ''; 368 $post->comment_status = get_option( 'default_comment_status' ); 369 $post->ping_status = get_option( 'default_ping_status' ); 370 $post->post_pingback = get_option( 'default_pingback_flag' ); 371 $post->post_category = get_option( 'default_category' ); 372 $post->page_template = 'default'; 373 $post->post_parent = 0; 374 $post->menu_order = 0; 375 } 376 377 $post->post_content = apply_filters( 'default_content', $post_content ); 378 $post->post_title = apply_filters( 'default_title', $post_title ); 379 $post->post_excerpt = apply_filters( 'default_excerpt', $post_excerpt ); 354 380 $post->post_name = ''; 355 $post->post_author = '';356 $post->post_date = '';357 $post->post_date_gmt = '';358 $post->post_password = '';359 $post->post_status = 'draft';360 $post->post_type = $post_type;361 $post->to_ping = '';362 $post->pinged = '';363 $post->comment_status = get_option( 'default_comment_status' );364 $post->ping_status = get_option( 'default_ping_status' );365 $post->post_pingback = get_option( 'default_pingback_flag' );366 $post->post_category = get_option( 'default_category' );367 $post->post_content = apply_filters( 'default_content', $post_content);368 $post->post_title = apply_filters( 'default_title', $post_title );369 $post->post_excerpt = apply_filters( 'default_excerpt', $post_excerpt);370 $post->page_template = 'default';371 $post->post_parent = 0;372 $post->menu_order = 0;373 381 374 382 return $post; … … 466 474 467 475 // Check for autosave collisions 476 // Does this need to be updated? ~ Mark 468 477 $temp_id = false; 469 478 if ( isset($_POST['temp_ID']) ) { … … 474 483 if ( time() + $temp > 86400 ) // 1 day: $temp is equal to -1 * time( then ) 475 484 unset($draft_ids[$temp]); 476 485 477 486 if ( isset($draft_ids[$temp_id]) ) { // Edit, don't write 478 487 $_POST['post_ID'] = $draft_ids[$temp_id]; … … 514 523 515 524 // Reunite any orphaned attachments with their parent 525 // Does this need to be udpated? ~ Mark 516 526 if ( !$draft_ids = get_user_option( 'autosave_draft_ids' ) ) 517 527 $draft_ids = array(); -
trunk/wp-admin/post-new.php
r12927 r12987 51 51 // Show post form. 52 52 if ( current_user_can($post_type_object->edit_type_cap) ) { 53 $post = get_default_post_to_edit( $post_type ); 53 $post = get_default_post_to_edit( $post_type, true ); 54 $post_ID = $post->ID; 54 55 include('edit-form-advanced.php'); 55 56 } -
trunk/wp-includes/js/autosave.dev.js
r12733 r12987 40 40 // preview 41 41 $('#post-preview').click(function(){ 42 if ( 1 > $('#post_ID').val()&& notSaved ) {42 if ( $('#auto_draft').val() == '1' && notSaved ) { 43 43 autosaveDelayPreview = true; 44 44 autosave(); … … 59 59 $('#title')[$.browser.opera ? 'keypress' : 'keydown'](function (e) { 60 60 if ( e.which == 9 && !e.shiftKey && !e.controlKey && !e.altKey ) { 61 if ( ($( "#post_ID").val() < 1) && ($("#title").val().length > 0) ) { autosave(); }61 if ( ($('#auto_draft').val() == '1') && ($("#title").val().length > 0) ) { autosave(); } 62 62 if ( tinyMCE.activeEditor && ! tinyMCE.activeEditor.isHidden() && dotabkey ) { 63 63 e.preventDefault(); … … 71 71 72 72 // autosave new posts after a title is typed but not if Publish or Save Draft is clicked 73 if ( 0 > $('#post_ID').val() ) {73 if ( '1' == $('#auto_draft').val() ) { 74 74 $('#title').blur( function() { 75 if ( !this.value || 0 < $('#post_ID').val())75 if ( !this.value || $('#auto_draft').val() != '1' ) 76 76 return; 77 78 77 delayed_autosave(); 79 78 }); … … 122 121 // called when autosaving pre-existing post 123 122 function autosave_saved(response) { 123 blockSave = false; 124 124 autosave_parse_response(response); // parse the ajax response 125 125 autosave_enable_buttons(); // re-enable disabled form buttons … … 128 128 // called when autosaving new post 129 129 function autosave_saved_new(response) { 130 blockSave = false; 130 131 var res = autosave_parse_response(response), tempID, postID; 131 // if no errors: update post_ID from the temporary value, grab new save-nonce for that new ID132 132 if ( res && res.responses.length && !res.errors ) { 133 tempID = jQuery('#post_ID').val();133 // An ID is sent only for real auto-saves, not for autosave=0 "keepalive" saves 134 134 postID = parseInt( res.responses[0].id, 10 ); 135 135 autosave_update_post_ID( postID ); // disabled form buttons are re-enabled here 136 if ( tempID < 0 && postID > 0 ) { // update media buttons137 notSaved = false;138 jQuery('#media-buttons a').each(function(){139 this.href = this.href.replace(tempID, postID);140 });141 }142 136 if ( autosaveDelayPreview ) { 143 137 autosaveDelayPreview = false; … … 152 146 if ( !isNaN(postID) && postID > 0 ) { 153 147 if ( postID == parseInt(jQuery('#post_ID').val(), 10) ) { return; } // no need to do this more than once 154 jQuery('#post_ID').attr({name: "post_ID"}); 155 jQuery('#post_ID').val(postID); 156 // We need new nonces 157 jQuery.post(autosaveL10n.requestFile, { 158 action: "autosave-generate-nonces", 159 post_ID: postID, 160 autosavenonce: jQuery('#autosavenonce').val(), 161 post_type: jQuery('#post_type').val() 162 }, function(html) { 163 jQuery('#_wpnonce').val(html.updateNonce); 164 jQuery('#delete-action a.submitdelete').attr('href', html.deleteURL); 165 autosave_enable_buttons(); // re-enable disabled form buttons 166 jQuery('#delete-action a.submitdelete').fadeIn(); 167 }, 168 'json'); 148 notSaved = false; 149 autosave_enable_buttons(); 150 jQuery('#delete-action a.submitdelete').fadeIn(); 169 151 jQuery('#hiddenaction').val('editpost'); 152 jQuery('#auto_draft').val('0'); // No longer an auto-draft 170 153 } 171 154 } … … 218 201 autosave = function() { 219 202 // (bool) is rich editor enabled and active 203 blockSave = true; 220 204 var rich = (typeof tinyMCE != "undefined") && tinyMCE.activeEditor && !tinyMCE.activeEditor.isHidden(), post_data, doAutoSave, ed, origStatus, successCallback; 221 205 … … 282 266 post_data["post_author"] = jQuery("#post_author").val(); 283 267 post_data["user_ID"] = jQuery("#user-id").val(); 268 if ( jQuery('#auto_draft').val() == '1' ) 269 post_data["auto_draft"] = '1'; 284 270 285 271 if ( doAutoSave ) { … … 289 275 } 290 276 291 if ( parseInt(post_data["post_ID"], 10) < 1 ) { 292 post_data["temp_ID"] = post_data["post_ID"]; 277 if ( post_data["auto_draft"] == '1' ) { 293 278 successCallback = autosave_saved_new; // new post 294 279 } else { … … 297 282 298 283 autosaveOldMessage = jQuery('#autosave').html(); 299 300 284 jQuery.ajax({ 301 285 data: post_data, -
trunk/wp-includes/js/autosave.js
r12022 r12987 1 var autosave,autosaveLast="",autosavePeriodical,autosaveOldMessage="",autosaveDelayPreview=false,notSaved=true,blockSave=false,interimLogin=false;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")}});b("#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{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(1>b("#post_ID").val()&¬Saved){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("#post_ID").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(0>b("#post_ID").val()){b("#title").blur(function(){if(!this.value||0<b("#post_ID").val()){return}delayed_autosave()})}});function autosave_parse_response(c){var e=wpAjax.parseAjaxResponse(c,"autosave"),f="",a,b,d;if(e&&e.responses&&e.responses.length){f=e.responses[0].data;if(e.responses[0].supplemental){b=e.responses[0].supplemental;if("disable"==b.disable_autosave){autosave=function(){};e={errors:true}}if(b.session_expired&&(d=b.session_expired)){if(!interimLogin||interimLogin.closed){interimLogin=window.open(d,"login","width=600,height=450,resizable=yes,scrollbars=yes,status=yes");interimLogin.focus()}delete b.session_expired}jQuery.each(b,function(g,h){if(g.match(/^replace-/)){jQuery("#"+g.replace("replace-","")).val(h)}})}if(!e.errors){a=parseInt(e.responses[0].id,10);if(!isNaN(a)&&a>0){autosave_update_slug(a)}}}if(f){jQuery("#autosave").html(f)}else{if(autosaveOldMessage&&e){jQuery("#autosave").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&&d.responses.length&&!d.errors){c=jQuery("#post_ID").val();a=parseInt(d.responses[0].id,10);autosave_update_post_ID(a);if(c<0&&a>0){notSaved=false;jQuery("#media-buttons a").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)&&a>0){if(a==parseInt(jQuery("#post_ID").val(),10)){return}jQuery("#post_ID").attr({name:"post_ID"});jQuery("#post_ID").val(a);jQuery.post(autosaveL10n.requestFile,{action:"autosave-generate-nonces",post_ID:a,autosavenonce:jQuery("#autosavenonce").val(),post_type:jQuery("#post_type").val()},function(b){jQuery("#_wpnonce").val(b.updateNonce);jQuery("#delete-action a.submitdelete").attr("href",b.deleteURL);autosave_enable_buttons();jQuery("#delete-action a.submitdelete").fadeIn()},"json");jQuery("#hiddenaction").val("editpost")}}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:jQuery("#title").val(),samplepermalinknonce:jQuery("#samplepermalinknonce").val()},function(b){jQuery("#edit-slug-box").html(b);makeSlugeditClickable()})}}function autosave_loading(){jQuery("#autosave").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").attr("disabled","disabled");setTimeout(autosave_enable_buttons,5000)}function delayed_autosave(){setTimeout(function(){if(blockSave){return}autosave()},200)}autosave=function(){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,post_title:jQuery("#title").val()||"",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){tinyMCE.get("content").setContent(b.getContent({format:"raw"}),{format:"raw"})}tinyMCE.get("content").save()}}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").attr("checked")){d.comment_status="open"}if(jQuery("#ping_status").attr("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()}d.user_ID=jQuery("#user-id").val();if(f){autosaveLast=jQuery("#title").val()+jQuery("#content").val()}else{d.autosave=0}if(parseInt(d.post_ID,10)<1){d.temp_ID=d.post_ID;a=autosave_saved_new}else{a=autosave_saved}autosaveOldMessage=jQuery("#autosave").html();jQuery.ajax({data:d,beforeSend:f?autosave_loading:null,type:"POST",url:autosaveL10n.requestFile,success:a})};1 var autosave,autosaveLast="",autosavePeriodical,autosaveOldMessage="",autosaveDelayPreview=false,notSaved=true,blockSave=false,interimLogin=false;jQuery(document).ready(function($){var dotabkey=true;autosaveLast=$("#post #title").val()+$("#post #content").val();autosavePeriodical=$.schedule({time:autosaveL10n.autosaveInterval*1000,func:function(){autosave()},repeat:true,protect:true});$("#post").submit(function(){$.cancel(autosavePeriodical)});$('input[type="submit"], a.submitdelete',"#submitpost").click(function(){blockSave=true;window.onbeforeunload=null;$(":button, :submit","#submitpost").each(function(){var t=$(this);if(t.hasClass("button-primary")){t.addClass("button-primary-disabled")}else{t.addClass("button-disabled")}});$("#ajax-loading").css("visibility","visible")});window.onbeforeunload=function(){var mce=typeof(tinyMCE)!="undefined"?tinyMCE.activeEditor:false,title,content;if(mce&&!mce.isHidden()){if(mce.isDirty()){return autosaveL10n.saveAlert}}else{title=$("#post #title").val(),content=$("#post #content").val();if((title||content)&&title+content!=autosaveLast){return autosaveL10n.saveAlert}}};$("#post-preview").click(function(){if($("#auto_draft").val()=="1"&¬Saved){autosaveDelayPreview=true;autosave();return false}doPreview();return false});doPreview=function(){$("input#wp-preview").val("dopreview");$("form#post").attr("target","wp-preview").submit().attr("target","");$("input#wp-preview").val("")};if(typeof tinyMCE!="undefined"){$("#title")[$.browser.opera?"keypress":"keydown"](function(e){if(e.which==9&&!e.shiftKey&&!e.controlKey&&!e.altKey){if(($("#auto_draft").val()=="1")&&($("#title").val().length>0)){autosave()}if(tinyMCE.activeEditor&&!tinyMCE.activeEditor.isHidden()&&dotabkey){e.preventDefault();dotabkey=false;tinyMCE.activeEditor.focus();return false}}})}if("1"==$("#auto_draft").val()){$("#title").blur(function(){if(!this.value||$("#auto_draft").val()!="1"){return}delayed_autosave()})}});function autosave_parse_response(response){var res=wpAjax.parseAjaxResponse(response,"autosave"),message="",postID,sup,url;if(res&&res.responses&&res.responses.length){message=res.responses[0].data;if(res.responses[0].supplemental){sup=res.responses[0].supplemental;if("disable"==sup.disable_autosave){autosave=function(){};res={errors:true}}if(sup.session_expired&&(url=sup.session_expired)){if(!interimLogin||interimLogin.closed){interimLogin=window.open(url,"login","width=600,height=450,resizable=yes,scrollbars=yes,status=yes");interimLogin.focus()}delete sup.session_expired}jQuery.each(sup,function(selector,value){if(selector.match(/^replace-/)){jQuery("#"+selector.replace("replace-","")).val(value)}})}if(!res.errors){postID=parseInt(res.responses[0].id,10);if(!isNaN(postID)&&postID>0){autosave_update_slug(postID)}}}if(message){jQuery("#autosave").html(message)}else{if(autosaveOldMessage&&res){jQuery("#autosave").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&&res.responses.length&&!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)&&postID>0){if(postID==parseInt(jQuery("#post_ID").val(),10)){return}notSaved=false;autosave_enable_buttons();jQuery("#delete-action a.submitdelete").fadeIn();jQuery("#hiddenaction").val("editpost");jQuery("#auto_draft").val("0")}}function autosave_update_slug(post_id){if("undefined"!=makeSlugeditClickable&&jQuery.isFunction(makeSlugeditClickable)&&!jQuery("#edit-slug-box > *").size()){jQuery.post(ajaxurl,{action:"sample-permalink",post_id:post_id,new_title:jQuery("#title").val(),samplepermalinknonce:jQuery("#samplepermalinknonce").val()},function(data){jQuery("#edit-slug-box").html(data);makeSlugeditClickable()})}}function autosave_loading(){jQuery("#autosave").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").attr("disabled","disabled");setTimeout(autosave_enable_buttons,5000)}function delayed_autosave(){setTimeout(function(){if(blockSave){return}autosave()},200)}autosave=function(){blockSave=true;var rich=(typeof tinyMCE!="undefined")&&tinyMCE.activeEditor&&!tinyMCE.activeEditor.isHidden(),post_data,doAutoSave,ed,origStatus,successCallback;autosave_disable_buttons();post_data={action:"autosave",post_ID:jQuery("#post_ID").val()||0,post_title:jQuery("#title").val()||"",autosavenonce:jQuery("#autosavenonce").val(),post_type:jQuery("#post_type").val()||"",autosave:1};jQuery(".tags-input").each(function(){post_data[this.name]=this.value});doAutoSave=true;if(jQuery("#TB_window").css("display")=="block"){doAutoSave=false}if(rich&&doAutoSave){ed=tinyMCE.activeEditor;if(ed.plugins.spellchecker&&ed.plugins.spellchecker.active){doAutoSave=false}else{if("mce_fullscreen"==ed.id){tinyMCE.get("content").setContent(ed.getContent({format:"raw"}),{format:"raw"})}tinyMCE.get("content").save()}}post_data.content=jQuery("#content").val();if(jQuery("#post_name").val()){post_data.post_name=jQuery("#post_name").val()}if((post_data.post_title.length==0&&post_data.content.length==0)||post_data.post_title+post_data.content==autosaveLast){doAutoSave=false}origStatus=jQuery("#original_post_status").val();goodcats=([]);jQuery("[name='post_category[]']:checked").each(function(i){goodcats.push(this.value)});post_data.catslist=goodcats.join(",");if(jQuery("#comment_status").attr("checked")){post_data.comment_status="open"}if(jQuery("#ping_status").attr("checked")){post_data.ping_status="open"}if(jQuery("#excerpt").size()){post_data.excerpt=jQuery("#excerpt").val()}if(jQuery("#post_author").size()){post_data.post_author=jQuery("#post_author").val()}post_data.user_ID=jQuery("#user-id").val();if(jQuery("#auto_draft").val()=="1"){post_data.auto_draft="1"}if(doAutoSave){autosaveLast=jQuery("#title").val()+jQuery("#content").val()}else{post_data.autosave=0}if(post_data.auto_draft=="1"){successCallback=autosave_saved_new}else{successCallback=autosave_saved}autosaveOldMessage=jQuery("#autosave").html();jQuery.ajax({data:post_data,beforeSend:doAutoSave?autosave_loading:null,type:"POST",url:autosaveL10n.requestFile,success:successCallback})}; -
trunk/wp-includes/link-template.php
r12979 r12987 112 112 $permalink = get_option('permalink_structure'); 113 113 114 if ( '' != $permalink && !in_array($post->post_status, array('draft', 'pending' )) ) {114 if ( '' != $permalink && !in_array($post->post_status, array('draft', 'pending', 'auto-draft')) ) { 115 115 $unixtime = strtotime($post->post_date); 116 116 -
trunk/wp-includes/post.php
r12948 r12987 1977 1977 // post name. 1978 1978 if ( !isset($post_name) || empty($post_name) ) { 1979 if ( !in_array( $post_status, array( 'draft', 'pending' ) ) )1979 if ( !in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ) ) ) 1980 1980 $post_name = sanitize_title($post_title); 1981 1981 else … … 1990 1990 1991 1991 if ( empty($post_date_gmt) || '0000-00-00 00:00:00' == $post_date_gmt ) { 1992 if ( !in_array( $post_status, array( 'draft', 'pending' ) ) )1992 if ( !in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ) ) ) 1993 1993 $post_date_gmt = get_gmt_from_date($post_date); 1994 1994 else … … 2090 2090 } 2091 2091 2092 if ( empty($data['post_name']) && !in_array( $data['post_status'], array( 'draft', 'pending' ) ) ) {2092 if ( empty($data['post_name']) && !in_array( $data['post_status'], array( 'draft', 'pending', 'auto-draft' ) ) ) { 2093 2093 $data['post_name'] = sanitize_title($data['post_title'], $post_ID); 2094 2094 $wpdb->update( $wpdb->posts, array( 'post_name' => $data['post_name'] ), $where ); … … 2173 2173 2174 2174 // Drafts shouldn't be assigned a date unless explicitly done so by the user 2175 if ( in_array($post['post_status'], array('draft', 'pending' )) && empty($postarr['edit_date']) &&2175 if ( in_array($post['post_status'], array('draft', 'pending', 'auto-draft')) && empty($postarr['edit_date']) && 2176 2176 ('0000-00-00 00:00:00' == $post['post_date_gmt']) ) 2177 2177 $clear_date = true; … … 2277 2277 */ 2278 2278 function wp_unique_post_slug($slug, $post_ID, $post_status, $post_type, $post_parent) { 2279 if ( in_array( $post_status, array( 'draft', 'pending' ) ) )2279 if ( in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ) ) ) 2280 2280 return $slug; 2281 2281 -
trunk/wp-includes/script-loader.php
r12817 r12987 100 100 ) ); 101 101 102 $scripts->add( 'autosave', "/wp-includes/js/autosave$suffix.js", array('schedule', 'wp-ajax-response'), '20 091012' );102 $scripts->add( 'autosave', "/wp-includes/js/autosave$suffix.js", array('schedule', 'wp-ajax-response'), '20100205' ); 103 103 $scripts->add_data( 'autosave', 'group', 1 ); 104 104
Note: See TracChangeset
for help on using the changeset viewer.