From 83e351a7ccf68a89059b9b971c0cc0d74058842c Mon Sep 17 00:00:00 2001 From: Peter Westwood Date: Wed, 1 Jun 2011 14:24:02 +0000 Subject: [PATCH] Only close comments on old posts by default. Fixes #16090 props nacin and johnjamesjacoby. git-svn-id: https://develop.svn.wordpress.org/trunk@18087 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/comment.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/wp-includes/comment.php b/wp-includes/comment.php index 7a8aa96864..8e17000a5d 100644 --- a/wp-includes/comment.php +++ b/wp-includes/comment.php @@ -1965,6 +1965,10 @@ function _close_comments_for_old_posts( $posts ) { if ( empty($posts) || !is_singular() || !get_option('close_comments_for_old_posts') ) return $posts; + $post_types = apply_filters( 'close_comments_for_post_types', array( 'post' ) ); + if ( ! in_array( $posts[0]->post_type, $post_types ) ) + return $posts; + $days_old = (int) get_option('close_comments_days_old'); if ( !$days_old ) return $posts; @@ -2000,6 +2004,10 @@ function _close_comments_for_old_post( $open, $post_id ) { $post = get_post($post_id); + $post_types = apply_filters( 'close_comments_for_post_types', array( 'post' ) ); + if ( ! in_array( $post->post_type, $post_types ) ) + return $open; + if ( time() - strtotime( $post->post_date_gmt ) > ( $days_old * 24 * 60 * 60 ) ) return false;