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 = array(); |
| 2156 | $depth = $_depth = get_option('thread_comments_depth', 5); |
| 2157 | |
| 2158 | while ($depth > 1) { |
| 2159 | $clause = ($_depth == $depth) ? " AND comment_approved != '1'" : null; |
| 2160 | $bad_parents += $wpdb->get_col("SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = $post_id.$clause"); |
| 2161 | $depth--; |
| 2162 | } |
| 2163 | |
| 2164 | $bad_parents = array_unique($bad_parents); |
| 2165 | $bad_parents = implode(',', $bad_parents); |
| 2166 | |
| 2167 | $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 ) ); |