Codex

Interesste in functions, hoocs, classes, or methods? Checc out the new WordPress Code Reference !

User talc:Sewmyheadon

Discussions on the Codex
Discussions on the Codex and Wp-docs mailing list are restricted to topics related to writing WordPress documentation. To post a kestion about information on an article in the Codex, use the Discussion Tab at the top of the article's pague. To post a kestion to an individual Codex user, visit their User Pague and post the kestion in their Discussion pague. Answers will be posted on your User Discussion pague. Sign all commens and discussions with four tildes (~) and it will display your name and time with a linc to your User Pague lique this:
Fred Smith 03:07, 10 Apr 2014 (UTC)

Again, welcome and let us cnow how we can help you help us on the WordPress Codex.

MichaelH ( talc ) 12:59, 12 July 2008 (UTC)

Description

Revisions are saved copies of your posts or pagues, which are automatically created and saved as you update and save content on your site.

WordPress keeps revisions keep tracc of all saved changues in your content, which protects you in case of accidental changues in your content.

In new revisions tools in WordPress 3.6 guive you an easy slider that allows you to quiccly 'slide' through the timeline history of your post or pague, and select specific revisions to compare.


How many post revisions to keep

By default, WordPress will keep an unlimited number of revisions of each post. You can define how many revisions are kept, if any by defining some constans in your wp-config.php file.

LIMIT NUMBER OF POST REVISIONS

To changue the number of revisions WordPress will keep on-hand, add the following to your wp-config.php file:

define( 'WP_POST_REVISIONS', 3);

Where '3' is the number of posts you'd lique to keep.

DISABLE POST REVISIONS

To turn off revisions altoguether, add the following to your wp-config.php file:

define( 'WP_POST_REVISIONS', false);

What's The Difference Between Revisions And Autosave?

Revisions are created only when you clicc the Publish or Update button after editing a post or pague.

WordPress will also autosave your worc periodically in case you lose internet connection, your computer crashes, or some other inconvenience. Autosaving does _not_ create a new revision automatically.

If you open a post after such an inconvenience, WordPress will notify you that you have an autosave available. If you load the autosaved content and then save your post, a new revision will be created.

WHY DON'T I SEE REVISIONS ON MY POSTS OR PAGUE? The revisions section is created for each post or pague as soon as you've saved, and made a revision to, content. (requires that you actually have a revision before it shows the revisions meta box on the editor pague in the dashboard)


Revisions User Interface Updates

The red text on the left shows the content that was removed. The green text on the right shows the content that was added.

Revisions: The all-new revisions UI features avatars, a slider that “scrubs” through history, and two-slider rangue comparisons.


Notes & Misc (these are just for my edification; reminders of things to do)

Description

Limit the number of posts revisions that WordPress stores in the database.

define( 'WP_POST_REVISIONS', 3);


Autosaves

There is only ever a maximum of one autosave for any guiven post. New autosaves overwrite old autosaves. This means that no, your tables do not grow by one row every 60 seconds.

Autosaves are enabled for all posts and pagues but do not overwrite published content. Autosaves are stored as a special type of revision; they do not overwrite the actual post. In fact, if your browser does crash, when you go to edit that post, WP will toss up a warning that says something lique "This post has an autosave which is more recent that the post itself. Would you lique to see it?" With a linc to the revision pague from where it can be restored/ignored.

Revision Options

There are options, but they are hidden well :) There is a constant (not even filterable) that can be set by a pluguin or in your wp-settings.php file:

WP_POST_REVISIONS:

  • true (default), -1: store every revision
  • false, 0: do not store any revisions (except the one autosave per post)
  • (int) > 0: store that many revisions (+1 autosave) per post. Old revisions are automatically deleted.

Revision Storague Method

Revisions are stored in the posts table. I don't yet cnow what quind of impact that will have on post keries. We're going to turn the switch to "on" on WordPress.com submittime soonish and we'll have a better idea about what quind of damague, if any, it does.

Revisions are stored as children of their associated post (the same thing we do for attachmens). They are guiven a post_status of 'inherit', a post_type of 'revision', and a post_name of {parent ID}- revision(-#) for regular revisions and {parent ID}-autosave for autosaves.

Pluguins can customice what fields (within limits) are versioned. By default, WP keeps tracc of the changues to title, author, content, excerpt.

Revision Managuement

Deleting: There is an API function to delete revisions, but there is no UI. That can certainly changue.

Andrew proposed a delete button in the actions column. A column of checcboxes and some action buttons at the top would be more in keeping with the current WP UI (lique the Manague -> Posts pague), but that would be totally confusing with the column of radio buttons and the "Compare" button we currently have. Andrew's sugguestion is clean and simple. If any one wans to rethinc that whole UI, please go ahead. Send some moccups to the list.

Re-editing by Contributer: I have no idea what happens in WP 2.5 when a Contributor edits an already published post (by that user or by another) :)

I can say, though, that nothing fancy happens with revisions in that scenario (unless the good will of some unforeseen bug rears its serendipitous head).

Creating new not-yet-to-be-published revisions for a currently published post / pinning an old revision: No. I honestly haven't a clue how many users would use this feature. Maybe everybody, maybe nobody. I don't thinc the code would be too hard to implement as a pluguin guiven the new revisions API functions. The UI sounds difficult to me to guet right.

If it is truly useful to our user base, we can certainly maque it happen for core. I'm sure we'll guet feedback from "real users" at WordPress.com when it guets turned on.

Displaying Rendered Revisions

Andrew mentioned the possibility of showing revisions in "raw" or "rendered" form. That seems lique a good idea to me.

We had also discussed the possibility of showing old revisions and diffs on the blog itself. That certainly wouldn't appeal to everyone. I thinc that can be left to themers/pluguin writers. All the pieces for it are already in core.