$remaining_items ){
$total_posts = $remaining_items;
}
$fixed ='';
if( $remaining_items < $online_shop_slider_display_options || $online_shop_slider_display_options < 3 ){
$fixed = 'fix remain-'.$remaining_items;
}
echo "
";
foreach ( $online_shop_featured_cats as $term_id => $value ) {
$taxonomy = 'product_cat';
$term = get_term_by( 'id', $term_id, $taxonomy );
if ( $term && ! is_wp_error( $term ) ) {
$term_link = get_term_link( $term_id, $taxonomy );
$term_name = $term->name;
$total_product = $term->count;
$thumbnail_id = get_term_meta( $term_id, 'thumbnail_id', true );
$image_url = wp_get_attachment_image_src( $thumbnail_id, $online_shop_img_size );
if ( !$image_url ) {
$image_url[0] = get_template_directory_uri() . '/assets/img/default-image.jpg';
}
if( $j > $online_shop_slider_display_options ){
if( $online_shop_slider_display_options == 1 || $j % $online_shop_slider_display_options == 1 ){
$current_slide_number = $current_slide_number + 1;
$remaining_items = $remaining_items - $online_shop_slider_display_options;
if( $online_shop_slider_display_options > $remaining_items ){
$total_posts = $remaining_items;
}
$fixed ='';
if( $remaining_items < $online_shop_slider_display_options || $online_shop_slider_display_options < 3 )
if( $remaining_items < $online_shop_slider_display_options ){
$fixed = 'fix remain-'.$remaining_items;
}
$i = 1;
echo "
";
}
}
$col = 'acme-col-1';
if( 1 == $total_posts ){
$col = 'at-extra-height acme-col-1';
}
elseif( 2 == $total_posts ){
$col = 'at-extra-height acme-col-2';
}
elseif( 3 == $total_posts ){
$col = 'acme-col-2';
if( $i == 3 ){
echo "
";
$col = 'acme-col-1';
}
}
elseif( 4 == $total_posts ){
$col = 'acme-col-2';
}
elseif( 5 == $total_posts ){
$col = 'acme-col-2';
if( $i > 2 ){
$col = 'acme-col-3';
}
}
elseif( 6 == $total_posts ){
$col = 'acme-col-3';
}
?>
";/*at-unique-slide at-custom-slide*/
}
endif;
if ( ! function_exists( 'online_shop_wc_feature_type_two' ) ) :
function online_shop_wc_feature_type_two( $online_shop_featured_cats, $term_per_slide, $online_shop_img_size, $number_of_product_text ){
$i = 1;
$j = 1;
$total_items = count( $online_shop_featured_cats );
$remaining_items = $total_items;
$current_slide_number = 1;
$online_shop_slider_display_options = $term_per_slide;
$total_posts = $online_shop_slider_display_options;
if( $online_shop_slider_display_options > $remaining_items ){
$total_posts = $remaining_items;
}
$fixed ='';
$closed = 1;
if( $remaining_items < $online_shop_slider_display_options || $online_shop_slider_display_options < 3 ){
$fixed = 'fix remain-'.$remaining_items;
}
echo "
";
foreach ( $online_shop_featured_cats as $term_id => $value ) {
$taxonomy = 'product_cat';
$term = get_term_by( 'id', $term_id, $taxonomy );
if ( $term && ! is_wp_error( $term ) ) {
$term_link = get_term_link( $term_id, $taxonomy );
$term_name = $term->name;
$total_product = $term->count;
$thumbnail_id = get_term_meta( $term_id, 'thumbnail_id', true );
$image_url = wp_get_attachment_image_src( $thumbnail_id, $online_shop_img_size );
if ( !$image_url ) {
$image_url[0] = get_template_directory_uri() . '/assets/img/default-image.jpg';
}
if( $j > $online_shop_slider_display_options ){
if( $online_shop_slider_display_options == 1 || $j % $online_shop_slider_display_options == 1 ){
$current_slide_number = $current_slide_number + 1;
$remaining_items = $remaining_items - $online_shop_slider_display_options;
if( $online_shop_slider_display_options > $remaining_items ){
$total_posts = $remaining_items;
}
$fixed ='';
if( $remaining_items < $online_shop_slider_display_options || $online_shop_slider_display_options < 3 )
if( $remaining_items < $online_shop_slider_display_options ){
$fixed = 'fix remain-'.$remaining_items;
}
$i = 1;
echo "
";
}
}
$col = 'acme-col-1';
/*first post slide*/
if( $i == 1 ){
/*open left wrapper div*/
echo "
";
if( 1 == $total_posts ){
$col = 'at-extra-height at-extra-width acme-col-1';
}
else{
$col = 'at-extra-height acme-col-1';
}
}
else{
/*close left wrapper and open right wrapper*/
if( $i == 2 ){
echo "
";
echo "
";
}
if( 2 == $total_posts ){
$col = 'at-extra-height acme-col-1';
}
elseif( 3 == $total_posts ){
$col = 'acme-col-1';
}
elseif( 4 == $total_posts ){
if( $i == 2 ){
$col = 'acme-col-1';
}
else{
$col = 'acme-col-2';
}
}
elseif( 5 == $total_posts ){
$col = 'acme-col-2';
}
}
?>
=$total_posts ){
$closed =1;
echo "
";
}
$i++;
$j++;
}
}
if( 1 != $closed ){
echo "
";
}
echo "
";/*at-unique-slide at-custom-slide*/
}
endif;
/**
* Feature Section
* Two different types
*
* @package Acme Themes
* @subpackage Online Shop
* @since 1.0.0
*/
if ( ! class_exists( 'Online_Shop_Wc_Feature_Cats' ) ) {
/**
* Class for adding widget
*
* @package Acme Themes
* @subpackage Online_Shop_Wc_Feature_Cats
* @since 1.0.0
*/
class Online_Shop_Wc_Feature_Cats extends WP_Widget {
/*defaults values for fields*/
private $defaults = array(
'online_shop_widget_title' => '',
'online_shop_featured_cats' => array(),
'layout_type' => 2,
'enable_slider_mode' => 0,
'term_per_slide' => 4,
'view_all_option' => 'disable',
'all_link_text' => '',
'all_link_url' => '',
'number_of_product_text' => '',
'enable_prev_next' => 1,
'online_shop_img_size' => 'full',
);
function __construct() {
parent::__construct(
/*Base ID of your widget*/
'online_shop_wc_feature_cats',
/*Widget name will appear in UI*/
esc_html__('AT WooCommerce Categories', 'online-shop'),
/*Widget description*/
array( 'description' => esc_html__( 'Show WooCommerce Categories Beautifully', 'online-shop' ), )
);
}
/*Widget Backend*/
public function form( $instance ) {
$instance = wp_parse_args( (array) $instance, $this->defaults);
$online_shop_widget_title = esc_attr( $instance['online_shop_widget_title'] );
$online_shop_featured_cats = array_map( 'esc_attr', $instance['online_shop_featured_cats'] );
$layout_type = esc_attr( $instance[ 'layout_type' ] );
$enable_slider_mode = esc_attr( $instance[ 'enable_slider_mode' ] );
$term_per_slide = absint( $instance[ 'term_per_slide' ] );
$view_all_option = esc_attr( $instance[ 'view_all_option' ] );
$all_link_text = esc_attr( $instance['all_link_text'] );
$all_link_url = esc_url( $instance['all_link_url'] );
$number_of_product_text = esc_attr( $instance['number_of_product_text'] );
$enable_prev_next = esc_attr( $instance['enable_prev_next'] );
$online_shop_img_size = $instance['online_shop_img_size'];
$choices = online_shop_get_image_sizes_options();
?>
/>
/>
defaults );
$online_shop_widget_title = !empty( $instance['online_shop_widget_title'] ) ? esc_attr( $instance['online_shop_widget_title'] ) : '';
$online_shop_widget_title = apply_filters( 'widget_title', $online_shop_widget_title, $instance, $this->id_base );
$online_shop_featured_cats = array_map( 'esc_attr', $instance['online_shop_featured_cats'] );
$layout_type = esc_attr( $instance[ 'layout_type' ] );
$enable_slider_mode = esc_attr( $instance['enable_slider_mode'] );
$term_per_slide = absint( $instance[ 'term_per_slide' ] );
$view_all_option = esc_attr( $instance[ 'view_all_option' ] );
$all_link_text = esc_html( $instance[ 'all_link_text' ] );
$number_of_product_text = esc_html( $instance[ 'number_of_product_text' ] );
$all_link_url = esc_url( $instance[ 'all_link_url' ] );
$enable_prev_next = esc_attr( $instance['enable_prev_next'] );
$online_shop_img_size = esc_attr( $instance['online_shop_img_size'] );
echo $args['before_widget'];
if ( !empty( $online_shop_widget_title ) ||
'disable' != $view_all_option ||
( 1 == $enable_prev_next && 1 == $enable_slider_mode )
){
echo $args['before_title'];
echo $online_shop_widget_title;
echo "";
if( 'disable' != $view_all_option && !empty( $all_link_text ) && !empty( $all_link_url )){
$target ='';
if( 'new-tab-link' == $view_all_option ){
$target = 'target="_blank"';
}
echo ''.$all_link_text.'';
}
if( 1 == $enable_prev_next && 1 == $enable_slider_mode ){
echo '';
}
echo "";/*.at-action-wrapper*/
echo $args['after_title'];
}
if(!empty( $online_shop_featured_cats ) ){
if( 1 == $enable_slider_mode ){
$class = 'at-cat-feature-slider acme-slick-carausel';
}
else{
$class = 'at-cat-feature-section column';
}
?>