esc_html__('A widget that display latest three posts', 'buzzstore-lite') )); } private function widget_fields() { $args = array( 'type' => 'post', 'child_of' => 0, 'orderby' => 'name', 'order' => 'ASC', 'hide_empty' => 1, 'taxonomy' => 'category', ); $categories = get_categories($args); $cat_lists = array(); foreach ($categories as $category) { $cat_lists[$category->term_id] = $category->name; } $fields = array( 'buzzstore_blogs_title' => array( 'buzzstore_widgets_name' => 'buzzstore_blogs_title', 'buzzstore_widgets_title' => esc_html__('Blogs Title', 'buzzstore-lite'), 'buzzstore_widgets_field_type' => 'title', ), 'blogs_category_list' => array( 'buzzstore_widgets_name' => 'blogs_category_list', 'buzzstore_mulicheckbox_title' => esc_html__('Select Blogs Category', 'buzzstore-lite'), 'buzzstore_widgets_field_type' => 'multicheckboxes', 'buzzstore_widgets_field_options' => $cat_lists ), 'blogs_posts_display_order' => array( 'buzzstore_widgets_name' => 'blogs_posts_display_order', 'buzzstore_widgets_title' => esc_html__('Display Posts Order', 'buzzstore-lite'), 'buzzstore_widgets_field_type' => 'select', 'buzzstore_widgets_field_options' => array( 'ASC' => esc_html__('Ascending Order','buzzstore-lite'), 'DESC' => esc_html__('Descending Order', 'buzzstore-lite') ) ), ); return $fields; } public function widget($args, $instance) { extract($args); extract($instance); /** * wp query for first block */ $blog_post_title = empty( $instance['buzzstore_blogs_title'] ) ? '' : $instance['buzzstore_blogs_title']; $blogs_category_list = empty( $instance['blogs_category_list'] ) ? '' : $instance['blogs_category_list']; $blogs_posts_display_order = empty( $instance['blogs_posts_display_order'] ) ? '' : $instance['blogs_posts_display_order']; $blogs_cat_id = array(); if (!empty($blogs_category_list)) { $blogs_cat_id = array_keys($blogs_category_list); } $blogs_posts = new WP_Query(array( 'posts_per_page' => 3, 'post_type' => 'post', 'cat' => $blogs_cat_id, 'order' => $blogs_posts_display_order )); echo $before_widget; ?>

widget_fields(); foreach ($widget_fields as $widget_field) { extract($widget_field); $instance[$buzzstore_widgets_name] = buzzstore_widgets_updated_field_value($widget_field, $new_instance[$buzzstore_widgets_name]); } return $instance; } public function form($instance) { $widget_fields = $this->widget_fields(); foreach ($widget_fields as $widget_field) { extract($widget_field); $buzzstore_widgets_field_value = !empty($instance[$buzzstore_widgets_name]) ? $instance[$buzzstore_widgets_name] : ''; buzzstore_widgets_show_widget_field($this, $widget_field, $buzzstore_widgets_field_value); } } }