New Plugin: Post update pushes a copy as a revision

I’ve been working alot with editing of posts after they’ve been published. I know I can hit update on the post to just update it, but I want to have the journey of revisions available for users to view on site.

So I was thinking of a plugin. I’ve looked at http://wordpress.org/extend/plugins/duplicate-post/ which creates another copy on a new permalink. This is a good starting point I think, but I’m wondering if the functionality could be done in reverse.

Read More

Functionality: When a post is updated (on every update no matter how small), it pushes the new updated content to the original post permalink, and moves the older post to a new permalink with a suffix of the update count.

Example: My post is called hello-world. I publish it and the permalink becomes http://mysite.com/hello-world. I need to edit it, so I go to posts and edit the page. I click update, and the original hello-world post is copied and published under hello-world-draft-1, and the newly updated post takes the place of the original hello-world post.

This way anyone linking to the post would always see the most up-to-date version of it, but all drafts would be available to view to any user by visiting /hello-world-draft-X, where ‘X’ is every update made that is not the main post slug.

I’m thinking this is something like being able to show revisions to the user? Comments and suggestions welcome.

Thanks.

Update: This plugin looks good but only works on uploaded .doc files and not posts. http://wordpress.org/extend/plugins/wp-document-revisions/

Related posts

Leave a Reply

1 comment

  1. Your question specifies that you are looking for ‘suggestions’ so this answer is in that category rather than in the ‘working code’ category.

    I am going to start by saying that I don’t know if this is a good idea. You are going to multiply the size of your database many times over. Now that is off my chest, if you are going to proceed here are my thoughts.

    Don’t write new posts for your ‘revisions’. You will end up with every one of them in the RSS feeds, the post, index, the backend panels, etc. It would be a mess, and you’d have to put in a lot of work to hide them.

    WordPress already has revisions, and all of the issues above have already been solved in core. Use them to your advantage.

    Tell WordPress to keep all of your revisions.

    define( 'WP_POST_REVISIONS', -1);
    

    That is supposed to be the default but I’d set it just to be sure, in case a theme or plugin decides to think for you. Using the existing revisions will also alleviate the problem of increasing your database size. Unless you have turned off revisions, you already have this stuff in the database./

    Now you need to work out how to display the revision.

    wp_get_post_revisions($post_id) (assuming $post_id is set to the revision’s parent post) should get you your revisions, which you can then use to create a list or a full post display.

    For ‘single’ post displays you should be able to pass your single.php a ?rev=<post_id> parameter or even a ?rev=<revision_number> since WordPress saves post_name for revisions as <parent_post_id>-revision-<revision_number> with -<revision_number> not present for the first revision.

    Those are my “comments and suggestions” as requested.