Ticket #8177: 8177.2.diff
| File 8177.2.diff, 6.4 KB (added by , 13 years ago) |
|---|
-
wp-includes/comment.php
2009 2009 * @return object 2010 2010 */ 2011 2011 function _close_comments_for_old_posts( $posts, $query ) { 2012 if ( empty( $posts ) || ! $query->is_singular() || !get_option( 'close_comments_for_old_posts' ) )2012 if ( empty( $posts ) || ! get_option( 'close_comments_for_old_posts' ) ) 2013 2013 return $posts; 2014 2014 2015 2015 $post_types = apply_filters( 'close_comments_for_post_types', array( 'post' ) ); … … 2020 2020 if ( ! $days_old ) 2021 2021 return $posts; 2022 2022 2023 if ( time() - strtotime( $posts[0]->post_date_gmt ) > ( $days_old * DAY_IN_SECONDS ) ) { 2024 $posts[0]->comment_status = 'closed'; 2025 $posts[0]->ping_status = 'closed'; 2026 } 2023 for ( $i = 0; $i < count( $posts ); $i++ ) { 2024 if ( time() - strtotime( $posts[ $i ]->post_date_gmt ) > ( $days_old * DAY_IN_SECONDS ) ) { 2025 $posts[ $i ]->comment_status = 'closed'; 2026 $posts[ $i ]->ping_status = 'closed'; 2027 } 2028 } 2027 2029 2028 2030 return $posts; 2029 2031 } … … 2060 2062 2061 2063 return $open; 2062 2064 } 2065 2066 /** 2067 * Close comments/pings on attachments if the parent's comments are closed. Hooked to the_posts. 2068 * 2069 * @access private 2070 * @since 3.6.0 2071 * 2072 * @param object $posts Post data object. 2073 * @return object 2074 */ 2075 function _close_comments_for_attachments( $posts ) { 2076 2077 foreach ( (array) $posts as $key => $post ) { 2078 if ( 'attachment' != $post->post_type || 0 == $post->post_parent || $post->post_parent == $post->ID ) 2079 continue; 2080 2081 $parent = get_post($post->post_parent); 2082 $posts[ $key ]->comment_status = $parent->comment_status; 2083 $posts[ $key ]->ping_status = $parent->ping_status; 2084 } 2085 2086 return $posts; 2087 } 2088 2089 /** 2090 * Close comments/pings on attachment if parents comments/pings are closed. Hooked to comments_open and pings_open. 2091 * 2092 * @access private 2093 * @since 3.6.0 2094 * 2095 * @param bool $open Comments open or closed 2096 * @param int $post_id Post ID 2097 * @return bool $open 2098 */ 2099 function _close_comments_for_attachment( $open, $post_id) { 2100 if ( ! $open ) 2101 return $open; 2102 2103 $post = get_post( $post_id ); 2104 2105 if ( 'attachment' != $post->post_type || 0 == $post->post_parent ) 2106 return $open; 2107 2108 $parent = get_post( $post->post_parent ); 2109 2110 if ( ! $parent ) 2111 return $open; 2112 2113 if ( 'comments_open' == current_filter() ) 2114 $open = ( 'open' == $parent->comment_status ); 2115 else //pings 2116 $open = ( 'open' == $parent->ping_status ); 2117 2118 return $open; 2119 } 2120 No newline at end of file -
wp-includes/default-filters.php
173 173 add_filter( 'the_author', 'ent2ncr', 8 ); 174 174 175 175 // Misc filters 176 add_filter( 'option_ping_sites', 'privacy_ping_filter' ); 177 add_filter( 'option_blog_charset', '_wp_specialchars' ); // IMPORTANT: This must not be wp_specialchars() or esc_html() or it'll cause an infinite loop 178 add_filter( 'option_home', '_config_wp_home' ); 179 add_filter( 'option_siteurl', '_config_wp_siteurl' ); 180 add_filter( 'tiny_mce_before_init', '_mce_set_direction' ); 181 add_filter( 'pre_kses', 'wp_pre_kses_less_than' ); 182 add_filter( 'sanitize_title', 'sanitize_title_with_dashes', 10, 3 ); 183 add_action( 'check_comment_flood', 'check_comment_flood_db', 10, 3 ); 184 add_filter( 'comment_flood_filter', 'wp_throttle_comment_flood', 10, 3 ); 185 add_filter( 'pre_comment_content', 'wp_rel_nofollow', 15 ); 186 add_filter( 'comment_email', 'antispambot' ); 187 add_filter( 'option_tag_base', '_wp_filter_taxonomy_base' ); 188 add_filter( 'option_category_base', '_wp_filter_taxonomy_base' ); 189 add_filter( 'the_posts', '_close_comments_for_old_posts', 10, 2); 190 add_filter( 'comments_open', '_close_comments_for_old_post', 10, 2 ); 191 add_filter( 'pings_open', '_close_comments_for_old_post', 10, 2 ); 192 add_filter( 'editable_slug', 'urldecode' ); 193 add_filter( 'editable_slug', 'esc_textarea' ); 194 add_filter( 'nav_menu_meta_box_object', '_wp_nav_menu_meta_box_object' ); 176 add_filter( 'option_ping_sites', 'privacy_ping_filter' ); 177 add_filter( 'option_blog_charset', '_wp_specialchars' ); // IMPORTANT: This must not be wp_specialchars() or esc_html() or it'll cause an infinite loop 178 add_filter( 'option_home', '_config_wp_home' ); 179 add_filter( 'option_siteurl', '_config_wp_siteurl' ); 180 add_filter( 'tiny_mce_before_init', '_mce_set_direction' ); 181 add_filter( 'pre_kses', 'wp_pre_kses_less_than' ); 182 add_filter( 'sanitize_title', 'sanitize_title_with_dashes', 10, 3 ); 183 add_action( 'check_comment_flood', 'check_comment_flood_db', 10, 3 ); 184 add_filter( 'comment_flood_filter', 'wp_throttle_comment_flood', 10, 3 ); 185 add_filter( 'pre_comment_content', 'wp_rel_nofollow', 15 ); 186 add_filter( 'comment_email', 'antispambot' ); 187 add_filter( 'option_tag_base', '_wp_filter_taxonomy_base' ); 188 add_filter( 'option_category_base', '_wp_filter_taxonomy_base' ); 189 add_filter( 'the_posts', '_close_comments_for_old_posts', 10, 2 ); 190 add_filter( 'comments_open', '_close_comments_for_old_post', 10, 2 ); 191 add_filter( 'pings_open', '_close_comments_for_old_post', 10, 2 ); 192 add_filter( 'the_posts', '_close_comments_for_attachments' ); 193 add_filter( 'comments_open', '_close_comments_for_attachment', 10, 2 ); 194 add_filter( 'pings_open', '_close_comments_for_attachment', 10, 2 ); 195 add_filter( 'editable_slug', 'urldecode' ); 196 add_filter( 'editable_slug', 'esc_textarea' ); 197 add_filter( 'nav_menu_meta_box_object', '_wp_nav_menu_meta_box_object' ); 195 198 196 199 // Actions 197 200 add_action( 'wp_head', 'wp_enqueue_scripts', 1 );