Title: Activate Revisions
Last modified: July 31, 2023

---

# Activate Revisions

 *  Resolved [ostii](https://wordpress.org/support/users/ostii/)
 * (@ostii)
 * [2 years, 10 months ago](https://wordpress.org/support/topic/activate-revisions/)
 * Hi, I currently have the Pro version of the plugin and I’m wondering why Revisions
   are not activated and displayed in a Revisions meta box.
 * With a plugin like this, Revisions are more crucial to me than on other types
   of post, as if one of my team edits the code and gets it wrong, we’re unable 
   to roll back to a previous version unless we set up GIT commits, which we don’t
   want to do on our smaller client sites.
 * I’ve tried to add the code for revisions (see below), but it does not seem to
   function correctly. Not sure what I’m doing wrong.
   Can you please provide the
   code to make revisions work on Saving of each file.ThanksOstii
 *     ```wp-block-code
       <?php
       function enable_custom_code_revisions( $args ) {
           $args['supports'][] = 'revisions';
           return $args;
       }
       add_filter( 'register_post_type_args', 'enable_custom_code_revisions', 10, 1 );
   
       function add_custom_codes_revisions_meta_box() {
           global $post;
   
           if ( ! $post ) return;
   
           $revisions = wp_get_post_revisions( $post->ID );
   
           if ( count( $revisions ) > 0 ) {
               add_meta_box(
                   'revisionsdiv',
                   __('Revisions'),
                   'post_revisions_meta_box',
                   'custom-code',
                   'normal',
                   'core'
               );
           }
       }
       add_action('edit_form_after_title', 'add_custom_codes_revisions_meta_box');
   
       function custom_code_revision_limit( $num, $post ) {
           if ( $post->post_type === 'custom-code' ) {
               return 20; // Set the number of revisions to keep for the 'custom-code' post type.
           }
           return $num;
       }
       add_filter( 'wp_revisions_to_keep', 'custom_code_revision_limit', 10, 2 );
       ```
   

Viewing 1 replies (of 1 total)

 *  Plugin Author [Bilal TAS](https://wordpress.org/support/users/bilaltas/)
 * (@bilaltas)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/activate-revisions/#post-16986955)
 * Hi [@ostii](https://wordpress.org/support/users/ostii/), this is exactly one 
   of our features that we are going to develop for the CodeKit PRO soon. Yes, this
   is really helpful feature to be able to rollback.
 * The reason that snippet you wrote is not working directly is CodeKit’s currently
   working fully file based. Which means, it does not record the codes to the database
   to be able to receive the code changes by source control management systems like
   Git.
 * Once that feature is ready to use, you’ll be notified. 
   Thanks for your great
   feedback [@ostii](https://wordpress.org/support/users/ostii/)!

Viewing 1 replies (of 1 total)

The topic ‘Activate Revisions’ is closed to new replies.

 * ![](https://ps.w.org/custom-codes/assets/icon.svg?rev=2536106)
 * [CodeKit - Custom Codes Editor](https://wordpress.org/plugins/custom-codes/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/custom-codes/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/custom-codes/)
 * [Active Topics](https://wordpress.org/support/plugin/custom-codes/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/custom-codes/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/custom-codes/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Bilal TAS](https://wordpress.org/support/users/bilaltas/)
 * Last activity: [2 years, 9 months ago](https://wordpress.org/support/topic/activate-revisions/#post-16986955)
 * Status: resolved