Ticket #20262: 20262.2.diff
| File 20262.2.diff, 1.6 KB (added by , 12 years ago) |
|---|
-
src/wp-includes/comment.php
2797 2797 * @return object 2798 2798 */ 2799 2799 function _close_comments_for_old_posts( $posts, $query ) { 2800 if ( empty( $posts ) || ! $query->is_singular() || ! get_option( 'close_comments_for_old_posts' ) )2800 if ( empty( $posts ) || ! $query->is_singular() || ! get_option( 'close_comments_for_old_posts' ) || $posts[0]->post_status != 'publish' ) { 2801 2801 return $posts; 2802 } 2802 2803 2803 2804 /** 2804 2805 * Filter the list of post types to automatically close comments for. … … 2834 2835 * @return bool $open 2835 2836 */ 2836 2837 function _close_comments_for_old_post( $open, $post_id ) { 2837 if ( ! $open ) 2838 if ( ! $open ) { 2838 2839 return $open; 2840 } 2839 2841 2840 if ( !get_option('close_comments_for_old_posts') ) 2842 if ( !get_option('close_comments_for_old_posts') ) { 2841 2843 return $open; 2844 } 2842 2845 2843 2846 $days_old = (int) get_option('close_comments_days_old'); 2844 if ( !$days_old ) 2847 if ( !$days_old ) { 2845 2848 return $open; 2849 } 2846 2850 2847 2851 $post = get_post($post_id); 2852 2853 if( $post->post_status != 'publish' ) { 2854 return $open; 2855 } 2848 2856 2849 2857 /** This filter is documented in wp-includes/comment.php */ 2850 2858 $post_types = apply_filters( 'close_comments_for_post_types', array( 'post' ) ); 2851 if ( ! in_array( $post->post_type, $post_types ) ) 2859 if ( ! in_array( $post->post_type, $post_types ) ) { 2852 2860 return $open; 2861 } 2853 2862 2854 if ( time() - strtotime( $post->post_date_gmt ) > ( $days_old * DAY_IN_SECONDS ) ) 2863 if ( time() - strtotime( $post->post_date_gmt ) > ( $days_old * DAY_IN_SECONDS ) ) { 2855 2864 return false; 2865 } 2856 2866 2857 2867 return $open; 2858 2868 }
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)