'awp_recent_comments awp_widget', 'description' => __('Widget to display recent comments.', 'awp')); $control_ops = array('width' => 200, 'height' => 250); parent::__construct(false, $name = __('AWP Recent Comments', 'awp'), $widget_ops, $control_ops ); $this->alt_option_name = 'widget_recent_comments'; if ( is_active_widget(false, false, $this->id_base) ) add_action( 'comment_post', array($this, 'flush_widget_cache') ); add_action( 'edit_comment', array($this, 'flush_widget_cache') ); add_action( 'transition_comment_status', array($this, 'flush_widget_cache') ); } function widget( $args, $instance ) { global $comments, $comment,$image,$com; extract($args, EXTR_SKIP); $output = ''; $title = ( ! empty( $instance['title'] ) ) ? $instance['title'] : __( 'Recent Comments', 'awp' ); $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); $number = ( ! empty( $instance['number'] ) ) ? absint( $instance['number'] ) : 5; if ( ! $number ) $number = 5; $comments = get_comments( apply_filters( 'widget_comments_args', array( 'number' => $number, 'status' => 'approve', 'post_status' => 'publish' ) ) ); $output .= $before_widget; if ( $title ) $output .= $before_title . $title . $after_title; $output .= '