Changeset 23693
- Timestamp:
- 03/14/2013 03:06:07 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/post.php
r23661 r23693 211 211 $post_id = edit_post(); 212 212 213 // Session cookie flag that the post was saved 214 if ( isset( $_COOKIE['wp-saving-post-' . $post_id] ) ) 215 setcookie( 'wp-saving-post-' . $post_id, 'saved' ); 216 213 217 redirect_post($post_id); // Send user on their way while we keep working 214 218 -
trunk/wp-includes/js/autosave.js
r23683 r23693 476 476 } 477 477 478 // If the content and title are empty ordid not change since the last save, don't save again478 // If the content and title did not change since the last save, don't save again 479 479 if ( post_data.post_title + ': ' + post_data.content == this.lastsaveddata ) 480 480 return false; … … 538 538 539 539 $('form#post').on('submit.autosave-local', function() { 540 var editor = typeof tinymce != 'undefined' && tinymce.get('content') ;540 var editor = typeof tinymce != 'undefined' && tinymce.get('content'), post_id = $('#post_ID').val() || 0; 541 541 542 542 if ( editor && ! editor.isHidden() ) { … … 556 556 }); 557 557 } 558 559 wpCookies.set( 'wp-saving-post-' + post_id, 'check' ); 558 560 }); 559 561 }, 560 562 561 563 // Strip whitespace and compare two strings 562 compare: function( str1, str2, strip_tags ) { 563 function remove( string, strip_tags ) { 564 string = string.toString(); 565 566 if ( strip_tags ) 567 string = string.replace(/<[^<>]+>/g, ''); 568 569 return string.replace(/[\x20\t\r\n\f]+/g, ''); 570 } 571 572 return ( remove( str1 || '', strip_tags ) == remove( str2 || '', strip_tags ) ); 564 compare: function( str1, str2 ) { 565 function remove( string ) { 566 return string.toString().replace(/[\x20\t\r\n\f]+/g, ''); 567 } 568 569 return ( remove( str1 || '' ) == remove( str2 || '' ) ); 573 570 }, 574 571 … … 581 578 */ 582 579 checkPost: function() { 583 var self = this, post_data = this.getData(), content, check_data, strip_tags = false, notice; 580 var self = this, post_data = this.getData(), content, check_data, strip_tags = false, notice, 581 post_id = $('#post_ID').val() || 0, cookie = wpCookies.get( 'wp-saving-post-' + post_id ); 584 582 585 583 if ( ! post_data ) … … 590 588 return; 591 589 592 content = $('#content').val(); 593 check_data = $.extend( {}, post_data ); 594 595 if ( $('#wp-content-wrap').hasClass('tmce-active') ) 596 content = switchEditors.pre_wpautop( content ); 597 598 // The post has just been published, only compare text 599 if ( $('#post_status').val() == 'publish' && check_data.status != 'publish' ) 600 strip_tags = true; 601 602 if ( this.compare( content, check_data.content, strip_tags ) && this.compare( $('#title').val(), check_data.post_title, strip_tags ) && this.compare( $('#excerpt').val(), check_data.excerpt, strip_tags ) ) 603 return; 604 605 // We have three choices here: 606 // - Do an autosave and then show the standard notice "There is an autosave newer than...". 607 // - Offer to load/restore the backed up post data. 608 // - Restore the post_data without asking, then show a notice with an Undo link/button. 609 // Doing an autosave will take few seconds and may take up to 30 and fail if network connectivity is bad 610 // Restoring the post will leave the user with the proper content, but it won't be saved to the server until the next autosave. 590 if ( cookie == 'saved' ) { 591 return; 592 } else if ( cookie != 'check' ) { 593 content = $('#content').val(); 594 check_data = $.extend( {}, post_data ); 595 596 if ( $('#wp-content-wrap').hasClass('tmce-active') ) 597 content = switchEditors.pre_wpautop( content ); 598 599 if ( this.compare( content, check_data.content ) && this.compare( $('#title').val(), check_data.post_title ) && this.compare( $('#excerpt').val(), check_data.excerpt ) ) 600 return; 601 } 611 602 612 603 this.restore_post_data = post_data; 613 604 this.undo_post_data = wp.autosave.getPostData(); 614 615 /*616 if ( $('#post_status').val() == 'publish' ) {617 // Different message when a post is published?618 // Comparing the current and saved post data may fail (false positive) when the post is published619 // as in some cases there are changes to post_content on publishing and updating before saving to the DB.620 }621 */622 605 623 606 notice = $('#local-storage-notice');
Note: See TracChangeset
for help on using the changeset viewer.