Only close comments on old posts by default. Fixes #16090 props nacin and johnjamesjacoby.

git-svn-id: http://svn.automattic.com/wordpress/trunk@18087 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
westi 2011-06-01 14:24:02 +00:00
parent ea720f6a36
commit 2ad5ccbe7b

View File

@ -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;