I don’t think you should define constants in your plugin. It will be very hard to debug later on.
IMHO using wp_revisions_to_keep
filter will be much nicer solution.
So your code could look like this:
add_filter( 'wp_revisions_to_keep', 'my_revisions_to_keep_based_on_settings', 10, 2 );
function my_revisions_to_keep_based_on_settings( $num, $post ) {
// change that according to your needs
return intval( get_option('disable-revisions') );
}
Related Posts:
- What happens if I delete all the rows that represents a post revision from the posts table into WordPress database?
- Get page ID of page that is set as the posts page
- How to add an admin notice upon post save/update
- Passing current cookies in wp_remote_get to get Draft Post Preview
- SQL Query for getting all posts in their latest revised state
- Listen to Post action
- Manipulate post category after time
- Any way to create a revision of a post ONLY with a new button in the Meta Box?
- Display all search results
- Add “Post Options” for new wordpress post
- WooCommerce – Create Products Programatically [closed]
- how to enable different number of revisions for different blogs when using WPMU?
- which action to hook to in order to perform post-publish action
- Cannot access current post’s ID in custom plugin
- Set number of article per number of page
- Get the author of the latest revision
- How to change post status from publish to draft using hook in wordpress?
- prevent showing posts of an specific category in admin posts section
- Add a custom option to a page in backend
- Using radio button meta data from a custom meta box
- Adding a cancel button to edit post screen
- How do I batch create revisions of all posts?
- Manually removing revision post types
- How to activate Markdown in a local installation of WordPress 4.3?
- Are posts updated or built from revisions + autosaves?
- How to store an extra (surrogate) ID when creating a post with wp_insert_post?
- Global $post not working in OOP function WordPress
- Enable post revisions for a specific post
- How to find what index page a post is on?
- Post revisions disappeared (for some posts)
- How to get post bulk edit action trigger and get edited post ids?
- How to change the setting so there is no post on home page
- How do I get blog posts to appear within CMS?
- Display post option on frontend
- How to hide html tags on revision comparison pages?
- updating a post doesn’t trigger a function
- Hide a specific category in admin All Posts page (WordPress)
- Prevent Delete Attachment by URL or When Submit
- What hook do you use to update a post?
- Updating post data on save (save_post vs wp_insert_post_data)
- Set Default Category to Username
- Visual (non-HTML) display of post revisions [closed]
- Redirect to another page using contact form 7? [closed]
- why there are so many posts whoes post_type is revision? will these records waste too much database space?
- Display post changelog in post
- Why my wp_posts data is so huge?
- Delete post revisions only for a single post
- Filter Hook for post table (not columns)
- why str_replace targeting pages instead just targeting post?
- Get author posts count after excluding a category
- Stop post submission without losing data?
- Cant’ Grab WordPress Built-in Posts Through Loop
- Update field in database for users
- How can my plugin display a populated new post window
- Dark Bar at the top of wordpress page can’t be seen?
- search content of pages and list in wp-admin
- Finding a post’s slug
- Insert specific information to a posts of a predefined category
- Open a wordpress single post in a lightbox without the header and footer
- Post page overwrite the custom blog page
- How can I change the date format of the revision list?
- blog post not accesible on click [closed]
- WordPress: Develop multiple posts with different data
- Category URL to use same string as Post URL Permalink
- How do I change the post title’s link on the posts page?
- Clean up customize_changeset in DB
- Post being duplicated with foreach loop
- Showing get_option( ‘page_for_posts’ ) or View all posts link is not working in wordpress
- Update user meta when post published no working
- Fixing the WP Post Object for Custom Route
- Export Posts with specific custom fields by sql
- Custom plugin to get related posts by category
- Hide the contents for specific post
- Error 404 blog/page/2/
- Onclick open posts displayed in slider in a popup [closed]
- How do I save JS classes being applied to the WP dashboard via custom plugin?
- Ajax the create and edit post form into lightbox and get results
- Add Categories To Custom Post
- Wp_query loop is not working as it should
- Blank page after changing number of post displayed in wp-admin
- Setting at job with shortcode not working
- Display post on main page with thumbnail
- How to create REST Based JSON API(how to modify the code below)?
- Get current user, change users post status to published
- How to put the WordPress blog into theme
- Post formatting bug in WordPress
- How do I get a certain set of posts from the database?
- Show all posts from the tags without having to set all of them
- Show author bio box
- post categories – how to show only categories with a specific parent id
- Get content and send to 3rd party
- How to correctly escape data
- Creating a “category” of featured posts
- How do I use slideToggle inside a wordpress post?
- Redirecting user to a page when there is no content?
- Posts on Sidebar only
- How to fetch posts that are stored in the different table than the default table (wp_posts)?
- How can I get post text from all posts on a WordPress news site?
- Display author bio box
- wordpress display posts by terms id or name