EDIT: See comments below. changing the question to reflect this new info
From what I understand from the codex, save_post is meant to always fire after the post is saved (and when creating a new post). However, I am experiencing some odd behavior when using Bulk Edit. Using the code below, my sync function runs when using Quick Edit and Bulk Edit just fine, with the exception of syncing Post Format when using Bulk Edit only.
Just to be clear the only things I am syncing that are available with Bulk Edit are author, post format, categories, tags and post status. The all are updating in the WordPress DB fine, but for some reason only author, tags, and categories are syncing to external DB using my sync method. Post Format wont sync, but if I run the Bulk Edit action again, even without changing anything, the syncing does occur, which originally led me to think that the save_post function was firing before the post was saved causing the old data to sync, but that can't be if the rest are working (NOTE: I discovered that is actually is the case, except only for post_format and setting sticky post (which I don't care about)). Here is my code located in my main plugin file:
require( plugin_admin_dir . 'plugin-sync.php' );
add_action( 'save_post', 'savethepost', 2000);
function savethepost($post_id) {
if (get_post_meta($post_id, '_externaldb_post_donotsync', true) == 1) {
return;
} else {
if (get_post_status( $post_id ) != 'publish') {
plugin_sync::externaldb_delete($post_id);
} else {
plugin_sync::externaldb_sync($post_id);
} // end if
} // end if
}
Since I originally posted this I discovered that set_post_format occures after wp_update_post when using Bulk Edit. How can I create a work around to get the new post format when running my sync function? Is there another hook I can use? Anyway, I hope that this is enough information. Thanks for the help.