esc_html__('This Widget show Recent Blogs', 'buzmag') ) ); } /** * Helper function that holds widget fields * Array is used in update and form functions */ private function widget_fields() { $buzmag_cat_list = buzmag_Category_list(); $fields = array( 'bm_recent_blog_title' => array( 'buzmag_widgets_name' => 'bm_recent_blog_title', 'buzmag_widgets_title' => esc_html__('Title', 'buzmag'), 'buzmag_widgets_field_type' => 'text', ), 'bm_recent_blog_category' => array( 'buzmag_widgets_name' => 'bm_recent_blog_category', 'buzmag_widgets_title' => esc_html__('Blog Category', 'buzmag'), 'buzmag_widgets_field_type' => 'select', 'buzmag_widgets_field_options' => $buzmag_cat_list, ), 'bm_recent_blog_posts' => array( 'buzmag_widgets_name' => 'bm_recent_blog_posts', 'buzmag_widgets_title' => esc_html__('Recent Blog Posts Number', 'buzmag'), 'buzmag_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); $bm_title_widget = apply_filters( 'widget_title', empty( $instance['bm_recent_blog_title'] ) ? '' : $instance['bm_recent_blog_title'], $instance, $this->id_base ); $bm_recent_blog_category = isset( $instance['bm_recent_blog_category'] ) ? $instance['bm_recent_blog_category'] : '' ; $bm_recent_blog_posts = isset( $instance['bm_recent_blog_posts'] ) ? $instance['bm_recent_blog_posts'] : '' ; if($bm_recent_blog_posts == ''){ $bm_recent_blog_posts = '4'; } echo $before_widget; ?>