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: https://develop.svn.wordpress.org/trunk@18836 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2011-09-30 15:35:50 +00:00
parent 4219b8b03f
commit 83551cc744
2 changed files with 6 additions and 5 deletions

View File

@ -1959,18 +1959,19 @@ function update_comment_cache($comments) {
* @since 2.7.0 * @since 2.7.0
* *
* @param object $posts Post data object. * @param object $posts Post data object.
* @param object $query Query object.
* @return object * @return object
*/ */
function _close_comments_for_old_posts( $posts ) { function _close_comments_for_old_posts( $posts, $query ) {
if ( empty($posts) || !is_singular() || !get_option('close_comments_for_old_posts') ) if ( empty( $posts ) || ! $query->is_singular() || ! get_option( 'close_comments_for_old_posts' ) )
return $posts; return $posts;
$post_types = apply_filters( 'close_comments_for_post_types', array( 'post' ) ); $post_types = apply_filters( 'close_comments_for_post_types', array( 'post' ) );
if ( ! in_array( $posts[0]->post_type, $post_types ) ) if ( ! in_array( $posts[0]->post_type, $post_types ) )
return $posts; return $posts;
$days_old = (int) get_option('close_comments_days_old'); $days_old = (int) get_option( 'close_comments_days_old' );
if ( !$days_old ) if ( ! $days_old )
return $posts; return $posts;
if ( time() - strtotime( $posts[0]->post_date_gmt ) > ( $days_old * 24 * 60 * 60 ) ) { 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( 'comment_email', 'antispambot' );
add_filter( 'option_tag_base', '_wp_filter_taxonomy_base' ); add_filter( 'option_tag_base', '_wp_filter_taxonomy_base' );
add_filter( 'option_category_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( 'comments_open', '_close_comments_for_old_post', 10, 2 );
add_filter( 'pings_open', '_close_comments_for_old_post', 10, 2 ); add_filter( 'pings_open', '_close_comments_for_old_post', 10, 2 );
add_filter( 'editable_slug', 'urldecode' ); add_filter( 'editable_slug', 'urldecode' );