From 96b3575b72f5f174e9aa0e19684e681fa3364ba6 Mon Sep 17 00:00:00 2001 From: ryan Date: Fri, 30 Sep 2011 15:35:50 +0000 Subject: [PATCH] Pass the query object to _close_comments_for_old_posts() so that is_singular is checked for the proper query. Props kawauso. fixes #18109 git-svn-id: http://svn.automattic.com/wordpress/trunk@18836 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/comment.php | 9 +++++---- wp-includes/default-filters.php | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/wp-includes/comment.php b/wp-includes/comment.php index 8e17000a5..df234a73a 100644 --- a/wp-includes/comment.php +++ b/wp-includes/comment.php @@ -1959,18 +1959,19 @@ function update_comment_cache($comments) { * @since 2.7.0 * * @param object $posts Post data object. + * @param object $query Query object. * @return object */ -function _close_comments_for_old_posts( $posts ) { - if ( empty($posts) || !is_singular() || !get_option('close_comments_for_old_posts') ) +function _close_comments_for_old_posts( $posts, $query ) { + if ( empty( $posts ) || ! $query->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 ) + $days_old = (int) get_option( 'close_comments_days_old' ); + if ( ! $days_old ) return $posts; if ( time() - strtotime( $posts[0]->post_date_gmt ) > ( $days_old * 24 * 60 * 60 ) ) { diff --git a/wp-includes/default-filters.php b/wp-includes/default-filters.php index f82da2986..2507a8848 100644 --- a/wp-includes/default-filters.php +++ b/wp-includes/default-filters.php @@ -189,7 +189,7 @@ add_filter( 'pre_comment_content', 'wp_rel_nofollow', 15 ); add_filter( 'comment_email', 'antispambot' ); add_filter( 'option_tag_base', '_wp_filter_taxonomy_base' ); add_filter( 'option_category_base', '_wp_filter_taxonomy_base' ); -add_filter( 'the_posts', '_close_comments_for_old_posts' ); +add_filter( 'the_posts', '_close_comments_for_old_posts', 10, 2); add_filter( 'comments_open', '_close_comments_for_old_post', 10, 2 ); add_filter( 'pings_open', '_close_comments_for_old_post', 10, 2 ); add_filter( 'editable_slug', 'urldecode' );