The url is clickable and can maybe be of help with debugging. Note that it takes you to the revision snapshotted, but to compare with the latest you have to either click "Next" or "Compare any two revisions" to see the diff. I wish WP supported a url like https://some-site.local/wp-admin/revision.php?from=67180&to=current but it looks like no. Also note that the last one is an edit url. If a post has no existing revisions, this revisions url will not work. We could work around that with wrapping wp_update_post someday and then grab before and after.
How to test
Take a look at the command wp newspack-content-migrator post-time-machine-test (cmd_post_time_machine_test()). That is probably the best way to grok what is going on. That command we can remove later, but while we play around with this it's handy.
This is a very first and naive stab at a "Time Machine" we can use to record revisions of a post and roll back to that revision if we need to.
The idea is that we update a .csv file with revision ids when we run a command, and should we need to roll content back, we can with this thingy.
There are two files:
PostTimeMachine
that you would call from your migration command to record a "snapshot" of a post that you are about to do something to.PostTimeMachineCommand
that just has a command to restore revisions from a snapshot file.A snapshot file is simply a csv file for now. It could look something like this:
The url is clickable and can maybe be of help with debugging. Note that it takes you to the revision snapshotted, but to compare with the latest you have to either click "Next" or "Compare any two revisions" to see the diff. I wish WP supported a url like https://some-site.local/wp-admin/revision.php?from=67180&to=current but it looks like no. Also note that the last one is an edit url. If a post has no existing revisions, this revisions url will not work. We could work around that with wrapping
wp_update_post
someday and then grab before and after.How to test
Take a look at the command
wp newspack-content-migrator post-time-machine-test
(cmd_post_time_machine_test()
). That is probably the best way to grok what is going on. That command we can remove later, but while we play around with this it's handy.