Make WordPress Core

Ticket #19858: 19858.2.diff

File 19858.2.diff, 1.5 KB (added by Mamaduka, 13 years ago)
  • wp-includes/comment.php

     
    19751975        if ( empty( $posts ) || ! $query->is_singular() || ! get_option( 'close_comments_for_old_posts' ) )
    19761976                return $posts;
    19771977
    1978         $post_types = apply_filters( 'close_comments_for_post_types', array( 'post' ) );
     1978        $post_types = apply_filters( 'close_comments_for_post_types', array( 'post', 'attachment' ) );
    19791979        if ( ! in_array( $posts[0]->post_type, $post_types ) )
    19801980                return $posts;
    19811981
     
    19831983        if ( ! $days_old )
    19841984                return $posts;
    19851985
    1986         if ( time() - strtotime( $posts[0]->post_date_gmt ) > ( $days_old * 24 * 60 * 60 ) ) {
     1986        $post = $posts[0];
     1987
     1988        if ( 'inherit' == $posts[0]->post_status )
     1989                $post = get_post( $posts[0]->post_parent );
     1990
     1991        if ( time() - strtotime( $post->post_date_gmt ) > ( $days_old * 24 * 60 * 60 ) ) {
    19871992                $posts[0]->comment_status = 'closed';
    19881993                $posts[0]->ping_status = 'closed';
    19891994        }
     
    20142019
    20152020        $post = get_post($post_id);
    20162021
    2017         $post_types = apply_filters( 'close_comments_for_post_types', array( 'post' ) );
     2022        $post_types = apply_filters( 'close_comments_for_post_types', array( 'post', 'attachment' ) );
    20182023        if ( ! in_array( $post->post_type, $post_types ) )
    20192024                return $open;
    20202025
     2026        if ( 'inherit' == get_post_status( $post_id ) )
     2027                $post = get_post( $post->post_parent );
     2028
    20212029        if ( time() - strtotime( $post->post_date_gmt ) > ( $days_old * 24 * 60 * 60 ) )
    20222030                return false;
    20232031