Handle publish and save post buttons by storing ID of button pressed

This commit is contained in:
Mike Jolley 2019-01-09 16:31:53 +00:00
parent 679af01f8d
commit 83543a9232
1 changed files with 13 additions and 4 deletions

View File

@ -329,7 +329,13 @@ jQuery( function( $ ) {
.on( 'change', '#variable_product_options .woocommerce_variations :input', this.input_changed )
.on( 'change', '.variations-defaults select', this.defaults_changed );
$( 'form#post' ).on( 'submit', this.save_on_submit );
var postForm = $( 'form#post' );
postForm.on( 'submit', this.save_on_submit );
$( 'input:submit', postForm ).bind( 'click keypress', function() {
postForm.data( 'callerid', this.id );
});
$( '.wc-metaboxes-wrapper' ).on( 'click', 'a.do_variation_action', this.do_variation_action );
},
@ -524,10 +530,13 @@ jQuery( function( $ ) {
* After saved, continue with form submission
*/
save_on_submit_done: function() {
if ( $( '#hidden_post_status' ).val() !== 'publish' ) {
$( 'form#post' ).append('<input type="hidden" name="save-post" value="1" />').submit();
var postForm = $( 'form#post' ),
callerid = postForm.data( 'callerid' );
if ( 'publish' === callerid ) {
postForm.append('<input type="hidden" name="publish" value="1" />').submit();
} else {
$( 'form#post' ).append('<input type="hidden" name="publish" value="1" />').submit();
postForm.append('<input type="hidden" name="save-post" value="1" />').submit();
}
},