From c52762ef7db2c7f4e6029435b5f4be6f64f4689b Mon Sep 17 00:00:00 2001 From: Ben Keith Date: Fri, 15 Mar 2019 18:20:16 -0400 Subject: [PATCH 1/4] Add term taxonomy and slug as taxonomy-slug to output of largo_top_term and largo_category_and_tags For https://github.com/INN/largo/issues/1646 --- inc/related-content.php | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/inc/related-content.php b/inc/related-content.php index f1a57368e..518bfbe57 100644 --- a/inc/related-content.php +++ b/inc/related-content.php @@ -268,12 +268,17 @@ function largo_categories_and_tags( $max = 5, $echo = true, $link = true, $use_i if ( $link ) { $output[] = sprintf( - __( '<%1$s class="post-category-link">%5$s%4$s', 'largo' ), + __( '<%1$s class="post-category-link %6$s">%5$s%4$s', 'largo' ), $item_wrapper, ( $rss ? get_category_feed_link( $cat->term_id ) : get_category_link( $cat->term_id ) ), of_get_option( 'posts_term_plural' ), $cat->name, - $icon + $icon, + sprintf( + '%1$s-%2$s', + $cat->taxonomy, + $cat->slug + ) ); } else { $output[] = $cat->name; @@ -289,12 +294,17 @@ function largo_categories_and_tags( $max = 5, $echo = true, $link = true, $use_i if ( $link ) { $output[] = sprintf( - __( '<%1$s class="post-tag-link">%5$s%4$s', 'largo' ), + __( '<%1$s class="post-tag-link %6$s">%5$s%4$s', 'largo' ), $item_wrapper, ( $rss ? get_tag_feed_link( $tag->term_id ) : get_tag_link( $tag->term_id ) ), of_get_option( 'posts_term_plural' ), $tag->name, - $icon + $icon, + sprintf( + '%1$s-%2$s', + $tag->taxonomy, + $tag->slug + ) ); } else { $output[] = $tag->name; @@ -363,17 +373,26 @@ function largo_top_term( $options = array() ) { */ if ( $term_id && $term_id !== 'none' && !empty( $taxonomy ) ) { $icon = ( $args['use_icon'] ) ? '' : '' ; //this will probably change to a callback largo_term_icon() someday + $link = ( $args['link'] ) ? array( '','' ) : array( '', '' ) ; + // get the term object $term = get_term( $term_id, $taxonomy ); + if ( is_wp_error( $term ) ) return; + $output = sprintf( - '<%1$s class="post-category-link">'.$link[0].'%5$s%4$s'.$link[1].'', + '<%1$s class="post-category-link _top_term_output %6$s">'.$link[0].'%5$s%4$s'.$link[1].'', $args['wrapper'], get_term_link( $term ), of_get_option( 'posts_term_plural' ), $term->name, - $icon + $icon, + sprintf( + '%1$s-%2$s', + $term->taxonomy, + $term->slug + ) ); } From 97f0d95296a24b65f317a1f9dda678a2eff383d2 Mon Sep 17 00:00:00 2001 From: Ben Keith Date: Fri, 15 Mar 2019 19:06:05 -0400 Subject: [PATCH 2/4] Fix homepage top term output problems on homepage featured stories list --- homepages/zones/zones.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/homepages/zones/zones.php b/homepages/zones/zones.php index ad0bd2992..39d6f84d2 100644 --- a/homepages/zones/zones.php +++ b/homepages/zones/zones.php @@ -137,13 +137,16 @@ function homepage_feature_stories_list() { $featured_stories = largo_home_featured_stories( $max ); foreach ( $featured_stories as $featured ) { $shown_ids[] = $featured->ID; -?> - - + + Date: Fri, 15 Mar 2019 19:07:53 -0400 Subject: [PATCH 3/4] largo_top_term: better array output handling from largo_category_and_tags(), and a fix for https://github.com/INN/largo/issues/1647 by not calling largo_category_and_tags() when the post given to largo_top_term() does not match the post returned by get_the_ID() --- inc/related-content.php | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/inc/related-content.php b/inc/related-content.php index 518bfbe57..c0dab1d80 100644 --- a/inc/related-content.php +++ b/inc/related-content.php @@ -333,7 +333,7 @@ function largo_top_term( $options = array() ) { 'echo' => TRUE, 'link' => TRUE, 'use_icon' => FALSE, - 'wrapper' => 'span', + 'wrapper' => 'span', // an HTML tag ID 'exclude' => array(), //only for compatibility with largo_categories_and_tags ); @@ -400,10 +400,33 @@ function largo_top_term( $options = array() ) { * No output? * generate a link to the post's category or tags */ - if ( empty( $output ) ) { - $output = largo_categories_and_tags( 1, false, $args['link'], $args['use_icon'], '', $args['wrapper'], $args['exclude']); - if ( is_array( $output ) && ! empty( $output[0] ) ) { - $output = ( is_array( $output ) ) ? $output[0] : ''; + if ( + empty( $output ) + && 'none' !== $term_id + && (int) $args['post'] === get_the_ID() + ) { + + // Can't pass a post ID to largo_categories_and_tags, so this may return the wrong links. + $lcat_output = largo_categories_and_tags( 1, false, $args['link'], $args['use_icon'], '', $args['wrapper'], $args['exclude'] ); + + if ( is_string( $lcat_output ) ) { + $output = $lcat_output; + } elseif ( is_array( $lcat_output ) ) { + if ( empty( $lcat_output ) ) { + $output = ''; + } else { + foreach ( $lcat_output as $o ) { + if ( empty( $o ) ) { + continue; + } + if ( is_string( $o ) ) { + $output = $o; + break; + } + } + } + } else { + $output = ''; } } From 59ca9f5aacc247781fff0a0bf809063858f22ef1 Mon Sep 17 00:00:00 2001 From: Ben Keith Date: Fri, 15 Mar 2019 19:24:24 -0400 Subject: [PATCH 4/4] Changelog for https://github.com/INN/largo/pull/1648 --- changelog.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/changelog.md b/changelog.md index b88c6b98f..aa4ff4499 100644 --- a/changelog.md +++ b/changelog.md @@ -12,17 +12,20 @@ This release contains bug fixes for Largo 0.6. ### Feature updates - Updates INN's logos in the `img/` folder. If your child theme redefines the function `inn_logo()`, please update that function to reference the new SVG image locations in `img/`. [Pull request #1633](https://github.com/INN/largo/pull/1633) for [issue #1621](https://github.com/INN/largo/issues/1631) +- Adds the term's taxonomy slug and term slug in the format `taxonomy-term` as a class on the term in the output of `largo_top_term()`, `largo_category_and_tags()`, and `largo_maybe_top_term()`. [Pull request](https://github.com/INN/largo/pull/1648) for [issue #1646](https://github.com/INN/largo/issues/1646). ### Fixes - Increases contrast of the floating social button icons against the background, to improve accessibility. [Pull request #1635](https://github.com/INN/largo/pull/1635/). -- Fixes issue where `[module]content[/module]` was not rendering `content` in the output of the `largo_module_shortcode()` function. [Pull request #1645](https://github.com/INN/largo/pull/1645) for [issue #1639](https://github.com/INN/largo/issues/1639). - Fixes issue where floating social buttons were not clickable, because of z-index ordering. [Pull request #1635](https://github.com/INN/largo/pull/1635/) for [issue #1576](https://github.com/INN/largo/issues/1576). - Fixes links in social media buttons not respecting the blog's character set. [Pull request #1635](https://github.com/INN/largo/pull/1635/) for [issue #1283](https://github.com/INN/largo/issues/1283). +- Fixes issue where `[module]content[/module]` was not rendering `content` in the output of the `largo_module_shortcode()` function. [Pull request #1645](https://github.com/INN/largo/pull/1645) for [issue #1639](https://github.com/INN/largo/issues/1639). - Function `largo_post_social_links` now respects the blog character set option. [Pull request #1635](https://github.com/INN/largo/pull/1635/) for [issue #1283](https://github.com/INN/largo/issues/1283). - Fixes PHP notices in class `Bootstrap_Walker_Nav_Menu`. [Pull request #1624](https://github.com/INN/largo/pull/1624) and [#1625](https://github.com/INN/largo/pull/1625) for [issue #1623](https://github.com/INN/largo/issues/1623) as part of [issue #1492](https://github.com/INN/largo/issues/1492). - Fixes a regression in the behavior of the Largo Follow widget. [Pull request #1600](https://github.com/INN/largo/pull/1600) for [issue #1599](https://github.com/INN/largo/issues/1599). -- Fixes issue where post excerpt and featured media were not being used for open graph tags on post types that are `is_singular()` but not `is_single()`. [Pull request #1604)(https://github.com/INN/largo/pull/1604) for [issue #1602](https://github.com/INN/largo/issues/1602). +- Fixes issue where post excerpt and featured media were not being used for open graph tags on post types that are `is_singular()` but not `is_single()`. [Pull request #1604](https://github.com/INN/largo/pull/1604) for [issue #1602](https://github.com/INN/largo/issues/1602). +- Prevents `largo_top_term()` from calling `largo_category_and_tags()` when the post ID argument passed to `largo_top_term()` does not match `get_the_ID`'s post ID, because there is presently no way to pass that ID to `largo_category_and_tags()`. [Pull request #1648](https://github.com/INN/largo/pull/1648) for [issue #1647](https://github.com/INN/largo/issues/1647). +- Fixes improper post ID argument passed to `largo_top_term()` in the homepage featured stories zone. [Pull request #1648](https://github.com/INN/largo/pull/1648). - Removes duplicate site title in opengraph tags for non-archive, non-`is_front_page()`, non-`is_singular()` URLs. [Pull request #1604](https://github.com/INN/largo/pull/1604) for [issue #1602](https://github.com/INN/largo/issues/1602). - Removes search form from global nav bar when on the search page, so that there's only one search form. [Pull request #1604](https://github.com/INN/largo/pull/1604). - Cleans up the search page when no query has been entered. [Pull request #1604](https://github.com/INN/largo/pull/1604) for [issue #1603](https://github.com/INN/largo/issues/1603).