'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_date); ?>