__('A widget that shows woocommerce product in tab format (Latest, Feature, On Sale, Up Sale).', 'sparklestore') )); } private function widget_fields() { $fields = array( 'sparklestore_tab_title' => array( 'sparklestore_widgets_name' => 'sparklestore_tab_title', 'sparklestore_widgets_title' => __('Title', 'sparklestore'), 'sparklestore_widgets_field_type' => 'text', ), 'sparklestore_latest_product' => array( 'sparklestore_widgets_name' => 'sparklestore_latest_product', 'sparklestore_widgets_title' => __('Latest Products', 'sparklestore'), 'sparklestore_widgets_field_type' => 'checkbox' ), 'sparklestore_feature_product' => array( 'sparklestore_widgets_name' => 'sparklestore_feature_product', 'sparklestore_widgets_title' => __('Feature Products', 'sparklestore'), 'sparklestore_widgets_field_type' => 'checkbox' ), 'sparklestore_upsell_product' => array( 'sparklestore_widgets_name' => 'sparklestore_upsell_product', 'sparklestore_widgets_title' => __('UpSell Products', 'sparklestore'), 'sparklestore_widgets_field_type' => 'checkbox' ), 'sparklestore_on_sale' => array( 'sparklestore_widgets_name' => 'sparklestore_on_sale', 'sparklestore_widgets_title' => __('On Sale Products', 'sparklestore'), 'sparklestore_widgets_field_type' => 'checkbox' ), 'sparklestore_product_number' => array( 'sparklestore_widgets_name' => 'sparklestore_product_number', 'sparklestore_widgets_title' => __('Enter Number of Products Show', 'sparklestore'), 'sparklestore_widgets_field_type' => 'number', ), ); return $fields; } public function widget($args, $instance) { extract($args); extract($instance); /** ** wp query for first block **/ $title = esc_attr( $instance['sparklestore_tab_title'] ); $latest_product = $instance['sparklestore_latest_product']; $feature_product = $instance['sparklestore_feature_product']; $upsell_product = $instance['sparklestore_upsell_product']; $on_sale = $instance['sparklestore_on_sale']; $product_number = intval( $instance['sparklestore_product_number'] ); echo $before_widget; ?>
widget_fields(); foreach ($widget_fields as $widget_field) { extract($widget_field); $instance[$sparklestore_widgets_name] = sparklestore_widgets_updated_field_value($widget_field, $new_instance[$sparklestore_widgets_name]); } return $instance; } public function form($instance) { $widget_fields = $this->widget_fields(); foreach ($widget_fields as $widget_field) { extract($widget_field); $sparklestore_widgets_field_value = !empty($instance[$sparklestore_widgets_name]) ? $instance[$sparklestore_widgets_name] : ''; sparklestore_widgets_show_widget_field($this, $widget_field, $sparklestore_widgets_field_value); } } }