Archive for January, 2009

Recent comments

Tuesday, January 6th, 2009

To prevent comments from protected pages from appearing in “Recent comments” widget, open up “/wp-includes/widgets.php” and replace the function “wp_widget_recent_comments” with this code:

function wp_widget_recent_comments($args) {
global $wpdb, $comments, $comment, $current_user;
extract($args, EXTR_SKIP);
$options = get_option(’widget_recent_comments’);
$title = empty($options['title']) ? __(’Recent Comments’) : apply_filters(’widget_title’, $options['title']);
if ( !$number = (int) $options['number'] )
$number = 5;
else if ( $number < 1 )
$number = 1;
else if ( $number > 15 )
$number = 15;

if ( !$comments = wp_cache_get( ‘recent_comments’, ‘widget’ ) ) {
$comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_approved = ‘1′ AND comment_post_ID NOT IN (SELECT post_id FROM " . $wpdb->prefix . "named_users WHERE (user_id <> " . $current_user->ID . " OR group_id NOT IN (SELECT group_id FROM " . $wpdb->prefix . "named_users_groups_relations WHERE user_id = " . $current_user->ID . "))) ORDER BY comment_date_gmt DESC LIMIT $number");
wp_cache_add( ‘recent_comments’, $comments, ‘widget’ );
}
?>

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

Internationalization

Friday, January 2nd, 2009

I’ve made some changes to the plugin to support internationalization. The POT file is placed in the plugin directory. Let me know if you find any bugs!

I’ve included a danish translation. Please write a comment if you want to share your translation files (.po and .mo) and remember to write your email address in the “Mail” field, so that I can contact you.