'widget_klasik_features', 'description' => __('KlasikTheme Features','klasik') ); $this->WP_Widget('klasik-features-widget', __('KlasikTheme Features','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']); $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 = '
'; $tpl .= '
'; $tpl .= '
'; $tpl .= '
%%THUMB%%
'; $tpl .= '

%%TITLE%%

'; $tpl .= '
'; $tpl .= '
%%TEXT%%
'; $tpl .= '
'; $tpl .= '
'; $tpl .= '
'; $tpl = apply_filters( 'klasik_features_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-feature', array('class' => 'alignleft')); $cf_extlink = (isset($custom['klasik_link'][0]))? $custom['klasik_link'][0] : ""; $x++; if($x%$cols==0){ $omega = "omega"; }elseif($x%$cols==1){ $omega = "alpha"; }else{ $omega = ""; } //FEATUREID $template = str_replace( '%%ID%%', $post->ID, $template ); //FEATURECLASS $fclass = 'columns fitem '; $fclass .= $colclass.' '; $fclass .= 'feature'.$x.' '; $fclass .= $omega; $template = str_replace( '%%CLASS%%', $fclass, $template ); //FEATUREIMAGE $fthumb = ''; $fthumb .= $cf_thumb; $template = str_replace( '%%THUMB%%', $fthumb, $template ); //FEATURELINK $flink = get_permalink(); $template = str_replace( '%%LINK%%', $flink, $template ); //FEATURETITLE $ftitle = ''; $ftitle .= get_the_title(); $template = str_replace( '%%TITLE%%', $ftitle, $template ); //FEATURETEXT $ftext = ''; if($longdesc>0){ $excerpt = klasik_string_limit_char(get_the_excerpt(), $longdesc); }else{ $excerpt = get_the_excerpt(); } $ftext .= $excerpt; $template = str_replace( '%%TEXT%%', $ftext, $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']); ?>