'profile widget', 'description' => esc_html__( 'Display Recent Comment', 'awesome-blog-lite' ) ); parent::__construct( 'Awesome_blog_recent_comment', esc_html__( 'Awesome : Recent Comment', 'awesome-blog-lite' ), $widget_ops ); } /** * Helper function that holds widget fields * Array is used in update and form functions */ private function widget_fields() { $fields = array( 'recent_comment_title' => array( 'awesome_blog_widgets_name' => 'recent_comment_title', 'awesome_blog_widgets_title' => esc_html__( 'Widget title', 'awesome-blog-lite' ), 'awesome_blog_widgets_field_type' => 'text' ), 'number_of_comment' => array( 'awesome_blog_widgets_name' => 'number_of_comment', 'awesome_blog_widgets_title' => esc_html__( 'Enter the number of comment to display', 'awesome-blog-lite' ), 'awesome_blog_widgets_default' => '5', 'awesome_blog_widgets_field_type' => 'number' ), ); return $fields; } /** * Front-end display of widget. * * @see WP_Widget::widget() * * @param array $args Widget arguments. * @param array $instance Saved values from database. */ public function widget( $args, $instance ) { extract( $args ); if( empty( $instance ) ) { return ; } $awesome_blog_recent_comment_title = empty( $instance['recent_comment_title'] ) ? '' : $instance['recent_comment_title']; $awesome_blog_number_of_comment = empty( $instance['number_of_comment'] ) ? '5' : $instance['number_of_comment']; echo $before_widget; if( !empty( $awesome_blog_recent_comment_title ) ) { echo $before_title . esc_html( $awesome_blog_recent_comment_title ) . $after_title; } ?>
absint($awesome_blog_number_of_comment), 'status' => 'approve'); $awesome_blog_comments = get_comments($args); foreach($awesome_blog_comments as $comment) { ?>-
comment_author); ?> comment_ID ); echo esc_html($comment_date); ?>
comment_content); ?>