rendered paste body<?php
/*
Plugin Name: Sean's Comments
Plugin URI: http://www.headzoo.com
Description: Show latest comments and a piece of the comment...
Author: Sean Hickey
Version: 1.0
Author URI: http://www.headzoo.com
*/
function scomments($num = 10, $length = 90, $before = '<li>', $after = '</li>', $dateFormat = 'Y m-d') {
global $wpdb;
$comments = $wpdb->get_results("SELECT comment_author, comment_ID, comment_post_ID, comment_content, comment_date FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT $num");
$html = "<ul class='seans_comments'>\r\n";
foreach ($comments as $comment) {
$commentDate = strtotime($comment->comment_date);
$commentDate = date($dateFormat, $commentDate);
/**
* This is the start of the mini-loop. Edit inside here
*/
$html .= $before;
$html .= '<p><a href="' . get_permalink($comment->comment_post_ID) . '#comment-' . $comment->comment_ID . '">';
$html .= get_the_title($comment->comment_post_ID);
$html .= '</a></p>';
$html .= '<p>by <i>' . $comment->comment_author . '</i> on ' . $commentDate . '</p>';
$html .= '<p>' . nl2br(chopString($comment->comment_content, $length)) . '</p>';
$html .= $after;
/**
* This is the end of the mini-loop. Don't edit past here.
*/
}
$html .= "</ul>\r\n";
echo $html;
}
function chopString($string, $length) {
$string = strip_tags($string);
if (strlen($string) > $length) {
$string = substr($string, 0, $length) . '[...]';
}
return $string;
}
?>