diff --git a/archive.php b/archive.php index ce0781f5e..30791f2dc 100644 --- a/archive.php +++ b/archive.php @@ -105,11 +105,13 @@ 0 ) { + // do nothing + // We have n > 1 posts in the featured header + // It's not appropriate to display partials/content-not-found here. } else { get_template_part( 'partials/content', 'not-found' ); } diff --git a/docs/developers/hooksfilters.rst b/docs/developers/hooksfilters.rst index 692c9dd3a..e482b6df3 100644 --- a/docs/developers/hooksfilters.rst +++ b/docs/developers/hooksfilters.rst @@ -271,6 +271,29 @@ Here is the current list of hooks available in Largo (available as of v.0.4): - **largo_header_before_largo_header** - immediately before ``largo_header()`` is output - **largo_header_after_largo_header** - immediately after ``largo_header()`` is output. By default, ``largo_header_widget_sidebar`` is hooked here. + +**for all lists of posts** + +- **largo_loop_after_post_x** - fires after every post in a river of posts on the homepage or archive pages. This is helpful if you want to insert interstitial content in a river of posts (typically things like newsletter subscription widgets, donation messages, etc.). + +This action takes a couple of arguments that may come in handy: + + do_action( 'largo_loop_after_post_x', $counter, $context ); + + - **$counter** tracks the number of posts in any given loop + - **$context** is presently either 'archive' or 'home' to give you flexibility to insert different interstitials for different page types. + +an example of this in use might look like: + + function mytheme_interstitial( $counter, $context ) { + if ( $counter === 2 && $context === 'home' ) { + // do homepage stuff + } elseif ( $counter === 2 && $context === 'archive' ) { + // do something different in the same spot on archive pages + } + } + add_action( 'largo_loop_after_post_x', 'mytheme_interstitial', 10, 2 ); + **home.php** @@ -322,6 +345,7 @@ These actions are run on all homepage templates, including the Legacy Three Colu - **largo_category_after_description_in_header** - between the ``div.archive-description`` and before ``get_template_part('partials/archive', 'category-related');``. - **largo_before_category_river** - just before the river of stories at the bottom of the category archive page (for adding a header to this column, for example) + - **largo_loop_after_post_x** - runs after every post, with arguments ``$counter`` and ``context`` describing which post it's running after and what the context is. (In categories, the context is ``archive``.) - **largo_after_category_river** - immediately after the river of stories at the bottom of the category archive page, after the Load More Posts button (for adding a footer to this column, for example.) **search.php** diff --git a/functions.php b/functions.php index 8a53ff114..92ef4bb5f 100644 --- a/functions.php +++ b/functions.php @@ -419,6 +419,9 @@ function largo_setup() { // Add support for localization (this is a work in progress) load_theme_textdomain('largo', get_template_directory() . '/lang'); + + //Add support for tags + add_theme_support( 'title-tag' ); } } diff --git a/inc/post-metaboxes.php b/inc/post-metaboxes.php index 41c0afda7..0a31b2178 100644 --- a/inc/post-metaboxes.php +++ b/inc/post-metaboxes.php @@ -330,21 +330,11 @@ function largo_top_terms_js() { * */ function largo_prominence_meta_box($post, $args) { - $largoProminenceTerms = $args['args']; - - $terms = get_terms('prominence', array( + $termList = get_terms('prominence', array( 'hide_empty' => false, 'fields' => 'all' )); - $slugs = array_map(function($arg) { return $arg['slug']; }, $largoProminenceTerms); - - $termList = array(); - foreach ($terms as $k => $v) { - if (in_array($v->slug, $slugs)) - $termList[] = $v; - } - $tax = get_taxonomy('prominence'); $args = array( 'taxonomy' => 'prominence', diff --git a/inc/related-content.php b/inc/related-content.php index 6387f50d5..e30c8ffcd 100644 --- a/inc/related-content.php +++ b/inc/related-content.php @@ -615,7 +615,7 @@ protected function get_series_posts() { protected function get_term_posts() { //we've gone back and forth through all the post's series, now let's try traditional taxonomies - $taxonomies = get_the_terms( $this->post_id, array('category', 'post_tag') ); + $taxonomies = get_the_terms( $this->post_id, array( 'category', 'post_tag' ) ); //loop thru taxonomies, much like series, and get posts if ( is_array($taxonomies) ) { @@ -629,7 +629,7 @@ protected function get_term_posts() { 'taxonomy' => $term->taxonomy, 'term' => $term->slug, 'orderby' => 'date', - 'order' => 'ASC', + 'order' => 'DESC', 'ignore_sticky_posts' => 1, 'date_query' => array( 'after' => $this->post->post_date, @@ -640,7 +640,7 @@ protected function get_term_posts() { $term_query = new WP_Query( $args ); // If not enough posts were added from after this post, look before this post - if ( count($term_query->posts) < $this->number ) { + if ( count( $term_query->posts ) < $this->number ) { // Store the returned posts from the after query $this->add_from_query( $term_query ); @@ -681,7 +681,7 @@ protected function get_recent_posts() { $posts_query = new WP_Query( $args ); if ( $posts_query->have_posts() ) { - $this->add_from_query($posts_query); + $this->add_from_query( $posts_query ); } } diff --git a/inc/users.php b/inc/users.php index bdca436e7..d87edd4f0 100644 --- a/inc/users.php +++ b/inc/users.php @@ -140,8 +140,13 @@ function largo_edit_permission_check() { global $current_user, $profileuser; $screen = get_current_screen(); - - get_currentuserinfo(); + + global $wp_version; + if ( $wp_version < 4.5 ) { + get_currentuserinfo(); + } else { + wp_get_current_user(); + } if( ! is_super_admin( $current_user->ID ) && in_array( $screen->base, array( 'user-edit', 'user-edit-network' ) ) ) { // editing a user profile if ( is_super_admin( $profileuser->ID ) ) { // trying to edit a superadmin while less than a superadmin diff --git a/inc/widgets/largo-related-posts.php b/inc/widgets/largo-related-posts.php index 6bc419e06..9f93b0c0e 100644 --- a/inc/widgets/largo-related-posts.php +++ b/inc/widgets/largo-related-posts.php @@ -27,36 +27,42 @@ function widget( $args, $instance ) { if ( $title ) echo $before_title . $title . $after_title; - $related = new Largo_Related( $instance['qty'] ); + $related = new Largo_Related( $instance['qty'] ); - //get the related posts - $rel_posts = new WP_Query( array( - 'post__in' => $related->ids(), - 'nopaging' => 1, - 'posts_per_page' => $instance['qty'], - 'ignore_sticky_posts' => 1 - ) ); + //get the related posts + $rel_posts = new WP_Query( array( + 'post__in' => $related->ids(), + 'nopaging' => 1, + 'posts_per_page' => $instance['qty'], + 'ignore_sticky_posts' => 1 + ) ); - if ( $rel_posts->have_posts() ) { + if ( $rel_posts->have_posts() ) { - echo '<ul class="related">'; + echo '<ul class="related">'; - while ( $rel_posts->have_posts() ) { - $rel_posts->the_post(); - echo '<li>'; - echo '<a href="' . get_permalink() . '"/>' . get_the_post_thumbnail( get_the_ID(), 'thumbnail', array('class'=>'alignleft') ) . '</a>'; + while ( $rel_posts->have_posts() ) { + $rel_posts->the_post(); + echo '<li>'; + + echo '<a href="' . get_permalink() . '"/>' . get_the_post_thumbnail( get_the_ID(), 'thumbnail', array( 'class' => '' ) ) . '</a>'; ?> - <h4><a href="<?php the_permalink(); ?>" title="Read: <?php esc_attr( the_title('','', FALSE) ); ?>"><?php the_title(); ?></a></h4> - <h5 class="byline"> - <span class="by-author"><?php largo_byline( true, false ); ?></span> - </h5> + + <h4><a href="<?php the_permalink(); ?>" title="Read: <?php esc_attr( the_title( '','', FALSE ) ); ?>"><?php the_title(); ?></a></h4> + + <?php if ( $instance['show_byline'] ) { ?> + <h5 class="byline"> + <span class="by-author"><?php largo_byline( true, false ); ?></span> + </h5> + <?php } ?> + <?php // post excerpt/summary - largo_excerpt(get_the_ID(), 2, null, null, true); - echo '</li>'; - } + largo_excerpt(get_the_ID(), 2, false, '', true); + echo '</li>'; + } - echo "</ul>"; - } + echo "</ul>"; + } echo $after_widget; // Restore global $post wp_reset_postdata(); @@ -68,7 +74,6 @@ function update( $new_instance, $old_instance ) { $instance['title'] = sanitize_text_field($new_instance['title']); $instance['qty'] = (int) $new_instance['qty']; $instance['show_byline'] = (int) $new_instance['show_byline']; - $instance['thumbnail_location'] = sanitize_key( $new_instance['thumbnail_location'] ); return $instance; } @@ -93,18 +98,7 @@ function form( $instance ) { </p> <p><input id="<?php echo $this->get_field_id('show_byline'); ?>" name="<?php echo $this->get_field_name('show_byline'); ?>" type="checkbox" value="1" <?php checked( $instance['show_byline'], 1);?> /> - <label for="<?php echo $this->get_field_id('show_byline'); ?>"><?php _e( 'Show date with each post', 'largo' ); ?></label> - </p> - - <p> - <label for="<?php echo $this->get_field_id('thumbnail_location'); ?>"><?php _e('Thumbnail position', 'largo'); ?>:</label> - <select name="<?php echo $this->get_field_name('thumbnail_location'); ?>" id="<?php echo $this->get_field_id('thumbnail_location'); ?>"> - <?php - $choices = array( 'before' => __( 'Before Headline', 'largo' ), 'after' => __( 'After Headline', 'largo' ) ); - foreach( $choices as $i => $display ) { - echo '<option value="', $i, '"', selected($instance['thumbnail_location'], $i, false), '>', $display, '</option>'; - } ?> - </select> + <label for="<?php echo $this->get_field_id('show_byline'); ?>"><?php _e( 'Show byline on each post', 'largo' ); ?></label> </p> <?php diff --git a/partials/content-not-found.php b/partials/content-not-found.php index 4bc261797..041aaed44 100644 --- a/partials/content-not-found.php +++ b/partials/content-not-found.php @@ -10,14 +10,17 @@ wp_kses($_SERVER['REQUEST_URI'], array()) // The url, sanitized ); } + + $title = '<h1 class="entry-title">' . __( 'Page Not Found', 'largo' ) . '</h1>'; } else if ( is_search() ) { $apologies = __( 'Apologies, but no results were found. Perhaps searching for something else will help.', 'largo' ); + $title = ''; } ?> <article id="post-0" class="post no-results not-found"> <header class="entry-header"> - <h1 class="entry-title"><?php _e( 'Page Not Found', 'largo' ); ?></h1> + <?php echo $title ?> </header><!-- .entry-header --> <div class="entry-content"> diff --git a/partials/home-post-list.php b/partials/home-post-list.php index 2e5b96a68..a50bebccf 100644 --- a/partials/home-post-list.php +++ b/partials/home-post-list.php @@ -11,25 +11,31 @@ 'ignore_sticky_posts' => true ); -if (of_get_option('num_posts_home')) - $args['posts_per_page'] = of_get_option('num_posts_home'); -if (of_get_option('cats_home')) - $args['cat'] = of_get_option('cats_home'); +if ( of_get_option( 'num_posts_home' ) ) { + $args['posts_per_page'] = of_get_option( 'num_posts_home', 10 ); +} +if ( of_get_option( 'cats_home' ) ) { + $args['cat'] = of_get_option( 'cats_home', '' ); +} $query = new WP_Query($args); -if ($query->have_posts()) { + +if ( $query->have_posts() ) { + $counter = 1; while ($query->have_posts()) : $query->the_post(); //if the post is in the array of post IDs already on this page, skip it. Just a double-check - if (in_array(get_the_ID(), $shown_ids)) + if ( in_array( get_the_ID(), $shown_ids)) continue; else { $shown_ids[] = get_the_ID(); - do_action('largo_before_home_list_post', $post, $query); + do_action( 'largo_before_home_list_post', $post, $query ); get_template_part('partials/content', 'home'); - do_action('largo_after_home_list_post', $post, $query); + do_action( 'largo_after_home_list_post', $post, $query ); + do_action( 'largo_loop_after_post_x', $counter, $context = 'home' ); + $counter++; } endwhile; - largo_content_nav('nav-below'); + largo_content_nav( 'nav-below' ); } else { - get_template_part('partials/content', 'not-found'); + get_template_part( 'partials/content', 'not-found' ); } diff --git a/series-landing.php b/series-landing.php index 3c841852b..e6947f52f 100644 --- a/series-landing.php +++ b/series-landing.php @@ -129,8 +129,11 @@ } $series_query = new WP_Query($args); + $counter = 1; while ( $series_query->have_posts() ) : $series_query->the_post(); get_template_part( 'partials/content', 'series' ); + do_action( 'largo_loop_after_post_x', $counter, $context = 'archive' ); + $counter++; endwhile; wp_reset_postdata();