Skip to content

Instantly share code, notes, and snippets.

@chrisguitarguy
Created June 6, 2012 19:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save chrisguitarguy/2884090 to your computer and use it in GitHub Desktop.
Save chrisguitarguy/2884090 to your computer and use it in GitHub Desktop.
Per post type revisions
<?php
add_action('pre_post_update', 'wpse54199_pre_update', 1);
function wpse54199_pre_update($post_id)
{
if(defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
return;
if(get_post_type($post_id) == 'some_type')
{
remove_action('pre_post_update', 'wp_save_post_revision', 10);
if(!$post = get_post($post_id, ARRAY_A))
return;
if (!post_type_supports($post['post_type'], 'revisions'))
return;
$return = _wp_put_post_revision( $post );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment