widget_cssclass = 'woocommerce best_shop_tabbed_product_by_attribute_grid_widget'; $this->widget_description = __( 'Display Tabbed Product by Attribute.', 'best-shop' ); $this->widget_id = 'best_shop_tabbed_tabbed_product_by_attribute_grid_widget'; $this->widget_name = __( '+ Tabbed Product by Attribute Grid', 'best-shop' ); parent::__construct(); } public function widget( $args, $instance ) { $max_items = ( ! empty( $instance['max_items'] ) ) ? absint( $instance['max_items'] ) : 10; $category1 = ( ! empty( $instance['category1'] ) ) ? wp_strip_all_tags( $instance['category1'] ) : ''; $category2 = ( ! empty( $instance['category2'] ) ) ? wp_strip_all_tags( $instance['category2'] ) : ''; $category3 = ( ! empty( $instance['category3'] ) ) ? wp_strip_all_tags( $instance['category3'] ) : ''; $colums = (!empty($instance['colums'])) ? absint($instance['colums']) : 5; $pagination = ( ! empty( $instance['pagination'] ) ) ? true : false; $product_shortcode1 = ''; $product_shortcode2 = ''; $product_shortcode3 = ''; $product_shortcode = ''; if($category1 == 'on_sale'){ $product_shortcode1 = "[products limit='".absint($max_items)."' columns='".absint($colums)."' on_sale='true' orderby='id' order='DESC' paginate=true ]"; } if($category1 == 'best_selling'){ $product_shortcode1 = "[products limit='".absint($max_items)."' columns='".absint($colums)."' best_selling='true' orderby='id' order='DESC' paginate=true ]"; } if($category1 == 'featured'){ $product_shortcode1 = "[products limit='".absint($max_items)."' columns='".absint($colums)."' visibility='featured' orderby='id' order='DESC' paginate=true ]"; } if($category1 == 'top_rated'){ $product_shortcode1 = "[products limit='".absint($max_items)."' columns='".absint($colums)."' visibility='top_rated' orderby='id' order='DESC' paginate=true ]"; } if($category1 == 'newest'){ $product_shortcode1 = "[products limit='".absint($max_items)."' columns='".absint($colums)."' orderby='id' order='DESC' visibility='visible' paginate=true ]"; } if($category2 == 'on_sale'){ $product_shortcode2 = "[products limit='".absint($max_items)."' columns='".absint($colums)."' on_sale='true' orderby='id' order='DESC' paginate=true ]"; } if($category2 == 'best_selling'){ $product_shortcode2 = "[products limit='".absint($max_items)."' columns='".absint($colums)."' best_selling='true' orderby='id' order='DESC' paginate=true ]"; } if($category2 == 'featured'){ $product_shortcode2 = "[products limit='".absint($max_items)."' columns='".absint($colums)."' visibility='featured' orderby='id' order='DESC' paginate=true ]"; } if($category2 == 'top_rated'){ $product_shortcode2 = "[products limit='".absint($max_items)."' columns='".absint($colums)."' visibility='top_rated' orderby='id' order='DESC' paginate=true ]"; } if($category2 == 'newest'){ $product_shortcode2 = "[products limit='".absint($max_items)."' columns='".absint($colums)."' orderby='id' order='DESC' visibility='visible' paginate=true ]"; } if($category3 == 'on_sale'){ $product_shortcode3 = "[products limit='".absint($max_items)."' columns='".absint($colums)."' on_sale='true' orderby='id' order='DESC' paginate=true ]"; } if($category3 == 'best_selling'){ $product_shortcode3 = "[products limit='".absint($max_items)."' columns='".absint($colums)."' best_selling='true' orderby='id' order='DESC' paginate=true ]"; } if($category3 == 'featured'){ $product_shortcode3 = "[products limit='".absint($max_items)."' columns='".absint($colums)."' visibility='featured' orderby='id' order='DESC' paginate=true ]"; } if($category3 == 'top_rated'){ $product_shortcode3 = "[products limit='".absint($max_items)."' columns='".absint($colums)."' visibility='top_rated' orderby='id' order='DESC' paginate=true ]"; } if($category3 == 'newest'){ $product_shortcode3 = "[products limit='".absint($max_items)."' columns='".absint($colums)."' orderby='id' order='DESC' visibility='visible' paginate=true ]"; } if(!$pagination) { $product_shortcode1 = str_replace("paginate=true", " paginate=false", $product_shortcode1); } if(!$pagination) { $product_shortcode2 = str_replace("paginate=true", " paginate=false", $product_shortcode2); } if(!$pagination) { $product_shortcode3 = str_replace("paginate=true", " paginate=false", $product_shortcode3); } global $best_shop_uniqueue_id ; $tab1_id1 = ++$best_shop_uniqueue_id; //used for class name in all tabs $tab1_id2 = ++$best_shop_uniqueue_id; $tab1_id3 = ++$best_shop_uniqueue_id; ?>
esc_html__('On Sale','best-shop') , 'best_selling'=>esc_html__('Best Selling','best-shop'), 'top_rated'=>esc_html__('Top Rated','best-shop') , 'featured'=> esc_html__('Featured','best-shop'), 'newest'=> esc_html__('Newest','best-shop'), ); $category_list1 = ''; $category_list2 = ''; $category_list3 = ''; if(0 == $category1){ $category_list1 = $category_list1.''; } else{ $category_list1 = $category_list1.''; } if(0 == $category2){ $category_list2 = $category_list2.''; } else{ $category_list2 = $category_list2.''; } if(0 == $category3){ $category_list3 = $category_list3.''; } else{ $category_list3 = $category_list3.''; } foreach ( $categories as $cat=>$value ) { $selected =''; if( ($cat)==$category1 ){ $selected ='Selected=selected'; } $category_list1 = $category_list1.''; } foreach ( $categories as $cat=>$value ) { $selected =''; if( ($cat)==$category2 ){ $selected ='Selected=selected'; } $category_list2 = $category_list2.''; } foreach ( $categories as $cat=>$value ) { $selected =''; if( ($cat)==$category3 ){ $selected ='Selected=selected'; } $category_list3 = $category_list3.''; } ?>
id="get_field_id( 'pagination' )); ?>" name="get_field_name( 'pagination' )); ?>" />