All pastes #475807 Raw Edit

Unnamed

public text v1 · immutable
·published 2007-05-07 18:21 UTC
rendered paste body
function widget_recent_comments($args) {
        global $wpdb, $comments, $comment;
        extract($args, EXTR_SKIP);
        $options = get_option('widget_recent_comments');
        $title = empty($options['title']) ? __('Recent Comments', 'widgets') : $options['title'];
        $comments = $wpdb->get_results("SELECT comment_author, comment_author_url, comment_ID, comment_post_ID FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 5");
?>

                <?php echo $before_widget; ?>
                        <?php echo $before_title . $title . $after_title; ?>
                        <ul id="recentcomments"><?php
                        if ( $comments ) : foreach ($comments as $comment) :
                        echo  '<li class="recentcomments">' . sprintf(__('%1$s on %2$s'), get_comment_author_link(), '<a href="'. get_permalink($comment->comment_post_ID) . '#comment-' . $comment->comment_ID . '">' . get_the_title($comment->comment_post_ID) . '</a>') . '</li>';
                        endforeach; endif;?></ul>
                <?php echo $after_widget; ?>
<?php
}