%2$s';
if ( get_the_time(get_option('date_format')) !== get_the_modified_time(get_option('date_format')) ) {
$time_string = '';
}
$time_string = sprintf( $time_string,
esc_attr( get_the_date(get_option('date_format')) ),
esc_html( get_the_date() ),
esc_attr( get_the_modified_date(get_option('date_format')) ),
esc_html( get_the_modified_date() )
);
$posted_on = sprintf(
/* translators: %s: post date. */
esc_html_x( 'Posted on %s', 'post date', 'alacrity-lite' ),
'' . $time_string . ''
);
$byline = sprintf(
/* translators: %s: post author. */
esc_html_x( 'by %s', 'post author', 'alacrity-lite' ),
'' . esc_html( get_the_author() ) . ''
);
echo '' . $posted_on . ' ' . $byline . ''; // WPCS: XSS OK.
if ( ! is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) {
echo '';
comments_popup_link( __( 'Leave a comment', 'alacrity-lite' ), __( '1 Comment', 'alacrity-lite' ), __( '% Comments', 'alacrity-lite' ) );
echo '';
}
$categories_list = get_the_category_list( esc_html_x( ', ', 'Used between list items, there is a space after the comma.', 'alacrity-lite' ) );
/* translators: used between list items, there is a space after the comma */
$categories_list = get_the_category_list( esc_html__( ', ', 'alacrity-lite' ) );
if ( $categories_list && alacrity_lite_categorized_blog() ) {
/* translators: %s: category name */
printf( '' . esc_html__( 'Posted in %1$s', 'alacrity-lite' ) . '', $categories_list );//WPCS: XSS OK
}
}
endif;
if ( ! function_exists( 'alacrity_lite_entry_footer' ) ) :
/**
* Prints HTML with meta information for the categories, tags and comments.
*/
function alacrity_lite_entry_footer() {
// Hide category and tag text for pages.
if ( 'post' == get_post_type() ) {
/* translators: used between list items, there is a space after the comma */
$tags_list = get_the_tag_list( '', esc_html__( ', ', 'alacrity-lite' ) );
if ( $tags_list && is_single() ) {
/* translators: %s: tag name */
printf( '' . esc_html__( 'Tagged %1$s', 'alacrity-lite' ) . '', $tags_list ); // WPCS: XSS OK.
}
}
edit_post_link( __( 'Edit', 'alacrity-lite' ), '', '' );
}
endif;
/**
* Returns true if a blog has more than 1 category.
*
* @return bool
*/
function alacrity_lite_categorized_blog() {
if ( false === ( $cat_list = get_transient( 'alacrity_lite_categories' ) ) ) {
// Create an array of all the categories that are attached to posts.
$cat_list = get_categories( array(
'fields' => 'ids',
'hide_empty' => 1,
'number' => 2,
) );
// Count the number of categories that are attached to the posts.
$cat_list = count( $cat_list );
set_transient( 'alacrity_lite_categories', $cat_list );
}
if ( $cat_list > 1 ) {
// This blog has more than 1 category so alacrity_lite_categorized_blog should return true.
return true;
} else {
// This blog has only 1 category so alacrity_lite_categorized_blog should return false.
return false;
}
}
/**
* Flush out the transients used in alacrity_lite_categorized_blog.
*/
function alacrity_lite_category_transient_flusher() {
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
return;
}
// Like, beat it. Dig?
delete_transient( 'alacrity_lite_categories' );
}
add_action( 'edit_category', 'alacrity_lite_category_transient_flusher' );
add_action( 'save_post', 'alacrity_lite_category_transient_flusher' );