comments WHERE comment_type ='' AND comment_approved = '1'"; $have_comment_post_ids = $wpdb->get_results($q); foreach ($have_comment_post_ids as $have_comment_post_id){ $q = "SELECT comment_author,user_id FROM $wpdb->comments WHERE comment_type ='' AND comment_approved = '1' AND comment_post_id = $have_comment_post_id->comment_post_id order by comment_date limit 1"; $first_comment = $wpdb->get_results($q); $top_first_commentors_exclude = $top_first_commentors_options["exclude"]; if(!$top_first_commentors_exclude){ array_push($first_commentors,$first_comment[0] -> comment_author); }else{ $top_first_commentors_exclude = explode(",",$top_first_commentors_exclude); if(!in_array($first_comment[0] -> user_id,$top_first_commentors_exclude)){ array_push($first_commentors,$first_comment[0] -> comment_author); } } } $first_commentors = (array_count_values ($first_commentors)); arsort($first_commentors); $first_commentors_author = array_keys($first_commentors); $top_first_commentors = array(); $top_first_commentors_number = $top_first_commentors_options["number"]; if(!$top_first_commentors_number) $top_first_commentors_number = 3; $top_first_commentors_titles = $top_first_commentors_options["titles"]; if($top_first_commentors_titles) $top_first_commentors_titles = explode(",",$top_first_commentors_titles); for($i=0; $i<$top_first_commentors_number; $i++){ $q = "SELECT comment_author_url FROM $wpdb->comments WHERE comment_type ='' AND user_id = 0 AND comment_approved = '1' AND comment_author_url !='' AND comment_author = '$first_commentors_author[$i]' limit 1"; $first_comment_url = $wpdb->get_results($q); $top_first_commentors_title = $top_first_commentors_titles[$i]; if($top_first_commentors_title) $top_first_commentors_title .= " : "; if($first_comment_url){ $top_first_commentors[$i] = $top_first_commentors_title . '' . $first_commentors_author[$i] . '(' . $first_commentors["$first_commentors_author[$i]"].')'; } else { $top_first_commentors[$i] = $top_first_commentors_titles[$i] .$first_commentors_author[$i] . '('.$first_commentors["$first_commentors_author[$i]"] . ')'; } } wp_cache_set("top_first_commentors", $top_first_commentors, "tfc", 36000); return $top_first_commentors; } function get_top_first_commentors(){ $output = ""; $output .= '
'. $message . '