esc_html__('A widget that shows client testimonial 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_testimonial_top_title' => array( 'buzzstore_widgets_name' => 'buzzstore_testimonial_top_title', 'buzzstore_widgets_title' => esc_html__('Testimonial Top Title', 'buzzstore-lite'), 'buzzstore_widgets_field_type' => 'title', ), 'testimonial_category_list' => array( 'buzzstore_widgets_name' => 'testimonial_category_list', 'buzzstore_mulicheckbox_title' => esc_html__('Select Blogs Category', 'buzzstore-lite'), 'buzzstore_widgets_field_type' => 'multicheckboxes', 'buzzstore_widgets_field_options' => $cat_lists ), 'testimonial_no_of_posts' => array( 'buzzstore_widgets_name' => 'testimonial_no_of_posts', 'buzzstore_widgets_title' => esc_html__('Number of Posts to Display', 'buzzstore-lite'), 'buzzstore_widgets_field_type' => 'select', 'buzzstore_widgets_field_options' => array( '1' => esc_html__('1', 'buzzstore-lite' ), '2' => esc_html__('2', 'buzzstore-lite'), '3' => esc_html__('3', 'buzzstore-lite'), '4' => esc_html__('4', 'buzzstore-lite'), '5' => esc_html__('5', 'buzzstore-lite'), ), ), 'testimonial_number_of_columns' => array( 'buzzstore_widgets_name' => 'testimonial_number_of_columns', 'buzzstore_widgets_title' => esc_html__('Number of Columns', 'buzzstore-lite'), 'buzzstore_widgets_field_type' => 'select', 'buzzstore_widgets_field_options' => array( '1' => esc_html__('1', 'buzzstore-lite' ), '2' => esc_html__('2', 'buzzstore-lite'), '3' => esc_html__('3', 'buzzstore-lite'), '4' => esc_html__('4', 'buzzstore-lite'), ), ), 'buzzstore_testimonial_layout' => array( 'buzzstore_widgets_name' => 'buzzstore_testimonial_layout', 'buzzstore_widgets_title' => esc_html__('Select Layout', 'buzzstore-lite'), 'buzzstore_widgets_field_type' => 'select', 'buzzstore_widgets_field_options' => array( '' => esc_html__('Layout One', 'buzzstore-lite'), 'style-two' => esc_html__('Layout Two', 'buzzstore-lite'), ), ), ); 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_no_of_posts = empty( $instance['testimonial_no_of_posts'] ) ? '' : $instance['testimonial_no_of_posts']; $testimonial_number_of_columns = empty ( $instance['testimonial_number_of_columns'] ) ? : $instance['testimonial_number_of_columns']; $testimonial_category_list = empty( $instance['testimonial_category_list'] ) ? '' : $instance['testimonial_category_list']; $buzzstore_testimonial_layout = empty( $instance['buzzstore_testimonial_layout'] ) ? '' : $instance['buzzstore_testimonial_layout']; $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' => $testimonial_no_of_posts, 'post_type' => 'post', 'cat' => $testimonial_cat_id, )); 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); } } }