?> </p> <ul class="meta"> <li class="author"><a href="<?php ecko_get_author_url(); ?> "><i class="fa fa-user"></i><?php the_author(); ?> </a></li> <li class="date"><a href="<?php the_permalink(); ?> "><i class="fa fa-clock-o"></i><time datetime="<?php the_time('Y-m-d'); ?> "><?php echo esc_html(ecko_date_format()); ?> </time></a></li> <li class="comments"><a href="<?php the_permalink(); ?> #comments"><i class="fa fa-comments-o"></i><?php comments_number('0', '1', '%'); ?> </a></li> </ul> </div> </article>
public function widget($args, $instance) { global $post; $ecko_related_posts = get_posts(array('numberposts' => $instance['postcount'], 'category__in' => wp_get_post_categories($post->ID), 'meta_key' => '_thumbnail_id', 'post__not_in' => array($post->ID), 'tax_query' => array(array('taxonomy' => 'post_format', 'field' => 'slug', 'terms' => array('post-format-aside', 'post-format-audio', 'post-format-chat', 'post-format-gallery', 'post-format-image', 'post-format-link', 'post-format-quote', 'post-format-status', 'post-format-video'), 'operator' => 'NOT IN')))); if (count($ecko_related_posts) > 0) { ?> <section class="widget relatedposts"> <?php if ($instance['title'] != '') { ?> <h3 class="widget-title"><?php echo esc_html($instance['title']); ?> </h3> <hr> <?php } foreach ($ecko_related_posts as $post) { setup_postdata($post); $ecko_thumb_id = get_post_thumbnail_id(); $ecko_thumb_url = wp_get_attachment_image_src(get_post_thumbnail_id(), 'sidebar'); ?> <article> <a href="<?php esc_url(the_permalink()); ?> " class="feature"><img src="<?php echo esc_attr($ecko_thumb_url[0]); ?> " alt="<?php esc_attr(the_title()); ?> "></a> <h4><a href="<?php esc_url(the_permalink()); ?> "><?php esc_html(the_title()); ?> </a></h4> <div class="meta"> <a href="<?php echo esc_url(get_author_posts_url(get_the_author_meta('ID'))); ?> " class="author"><?php esc_html(the_author()); ?> </a> <span class="divider">/</span> <a href="<?php esc_url(the_permalink()); ?> " class="date"><?php esc_html(ecko_date_format()); ?> </a> </div> </article> <?php } wp_reset_postdata(); ?> </section> <?php } }
public function widget($args, $instance) { global $post; $active_post = 0; if (is_single()) { $active_post = $post->ID; } $ecko_latest_posts = array('numberposts' => $instance['postcount'], 'meta_key' => '_thumbnail_id', 'post__not_in' => array($active_post)); if (!isset($instance['allformats'])) { $ecko_latest_posts['tax_query'] = array(array('taxonomy' => 'post_format', 'field' => 'slug', 'terms' => array('post-format-aside', 'post-format-audio', 'post-format-chat', 'post-format-gallery', 'post-format-image', 'post-format-link', 'post-format-quote', 'post-format-status', 'post-format-video'), 'operator' => 'NOT IN')); } $ecko_latest_posts = get_posts($ecko_latest_posts); if (count($ecko_latest_posts) > 0) { ?> <section class="widget latestposts"> <?php if ($instance['title'] != '') { ?> <h3 class="widget-title"><?php echo esc_html($instance['title']); ?> </h3> <hr> <?php } foreach ($ecko_latest_posts as $post) { setup_postdata($post); $ecko_thumb_id = get_post_thumbnail_id(); $ecko_thumb_url = wp_get_attachment_image_src(get_post_thumbnail_id(), 'thumbnail'); $ecko_category = get_the_category(); ?> <article class="post"> <div class="top"> <a href="<?php esc_url(the_permalink()); ?> " class="thumbnail"> <i class="fa fa-link"></i> <span style="background-image:url('<?php echo esc_url($ecko_thumb_url[0]); ?> ');"></span> </a> <div class="info"> <?php if ($ecko_category) { echo '<a href="' . esc_url(get_category_link($ecko_category[0]->term_id)) . '" class="button rounded grayoutline tiny category">' . esc_html($ecko_category[0]->name) . '</a> '; } ?> <h5 class="title"><a href="<?php esc_url(the_permalink()); ?> "><?php if (mb_strlen(get_the_title()) > 50) { echo esc_html(mb_substr(get_the_title(), 0, 50)) . "..."; } else { esc_html(the_title()); } ?> </a></h5> <section class="meta"> <span class="posted"><?php esc_html_e('Posted', ECKO_PLUGIN_ID); ?> </span> <span class="author"><span><?php esc_html_e('by', ECKO_PLUGIN_ID); ?> </span> <a href="<?php echo esc_url(get_author_posts_url(get_the_author_meta('ID'))); ?> "><img src="//0.gravatar.com/avatar/<?php echo esc_attr(md5(get_the_author_meta('user_email'))); ?> ?s=24" class="gravatarsmall" alt=""> <?php the_author(); ?> </a></span> <span class="date"><span><?php esc_html_e('on', ECKO_PLUGIN_ID); ?> </span> <a href="<?php the_permalink(); ?> "><i class="fa fa-clock-o"></i> <time datetime="<?php the_time('Y-m-d'); ?> "><?php if (function_exists('ecko_date_format')) { echo esc_html(ecko_date_format()); } else { the_date(); } ?> </time></a></span> </section> </div> </div> <p class="excerpt"><?php if (function_exists('ecko_truncate_by_words')) { echo esc_html(ecko_truncate_by_words(get_the_excerpt(), 130, '...')); } else { the_excerpt(); } ?> </p> </article> <?php } wp_reset_postdata(); ?> </section> <?php } }
public function widget($args, $instance) { if (is_single()) { global $post; $ecko_related_posts = array('numberposts' => $instance['postcount'], 'category__in' => wp_get_post_categories($post->ID), 'meta_key' => '_thumbnail_id', 'post__not_in' => array($post->ID)); if (!isset($instance['allformats'])) { $ecko_related_posts['tax_query'] = array(array('taxonomy' => 'post_format', 'field' => 'slug', 'terms' => array('post-format-aside', 'post-format-audio', 'post-format-chat', 'post-format-gallery', 'post-format-image', 'post-format-link', 'post-format-quote', 'post-format-status', 'post-format-video'), 'operator' => 'NOT IN')); } $ecko_related_posts = get_posts($ecko_related_posts); if (count($ecko_related_posts) > 0) { ?> <section class="widget relatedposts"> <?php if ($instance['title'] != '') { ?> <h3 class="widget-title"><?php echo esc_html($instance['title']); ?> </h3> <hr> <?php } foreach ($ecko_related_posts as $post) { setup_postdata($post); $ecko_thumb_id = get_post_thumbnail_id(); $ecko_thumb_url = wp_get_attachment_image_src(get_post_thumbnail_id(), 'sidebar'); ?> <article> <a href="<?php esc_url(the_permalink()); ?> " class="feature"> <?php $post_category = get_the_category(); if ($post_category) { $color_option = get_option('category_meta_' . $post_category[0]->term_id . '_color'); if (!empty($color_option)) { $color = get_option('category_meta_' . $post_category[0]->term_id . '_color'); } else { $color = '7fbb00'; } echo '<span class="category" style="background:#' . $color . ';">' . esc_html($post_category[0]->name) . '</span> '; } ?> <img src="<?php echo esc_attr($ecko_thumb_url[0]); ?> " alt="<?php esc_attr(the_title()); ?> "> </a> <h4><a href="<?php esc_url(the_permalink()); ?> "><?php esc_html(the_title()); ?> </a></h4> <div class="meta"> <a href="<?php echo esc_url(get_author_posts_url(get_the_author_meta('ID'))); ?> " class="author"><?php esc_html(the_author()); ?> </a> <span class="divider">/</span> <a href="<?php esc_url(the_permalink()); ?> " class="date"><?php if (function_exists('ecko_date_format')) { echo esc_html(ecko_date_format()); } else { the_date(); } ?> </a> </div> </article> <?php } wp_reset_postdata(); ?> </section> <?php } } }