function widget($args, $instance) { global $post; // Preserve global $post $preserve = $post; extract($args); $title = apply_filters('widget_title', empty($instance['title']) ? __('In Case You Missed It', 'largo') : $instance['title'], $instance, $this->id_base); echo $before_widget; if ($title) { echo $before_title . $title . $after_title; } ?> <?php $missedit = largo_get_featured_posts(array('tax_query' => array(array('taxonomy' => 'prominence', 'field' => 'slug', 'terms' => 'footer-featured')), 'showposts' => $instance['num_posts'])); if ($missedit->have_posts()) { ?> <?php while ($missedit->have_posts()) { $missedit->the_post(); ?> <div class="post-lead clearfix"> <?php the_post_thumbnail('60x60'); ?> <h5><a href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></h5> <?php echo '<p>' . largo_trim_sentences(get_the_content(), $instance['num_sentences']) . '</p>'; ?> </div> <!-- /.post-lead --> <?php } ?> <?php } else { ?> <p class="error"><strong><?php _e('You don\'t presently have any posts in the footer featured category.</strong> Mark more posts as featured on the add/edit post screen to populate this region.', 'largo'); ?> </p> <?php } // end more featured posts ?> <?php echo $after_widget; // Restore global $post wp_reset_postdata(); $post = $preserve; }
function largo_widget_rss_output($rss, $args = array()) { echo '<ul>'; foreach ($rss->get_items(0, $args['num_posts']) as $item) { $link = $item->get_link(); while (stristr($link, 'http') != $link) { $link = substr($link, 1); } $link = esc_url(strip_tags($link)); $title = esc_attr(strip_tags($item->get_title())); if ($args['show_excerpt'] === 1) { $desc = str_replace(array("\n", "\r"), ' ', esc_attr(strip_tags(@html_entity_decode($item->get_description(), ENT_QUOTES, get_option('blog_charset'))))); $desc = largo_trim_sentences($desc, 2); $summary = "<p class='rssSummary'>{$desc}</p>"; } else { $summary = ''; } $date = ''; $date = $item->get_date('U'); if ($date) { $date = ' <span class="rss-date">' . date_i18n(get_option('date_format'), $date) . '</span>'; } $author = ' <cite>' . esc_html(strip_tags($item->data['child']['']['source'][0]['data'])) . '</cite>'; if ($link == '') { echo "<li><h5>{$title}</h5><p class=\"byline\">{$author} | {$date}</p>{$summary}</li>"; } else { echo "<li><h5><a class='rsswidget' href='{$link}' title='{$title}'>{$title}</a></h5><p class=\"byline\">{$author} | {$date}</p>{$summary}</li>"; } } echo '</ul>'; $rss->__destruct(); unset($rss); }
?> " title="Read: <?php esc_attr(the_title('', '', FALSE)); ?> "><?php the_title(); ?> </a></h4> <?php // post thumbnail, by default after headline if (get_the_post_thumbnail() && isset($instance) && isset($instance['thumbnail_location']) && $instance['thumbnail_location'] == 'after') { echo '<a href="' . get_permalink() . '"/>' . get_the_post_thumbnail(get_the_ID(), 'thumbnail', array('class' => 'alignleft')) . '</a>'; } // post byline, if indicated if (isset($instance) && isset($instance['show_byline']) && $instance['show_byline']) { ?> <h5 class="byline"><time class="entry-date updated dtstamp pubdate" datetime="<?php echo esc_attr(get_the_date('c')); ?> "><?php largo_time(); ?> </time></h5> <?php } // post excerpt/summary if ($post->post_excerpt) { echo '<p>' . $post->post_excerpt . '</p>'; } else { echo '<p>' . largo_trim_sentences($post->post_content, 2) . '</p>'; }
function largo_excerpt($the_post = null, $sentence_count = 5, $use_more = false, $more_link = '', $echo = true, $strip_tags = true, $strip_shortcodes = true) { if (!empty($use_more)) { _deprecated_argument(__FUNCTION__, '0.5.1', 'Parameter $use_more is deprecated.'); } if (!empty($more_link)) { _deprecated_argument(__FUNCTION__, '0.5.1', 'Parameter $more_link is deprecated.'); } $the_post = get_post($the_post); // Normalize it into a post object if (!empty($the_post->post_excerpt)) { // if a post has a custom excerpt set, we'll use that $content = apply_filters('get_the_excerpt', $the_post->post_excerpt); } else { if (is_home() && preg_match('/<!--more(.*?)?-->/', $the_post->post_content, $matches) > 0) { // if we're on the homepage and the post has a more tag, use that $parts = explode($matches[0], $the_post->post_content, 2); $content = $parts[0]; } else { // otherwise we'll just do our best and make the prettiest excerpt we can muster $content = largo_trim_sentences($the_post->post_content, $sentence_count); } } // optionally strip shortcodes and html $output = ''; if ($strip_tags && $strip_shortcodes) { $output .= strip_tags(strip_shortcodes($content)); } else { if ($strip_tags) { $output .= strip_tags($content); } else { if ($strip_shortcodes) { $output .= strip_shortcodes($content); } else { $output .= $content; } } } $output = apply_filters('the_content', $output); if ($echo) { echo $output; } return $output; }
} ?> </a> </h5> <?php // byline on posts if (isset($instance['show_byline']) && $instance['show_byline'] == true) { ?> <span class="byline"><?php echo largo_byline(false); ?> </span> <?php } // the excerpt if ($excerpt == 'num_sentences') { ?> <p><?php echo largo_trim_sentences(get_the_content(), $instance['num_sentences']); ?> </p> <?php } elseif ($excerpt == 'custom_excerpt') { ?> <p><?php echo get_the_excerpt(); ?> </p> <?php }
function widget($args, $instance) { global $post; // Preserve global $post $preserve = $post; extract($args); // only useful on post pages if (!is_single()) { return; } $title = apply_filters('widget_title', empty($instance['title']) ? __('More About', 'largo') : $instance['title'], $instance, $this->id_base); echo $before_widget; if ($rel_topics = largo_get_post_related_topics($instance['topics'])) { ?> <div id="related-posts" class="idTabs row-fluid clearfix"> <ul id="related-post-nav" class="span4"> <li><h5><?php echo $title; ?> </h5></li> <?php foreach ($rel_topics as $count => $topic) { echo '<li><a href="#rp' . (int) $count . '">' . esc_html($topic->name) . '</a></li>'; } ?> </ul> <div class="related-items span8"> <?php foreach ($rel_topics as $count => $topic) { $rel_posts = largo_get_recent_posts_for_term($topic, $instance['posts']); ?> <div id="rp<?php echo (int) $count; ?> "> <ul> <?php // the top related post $top_post = array_shift($rel_posts); ?> <li class="top-related clearfix"> <?php $permalink = get_permalink($top_post->ID); $post_title = $top_post->post_title; echo '<h3><a href="' . esc_url($permalink) . '" title="' . esc_attr(sprintf(__('Read %s', 'largo'), $post_title)) . '">' . esc_html($post_title) . '</a></h3>'; if (get_the_post_thumbnail($top_post->ID)) { echo '<a href="' . esc_url($permalink) . '"/>' . get_the_post_thumbnail($top_post->ID, '60x60') . '</a>'; } if ($top_post->post_excerpt) { echo '<p>' . $top_post->post_excerpt . '</p>'; } else { echo '<p>' . largo_trim_sentences($top_post->post_content, 2) . '</p>'; } ?> </li> <?php // the other related posts foreach ($rel_posts as $rel_post) { echo '<li><a href="' . esc_url(get_permalink($rel_post->ID)) . '" title="' . esc_attr($topic->name) . '">' . $rel_post->post_title . '</a></li>'; } ?> </ul> <p><a href="<?php echo esc_url(get_term_link($topic)); ?> " title="<?php echo esc_attr($topic->name); ?> " target="_blank"><strong><?php printf(__('View all %1$s %2$s →', 'largo'), $topic->name, of_get_option('posts_term_plural')); ?> </strong></a></p> </div> <!-- /#rpX --> <?php } ?> </div> <!-- /.items --> </div> <!-- /#related-posts --> <?php } // if ( $rel_topics ) echo $after_widget; // Restore global $post wp_reset_postdata(); $post = $preserve; }
/** * Outputs the content of the recent posts widget. * * @param array $args widget arguments. * @param array $instance saved values from databse. */ function widget($args, $instance) { global $post, $shown_ids; // an array of post IDs already on a page so we can avoid duplicating posts; // Preserve global $post $preserve = $post; extract($args); $posts_term = of_get_option('posts_term_plural', 'Posts'); // Add the link to the title. $title = apply_filters('widget_title', empty($instance['title']) ? __('Recent ' . $posts_term, 'largo') : $instance['title'], $instance, $this->id_base); echo $before_widget; if ($title) { echo $before_title . $title . $after_title; } $thumb = isset($instance['thumbnail_display']) ? $instance['thumbnail_display'] : 'small'; $excerpt = isset($instance['excerpt_display']) ? $instance['excerpt_display'] : 'num_sentences'; $query_args = array('post__not_in' => get_option('sticky_posts'), 'showposts' => $instance['num_posts'], 'post_status' => 'publish'); if (isset($instance['avoid_duplicates']) && $instance['avoid_duplicates'] === 1) { $query_args['post__not_in'] = $shown_ids; } if ($instance['cat'] != '') { $query_args['cat'] = $instance['cat']; } if ($instance['tag'] != '') { $query_args['tag'] = $instance['tag']; } if ($instance['author'] != '') { $query_args['author'] = $instance['author']; } if ($instance['taxonomy'] != '') { $query_args['tax_query'] = array(array('taxonomy' => $instance['taxonomy'], 'field' => 'slug', 'terms' => $instance['term'])); } echo '<ul>'; $my_query = new WP_Query($query_args); if ($my_query->have_posts()) { $output = ''; while ($my_query->have_posts()) { $my_query->the_post(); $shown_ids[] = get_the_ID(); // wrap the items in li's. $output .= '<li>'; // The top term $top_term_args = array('echo' => false); if (isset($instance['show_top_term']) && $instance['show_top_term'] == 1 && largo_has_categories_or_tags()) { $output .= '<h5 class="top-tag">' . largo_top_term($top_term_args) . '</h5>'; } // the thumbnail image (if we're using one) if ($thumb == 'small') { $img_location = $instance['image_align'] != '' ? $instance['image_align'] : 'left'; $img_attr = array('class' => $img_location . '-align'); $img_attr['class'] .= " attachment-small"; $output .= '<a href="' . get_permalink() . '">' . get_the_post_thumbnail(get_the_ID(), '60x60', $img_attr) . '</a>'; } elseif ($thumb == 'medium') { $img_location = $instance['image_align'] != '' ? $instance['image_align'] : 'left'; $img_attr = array('class' => $img_location . '-align'); $img_attr['class'] .= " attachment-thumbnail"; $output .= '<a href="' . get_permalink() . '">' . get_the_post_thumbnail(get_the_ID(), 'post-thumbnail', $img_attr) . '</a>'; } elseif ($thumb == 'large') { $img_attr = array(); $img_attr['class'] .= " attachment-large"; $output .= '<a href="' . get_permalink() . '">' . get_the_post_thumbnail(get_the_ID(), 'large', $img_attr) . '</a>'; } // the headline $output .= '<h5><a href="' . get_permalink() . '">' . get_the_title() . '</a></h5>'; // byline on posts if (isset($instance['show_byline']) && $instance['show_byline'] == true) { $output .= '<span class="byline">' . largo_byline(false) . '</span>'; } // the excerpt if ($excerpt == 'num_sentences') { $output .= '<p>' . largo_trim_sentences(get_the_content(), $instance['num_sentences']) . '</p>'; } elseif ($excerpt == 'custom_excerpt') { $output .= '<p>' . get_the_excerpt() . '</p>'; } // read more link if (isset($instance['show_read_more']) && $instance['show_read_more'] === 1) { $output .= '<p class="more-link"><a href="' . get_permalink() . '">' . __('Read More', 'largo') . '</a></p>'; } // close the item $output .= '</li>'; } // print all of the items echo $output; } else { printf(__('<p class="error"><strong>You don\'t have any recent %s.</strong></p>', 'largo'), strtolower($posts_term)); } // end more featured posts // close the ul if we're just showing a list of headlines if ($excerpt == 'none') { echo '</ul>'; } if ($instance['linkurl'] != '') { echo '<p class="morelink"><a href="' . esc_url($instance['linkurl']) . '">' . esc_html($instance['linktext']) . '</a></p>'; } echo $after_widget; // Restore global $post wp_reset_postdata(); $post = $preserve; }