'widget_klasik_testimonial', 'description' => __('KlasikTheme Testimonial','klasik') ); $this->WP_Widget('klasik-testimonial-widget', __('KlasikTheme Testimonial','klasik'), $widget_ops); } /** @see WP_Widget::widget */ function widget($args, $instance) { extract( $args ); $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title']); $category = apply_filters('widget_category', $instance['category']); $cols = apply_filters('widget_cols', empty($instance['cols']) ? '' : $instance['cols']); $showposts = apply_filters('widget_showpost', empty($instance['showpost']) ? '' : $instance['showpost']); $longdesc = apply_filters('widget_longdesc', empty($instance['longdesc']) ? '' : $instance['longdesc']); $customclass = apply_filters('widget_customclass', empty($instance['customclass']) ? '' : $instance['customclass']); $disabletext = false; $instance['category'] = esc_attr(isset($instance['category'])? $instance['category'] : ""); global $wp_query; $longdesc = (!is_numeric($longdesc) || empty($longdesc))? 0 : $longdesc; $showposts = (!is_numeric($showposts))? get_option('posts_per_page') : $showposts; $cols = intval($cols); if(!is_numeric($cols) || $cols < 1 || $cols > 6){ $cols = 4; } echo $before_widget; if ( $title!='' ) echo $before_title . esc_html($title) . $after_title; $output = ""; $output .='
'; $output .='
'; if($cols==1){ $colclass = "twelve"; }elseif($cols==2){ $colclass = "one_half"; }elseif($cols==3){ $colclass = "one_third"; }elseif($cols==4){ $colclass = "one_fourth"; }elseif($cols==5){ $colclass = "one_fifth"; }elseif($cols==6){ $colclass = "one_sixth"; } $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query(); $args = array( "post_type" => "post", "showposts" => $showposts ); if( $category!="" ){ $args['tax_query'] = array( array( 'taxonomy' => 'category', 'field' => 'id', 'terms' => $category ) ); } $wp_query->query($args); global $post; $tpl = '
%%TEXT%%
%%THUMB%%%%TITLE%%
'; $tpl = apply_filters( 'klasik_testimonials_item_template', $tpl ); if ($wp_query->have_posts()) : $x = 0; while ($wp_query->have_posts()) : $wp_query->the_post(); $template = $tpl; $custom = get_post_custom($post->ID); $cf_thumb = get_the_post_thumbnail($post->ID, 'widget-testimonial', array('class' => 'alignleft testi-img')); $cf_extlink = (isset($custom['klasik_link'][0]))? $custom['klasik_link'][0] : ""; //TESTIID $template = str_replace( '%%ID%%', $post->ID, $template ); //CLASS $x++; if($x%$cols==0){ $omega = "omega"; }elseif($x%$cols==1){ $omega = "alpha"; }else{ $omega = ""; } $testiclass = 'titem '; $testiclass .= $colclass.' columns '; $testiclass .= 'testi'.$x.' '; $testiclass .= $omega; $template = str_replace( '%%CLASS%%', $testiclass, $template ); //MAINIMAGE $mainimg = ''; if($cf_thumb){ $mainimg .= $cf_thumb; } $template = str_replace( '%%THUMB%%', $mainimg, $template ); //TITLE $maintitle = get_the_title(); $template = str_replace( '%%TITLE%%', $maintitle, $template ); // MAINTEXT $maintext = ''; if(!$disabletext){ if($longdesc>0){ $excerpt = klasik_string_limit_char(get_the_excerpt(), $longdesc); }else{ $excerpt = get_the_excerpt(); } $maintext .= $excerpt; } $template = str_replace( '%%TEXT%%', $maintext, $template ); $output .= $template; endwhile; endif; $wp_query = null; $wp_query = $temp; wp_reset_query(); $output .='
'; $output.='
'; $output .='
'; echo do_shortcode($output); echo $after_widget; } /** @see WP_Widget::update */ function update($new_instance, $old_instance) { return $new_instance; } /** @see WP_Widget::form */ function form($instance) { $instance['title'] = (isset($instance['title']))? $instance['title'] : ""; $instance['category'] = (isset($instance['category']))? $instance['category'] : ""; $instance['cols'] = (isset($instance['cols']))? $instance['cols'] : ""; $instance['showpost'] = (isset($instance['showpost']))? $instance['showpost'] : ""; $instance['longdesc'] = (isset($instance['longdesc']))? $instance['longdesc'] : ""; $instance['customclass'] = (isset($instance['customclass']))? $instance['customclass'] : ""; $title = esc_attr($instance['title']); $category = esc_attr($instance['category']); $cols = esc_attr($instance['cols']); $longdesc = esc_attr($instance['longdesc']); $customclass = esc_attr($instance['customclass']); $showpost = esc_attr($instance['showpost']); ?>