| Line | |
|---|
| 1 | <?php
|
|---|
| 2 | /*
|
|---|
| 3 | Plugin Name: Comment Plugger
|
|---|
| 4 | Plugin URI: http://wordpress.org/extend/plugins/comment-plugger/
|
|---|
| 5 | Description: Gives a list of that last people to comment on a post, with a link to their site if they provided one.
|
|---|
| 6 | Version: 1.1
|
|---|
| 7 | Author: Nick Momrik
|
|---|
| 8 | Author URI: http://nickmomrik.com/
|
|---|
| 9 | */
|
|---|
| 10 |
|
|---|
| 11 | function 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.