';
}
endif;
/**
* Returns true if a blog has more than 1 category
*/
function quadro_categorized_blog() {
if ( false === ( $all_the_cool_cats = get_transient( 'quadro_categories' ) ) ) {
// Create an array of all the categories that are attached to posts.
$all_the_cool_cats = get_categories( array(
'fields' => 'ids',
'hide_empty' => 1,
// We only need to know if there is more than one category.
'number' => 2,
) );
// Count the number of categories that are attached to the posts.
$all_the_cool_cats = count( $all_the_cool_cats );
set_transient( 'quadro_categories', $all_the_cool_cats );
}
if ( $all_the_cool_cats > 1 ) {
// This blog has more than 1 category so quadro_categorized_blog should return true.
return true;
} else {
// This blog has only 1 category so quadro_categorized_blog should return false.
return false;
}
}
/**
* Print Categories and Taggs for single posts
*/
function quadro_cats_and_tags() {
/* translators: used between list items, there is a space after the comma */
$category_list = get_the_category_list( __( ', ', 'quadro' ) );
/* translators: used between list items, there is a space after the comma */
$tag_list = get_the_tag_list( '', __( ', ', 'quadro' ) );
if ( ! quadro_categorized_blog() ) {
// This blog only has 1 category so we just need to worry about tags in the meta text
if ( '' != $tag_list ) {
$meta_text = __( 'Tagged: %2$s.', 'quadro' );
}
} else {
// But this blog has loads of categories so we should probably display them here
if ( '' != $tag_list ) {
$meta_text = __( 'This entry was posted in %1$s. Tagged: %2$s.', 'quadro' );
} else {
$meta_text = __( 'This entry was posted in %1$s.', 'quadro' );
}
} // end check for categories on this blog
printf(
$meta_text,
$category_list,
$tag_list
);
}
/**
* Print only categories
*/
function quadro_cats() {
$categories_list = get_the_category_list( __( ' ', 'quadro' ) );
if ( $categories_list && quadro_categorized_blog() ) { ?>
comment_type || 'trackback' == $comment->comment_type ) : ?>