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?
- How can you change the ‘Insert into Post’ title in the media button?
- Pagination for Pages and Posts
- How to choose a sort order (for posts) per category? (ideally when creating a new category)
- orderby=meta_value_num creates duplicate posts
- Query posts from different categories in multisite
- Is there a way to backdate posts?
- How to make search for the custom post type?
- WordPress post tag & custom field
- posts_nav_link() not displaying anything
- Execute a plugin only on post pages
- Cannot get $post object in name_save_pre hook
- Update Modified date when scheduled posts get published
- How to check if single.php has already called the_post_thumbnail function
- Sort by last word in title
- When using Tribe Events Calendar, querying for a specific event category returns nothing
- How to remove special characters in post title
- custom post single page
- Loading posts outside wordpress
- Query post category & remove any post id
- Latest comment post should be the first post in the blog
- How to limit the number of results for all query_posts on mysite
- jquery: getting contents of #content field on post page
- How to show total view count across all posts for an author
- Imported Posts missing summary text on staging site