janez-svetin
12/2/2015 - 2:29 PM

Per post type revisions

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 );
    }
}