Make WordPress Core

Changeset 21444


Ignore:
Timestamp:
08/05/2012 11:04:32 PM (12 years ago)
Author:
lancewillett
Message:

Twenty Twelve: hide category and tag output in post meta if only 1 term. Props ryanimel, jkudish and fixes #21479.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-content/themes/twentytwelve/functions.php

    r21428 r21444  
    317317    if ( '' != $tag_list ) {
    318318        $utility_text = __( 'This entry was posted in %1$s and tagged %2$s on %3$s by %4$s.', 'twentytwelve' );
    319     } elseif ( '' != $categories_list ) {
     319    } elseif ( '' != $categories_list && twentytwelve_is_categorized_site() ) {
    320320        $utility_text = __( 'This entry was posted in %1$s on %3$s by %4$s.', 'twentytwelve' );
    321321    } else {
     
    334334
    335335/**
     336 * Returns true if a blog has more than one category.
     337 *
     338 * @since Twenty Twelve 1.0
     339 */
     340function twentytwelve_is_categorized_site() {
     341    $non_empty_categories = get_categories( array(
     342        'hide_empty' => 1,
     343    ) );
     344
     345    if ( is_wp_error( $non_empty_categories ) || empty( $non_empty_categories ) || count( $non_empty_categories ) < 1 )
     346        return false;
     347
     348    return true;
     349}
     350
     351/**
    336352 * Extends the default WordPress body class to denote:
    337353 * 1. Using a full-width layout, when no active widgets in the sidebar
Note: See TracChangeset for help on using the changeset viewer.