source: comment-plugger/trunk/comment-plugger.php @ 155531

Revision 155531, 1.3 KB checked in by MtDewVirus, 3 years ago (diff)

update urls

Line 
1<?php
2/*
3Plugin Name: Comment Plugger
4Plugin URI: http://wordpress.org/extend/plugins/comment-plugger/
5Description: Gives a list of that last people to comment on a post, with a link to their site if they provided one.
6Version: 1.1
7Author: Nick Momrik
8Author URI: http://nickmomrik.com/
9*/
10
11function mdv_comment_plugger($before = '', $limit = 10) {
12        global $wpdb, $id;
13
14        $commenters = $wpdb->get_results("SELECT comment_author, comment_author_email, comment_author_url, UNIX_TIMESTAMP(comment_date) AS unixdate FROM $wpdb->comments WHERE comment_post_ID='$id' AND comment_approved = '1' AND comment_type <> 'pingback' AND comment_type <> 'trackback' GROUP BY comment_author_email, comment_author ORDER BY comment_date DESC LIMIT $limit");
15
16        if ($commenters) {
17                $output = '';
18                $commenters = array_reverse($commenters); // Reserve the order so most recent commenter is last in the array
19
20                foreach ($commenters as $commenter) {
21                        if (!empty($commenter->comment_author)) {
22                                if (!empty($commenter->comment_author_url))
23                                        $output .= '<li><a href="' . $commenter->comment_author_url . '" title="Visit ' . $commenter->comment_author . '">' . $commenter->comment_author . '</a> </li>';
24                                else
25                                        $output .= '<li>' . $commenter->comment_author . ' </li>';
26                        }
27                }
28
29                echo $before . '<ul>' . $output . '</ul>';
30        }
31}
32?>
Note: See TracBrowser for help on using the repository browser.