Oct
7
(2008)
WordPress Plugin - Post Revision Display
Filed under: general. Tags: plugins, ucalgaryblogs.ca, wordpress.
One of the profs using UCalgaryBlogs.ca was asking if there was a way to show the “audit trail” for a blog posts. If she’s having students write stuff, and needs it in by a given date (say, an assignment deadline), she’d like a way to know if a post was saved before the deadline, or updated after it. It’s easy for people to futz around with the “published on” date for a post…
So, I did some poking around, looking for plugins or tricks to expose the revision display list without having to send the prof to the blog’s admin UI every time she wanted to look at the info.
I couldn’t find anything, so I asked a question on the WordPress support forum. On a tip from Otto42, I poked around with the wp_list_post_revisions() function. Looks exactly like what I need. So it was pretty simple to write a basic plugin that adds a Filter such that the list gets generated and appended to every post displayed on a blog that uses the plugin. If you’re logged in, and have proper privileges, you’ll also get a link to view the revisions directly. If not, you just get to see that the revisions exist.
I had to copy the wp_list_post_revisions() function and modify it a bit in the plugin, so it behaved as needed. Nothing too major, but the WordPress function relies on echo to dump the list directly, and I needed to modify it to return a string to append to the blog post. Easy peasy.
And so, post-revision-display is born. Install and activate it on your blog, and your posts will automagically generate and display the list of revisions as an audit trail, with no futzing about with themes and hardcoding stuff. Here’s what the audit trail looks like:
Download the plugin here (for now - I’m trying to get it added to WordPress.org/extend/plugins…)
Comments
15 Responses to “WordPress Plugin - Post Revision Display”
Leave a Reply
You must be logged in to post a comment.


Way cool, and pretty useful for teachers using this with students. It’s a favorite feature of Google Docs, makes perfect sense for blogs as well.
Nice job!
Nice one D’Arcy. As usual, you lead the way, the rest of us follow - I’ve been futzing around trying to write a couple of plugins but not making much effort; this renews my confidence that maybe I can do it. Way to go. Very useful.
[...] I whipped up a quick plugin for WordPress that, when activated, will automatically display the audit trail beneath each post on the blog, [...]
I’d be surprised if there wasn’t a checkbox option in a future version of WordPress to provide the same functionality, but in the meantime, this should do the trick.
@scott hey, if I can write a working WordPress plugin, ANYONE can do it!
“I had to copy the wp_list_post_revisions() function and modify it a bit in the plugin, so it behaved as needed. Nothing too major, but the WordPress function relies on echo to dump the list directly, and I needed to modify it to return a string to append to the blog post. Easy peasy.”
You have a very geeky sense of “easy”. I’m living in the same dimension so I get it, but others might dispute your use of the word.
But a sweet hack, nonetheless. Thanks for sharing it with the world.
@rob - anything that consists almost exclusively of selective copy-and-paste operations, followed by minor tweakage, gets classified as easy. I didn’t have to actually write new code, just grabbed bits from a few other places and mixed them together until it worked
Sounds like a good thing to write a patch for the core version (the function you had to copy).
Nice. I’d never seen that function before! Too bad the system doesn’t keep copies of revisions so they could be viewed…
@boris - perhaps. I think the revisions stuff is still a bit fresh, so it’s likely to mature a bit. maybe a separate method ala get_post_ID() and the_post_ID() (or whatever) that returns rather than echoes…
@chris - it does keep each revision. If you have privs, you can see links to each one, and can even use a visual diff to compare them. Very cool stuff.
Wait a second…two posts from Brian Lamb today and you are authoring WordPress plugins? Damn this is a good day for the right Reverend.
Rock on, D’Arcy!
Wow, that’s a nice feature!
I tried to send this through your contact form, but I didn’t look like it went though, so please excuse me if you get the message twice
Hi! I installed your post revision display plugin, but need to temporarily deactivate it because I’m still trying to get all my pages and stuff working right - meaning I’m saving and resaving them quite frequently, leading to a long trail of revision links.
The problem I’ve run into, though, is that even after deactivating and deleting the plugin, the lists of the revisions are still showing up on the pages and posts, and I cannot figure out how to delete them. I even went in and deleted the “revision.php” file and that didn’t help.
I plan to reinstall it once I finish getting everything set up, but do you have any suggestions as to how I can remove it until I’m ready for it to track things?
Thanks for a great plugin - I love the idea!
kriselda
@kriselda - I’m not sure what’s going on - could it be a cache issue? are you using wp-super-cache? I haven’t seen the persistent audit trails after deactivation. I’ll take a look to see what I can find out! Glad you like the plugin, and I’m sorry it’s causing you some grief.
Thanks for the quick reply. I do have wp-super-cache on, so I emptied the cache and also flushed my browser cache to make sure the problem was there, and it didn’t change anything.
Here’s what’s happening currently. I deactivated the plugin, and the post revision dates are no longer showing up on the live versions of the pages. However, Even on posts I created after deactivating the plugin, the “-Post Revisions” link on the main menu for managing posts and pages is still there, and it is still tracking every change.
Just for a test, I reactivated the plugin briefly, and when it was activated, all of the revision dates were again displayed on the live pages. After deactivating it, it once again removed the revisions from the live page, but is still keeping track of changes.
So, the two main issues at the moment are that I need it to stop tracking the revisions until I’m ready to open up the site (I end up making a lot of edits to posts and pages as I try to figure out the best way for embedding media and arranging content - once I’m ready to open up, I won’t be doing that any more) and I also need to figure out how to remove the revisions dates it’s already tracked, so that when I do reactivate the plugin, I won’t end up with this massive list on my posts and pages.
Thanks again for any ideas you might have - I hope this maybe gives you some better information to work with. Let me know if you need to know anything else
Kriselda
@thorswitch I’ve done some testing, and can’t reproduce the persistent-audit-trail-after-deactivating issue. When I deactivate the plugin, the audit trails on each post and page disappear immediately. I’m guessing it’s a caching issue - either through WP-Super-Cache or browser caching?