I’m using following code to force WordPress page to save post as draft, is there any callback function for it, I want to alert a text after it complete saving post as draft.

if ( wp.autosave.server ) {
wp.autosave.server.triggerSave();
}

1 Answer
1

So I found the solution, callback function for when post or page is:

jQuery(document).on('heartbeat-tick.autosave', function( event, data ) {
    // your code here
});

This uses the WordPress Heartbeat API.

Leave a Reply

Your email address will not be published. Required fields are marked *