2154 | | $new = (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved = '1'", $post_id ) ); |
| 2154 | |
| 2155 | $_bad_parents = $bad_parents = array(); |
| 2156 | $depth = $_depth = get_option('thread_comments_depth', 5); |
| 2157 | |
| 2158 | while ($depth > 1) { |
| 2159 | |
| 2160 | if ($_depth == $depth) { |
| 2161 | $depth--; |
| 2162 | $clause = " AND comment_approved != '1'"; |
| 2163 | } else { |
| 2164 | $depth--; |
| 2165 | if ($_bad_parents != $bad_parents) { |
| 2166 | $_bad_parents = $bad_parents; |
| 2167 | } else { |
| 2168 | continue; |
| 2169 | } |
| 2170 | |
| 2171 | $clause = ' AND comment_parent IN ('.implode(',', $bad_parents).')'; |
| 2172 | } |
| 2173 | |
| 2174 | $bad_parents = array_merge($bad_parents, $wpdb->get_col("SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = $post_id.$clause")); |
| 2175 | $bad_parents = array_unique($bad_parents); |
| 2176 | } |
| 2177 | |
| 2178 | |
| 2179 | $bad_parents = implode(',', $bad_parents); |
| 2180 | |
| 2181 | $new = (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved = '1' AND comment_parent NOT IN ($bad_parents)", $post_id ) ); |