I'm actually quite surprised WP hasn't already implemented this. I want to add a Cancel button to the edit post screen which will do some cleanup when pressed. After a little playing while watching my tables, here's some things I've noticed.
- A new post is created with a
auto-draft. This is changed to
autosave.jsscript. I'm assuming it's safe to just delete this post on cancel. How can you distinguish between a previously saved draft and a "promoted" autodraft?
- Post's with a
draftdon't produce a revision. Rather, these posts are updated without any way of reverting back. Is there a way to circumvent this behavior? Possibly by working on a copy of the original and merging on submit?
- Once a draft is published, a revision is also created. This leads to all posts taking up at least two rows. Wasteful in my opinion since it's impossible for the two to be different. This revision should be created the next time the post is to be edited. Is it best to just let WP handle the revisions?
- Post's with a
publishproduce an autosave at a set interval during its editing. This autosave is not removed when submitting the post, instead the
post_modifieddate of the original is updated. Is it safe to delete this autosave on cancel? Thus, preventing the "A more recent version exists" message. Does WP have an auto clean of these or can/should I delete on submit?
Basically what I want is a way for the user to gracefully undo all changes they made during an editing session. Is there anything I have overlooked or am I safe to implement this?