From 1838af3622298786436132e99a26539f93cbf7ca Mon Sep 17 00:00:00 2001 From: lucha <lucha@paranoici.org> Date: Wed, 19 May 2021 11:47:28 +0200 Subject: [PATCH] close comments also on old pages and attachments --- close-old-comments.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/close-old-comments.php b/close-old-comments.php index d8dde63..166b036 100644 --- a/close-old-comments.php +++ b/close-old-comments.php @@ -27,4 +27,17 @@ function override_close_comments_days_old($value, $option){ } add_filter('option_close_comments_days_old', 'override_close_comments_days_old', 10, 2); +# Filter on 'close_comments_for_post_types' +# which post_types do we need to close automatically after X days? +# Wordpress defaults to 'posts' (but let's check if got removed and add it back) +add_filter('close_comments_for_post_types', function ($post_types){ + if (! in_post_types('post'), $post_types ){ + $post_types[] = 'post'; + } + $post_types[] = 'page'; + $post_types[] = 'attachment'; + + return $post_types; +}); + ?> -- GitLab