Editor, Press This: force a page reload when the user publishes a post and then clicks the back button.

Fixes #23691.

git-svn-id: https://develop.svn.wordpress.org/trunk@33836 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz 2015-08-31 23:07:36 +00:00
parent 0807da1bdd
commit 43d053318e
2 changed files with 23 additions and 1 deletions

View File

@ -929,6 +929,18 @@ jQuery(document).ready( function($) {
event.preventDefault();
}
});
if ( $( '#original_post_status' ).val() === 'auto-draft' && window.history.replaceState ) {
var location;
$( '#publish' ).on( 'click', function() {
location = window.location.href;
location += ( location.indexOf( '?' ) !== -1 ) ? '&' : '?';
location += 'wp-post-new-reload=true';
window.history.replaceState( null, null, location );
});
}
});
( function( $, counter ) {

View File

@ -773,7 +773,8 @@
// Publish, Draft and Preview buttons
$( '.post-actions' ).on( 'click.press-this', function( event ) {
var $target = $( event.target ),
var location,
$target = $( event.target ),
$button = $target.closest( 'button' );
if ( $button.length ) {
@ -782,6 +783,15 @@
submitPost( 'draft' );
} else if ( $button.hasClass( 'publish-button' ) ) {
$button.addClass( 'is-saving' );
if ( window.history.replaceState ) {
location = window.location.href;
location += ( location.indexOf( '?' ) !== -1 ) ? '&' : '?';
location += 'wp-press-this-reload=true';
window.history.replaceState( null, null, location );
}
submitPost( 'publish' );
} else if ( $button.hasClass( 'preview-button' ) ) {
prepareFormData();