<div class="post-inner"> <header class="entry-header"> <h1 class="entry-title"><a href="<?php the_permalink(); ?> " title="<?php echo esc_attr(sprintf(__('Permalink to %s', 'dw_focus'), the_title_attribute('echo=0'))); ?> " rel="bookmark"><?php the_title(); ?> </a></h1> <div class="entry-meta entry-meta-top"> <span><?php echo dw_human_time(); ?> </span> <span class="author">by <?php the_author_posts_link(); ?> </span> <span class="comments-link"> <span>with</span> <?php comments_popup_link('<span class="leave-reply">' . __('0 comment ', 'dw-focus') . '</span>', __('1 comment', 'dw-focus'), __('% comments', 'dw-focus'), '', __('comment off', 'dw-focus')); ?> </span> </div>
function widget($args, $instance) { $cache = wp_cache_get('widget_dw_focus_recent_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); $title = apply_filters('widget_title', isset($instance['title']) ? $instance['title'] : '', $instance, $this->id_base); $thumbnail_size = isset($instance['thumbnail_size']) ? $instance['thumbnail_size'] : 'thumbnail'; echo $before_widget; if (!empty($title)) { echo $before_title . $title . $after_title; } $r = $this->query($instance); global $more; if ($r->have_posts()) { $i = 0; //Dectect first post if ($i == 0 && isset($instance['thumbnail']) && $instance['thumbnail']) { $r->the_post(); $i++; $more = 0; $class = 'first'; if (has_post_thumbnail(get_the_ID())) { $class .= ' has-thumbnail'; } ?> <article <?php post_class($class); ?> > <?php if (has_post_thumbnail(get_the_ID())) { ?> <div class="entry-thumbnail"> <?php if (isset($instance['post-format']) && $instance['post-format'] == 'gallery') { ?> <?php } else { ?> <a href="<?php the_permalink(); ?> "> <?php the_post_thumbnail($thumbnail_size); ?> </a> <?php } ?> </div> <?php } ?> <?php if (isset($instance['meta']) && $instance['meta']) { ?> <div class="entry-meta"> <?php if (isset($instance['date']) && $instance['date']) { echo '<div>' . dw_human_time() . '</div>'; } ?> <?php if (isset($instance['author']) && $instance['author']) { _e('by', 'dw-focus'); ?> <a href="<?php echo esc_url(get_author_posts_url(get_the_author_meta('ID'))); ?> " rel="author"><?php echo get_the_author(); ?> </a> <?php } ?> <?php if (isset($instance['cat']) && $instance['cat']) { $categories_list = get_the_category_list(__(', ', 'dw_focus')); if ($categories_list && dw_focus_categorized_blog()) { ?> <span class="cat-links"> <?php printf(__('<span> on </span>%1$s', 'dw_focus'), $categories_list); ?> </span> <?php } } ?> </div> <?php } ?> <h2 class="entry-title"><a href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></h2> <?php if (isset($instance['post_excerpt']) && $instance['post_excerpt']) { ?> <div class="entry-content"><?php the_excerpt(); ?> </div> <?php } ?> </article> <?php } ?> <?php $i = 0; while ($r->have_posts()) { $r->the_post(); $class = 'item'; if ($i == 0) { $class .= ' active'; $i++; } $post_id = get_the_ID(); if (has_post_thumbnail($post_id)) { $class .= ' has-thumbnail'; } ?> <article <?php post_class($class); ?> > <?php if (!isset($instance['thumbnail']) || !$instance['thumbnail']) { ?> <?php if (has_post_thumbnail($post_id)) { ?> <?php if (isset($instance['post-format']) && $instance['post-format'] == 'gallery') { ?> <?php $images = $this->get_images($post_id); if (!empty($images)) { ?> <div id="gallery-<?php echo $this->id; ?> -<?php echo $post_id; ?> " class="carousel slide"> <div class="carousel-inner"> <?php $g = 0; foreach ($images as $img) { $active = ''; if ($g == 0) { $active = 'active'; $g++; } ?> <div class="item <?php echo $active; ?> "> <a href="<?php the_permalink(); ?> "> <img src="<?php echo $img[0]; ?> " alt="<?php echo $img[1]; ?> "> </a> </div> <?php } ?> </div> <a class="left carousel-control" href="#gallery-<?php echo $this->id; ?> -<?php echo $post_id; ?> " data-slide="prev"><i class="icon-chevron-left"></i></a> <a class="right carousel-control" href="#gallery-<?php echo $this->id; ?> -<?php echo $post_id; ?> " data-slide="next"><i class="icon-chevron-right"></i></a> </div> <?php } ?> <?php } else { ?> <div class="entry-thumbnail"> <a href="<?php the_permalink(); ?> "> <?php the_post_thumbnail($thumbnail_size); ?> </a> </div> <?php } ?> <?php } ?> <?php } ?> <?php if (isset($instance['meta']) && $instance['meta']) { ?> <div class="entry-meta"> <?php if (isset($instance['date']) && $instance['date']) { echo '<div>' . dw_human_time() . '</div>'; } ?> <?php if (isset($instance['author']) && $instance['author']) { _e('by', 'dw-focus'); ?> <a href="<?php echo esc_url(get_author_posts_url(get_the_author_meta('ID'))); ?> " rel="author"><?php echo get_the_author(); ?> </a> <?php } ?> <?php if (isset($instance['cat']) && $instance['cat']) { $categories_list = get_the_category_list(__(', ', 'dw_focus')); if ($categories_list && dw_focus_categorized_blog()) { ?> <span class="cat-links"> <?php printf(__('<span> on </span>%1$s', 'dw_focus'), $categories_list); ?> </span> <?php } } ?> </div> <?php } ?> <h2 class="entry-title"><a href="<?php the_permalink(); ?> " title="<?php echo esc_attr(get_the_title() ? get_the_title() : get_the_ID()); ?> "><?php if (get_the_title()) { the_title(); } else { the_ID(); } ?> </a></h2> <?php if (isset($instance['post_excerpt']) && $instance['post_excerpt']) { ?> <div class="entry-content"><?php the_excerpt(); ?> </div> <?php } ?> </article> <?php } ?> <?php } else { get_template_part('no-results'); } echo $after_widget; $cache[$args['widget_id']] = ob_get_flush(); wp_cache_set('widget_recent_posts', $cache, 'widget'); }
function dw_focus_template_1col($args, $number, $category_id, $instance) { extract($args, EXTR_SKIP); $category = get_category($category_id); $category_link = get_category_link($category_id); $posts = new WP_Query(apply_filters('widget_dw_focus_categories_Widget', array('posts_per_page' => $number, 'cat' => $category_id, 'post_type' => 'post', 'post_status' => 'publish'))); echo '<div class="span4">'; $category_options = dw_get_category_option($category_id); $color_class = ''; if ($category_options['style']) { $color_class .= ' color-' . $category_options['style']; } echo "<h3 class='category-title {$color_class}'><a class='tab_title active' data-catid='{$category_id}' href='{$category_link}'>{$category->name}</a></h3>"; if ($posts->have_posts()) { $i = 0; if ($i == 0) { $posts->the_post(); $i++; $class = 'first'; if (has_post_thumbnail(get_the_ID())) { $class .= ' has-thumbnail'; } ?> <article <?php post_class($class); ?> > <?php if (has_post_thumbnail(get_the_ID())) { ?> <div class="entry-thumbnail"> <a href="<?php the_permalink(); ?> " title="<?php echo esc_attr(sprintf(__('Permalink to %s', 'dw_focus'), the_title_attribute('echo=0'))); ?> " rel="bookmark"> <?php the_post_thumbnail('medium'); ?> </a> </div> <?php } ?> <?php if (isset($instance['meta']) && $instance['meta']) { ?> <div class="entry-meta"> <?php if (isset($instance['date']) && $instance['date']) { echo '<div>' . dw_human_time() . '</div>'; } ?> <?php if (isset($instance['author']) && $instance['author']) { _e('by', 'dw-focus'); ?> <a href="<?php echo esc_url(get_author_posts_url(get_the_author_meta('ID'))); ?> " rel="author"><?php echo get_the_author(); ?> </a> <?php } ?> <?php if (isset($instance['cat']) && $instance['cat']) { $categories_list = get_the_category_list(__(', ', 'dw_focus')); if ($categories_list && dw_focus_categorized_blog()) { ?> <span class="cat-links"> <?php printf(__('<span> on </span>%1$s', 'dw_focus'), $categories_list); ?> </span> <?php } } ?> </div> <?php } ?> <h2 class="entry-title"> <a href="<?php the_permalink(); ?> " title="<?php echo esc_attr(sprintf(__('Permalink to %s', 'dw_focus'), the_title_attribute('echo=0'))); ?> " rel="bookmark"><?php the_title(); ?> </a> </h2> <div class="entry-content"><?php the_excerpt(); ?> </div> </article> <?php } ?> <ul class="other-entry"> <?php while ($posts->have_posts()) { $posts->the_post(); ?> <li><h2 class="entry-title"><a href="<?php the_permalink(); ?> " title="<?php echo esc_attr(sprintf(__('Permalink to %s', 'dw_focus'), the_title_attribute('echo=0'))); ?> " rel="bookmark"><?php the_title(); ?> </a></h2></li> <?php } ?> </ul> <?php } else { get_template_part('no-results'); } echo '</div>'; // Reset the global $the_post as this query will have stomped on it wp_reset_postdata(); }
function widget($args, $instance) { $cache = wp_cache_get('widget_dw_focus_recent_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); $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base); if (empty($instance['number']) || !($number = absint($instance['number']))) { $number = 10; } $interval = isset($instance['interval']) ? $instance['interval'] : 0; $r = new WP_Query(apply_filters('widget_posts_args', array('posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true, 'cat' => $instance['category'], 'meta_query' => array(array('key' => '_thumbnail_id'))))); if ($r->have_posts()) { $i = 0; //Dectect first post ?> <?php echo $before_widget; ?> <div class="clearfix"> <div id="top-stories-carousel-<?php echo $this->id; ?> " class="carousel slide"> <div class="carousel-inner"> <?php $i = 0; while ($r->have_posts()) { $r->the_post(); $active = ''; if ($i == 0) { $active = 'active'; $i++; } ?> <div id="widget-post-<?php the_ID(); ?> " class="item <?php echo $active; ?> "> <?php $class = ''; if (has_post_thumbnail(get_the_ID())) { $class .= 'has-thumbnail'; } ?> <article <?php post_class($class); ?> > <?php if (has_post_thumbnail(get_the_ID())) { ?> <div class="entry-thumbnail"> <?php $category = get_the_category(); if ($category[0]) { echo '<a class="entry-category" href="' . get_category_link($category[0]->term_id) . '">' . $category[0]->cat_name . '</a>'; } ?> <!--[if IE 8]> <div class="gradient-ie8"></div> <![endif]--> <?php the_post_thumbnail('slider-thumb'); ?> </div> <?php } ?> <header class="entry-header"> <div class="entry-header-inner"> <?php if (isset($instance['meta']) && $instance['meta']) { ?> <div class="entry-meta"> <?php if (isset($instance['date']) && $instance['date']) { echo dw_human_time(); } ?> <?php if (isset($instance['author']) && $instance['author']) { ?> by <a href="<?php echo esc_url(get_author_posts_url(get_the_author_meta('ID'))); ?> " rel="author"><?php echo get_the_author(); ?> </a> <?php } ?> <?php if (isset($instance['cat']) && $instance['cat']) { $categories_list = get_the_category_list(__(', ', 'dw_focus')); if ($categories_list && dw_focus_categorized_blog()) { ?> <span class="cat-links"> <?php printf(__('<span> on </span>%1$s', 'dw_focus'), $categories_list); ?> </span> <?php } } ?> </div> <?php } ?> <h1 class="entry-title"><a href="<?php the_permalink(); ?> " title="<?php echo esc_attr(get_the_title() ? get_the_title() : get_the_ID()); ?> "> <?php the_title(); ?> </a> </h1> </div> </header> </article> </div> <?php } ?> </div> <a data-slide="prev" href="#top-stories-carousel-<?php echo $this->id; ?> " class="left carousel-control hidden-desktop"><i class="icon-chevron-left"></i></a> <a data-slide="next" href="#top-stories-carousel-<?php echo $this->id; ?> " class="right carousel-control hidden-desktop"><i class="icon-chevron-right"></i></a> </div> <div class="carousel-list"> <?php if (!empty($title)) { echo $before_title . $title . $after_title; } ?> <ul class="other-entry"> <?php $i = 0; while ($r->have_posts()) { $r->the_post(); $active = ''; if ($i == 0) { $active = 'active'; } ?> <li class="<?php echo $active; ?> "> <h2><a data-slice="<?php echo $i; ?> " href="<?php echo the_permalink(); ?> "><?php the_title(); ?> </a></h2> </li> <?php $i++; } ?> </ul> <div class="carousel-nav"><ul></ul></div> </div> </div> <script> jQuery(document).ready(function($) { $('#top-stories-carousel-<?php echo $this->id; ?> ').carousel({ interval : <?php echo $interval > 0 ? $interval * 1000 : 'false'; ?> , pause: 'hover' }); }); </script> <?php echo $after_widget; // Reset the global $the_post as this query will have stomped on it wp_reset_postdata(); } $cache[$args['widget_id']] = ob_get_flush(); wp_cache_set('widget_recent_posts', $cache, 'widget'); }