widget_cssclass = 'blog_tale widget_express_double_column_posts'; $this->widget_description = __("Displays posts in express double column style", 'blog-tale'); $this->widget_id = 'blog_tale_express_double_column_posts'; $this->widget_name = __('BT: Express Double Col Posts', 'blog-tale'); $this->image_sizes = blog_tale_get_all_image_sizes(true); array_shift($this->image_sizes); $this->settings = array( 'title' => array( 'type' => 'text', 'label' => __('Title', 'blog-tale'), ), 'category' => array( 'type' => 'dropdown-taxonomies', 'label' => __('Select Category', 'blog-tale'), 'desc' => __('Leave empty if you don\'t want the posts to be category specific', 'blog-tale'), 'args' => array( 'taxonomy' => 'category', 'class' => 'widefat', 'hierarchical' => true, 'show_count' => 1, 'show_option_all' => __('— Select —', 'blog-tale'), ), ), 'number' => array( 'type' => 'number', 'step' => 1, 'min' => 1, 'max' => '', 'std' => 6, 'label' => __('Number of posts to show', 'blog-tale'), ), 'orderby' => array( 'type' => 'select', 'std' => 'date', 'label' => __('Order by', 'blog-tale'), 'options' => array( 'date' => __('Date', 'blog-tale'), 'ID' => __('ID', 'blog-tale'), 'title' => __('Title', 'blog-tale'), 'rand' => __('Random', 'blog-tale'), ), ), 'order' => array( 'type' => 'select', 'std' => 'desc', 'label' => __('Order', 'blog-tale'), 'options' => array( 'asc' => __('ASC', 'blog-tale'), 'desc' => __('DESC', 'blog-tale'), ), ), 'image_size' => array( 'type' => 'select', 'label' => __('Express Post Image Size', 'blog-tale'), 'options' => $this->image_sizes, 'std' => 'blog-tale-carousel-boxed', ), 'excerpt_length' => array( 'type' => 'number', 'step' => 1, 'min' => 1, 'max' => '', 'std' => 20, 'label' => __('Express Post Excerpt Length', 'blog-tale'), ), 'display_style' => array( 'type' => 'select', 'std' => 'style_1', 'label' => __('Display Style', 'blog-tale'), 'options' => array( 'style_1' => __('Style 1', 'blog-tale'), 'style_2' => __('Style 2', 'blog-tale'), ), ), ); parent::__construct(); } /** * Query the posts and return them. * @param array $args * @param array $instance * @return WP_Query */ public function get_posts($args, $instance) { $number = !empty($instance['number']) ? absint($instance['number']) : $this->settings['number']['std']; $orderby = !empty($instance['orderby']) ? sanitize_title($instance['orderby']) : $this->settings['orderby']['std']; $order = !empty($instance['order']) ? sanitize_title($instance['order']) : $this->settings['order']['std']; $query_args = array( 'posts_per_page' => $number, 'post_status' => 'publish', 'no_found_rows' => 1, 'orderby' => $orderby, 'order' => $order, 'ignore_sticky_posts' => 1 ); if (!empty($instance['category']) && -1 != $instance['category'] && 0 != $instance['category']) { $query_args['tax_query'][] = array( 'taxonomy' => 'category', 'field' => 'term_id', 'terms' => $instance['category'], ); } return new WP_Query(apply_filters('blog_tale_express_double_col_posts_query_args', $query_args)); } /** * Output widget. * * @see WP_Widget * * @param array $args * @param array $instance */ public function widget($args, $instance){ ob_start(); if (($posts = $this->get_posts($args, $instance)) && $posts->have_posts()) { $this->widget_start($args, $instance); do_action( 'blog_tale_before_express_double_col_posts'); ?>
'; while ($posts->have_posts()): $posts->the_post(); ?>
the_title_attribute( array( 'echo' => false, ) ), ) ); ?>

'; }else{ $total_posts = $posts->post_count; $counter = 1; while ($posts->have_posts()): $posts->the_post(); $wrapper_class_start = $wrapper_class_end = ''; if($counter <= 2){ $image_size = ($instance['image_size']) ? esc_attr($instance['image_size']) : 'blog-tale-carousel-boxed'; if(1 == $counter){ $wrapper_class_start = '
'; }else{ $wrapper_class_end = '
'; } }else{ $image_size = 'blog-tale-small'; if(3 == $counter){ $wrapper_class_start = '
'; } if($counter == $total_posts){ $wrapper_class_end = '
'; } } ?>
the_title_attribute( array( 'echo' => false, ) ), ) ); ?>

0) { blog_tale_post_excerpt_info($instance['excerpt_length'],true); ?>
widget_end($args); } echo ob_get_clean(); } }