From d21e5fe2320a1cc17f99330319431c8c27a3ad41 Mon Sep 17 00:00:00 2001 From: Lance Willett Date: Sun, 5 Aug 2012 23:04:32 +0000 Subject: [PATCH] Twenty Twelve: hide category and tag output in post meta if only 1 term. Props ryanimel, jkudish and fixes #21479. git-svn-id: https://develop.svn.wordpress.org/trunk@21444 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-content/themes/twentytwelve/functions.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/wp-content/themes/twentytwelve/functions.php b/wp-content/themes/twentytwelve/functions.php index b4b9ba45df..b886af0c40 100644 --- a/wp-content/themes/twentytwelve/functions.php +++ b/wp-content/themes/twentytwelve/functions.php @@ -316,7 +316,7 @@ function twentytwelve_entry_meta() { // Translators: 1 is category, 2 is tag, 3 is the date and 4 is the author's name. if ( '' != $tag_list ) { $utility_text = __( 'This entry was posted in %1$s and tagged %2$s on %3$s by %4$s.', 'twentytwelve' ); - } elseif ( '' != $categories_list ) { + } elseif ( '' != $categories_list && twentytwelve_is_categorized_site() ) { $utility_text = __( 'This entry was posted in %1$s on %3$s by %4$s.', 'twentytwelve' ); } else { $utility_text = __( 'This entry was posted on %3$s by %4$s.', 'twentytwelve' ); @@ -332,6 +332,22 @@ function twentytwelve_entry_meta() { } endif; +/** + * Returns true if a blog has more than one category. + * + * @since Twenty Twelve 1.0 + */ +function twentytwelve_is_categorized_site() { + $non_empty_categories = get_categories( array( + 'hide_empty' => 1, + ) ); + + if ( is_wp_error( $non_empty_categories ) || empty( $non_empty_categories ) || count( $non_empty_categories ) < 1 ) + return false; + + return true; +} + /** * Extends the default WordPress body class to denote: * 1. Using a full-width layout, when no active widgets in the sidebar