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
This commit is contained in:
ryan 2011-09-30 15:35:50 +00:00
parent d5232043ce
commit 96b3575b72
2 changed files with 6 additions and 5 deletions

View File

@ -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 ) ) {

View File

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