diff --git a/changelog.md b/changelog.md index 05deeaef0..abcfa2fc1 100644 --- a/changelog.md +++ b/changelog.md @@ -18,12 +18,14 @@ Thanks to Mike Schinkel for his work on [pull request 1469](https://github.com/I ## Changes - Fixes numerous undefined variable errors. - Users who have the capability to edit a given post will see the edit link on the frontend, where before users with the capability to edit published posts in general saw the link to edit the post in the frontend. [PR #1559](https://github.com/INN/largo/pull/1559) for [issue #1543](https://github.com/INN/largo/issues/1543). +- Largo now uses WordPress' `title-tag` support for `` tag output, which means that site title tags shoud now be modifiable by plugins. [PR #]() for [issue 1470](https://github.com/INN/largo/issues/1470). ### Removed - Removes the default inclusion of Google Analytics with INN's Largo Project IDs. [PR #1502](https://github.com/INN/largo/pull/1502) as part of [issue #1495](https://github.com/INN/largo/issues/1495), and by request. - Removes the INN Member RSS widget, because the RSS feed it draws from is no longer supported or maintained by INN. Because the RSS feed was occasionally empty, the widget would result in 500 errors. [RP #1535](https://github.com/INN/largo/pulls/1535) for [issue #1511](https://github.com/INN/largo/issues/1511) and [#893](https://github.com/INN/largo/issues/893). - Removes lingering traces of the Largo Featured Widget. [PR #1563](https://github.com/INN/largo/pull/1563) and [#1469](https://github.com/INN/largo/pull/1469) for [issue 1467](https://github.com/INN/largo/issues/1467), from Github user [mikeschinkel](https://github.com/mikeschinkel). - Removes many uses of `extract()` in widgets and theme functions, and improves code quality in widgets. +- Removes the `<title>` element from `header.php`, since Largo declares `title-tag` theme support. [PR #]() for [issue 1470](https://github.com/INN/largo/issues/1470). ### Upgrade notices - If your child theme has significant custom styling, or has custom post templates, your theme may need to provide additional styles to ensure Gutenberg compatibility. diff --git a/header.php b/header.php index 400bdd44b..362f6e963 100644 --- a/header.php +++ b/header.php @@ -18,30 +18,26 @@ * @since 0.1 */ ?> - <title> - <?php - global $page, $paged; - wp_title( '|', true, 'right' ); - bloginfo( 'name' ); // Add the blog name. - - // Add the blog description for the home/front page. - $site_description = get_bloginfo( 'description', 'display' ); - if ( $site_description && ( is_home() || is_front_page() ) ) - echo " | $site_description"; - - // Add a page number if necessary: - if ( $paged >= 2 || $page >= 2 ) - echo ' | ' . 'Page ' . max( $paged, $page ); - ?> - + tag on WP pre 4.1 + // @link https://make.wordpress.org/core/2014/10/29/title-tags-in-4-1/ + // @since 0.6 + if ( ! function_exists( '_wp_render_title_tag' ) ) { + printf( + '%1$s', + wp_title( '|', false, 'right' ) + ); + } + ?> - + wp_head(); + ?> > diff --git a/inc/featured-media.php b/inc/featured-media.php index 5b014b0ec..39f63b67c 100644 --- a/inc/featured-media.php +++ b/inc/featured-media.php @@ -638,12 +638,14 @@ function largo_fetch_video_oembed() { function largo_featured_media_post_classes( $classes ) { global $post; - $featured = largo_get_featured_media( $post->ID ); - if ( !empty( $featured ) ) { - $classes = array_merge( $classes, array( - 'featured-media', - 'featured-media-' . $featured['type'] - )); + if ( is_a( $post, 'WP_Post' ) ) { + $featured = largo_get_featured_media( $post->ID ); + if ( !empty( $featured ) ) { + $classes = array_merge( $classes, array( + 'featured-media', + 'featured-media-' . $featured['type'] + )); + } } return $classes; diff --git a/inc/open-graph.php b/inc/open-graph.php index 5192caf76..b942a216c 100644 --- a/inc/open-graph.php +++ b/inc/open-graph.php @@ -95,3 +95,59 @@ function largo_opengraph() { } } add_action( 'wp_head', 'largo_opengraph' ); + +/** + * Filter wp_title() to add our custom metadata + * + * @since 0.6 + * @link https://github.com/INN/largo/issues/1470 + * @param Array $parts An array of title parts. + * @return Array. + */ +function largo_wp_title_parts_filter( $parts ) { + global $page, $paged; + + // Add the blog description for the home/front page. + if ( is_home() || is_front_page() ) { + $site_description = get_bloginfo( 'description', 'display' ); + if ( ! empty ( $site_description ) ) { + $parts[] = $site_description; + } + } + + // Add a page number if necessary: + if ( isset( $paged ) || isset( $page ) ) { + if ( $paged >= 2 || $page >= 2 ) { + $parts[] = sprintf( + // translators: %1$s is the page number. + __( 'Page %1$s' , 'largo' ), + max( $paged, $page ) + ); + } + } + + $parts[] = get_bloginfo( 'name' ); // Add the blog name. + error_log(var_export( $parts, true)); + + + foreach ( $parts as $i => $part ) { + if ( empty( $part ) ) { + unset( $parts[$i] ); + } + } + + add_filter( 'wp_title', 'largo_wp_title_filter', 10, 3 ); + + return $parts; +} +add_filter( 'wp_title_parts', 'largo_wp_title_parts_filter' ); + +/** + * Return to using | + * + * @since Largo 0.6 + * @link https://developer.wordpress.org/reference/functions/wp_get_document_title/ + */ +add_filter( 'document_title_separator', function( $sep ) { + return '|'; +}); diff --git a/inc/related-content.php b/inc/related-content.php index c7cba0f16..f1a57368e 100644 --- a/inc/related-content.php +++ b/inc/related-content.php @@ -91,7 +91,8 @@ function _tags_associated_with_category( $cat_id, $max = 5 ) { $tag_keys = array_keys( $tags ); } else { - $tag_keys = array_splice( array_keys( $tags ), 0, $max ); + $temporary_array_keys = array_keys( $tags ); + $tag_keys = array_splice( $temporary_array_keys, 0, $max ); } // Create an array of the selected tag objects @@ -410,12 +411,14 @@ function largo_top_term( $options = array() ) { */ function largo_post_class_top_term( $classes ) { global $post; - $top_term = get_post_meta( $post->ID, 'top_term', TRUE ); - $term = get_term_by( 'id', $top_term, 'post_tag' ); + if ( is_a( $post, 'WP_Post' ) ) { + $top_term = get_post_meta( $post->ID, 'top_term', TRUE ); + $term = get_term_by( 'id', $top_term, 'post_tag' ); - // Don't output the class .top-term-- if there isn't a top term saved - if ( !empty( $term ) ) { - $classes[] = 'top-term-' . $term->taxonomy . '-' . $term->slug; + // Don't output the class .top-term-- if there isn't a top term saved + if ( !empty( $term ) ) { + $classes[] = 'top-term-' . $term->taxonomy . '-' . $term->slug; + } } return $classes; diff --git a/partials/archive-category-primary-feature.php b/partials/archive-category-primary-feature.php index 34c435a76..490d4d3d9 100644 --- a/partials/archive-category-primary-feature.php +++ b/partials/archive-category-primary-feature.php @@ -1,7 +1,7 @@
ID); ?>> ID) ) { ?>
- ID, 'rect_thumb'); ?> + ID, 'rect_thumb'); ?>
@@ -10,7 +10,7 @@

- post_title; ?>

diff --git a/partials/archive-category-secondary-feature.php b/partials/archive-category-secondary-feature.php index 60cc614a4..d4789012e 100644 --- a/partials/archive-category-secondary-feature.php +++ b/partials/archive-category-secondary-feature.php @@ -1,14 +1,14 @@