Plugin Contributor
cageehv
(@cageehv)
Hey Georg.io,
Thanks for your suggestion!
I will have a look at it and see how hard it is to implement such an option.
peace,
Rolf
Plugin Contributor
cageehv
(@cageehv)
Hey Georg.io,
Just released version 4.1.4 of my plugin.
Now you can add a custom field (‘keep_revisions’, ‘Y’) to the posts and pages of which you want to keep the revisions.
Enjoy!
peace,
Rolf
Thread Starter
Georgio
(@georgio-1)
Hi,
a priori that’s good news! I will try to find a way to use it, though it is not obvious.
Unfortunately Buddypress Docs doesn’t have custom fields feature. Regular posts and pages have that feature of course, but for a reason I ignore, this feature shows only options from A to F (I tested with two themes) so I don’t see ‘keep_revisions’. Even if I add it manually I cannot test it for a regular post as your plugin will remove the revisions of Buddypress Docs as well.
I will search for a plugin in order to add custom fields to Buddypress Docs.
Indepentently from the results, thanks for your work.
A custom field (ie, a piece of postmeta) is a good way to skip specific posts, but it’s not good for broad categories – the ‘Y’ would need to be filled in each time, making it hard to do programatically, especially with existing content.
If a filter were added to rvg-optimize-database, it would be very easy to write a small plugin that would exclude certain types of posts from having their revisions cleaned. In ODB_Cleaner
, change odb_post_is_excluded()
so it looks like this:
function odb_post_is_excluded($parent_id)
{
$keep_revisions = get_post_meta($parent_id, 'keep_revisions', true);
return apply_filters( 'odb_post_is_excluded', ($keep_revisions === 'Y'), $parent_id );;
} // odb_post_is_exclude()
Then, @georgio-1 can exclude Docs from the cleaner like this:
function exclude_buddypress_docs_from_odb_cleaner( $is_protected, $parent_id ) {
$parent = get_post( $parent_id );
if ( $parent && bp_docs_get_post_type_name() === $parent->post_type ) {
$is_protected = true;
}
return $is_protected;
}
add_filter( 'odb_post_is_excluded', 'exclude_buddypress_docs_from_odb_cleaner', 10, 2 );