WordPress.org

Make WordPress Core

Ticket #21479: 21479.2.patch

File 21479.2.patch, 1.4 KB (added by jkudish, 6 years ago)
  • wp-content/themes/twentytwelve/functions.php

     
    316316        // Translators: 1 is category, 2 is tag, 3 is the date and 4 is the author's name.
    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 {
    322322                $utility_text = __( 'This entry was posted on %3$s by %4$s.', 'twentytwelve' );
     
    333333endif;
    334334
    335335/**
     336 * Returns true if a blog has more than one category.
     337 *
     338 * (Cribbed from _s theme.)
     339 *
     340 * @since Twenty Twelve 1.0
     341 */
     342function twentytwelve_is_categorized_site() {
     343        $non_empty_categories = get_categories( array(
     344                'hide_empty' => 1,
     345        ) );
     346
     347        if ( is_wp_error( $non_empty_categories ) || empty( $non_empty_categories ) || count( $non_empty_categories ) < 1 )
     348                return false;
     349
     350        return true;
     351}
     352
     353
     354/**
    336355 * Extends the default WordPress body class to denote:
    337356 * 1. Using a full-width layout, when no active widgets in the sidebar
    338357 *    or full-width template.