All pastes #66916 Raw Edit

headzoo

public php v1 · immutable
#66916 ·published 2006-06-18 19:25 UTC
rendered paste body
<?php/*Plugin Name: Sean's CommentsPlugin URI: http://www.headzoo.comDescription: Show latest comments and a piece of the comment...Author: Sean HickeyVersion: 1.0Author 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");		echo "<ul class='seans_comments'>\r\n";	foreach ($comments as $comment) {			$commentDate = strtotime($comment->comment_date);		$commentDate = date($dateFormat, $commentDate);		$commentLink = get_permalink($comment->comment_post_ID) . '#comment-' . $comment->comment_ID;		$commentTitle = get_the_title($comment->comment_post_ID);		$commentAuthor = $comment->comment_author;		$commentContent = nl2br(chopString($comment->comment_content, $length));				/**		 * This is the start of the mini-loop.  Edit inside here		 */		?>						<?php echo $before; ?>		<p><a href="<?php echo $commentLink; ?>" title="<?php echo $commentTitle; ?>"><?php echo $commentTitle; ?></a></p>		<p>By <em><?php echo $commentAuthor; ?></em> on <?php echo $commentDate; ?></p>		<p><?php echo $commentContent; ?></p>		<?php echo $after; ?>				<?php		/**		 * This is the end of the mini-loop.  Don't edit past here.		 */	}	echo "</ul>\r\n";}function chopString($string, $length) {	$string = strip_tags($string);	if (strlen($string) > $length) {		$string = substr($string, 0, $length) . '[...]';	}	return $string;}?>