'widget_klasik_wooproduct', 'description' => __('KlasikThemes WooCommerce Products','klasik') ); $this->WP_Widget('klasik-theme-wooproduct-widget', __('KlasikThemes WooCommerce Products','klasik'), $widget_ops); } /** @see WP_Widget::widget */ function widget($args, $instance) { extract( $args ); $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title']); $subtitle = apply_filters('widget_subtitle', empty($instance['subtitle']) ? '' : $instance['subtitle']); $showposts = apply_filters('widget_showpost', empty($instance['showpost']) ? '' : $instance['showpost']); $type = apply_filters('widget_type', empty($instance['type']) ? '' : $instance['type']); $customclass = apply_filters('widget_customclass', empty($instance['customclass']) ? '' : $instance['customclass']); $show_variations = $instance['show_variations'] ? '1' : '0'; $show_advanced_option = isset($instance['show_advanced_option']) ? $instance['show_advanced_option'] : false; $layout = apply_filters('widget_layout', empty($instance['layout']) ? '' : $instance['layout']); $spacingtop = apply_filters('widget_spacingtop', empty($instance['spacingtop']) ? '' : $instance['spacingtop']); $spacingbottom = apply_filters('widget_spacingbottom', empty($instance['spacingbottom']) ? '' : $instance['spacingbottom']); $spacingside = apply_filters('widget_spacingside', empty($instance['spacingside']) ? '' : $instance['spacingside']); $border_top = apply_filters('widget_border_top', empty($instance['border_top']) ? '' : $instance['border_top']); $border_bottom = apply_filters('widget_border_bottom', empty($instance['border_bottom']) ? '' : $instance['border_bottom']); $customize_background = isset($instance['customize_background']) ? $instance['customize_background'] : false; $background_image = apply_filters('widget_background_image', empty($instance['background_image']) ? '' : $instance['background_image']); $background_color = apply_filters('widget_background_color', empty($instance['background_color']) ? '' : $instance['background_color']); $background_repeat = apply_filters('widget_background_repeat', empty($instance['background_repeat']) ? '' : $instance['background_repeat']); $background_position = apply_filters('widget_background_position', empty($instance['background_position']) ? '' : $instance['background_position']); $background_attachment = apply_filters('widget_background_attachment', empty($instance['background_attachment']) ? '' : $instance['background_attachment']); $background_size = apply_filters('widget_background_size', empty($instance['background_size']) ? '' : $instance['background_size']); $background_opacity = apply_filters('widget_background_opacity', empty($instance['background_opacity']) ? '' : $instance['background_opacity']); if ( $customclass ) { $before_widget = str_replace('class="', 'class="'. $customclass . ' ', $before_widget); } global $wp_query, $woocommerce; ?> '; echo '
'; echo '
'; if( $layout == 'fullwidth'){} else{ echo '
'; } echo '
'; $subtitlewrap =""; if($subtitle){ $subtitlewrap =''.$subtitle.''; } $titleline=''; if ( $title!='' ) echo $before_title . esc_html($title). $subtitlewrap . $titleline . $after_title; $showposts = (!is_numeric($showposts))? get_option('posts_per_page') : $showposts; //$categories = $cats; echo '
'; $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query(); if($type=='latest-product'){ $query_args = array('posts_per_page' => $showposts, 'no_found_rows' => 1, 'post_status' => 'publish', 'post_type' => 'product'); $query_args['meta_query'] = array(); if ( $show_variations == '0' ) { $query_args['meta_query'][] = $woocommerce->query->visibility_meta_query(); $query_args['parent'] = '0'; } $query_args['meta_query'][] = $woocommerce->query->stock_status_meta_query(); $query_args['meta_query'] = array_filter( $query_args['meta_query'] ); }elseif($type=='featured-product'){ $query_args = array('posts_per_page' => $showposts, 'no_found_rows' => 1, 'post_status' => 'publish', 'post_type' => 'product' ); $query_args['meta_query'] = $woocommerce->query->get_meta_query(); $query_args['meta_query'][] = array( 'key' => '_featured', 'value' => 'yes' ); }else{ $query_args = array( 'posts_per_page' => $showposts, 'post_status' => 'publish', 'post_type' => 'product', 'meta_key' => 'total_sales', 'orderby' => 'meta_value_num', 'no_found_rows' => 1, ); $query_args['meta_query'] = $woocommerce->query->get_meta_query(); if ( isset( $instance['hide_free'] ) && 1 == $instance['hide_free'] ) { $query_args['meta_query'][] = array( 'key' => '_price', 'value' => 0, 'compare' => '>', 'type' => 'DECIMAL', ); } } $wp_query->query($query_args); global $post; if ($wp_query->have_posts()) : $x = 0; $output = ""; echo '
    '; while ($wp_query->have_posts()) : $wp_query->the_post(); woocommerce_get_template_part( 'content', 'product' ); $x++; endwhile; echo '
'; $wp_query = null; $wp_query = $temp; wp_reset_query(); endif; $wp_query = null; $wp_query = $temp; wp_reset_query(); echo '
'; echo '
'; echo '
'; if( $layout == 'fullwidth'){} else{ echo '
'; } echo '
'; echo '
'; echo '
'; ?>

/>

/>

onchange="showAdvancedOps(this)"/>

class="hidden_options">


class="hidden_options">

onchange="showFeaturedImageOps(this)"/>

class="hidden_options">







__( 'Default', 'klasik' ), 'repeat' => __( 'Repeat', 'klasik' ), 'repeat-x' => __( 'Repeat Horizontal', 'klasik' ), 'repeat-y' => __( 'Repeat Vertical', 'klasik' ), 'no-repeat' => __( 'No Repeat', 'klasik' ) ); } // End get_bg_repeat_options() protected function get_bg_position_options (){ return array( 'default' => __( 'Default', 'klasik' ), 'left' => __( 'Left', 'klasik' ), 'center' => __( 'Center', 'klasik' ), 'right' => __( 'Right', 'klasik' ), 'top left' => __( 'Top', 'klasik' ), 'top center' => __( 'Top Center', 'klasik' ), 'top right' => __( 'Top Right', 'klasik' ), 'bottom left' => __( 'Bottom', 'klasik' ), 'bottom center' => __( 'Bottom Center', 'klasik' ), 'bottom right' => __( 'Bottom Right', 'klasik' ) ); } // End get_bg_position_options() protected function get_bg_attachment_options () { return array( 'default' => __( 'Default', 'klasik' ), 'scroll' => __( 'scroll', 'klasik' ), 'fixed' => __( 'fixed', 'klasik' ) ); } // End get_bg_attachment_options() protected function get_bg_size_options () { return array( 'default' => __( 'Default', 'klasik' ), 'auto' => __( 'auto', 'klasik' ), 'cover' => __( 'cover', 'klasik' ), 'contain' => __( 'contain', 'klasik' ) ); } // End get_bg_attachment_options() protected function get_bg_opacity_options () { return array( 'default' => __( 'Default', 'klasik' ), '0.1' => __( '10%', 'klasik' ), '0.2' => __( '20%', 'klasik' ), '0.3' => __( '30%', 'klasik' ), '0.4' => __( '40%', 'klasik' ), '0.5' => __( '50%', 'klasik' ), '0.6' => __( '60%', 'klasik' ), '0.7' => __( '70%', 'klasik' ), '0.8' => __( '80%', 'klasik' ), '0.9' => __( '90%', 'klasik' ), '1' => __( '100%', 'klasik' ) ); } // End get_bg_opacity_options() protected function get_layout_options () { return array( 'boxed' => __( 'Boxed', 'klasik' ), 'fullwidth' => __( 'Full Width', 'klasik' ) ); } // End get_layout_options() } // class Widget