function widget($args, $instance) { if (!is_singular()) { return; } $cache = wp_cache_get('dp_widget_related_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; } $style = isset($instance['style']) ? $instance['style'] : 'list'; extract($args); ob_start(); $title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Posts', 'dp') : $instance['title'], $instance, $this->id_base); ?> <?php echo $before_widget; ?> <?php $r = dp_related_posts(array('number' => $instance['posts_per_page'], 'fields' => 'object')); if (!$r || !is_object($r) || !$r->have_posts()) { return; } ?> <?php if ($title) { echo $before_title . $title . $after_title; } ?> <ul class="<?php echo 'post-' . $style; ?> "> <?php while ($r->have_posts()) { $r->the_post(); $item_format = is_video() ? 'video' : 'post'; ?> <li class="item cf <?php echo 'item-' . $item_format; ?> "> <?php $image_size = $style == 'list-full' ? 'custom-medium' : 'custom-small'; dp_thumb_html($image_size); ?> <div class="data"> <h4 class="entry-title"><a href="<?php the_permalink(); ?> " title="<?php echo esc_attr(get_the_title()); ?> "><?php the_title(); ?> </a></h4> <p class="meta"> <span class="author"><?php _e('Added by', 'dp'); ?> <?php the_author_posts_link(); ?> </span> <span class="time"><?php printf(__('%s ago', 'dp'), human_time(get_the_time('U'))); ?> </span> </p> <p class="stats"><?php echo dp_get_post_stats(); ?> </p> </div> </li> <?php } wp_reset_query(); ?> </ul> <?php echo $after_widget; ?> <?php $cache[$args['widget_id']] = ob_get_flush(); wp_cache_set('dp_widget_related_posts', $cache, 'widget'); }
?> </a> <a href="#" class="info-less"><?php _e('Show less', 'dp'); ?> </a> </div> </div><!--end #deatils--> </div><!-- end #post-<?php the_ID(); ?> --> <?php dp_related_posts(array('number' => get_option('dp_related_posts'), 'view' => get_option('dp_related_posts_view', 'grid-mini'))); ?> <?php comments_template('', true); ?> <?php } ?> </div><!-- end #content --> <?php get_sidebar(); ?>