I succeed to hack the Recent comments widget. For those who would need this hack, here is the code I used in my functions.php file:
add_action( 'widgets_init', 'recent_comments_widgets' );
function recent_comments_widgets() {
register_widget('Recent_Comments');
}
class Recent_Comments extends WP_Widget {
function Recent_Comments() {
$widget_ops = array('classname' => 'recent_comments', 'description' => __('The most recent comments'));
$this->WP_Widget('recent-comments', __('Recent Comments'), $widget_ops);
}
function widget($args, $instance) {
extract($args);
$title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Recent Comments' ) : $instance['title'], $instance, $this->id_base );
$number = $instance['number'];
// Begin Widget
echo $before_widget;
if ($title) echo $before_title . $title . $after_title; ?>
<div id="recent-comments">
<ul>
<?php
global $wpdb;
$request = "SELECT * FROM $wpdb->comments";
$request .= " JOIN $wpdb->posts ON ID = comment_post_ID";
$request .= " WHERE comment_approved = '1' AND post_status = 'publish' AND post_password =''";
$request .= " ORDER BY comment_date DESC LIMIT $number";
$comments = $wpdb->get_results($request);
if ($comments) { foreach ($comments as $comment) {
ob_start(); ?>
<li>
<div class="comment-excerpt">
<span class="comment-author"><?php echo($comment->comment_author) ?> <?php _e('on','artister'); ?> <a href="<?php echo get_permalink( $comment->comment_post_ID ); ?>"><?php echo get_the_title($comment->comment_post_ID) ?></a></span>
</div>
</li>
<?php ob_end_flush(); }} else { // If no comments ?>
<li></li>
<?php } ?>
</ul>
</div>
<?php echo $after_widget;
// End Widget
}
function update($new_instance, $old_instance) {
$instance = $old_instance;
$instance['title'] = strip_tags($new_instance['title']);
$instance['number'] = strip_tags($new_instance['number']);
return $instance;
}
function form( $instance ) {
$defaults = array('title' => 'Recent Comments', 'number' => '5'); $instance = wp_parse_args((array) $instance, $defaults ); ?>
<p>
<label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
<br/><input class="widefat" type="text" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo $instance['title']; ?>" />
</p>
<p>
<label for="<?php echo $this->get_field_id('number'); ?>"><?php _e('Number of comments to show:'); ?></label>
<input type="text" id="<?php echo $this->get_field_id('number'); ?>" name="<?php echo $this->get_field_name('number'); ?>" size="3" value="<?php echo $instance['number']; ?>" />
</p>
<?php
}
}