Ticket #20262: 20262.3.diff
| File 20262.3.diff, 1.6 KB (added by , 11 years ago) |
|---|
-
src/wp-includes/comment.php
3052 3052 * @return array 3053 3053 */ 3054 3054 function _close_comments_for_old_posts( $posts, $query ) { 3055 if ( empty( $posts ) || ! $query->is_singular() || ! get_option( 'close_comments_for_old_posts' ) )3055 if ( empty( $posts ) || ! $query->is_singular() || ! get_option( 'close_comments_for_old_posts' ) || $posts[0]->post_status !== 'publish' ) { 3056 3056 return $posts; 3057 } 3057 3058 3058 3059 /** 3059 3060 * Filter the list of post types to automatically close comments for. … … 3089 3090 * @return bool $open 3090 3091 */ 3091 3092 function _close_comments_for_old_post( $open, $post_id ) { 3092 if ( ! $open ) 3093 if ( ! $open ) { 3093 3094 return $open; 3095 } 3094 3096 3095 if ( ! get_option('close_comments_for_old_posts') )3097 if ( ! get_option('close_comments_for_old_posts' ) ) { 3096 3098 return $open; 3099 } 3097 3100 3098 3101 $days_old = (int) get_option('close_comments_days_old'); 3099 if ( !$days_old ) 3102 if ( !$days_old ) { 3100 3103 return $open; 3104 } 3101 3105 3102 3106 $post = get_post($post_id); 3107 3108 if ( $post->post_status !== 'publish' ) { 3109 return $open; 3110 } 3103 3111 3104 3112 /** This filter is documented in wp-includes/comment.php */ 3105 3113 $post_types = apply_filters( 'close_comments_for_post_types', array( 'post' ) ); 3106 if ( ! in_array( $post->post_type, $post_types ) ) 3114 if ( ! in_array( $post->post_type, $post_types ) ) { 3107 3115 return $open; 3116 } 3108 3117 3109 if ( time() - strtotime( $post->post_date_gmt ) > ( $days_old * DAY_IN_SECONDS ) ) 3118 if ( time() - strtotime( $post->post_date_gmt ) > ( $days_old * DAY_IN_SECONDS ) ) { 3110 3119 return false; 3120 } 3111 3121 3112 3122 return $open; 3113 3123 }
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)