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
This commit is contained in:
Peter Westwood 2011-06-01 14:24:02 +00:00
parent 6dcfd5fc14
commit 83e351a7cc
1 changed files with 8 additions and 0 deletions

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;