• Resolved ostii

    (@ostii)


    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.

    Thanks
    Ostii

    <?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

    (@bilaltas)

    Hi @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!

Viewing 1 replies (of 1 total)
  • The topic ‘Activate Revisions’ is closed to new replies.