esc_html__('A widget that shows client testimonial posts', 'buzzstore') )); } 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_testimonial_top_title' => array( 'buzzstore_widgets_name' => 'buzzstore_testimonial_top_title', 'buzzstore_widgets_title' => esc_html__('Testimonial Top Title', 'buzzstore'), 'buzzstore_widgets_field_type' => 'title', ), 'testimonial_category_list' => array( 'buzzstore_widgets_name' => 'testimonial_category_list', 'buzzstore_mulicheckbox_title' => esc_html__('Select Blogs Category', 'buzzstore'), 'buzzstore_widgets_field_type' => 'multicheckboxes', 'buzzstore_widgets_field_options' => $cat_lists ) ); return $fields; } public function widget($args, $instance) { extract($args); extract($instance); /** * wp query for first block */ $testimonial_top_title = empty( $instance['buzzstore_testimonial_top_title'] ) ? '' : $instance['buzzstore_testimonial_top_title']; $testimonial_category_list = empty( $instance['testimonial_category_list'] ) ? '' : $instance['testimonial_category_list']; $testimonial_cat_id = array(); if(!empty($testimonial_category_list)){ $testimonial_cat_id = array_keys($testimonial_category_list); } $testimonial_posts = new WP_Query( array( 'posts_per_page' => 5, 'post_type' => 'post', 'cat' => $testimonial_cat_id, )); echo $before_widget; ?>

    have_posts() ) : while( $testimonial_posts->have_posts() ) : $testimonial_posts->the_post(); ?>
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); } } }