</article> <?php } else { ?> <article id="post-<?php the_ID(); ?> " <?php post_class("cb-blog-style-b cb-module-a cb-article cb-article-row-2 cb-article-row cb-img-above-meta clearfix cb-separated cb-no-{$cb_count}"); ?> role="article"> <div class="cb-mask cb-img-fw" <?php cb_img_bg_color($cb_post_id); ?> > <?php cb_thumbnail('360', '240'); ?> <?php cb_review_ext_box($cb_post_id); ?> </div> <div class="cb-meta clearfix"> <h2 class="cb-post-title"><a href="<?php the_permalink(); ?>
function widget($args, $instance) { $cache = wp_cache_get('widget_popular_posts', 'widget'); if (!is_array($cache)) { $cache = array(); } if (!isset($args['widget_id'])) { $args['widget_id'] = $this->id; } if (isset($cache[$args['widget_id']])) { echo $cache[$args['widget_id']]; return; } ob_start(); extract($args); $cb_title = empty($instance['cb_title']) ? '' : $instance['cb_title']; $cb_category = empty($instance['category']) ? '' : $instance['category']; $cb_type = empty($instance['cb_type']) ? 'cb-article-small' : $instance['cb_type']; $cb_filter_date = empty($instance['cb_filter_date']) ? 'alltime' : $instance['cb_filter_date']; $cb_filter_by = empty($instance['cb_filter_by']) ? 'cb-comments' : $instance['cb_filter_by']; if (empty($instance['cb_number']) || !($cb_number = absint($instance['cb_number']))) { $cb_number = 5; } if ($cb_category != 'cb-all') { $cb_cat_qry = $cb_category; } else { $cb_cat_qry = NULL; } $cb_qry = NULL; $cb_c = 300; $i = 1; if ($cb_filter_by == 'cb-visits') { if (function_exists('stats_get_csv')) { if ($cb_filter_date == 'week') { $cb_weekly_qry = 'cb-week-pop'; if (($cb_qry = get_transient($cb_weekly_qry)) === false) { $cb_qry = stats_get_csv('postviews', 'days=8&limit=' . (6 + $cb_number)); set_transient($cb_weekly_qry, $cb_qry, $cb_c); } } elseif ($cb_filter_date == 'month') { $cb_monthly_qry = 'cb-month-pop'; if (($cb_qry = get_transient($cb_monthly_qry)) === false) { $cb_qry = stats_get_csv('postviews', 'days=31&limit=' . (6 + $cb_number)); set_transient($cb_monthly_qry, $cb_qry, $cb_c); } } elseif ($cb_filter_date == 'alltime') { $cb_alltime_qry = 'cb-alltime-pop'; if (($cb_qry = get_transient($cb_alltime_qry)) === false) { $cb_qry = stats_get_csv('postviews', 'days=-1&limit=' . (6 + $cb_number)); set_transient($cb_alltime_qry, $cb_qry, $cb_c); } } } else { echo '<div class="cb-sidebar-widget">15Zine Popular Posts Widget: To use the "View Count" option You need to install Jetpack plugin and enable the "Stats" module.</div>'; } } else { $cb_cpt_output = cb_get_custom_post_types(); $cb_qry = new WP_Query(array('post_type' => $cb_cpt_output, 'posts_per_page' => $cb_number, 'category_name' => $cb_cat_qry, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true, 'orderby' => 'comment_count')); } echo $before_widget; $cb_width = '100'; $cb_height = '65'; $cb_style = ' cb-separated'; if ($cb_type == 'cb-article-big') { $cb_width = '360'; $cb_height = '240'; $cb_style = ' cb-meta-style-2'; } if ($cb_title) { echo $before_title . esc_html($cb_title) . $after_title; } echo '<div class="cb-module-block cb-small-margin">'; if ($cb_filter_by == 'cb-comments' && $cb_qry->have_posts()) { while ($cb_qry->have_posts()) { $cb_qry->the_post(); global $post; $cb_post_id = $post->ID; ?> <article <?php post_class('cb-article ' . esc_attr($cb_type) . ' ' . esc_attr($cb_style) . ' clearfix'); ?> > <div class="cb-mask cb-img-fw" <?php cb_img_bg_color($cb_post_id); ?> > <?php cb_thumbnail($cb_width, $cb_height); ?> <?php cb_review_ext_box($cb_post_id, true); ?> </div> <div class="cb-meta cb-article-meta"> <h4 class="cb-post-title"><a href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></h4> <div class="cb-byline cb-byline-short cb-comment-count"> <a href="<?php echo get_comments_link($cb_post_id); ?> "> <?php echo number_format_i18n(get_comments_number($cb_post_id)) . ' ' . __('Comments', 'cubell'); ?> </a> </div> </div> <?php if ($cb_type == 'cb-article-big') { echo '<a href="' . get_the_permalink() . '" class="cb-link"></a>'; } ?> </article> <?php } wp_reset_postdata(); } if ($cb_filter_by == 'cb-visits' && !empty($cb_qry)) { $cb_meta_onoff = ot_get_option('cb_meta_onoff', 'on'); $cb_post_meta_views = ot_get_option('cb_byline_postviews', 'on'); foreach ($cb_qry as $cb_post) { $cb_post_id = $cb_post['post_id']; $cb_cats = wp_get_post_categories($cb_post_id); if (empty($cb_cats)) { continue; } ?> <article class="cb-article <?php echo esc_attr($cb_type) . ' ' . esc_attr($cb_style); ?> clearfix"> <div class="cb-mask cb-img-fw"> <?php cb_thumbnail($cb_width, $cb_height, $cb_post_id); ?> </div> <div class="cb-meta cb-article-meta"> <h4 class="cb-post-title"><a href="<?php echo esc_url($cb_post['post_permalink']); ?> "><?php echo esc_html($cb_post['post_title']); ?> </a></h4> <?php if ($cb_meta_onoff == 'on' && $cb_post_meta_views == 'on') { ?> <div class="cb-byline cb-byline-short cb-comment-count"><?php echo intval($cb_post['views']); ?> <?php _e('Views', 'cubell'); ?> </div> <?php } ?> </div> <?php if ($cb_type == 'cb-article-big') { echo '<a href="' . get_the_permalink() . '" class="cb-link"></a>'; } ?> </article> <?php if ($i == $cb_number) { break; } $i++; } } echo '</div>'; echo $after_widget; $cache[$args['widget_id']] = ob_get_flush(); wp_cache_set('widget_popular_posts', $cache, 'widget'); }