';
}
endif;
if ( ! function_exists( 'gaff_lite_print_post_meta_footer' ) ) :
/**
* Prints HTML with meta information for the categories, tags.
*
* @since 1.0.0
*/
function gaff_lite_print_post_meta_footer() {
// Do nothing for pages.
if ( 'post' !== get_post_type() ) {
return;
}
$tags_list = get_the_tag_list( '', '' );
if ( $tags_list ) {
echo '';
}
}
endif;
/**
* Returns true if a blog has more than 1 category.
*
* @return bool
*/
function gaff_lite_categorized_blog() {
if ( false === ( $all_the_cool_cats = get_transient( 'gaff_lite_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( 'gaff_lite_categories', $all_the_cool_cats );
}
if ( $all_the_cool_cats > 1 ) {
// This blog has more than 1 category so gaff_lite_categorized_blog should return true.
return true;
} else {
// This blog has only 1 category so gaff_lite_categorized_blog should return false.
return false;
}
}
/**
* Flush out the transients used in gaff_lite_categorized_blog.
*/
function gaff_lite_category_transient_flusher() {
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
return;
}
// Like, beat it. Dig?
delete_transient( 'gaff_lite_categories' );
}
add_action( 'edit_category', 'gaff_lite_category_transient_flusher' );
add_action( 'save_post', 'gaff_lite_category_transient_flusher' );
if ( ! function_exists( 'gaff_lite_print_post_author' ) ) :
/**
* Print post author info on single blog post page.
*
* @since 1.0.0
*/
function gaff_lite_print_post_author() {
if ( 'post' !== get_post_type() ) {
return;
}
global $post;
$author_ID = $post->post_author;
$avatar = get_avatar( $author_ID, 96 );
$name = get_the_author_meta( 'display_name', $author_ID );
$desc = get_the_author_meta( 'description', $author_ID );
$posts_url = get_author_posts_url( $author_ID );
// HTML
$html = '
';
echo $html;
}
endif;
if ( ! function_exists( 'gaff_lite_print_the_content' ) ) :
/**
* Print custom the_content(). Combines excerpt, read more link
* and the content into one function.
*
* - Prints automatically trimmed excerpt from the content as default.
* - If read more tag is set, prints the content and read more tag.
* - If custom excerpt is set, prints custom excerpt.
*
* Also includes wp_link_pages().
* @see https://codex.wordpress.org/Function_Reference/wp_link_pages
*
* @since 1.0.0
*/
function gaff_lite_print_the_content() {
global $post;
// Posts loop pages
if ( is_home() || is_archive() || is_search() || is_page_template( 'page-templates/blog.php') || is_page_template( 'page-templates/home.php' ) ) {
if ( strpos( $post->post_content, '' ) ) {
the_content( '' );
echo '