<li> <article id="post-<?php the_ID(); ?> " <?php post_class('title-thumb-hover'); ?> > <?php $post_format = et_get_post_format(); if (in_array($post_format, array('video', 'quote', 'link', 'audio', 'map', 'text'))) { $thumb_src = et_get_post_format_thumb($post_format); $img_style = sprintf('background-color:%s', $color); } else { if ('gallery' == $post_format) { $thumb_src = et_get_gallery_post_format_thumb(); } else { if (!get_post_thumbnail_id()) { $thumb_src = et_get_post_format_thumb('text', 'icon'); $img_style = sprintf('background-color:%s', $color); } else { $img_style = sprintf('background-color:%s', $color); } } } if ($show_thumbnails) { echo et_extra_get_post_thumb(array('size' => 'extra-image-square-small', 'a_class' => array('post-thumbnail'), 'thumb_src' => !empty($thumb_src) ? $thumb_src : '', 'img_style' => !empty($img_style) ? $img_style : '')); } ?> <div class="post-content"> <h3><a href="<?php
function widget($args, $instance) { $cache = array(); if (!$this->is_preview()) { $cache = wp_cache_get('widget_recent_posts', 'extra'); } 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(); $title = !empty($instance['title']) ? $instance['title'] : __('Recent Posts', 'extra'); /** This filter is documented in wp-includes/default-widgets.php */ $title = apply_filters('widget_title', $title, $instance, $this->id_base); $number = !empty($instance['number']) ? absint($instance['number']) : 5; if (!$number) { $number = 5; } $show_date = isset($instance['show_date']) ? $instance['show_date'] : false; $show_thumb = isset($instance['show_thumb']) ? $instance['show_thumb'] : false; $show_categories = isset($instance['show_categories']) ? $instance['show_categories'] : false; /** * Filter the arguments for the Recent Posts widget. * * @since 3.4.0 * * @see WP_Query::get_posts() * * @param array $args An array of arguments used to retrieve the recent posts. */ $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))); if ($r->have_posts()) { ?> <?php echo $args['before_widget']; ?> <?php if ($title) { echo $args['before_title'] . $title . $args['after_title']; } ?> <ul class="widget_list"> <?php while ($r->have_posts()) { $r->the_post(); ?> <li> <?php $color = extra_get_post_category_color(); $post_format = et_get_post_format(); if ($show_thumb) { if (in_array($post_format, array('video', 'quote', 'link', 'audio', 'map', 'text'))) { $thumb_src = et_get_post_format_thumb($post_format); $img_style = sprintf('background-color:%s', $color); } else { if ('gallery' == $post_format) { $thumb_src = et_get_gallery_post_format_thumb(); } else { if (!get_post_thumbnail_id()) { $thumb_src = et_get_post_format_thumb('text', 'icon'); $img_style = sprintf('background-color:%s', $color); } } } $thumb_args = array('a_class' => array('widget_list_thumbnail'), 'size' => 'extra-image-square-small', 'thumb_src' => !empty($thumb_src) ? $thumb_src : '', 'img_style' => !empty($img_style) ? $img_style : ''); ?> <?php echo et_extra_get_post_thumb($thumb_args); ?> <?php } ?> <div class="post_info"> <a href="<?php the_permalink(); ?> " class="title"><?php get_the_title() ? the_title() : the_ID(); ?> </a> <?php $meta_args = array('post_date' => $show_date, 'categories' => $show_categories, 'author_link' => false, 'comment_count' => false, 'rating_stars' => false); ?> <div class="post-meta"> <?php echo et_extra_display_post_meta($meta_args); ?> </div> </div> </li> <?php } ?> <?php wp_reset_postdata(); ?> </ul> <?php echo $args['after_widget']; // Reset the global $the_post as this query will have stomped on it wp_reset_postdata(); } if (!$this->is_preview()) { $cache[$args['widget_id']] = ob_get_flush(); wp_cache_set('et_widget_recent_posts', $cache, 'extra'); } else { ob_end_flush(); } }