__( 'Display Post Slider.', 'best-shop' ), ) ); } public function widget( $args, $instance ) { $max_items = ( ! empty( $instance['max_items'] ) ) ? absint( $instance['max_items'] ) : 3; $category = ( ! empty( $instance['category'] ) ) ? wp_strip_all_tags( $instance['category'] ) : -1; $hide_title_price = ( ! empty( $instance['hide_title_price'] ) ) ? true : false; $navigation = ( ! empty( $instance['navigation'] ) ) ? true : false; $max_height = (!empty($instance['max_height'])) ? absint($instance['max_height']) : 400; $speed = (!empty($instance['speed'])) ? absint($instance['speed']) : 4; $button_lbl = ( ! empty( $instance['button_lbl'] ) ) ? wp_strip_all_tags( $instance['button_lbl'] ) : ''; $args = array(); if( $category == -1 ){ $args = array ( 'post_type' => 'post', 'posts_per_page'=> $max_items ); } else { $args = array ( 'post_type' => 'post', 'posts_per_page'=> $max_items, 'cat' => $category ); } $loop = new WP_Query($args ); $i = 1; $items = array(); while( $loop->have_posts() ) : $loop->the_post(); $thumb_id = get_post_thumbnail_id(get_the_ID()); $url = get_the_post_thumbnail_url(get_the_ID(), 'full'); if(!$url) { $url = get_template_directory_uri().'/images/empty.png'; } $alt = get_post_meta($thumb_id, '_wp_attachment_image_alt', true); $link = get_permalink(); $title = get_the_title(); $content = get_the_excerpt(); $item = array ( 'link' => $link , 'image_url' => $url , 'content' => $content , 'title' => $title, 'alt' => $alt ); array_push($items, $item); $i++; endwhile; wp_reset_postdata(); global $best_shop_uniqueue_id ; $best_shop_uniqueue_id += 1; $carousal_id = 'product-carousal-'.$best_shop_uniqueue_id; //carousal begin echo '