800 | | // Count comments older than this one |
801 | | $oldercoms = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_parent = 0 AND comment_approved = '1' AND comment_date_gmt < '%s'" . $comtypewhere, $comment->comment_post_ID, $comment->comment_date_gmt ) ); |
| 800 | // Count comments older than this one, including this user's unmoderated comments |
| 801 | $current_user = wp_get_current_user(); |
| 802 | $current_commenter = wp_get_current_commenter(); |
| 803 | |
| 804 | if ( $comment->user_id && $comment->user_id == $current_user->id ) |
| 805 | $oldercoms = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_parent = 0 AND ( comment_approved = '1' OR ( user_id = %d AND comment_approved = '0' ) ) AND comment_date_gmt < %s" . $comtypewhere, $comment->comment_post_ID, $comment->user_id, $comment->comment_date_gmt ) ); |
| 806 | elseif ( $current_commenter['comment_author'] == $comment->comment_author && $current_commenter['comment_author_email'] == $comment->comment_author_email ) |
| 807 | $oldercoms = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_parent = 0 AND ( comment_approved = '1' OR ( comment_author = %s AND comment_author_email = %s AND comment_approved = '0' ) ) AND comment_date_gmt < %s" . $comtypewhere, $comment->comment_post_ID, $comment->comment_author, $comment->comment_author_email, $comment->comment_date_gmt ) ); |
| 808 | else |
| 809 | $oldercoms = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_parent = 0 AND comment_approved = '1' AND comment_date_gmt < %s" . $comtypewhere, $comment->comment_post_ID, $comment->comment_date_gmt ) ); |