function widget($args, $instance) { global $post; extract($args); $authors = array(); $bios = ''; if (get_post_meta($post->ID, 'largo_byline_text')) { $byline_text = esc_attr(get_post_meta($post->ID, 'largo_byline_text', true)); } $is_series_landing = function_exists('largo_is_series_landing') ? largo_is_series_landing($post) : false; if ((is_singular() || is_author() || $is_series_landing) && empty($byline_text)) { if (is_singular() || $is_series_landing) { if (function_exists('get_coauthors')) { $authors = get_coauthors(get_queried_object_id()); } else { $authors = array(get_user_by('id', get_queried_object()->post_author)); } } else { if (is_author()) { $authors = array(get_queried_object()); } } // make sure we have at least one bio before we show the widget foreach ($authors as $key => $author) { $bio = trim($author->description); if (!is_author() && empty($bio)) { unset($authors[$key]); } else { $bios .= $bio; } } if (!is_author() && empty($bios)) { return; } foreach ($authors as $author_obj) { $ctx = array('author_obj' => $author_obj); ?> <div class="author-box row-fluid author vcard clearfix"> <?php largo_render_template('partials/author-bio', 'description', $ctx); ?> <?php largo_render_template('partials/author-bio', 'social-links', $ctx); ?> </div> <?php } // foreach } elseif (empty($byline_text)) { _e('Not a valid author context'); } echo $after_widget; }
function widget($args, $instance) { global $post; // Preserve global $post $preserve = $post; // instance: num, series (id), title, heading extract($args); //get the posts $series_posts = largo_get_series_posts($instance['series'], $instance['num']); if (!$series_posts) { return; } //output nothing if no posts found $instance['title_link'] = get_term_link((int) $instance['series'], 'series'); $term = get_term($instance['series'], 'series'); $title = apply_filters('widget_title', $term->name, $instance, $this->id_base); echo $before_widget; if ($title) { echo $before_title . $title . $after_title; } //first post $series_posts->the_post(); $context = array('instance' => $instance, 'thumb' => 'medium', 'excerpt' => 'custom_excerpt'); largo_render_template('partials/widget', 'content', $context); //divider if ($series_posts->have_posts()) { echo '<h5 class="series-split top-tag">' . esc_html($instance['heading']) . '</h5><ul>'; while ($series_posts->have_posts()) { $series_posts->the_post(); echo '<li>'; post_type_icon(); echo '<a href="'; the_permalink(); echo '">'; the_title(); echo '</a></li>'; } echo '</ul>'; } echo '<a class="more" href="' . get_term_link((int) $instance['series'], 'series') . '">' . __('Complete Coverage', 'largo') . "</a>"; echo $after_widget; // Restore global $post wp_reset_postdata(); $post = $preserve; }
/** * Render a list of user profiles based on the array of users passed * * @param $users array The WP_User objects to use in rendering the list. * @param $show_users_with_empty_desc bool Whether we should skip users that have no bio/description. * @since 0.4 */ function largo_render_user_list($users, $show_users_with_empty_desc = false) { echo '<div class="user-list">'; foreach ($users as $user) { $desc = trim($user->description); if (empty($desc) && $show_users_with_empty_desc == false) { continue; } $hide = get_user_meta($user->ID, 'hide', true); if ($hide == 'on') { continue; } $ctx = array('author_obj' => $user); echo '<div class="author-box row-fluid">'; largo_render_template('partials/author-bio', 'description', $ctx); echo '</div>'; } echo '</div>'; }
/** * Returns DOM for a featured gallery hero. * * @since 0.5.1 * * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post. * @param String $classes Optional. Class string to apply to outer div.hero */ function largo_get_featured_gallery_hero($post = null, $classes = '') { $post = get_post($post); $featured_media = largo_get_featured_media($post->ID); if ($featured_media['type'] != 'gallery') { return; } $hero_class = largo_hero_class($post->ID, false); $classes = "hero {$hero_class} {$classes}"; $context = array('classes' => $classes, 'gallery_ids' => implode(',', $featured_media['gallery'])); ob_start(); largo_render_template('partials/hero', 'featured-gallery', $context); $ret = ob_get_clean(); return $ret; }
/** * 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>'; $context = array('instance' => $instance, 'thumb' => $thumb, 'excerpt' => $excerpt); ob_start(); largo_render_template('partials/widget', 'content', $context); $output .= ob_get_clean(); // 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; }
<div class="primary-featured-post"> <?php largo_render_template('partials/archive', 'category-primary-feature', array('featured_post' => $top_featured)); ?> </div> <?php $secondary_featured = array_slice($featured_posts, 1); if (count($secondary_featured) > 0) { ?> <div class="secondary-featured-post"> <div class="row-fluid clearfix"><?php foreach ($secondary_featured as $idx => $featured_post) { $shown_ids[] = $featured_post->ID; largo_render_template('partials/archive', 'category-secondary-feature', array('featured_post' => $featured_post)); } ?> </div> </div> <?php } } } ?> </div> <div class="row-fluid clearfix"> <div class="stories span8" role="main" id="content"> <?php if (have_posts()) {
function largo_content_nav($nav_id, $in_same_cat = false) { global $wp_query; if ($nav_id === 'single-post-nav-below') { ?> <nav id="nav-below" class="pager post-nav clearfix"> <?php if ($prev = get_previous_post($in_same_cat)) { if (get_the_post_thumbnail($prev->ID)) { $image = wp_get_attachment_image_src(get_post_thumbnail_id($prev->ID)); printf(__('<div class="previous"><a href="%1$s"><img class="thumb" src="%4$s" /><h5>Previous %2$s</h5><span class="meta-nav">%3$s</span></a></div>', 'largo'), get_permalink($prev->ID), of_get_option('posts_term_singular'), $prev->post_title, $image[0]); } else { printf(__('<div class="previous"><a href="%1$s"><h5>Previous %2$s</h5><span class="meta-nav">%3$s</span></a></div>', 'largo'), get_permalink($prev->ID), of_get_option('posts_term_singular'), $prev->post_title); } } if ($next = get_next_post($in_same_cat)) { if (get_the_post_thumbnail($next->ID)) { $image = wp_get_attachment_image_src(get_post_thumbnail_id($next->ID)); printf(__('<div class="next"><a href="%1$s"><img class="thumb" src="%4$s" /><h5>Next %2$s</h5><span class="meta-nav">%3$s</span></a></div>', 'largo'), get_permalink($next->ID), of_get_option('posts_term_singular'), $next->post_title, $image[0]); } else { printf(__('<div class="next"><a href="%1$s"><h5>Next %2$s</h5><span class="meta-nav">%3$s</span></a></div>', 'largo'), get_permalink($next->ID), of_get_option('posts_term_singular'), $next->post_title); } } ?> </nav><!-- #nav-below --> <?php } elseif ($wp_query->max_num_pages > 1) { $posts_term = of_get_option('posts_term_plural'); largo_render_template('partials/load-more-posts', array('nav_id' => $nav_id, 'the_query' => $wp_query, 'posts_term' => $posts_term ? $posts_term : 'Posts')); } }
case 'custom': $args['orderby'] = 'series_custom'; break; case 'featured, DESC': case 'featured, ASC': $args['orderby'] = $opt['post_order']; break; } $series_query = new WP_Query($args); while ($series_query->have_posts()) { $series_query->the_post(); get_template_part('partials/content', 'series'); } wp_reset_postdata(); $posts_term = of_get_option('posts_term_plural'); largo_render_template('partials/load-more-posts', array('nav_id' => 'nav-below', 'the_query' => $series_query, 'posts_term' => $posts_term ? $posts_term : 'Posts')); } ?> </div><!-- /.grid_8 #content --> <?php // display left rail if ($opt['cftl_layout'] != 'one-column') { if (!empty($opt['right_region']) && $opt['right_region'] !== 'none') { $right_rail = $opt['right_region']; } else { $right_rail = 'single'; } ?> <aside id="sidebar" class="span4">