Created
February 2, 2018 16:00
-
-
Save adamsilverstein/f4c0c12caf578a0a5343bed856bb2768 to your computer and use it in GitHub Desktop.
Meta Revision timing workaround
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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