'widget_rt_comments_widget', 'description' => __( 'Widget for Show Recent Comment with Author Gravatar in Sidebar.') ); $this->WP_Widget('rt-comments-widget', __('RT: Comments with Gravatar'), $widget_ops); } // end of function rt_comments_widget() function widget($args, $instance) { extract($args, EXTR_SKIP); $title = empty($instance['title']) ? 'Recent Comments' : apply_filters('widget_title', $instance['title']); $gravatar = !empty($instance['gravatar']) ? $instance['gravatar'] : 64; $count = !empty($instance['count']) ? $instance['count'] : 3; $alternative = !empty($instance['alternative']) ? $instance['alternative'] : ''; echo $before_widget; if ( $title ) echo $before_title . $title . $after_title; global $wpdb; $total_comments = $wpdb->get_results("SELECT comment_date_gmt,comment_content, comment_author, comment_ID, comment_post_ID, comment_author_email, comment_date_gmt FROM " . $wpdb->comments . " WHERE comment_approved = '1' and comment_type != 'trackback' ORDER BY comment_date_gmt DESC" ); $comment_total = count($total_comments); echo ''; echo $after_widget; } // end of function widget() function update($new_instance, $old_instance) { global $wpdb; $total_comments = $wpdb->get_results("SELECT comment_date_gmt,comment_content, comment_author, comment_ID, comment_post_ID, comment_author_email, comment_date_gmt FROM " . $wpdb->comments . " WHERE comment_approved = '1' and comment_type != 'trackback' ORDER BY comment_date_gmt DESC" ); $comment_total = count($total_comments); $instance = $old_instance; $instance['title'] = strip_tags($new_instance['title']); $instance['gravatar'] = strip_tags($new_instance['gravatar']); $instance['count'] = strip_tags($new_instance['count']) > $comment_total ? $comment_total : strip_tags($new_instance['count']); $instance['alternative'] = strip_tags($new_instance['alternative']); return $instance; } // end of function update() function form($instance) { $title = isset($instance['title']) ? ($instance['title']) : ''; $gravatar = !empty($instance['gravatar']) ? $instance['gravatar'] : 64; $count = !empty($instance['count']) ? $instance['count'] : 3; $alternative = !empty($instance['alternative']) ? $instance['alternative'] : ''; ?>

get_results("SELECT comment_date_gmt,comment_content, comment_author, comment_ID, comment_post_ID, comment_author_email, comment_date_gmt FROM " . $wpdb->comments . " WHERE comment_approved = '1' and comment_type != 'trackback' ORDER BY comment_date_gmt DESC" ); $comment_total = count($total_comments); echo "
You have total '".$comment_total."' comments to display
"; ?>

/>