{"id":16934558,"date":"2023-07-31T08:08:29","date_gmt":"2023-07-31T08:08:29","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/activate-revisions\/"},"modified":"2023-07-31T08:08:29","modified_gmt":"2023-07-31T08:08:29","slug":"activate-revisions","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/activate-revisions\/","title":{"rendered":"Activate Revisions"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Hi, I currently have the Pro version of the plugin and I&#8217;m wondering why Revisions are not activated and displayed in a Revisions meta box.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">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&#8217;re unable to roll back to a previous version unless we set up GIT commits, which we don&#8217;t want to do on our smaller client sites.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I&#8217;ve tried to add the code for revisions (see below), but it does not seem to function correctly. Not sure what I&#8217;m doing wrong.<br \/><br \/>Can you please provide the code to make revisions work on Saving of each file.<br \/><br \/>Thanks<br \/>Ostii<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\nfunction enable_custom_code_revisions( $args ) {\n    $args&#091;'supports']&#091;] = 'revisions';\n    return $args;\n}\nadd_filter( 'register_post_type_args', 'enable_custom_code_revisions', 10, 1 );\n\nfunction add_custom_codes_revisions_meta_box() {\n    global $post;\n\n    if ( ! $post ) return;\n\n    $revisions = wp_get_post_revisions( $post-&gt;ID );\n\n    if ( count( $revisions ) &gt; 0 ) {\n        add_meta_box(\n            'revisionsdiv',\n            __('Revisions'),\n            'post_revisions_meta_box',\n            'custom-code',\n            'normal',\n            'core'\n        );\n    }\n}\nadd_action('edit_form_after_title', 'add_custom_codes_revisions_meta_box');\n\nfunction custom_code_revision_limit( $num, $post ) {\n    if ( $post-&gt;post_type === 'custom-code' ) {\n        return 20; \/\/ Set the number of revisions to keep for the 'custom-code' post type.\n    }\n    return $num;\n}\nadd_filter( 'wp_revisions_to_keep', 'custom_code_revision_limit', 10, 2 );<\/code><\/pre>\n","protected":false},"template":"","class_list":["post-16934558","topic","type-topic","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/16934558","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/16934558\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=16934558"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}