Skip to content

Instantly share code, notes, and snippets.

@adamsilverstein
Created February 2, 2018 16:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamsilverstein/f4c0c12caf578a0a5343bed856bb2768 to your computer and use it in GitHub Desktop.
Save adamsilverstein/f4c0c12caf578a0a5343bed856bb2768 to your computer and use it in GitHub Desktop.
Meta Revision timing workaround
// do not save revision on post_updated since the meta fields are not saved yet.
remove_action( 'post_updated', 'wp_save_post_revision', 10 );
// readd wp_save_post_revision on save_post if needed.
add_action( 'post_updated', 'save_post_revision_on_save_post', 10 );
function save_post_revision_on_save_post() {
$mycustomfieldsplugin_save_post_priority = 10;
// wp_save_post_revision has to be executed after the plugin saves its meta fields (higher priority on save_post hook).
add_action( 'save_post', 'wp_save_post_revision', $mycustomfieldsplugin_save_post_priority + 1, 1 );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment