'widget_recent_review', 'description' => __('The most recent review')); $this->WP_Widget('recent-review', __('Geocraft Recent Review'), $widget_ops); $this->alt_option_name = 'widget_recent_review'; add_action('comment_post', array(&$this, 'geocraft_widget_cache')); add_action('transition_comment_status', array(&$this, 'geocraft_widget_cache')); } function geocraft_widget_cache() { wp_cache_delete('recent_review', 'widget'); } function widget($args, $instance) { global $wpdb, $comments, $comment, $rating_table_name; $post_type = POST_TYPE; extract($args, EXTR_SKIP); $title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Review') : $instance['title']); if (!$number = (int) $instance['number']) $number = 5; else if ($number < 1) $number = 1; else if ($number > 150) $number = 150; if (!$comments = wp_cache_get('recent_comments', 'widget')) { $comments = $wpdb->get_results("SELECT $wpdb->comments.* FROM $wpdb->comments JOIN $wpdb->posts ON $wpdb->posts.ID = $wpdb->comments.comment_post_ID WHERE comment_approved = '1' AND post_status = 'publish' AND post_type='$post_type' ORDER BY comment_date_gmt DESC LIMIT 150"); wp_cache_add('recent_comments', $comments, 'widget'); } $comments = array_slice((array) $comments, 0, $number); //how many characters in length should the comment excerpts be? $excerptLen = 50; ?>

comment_ID); $aRecentCommentTxt = trim(mb_substr(strip_tags(apply_filters('comment_text', $aRecentComment->comment_content)), 0, $excerptLen)); if (strlen($aRecentComment->comment_content) > $excerptLen) { $aRecentCommentTxt .= "\t[...]"; } ?>
comment_ID)) . '">' . $aRecentCommentTxt . ''); ?>
    get_var("select rating_rating from $rating_table_name where comment_id=\"$comment->comment_ID\""); echo geocraft_display_rating_star($post_rating); ?>

comment_date); ?>

geocraft_widget_cache(); $alloptions = wp_cache_get('alloptions', 'options'); if (isset($alloptions['widget_recent_comments'])) delete_option('widget_recent_comments'); return $instance; } function form($instance) { $title = isset($instance['title']) ? esc_attr($instance['title']) : ''; $number = isset($instance['number']) ? absint($instance['number']) : 5; ?>