I would generally not recommend modifying files for Plugins that you do not control. Better would be to write your own site/custom Plugin, to control this hook:
add_action('akismet_scheduled_delete', 'akismet_delete_old');
First, to stop the deletion altogether, simply call:
remove_action('akismet_scheduled_delete', 'akismet_delete_old');
Then, you can set up a cron job (or similar), to fire the akismet_delete_old()
function on whatever frequency you prefer.
Edit
To be more clear: I’m referring to a site/custom Plugin, that interacts with Akismet – not a fork/replacement of Akismet. Since Akismet adds the comment-deletion functionality as a callback to an action hook specific to the Plugin, you can override that added action from outside the Plugin.
The remove_action()
call above will simply stop the comment-deletion code from running at all. If you want to enable less-frequent comment deletion, you could use several methods:
- Rewrite the
akismet_delete_old()
callback (as you have done in your own answer), and then hook it intoakismet_scheduled_delete
- Write your own cron job to run on your desired frequency
- Etc.
Note: there is a companion callback, akismet_delete_old_meta()
, that you may need to modify/remove from the akismet_scheduled_delete
action, also.