__( 'Recent comments with avatars.', 'p2' ) ) ); add_action( 'comment_post', array(&$this, 'flush_widget_cache' ) ); add_action( 'transition_comment_status', array( &$this, 'flush_widget_cache' ) ); $this->default_num_to_show = 5; $this->default_avatar_size = 32; } function flush_widget_cache() { wp_cache_delete( 'p2_recent_comments', 'widget' ); } function form( $instance ) { $title = ( isset( $instance['title'] ) ) ? esc_attr( $instance['title'] ) : ''; $title_id = $this->get_field_id( 'title' ); $title_name = $this->get_field_name( 'title' ); $num_to_show = ( isset( $instance['num_to_show'] ) ) ? esc_attr( $instance['num_to_show'] ) : $this->default_num_to_show; $num_to_show_id = $this->get_field_id( 'num_to_show' ); $num_to_show_name = $this->get_field_name( 'num_to_show' ); $avatar_size = ( isset( $instance['avatar_size'] ) ) ? esc_attr( $instance['avatar_size'] ) : $this->default_avatar_size; $avatar_size_id = $this->get_field_id( 'avatar_size' ); $avatar_size_name = $this->get_field_name( 'avatar_size' ); $sizes = array( '32' => 'Yes — 32x32', '-1' => __( 'No avatar', 'p2' ), ); ?>
default_num_to_show; $new_instance['avatar_size'] = (int)$new_instance['avatar_size']? (int)$new_instance['avatar_size'] : $this->default_avatar_size; return $new_instance; } function widget( $args, $instance ) { extract( $args ); $title = (isset( $instance['title'] ) && $instance['title'])? $instance['title'] : __( 'Recent comments', 'p2' ); $num_to_show = (isset( $instance['num_to_show'] ) && (int)$instance['num_to_show'])? (int)$instance['num_to_show'] : $this->default_num_to_show; $avatar_size = (isset( $instance['avatar_size'] ) && (int)$instance['avatar_size'])? (int)$instance['avatar_size'] : $this->default_avatar_size; $no_avatar = $avatar_size == '-1'; $recent_comments = $this->recent_comments( $num_to_show ); echo $before_widget . $before_title . esc_html( $title ) . $after_title; ?>
" . $avatar . ' | '; $post_title = esc_html( strip_tags( get_the_title( $comment->comment_post_ID ) ) ); $excerpt = wp_html_excerpt( $post_title, 30 ); if ( $post_title != $excerpt ) $post_title = $excerpt.'…'; $comment_content = strip_tags( $comment->comment_content ); $excerpt = wp_html_excerpt( $comment_content, 50 ); if ( $comment_content != $excerpt ) $comment_content = $excerpt.'…'; $comment_url = P2_Recent_Comments::comment_url_maybe_local( $comment ); $row .= sprintf( ''.__( "%s on %s" , 'p2' ) . ' |