Question:
I was wondering if there is a way to override a FALSE wp_post_revisions configuration, by excluding specific posts upon user action, and have the database store revisions for those only.
Any ideas, how this can be implemented?
Answer:
Since the check is made in
wp_revisions_to_keep($post) in wp-includes/revision.php, and the result is run through a filter, you should be able to do something like this:<?php
function wpse_289553($num, $post) {
if(in_array($post->ID, array(123, 456, 789))) {
return -1;
}
return $num;
}
add_filter("wp_revisions_to_keep", "wpse_289553", 10, 2);
Set your post IDs in that array and adjust the returned number to how many revisions you'd like to keep. -1 means "all of them".

Không có nhận xét nào:
Đăng nhận xét