%2$s';
if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
$time_string = '';
}
$time_string = sprintf( $time_string,
esc_attr( get_the_date( 'c' ) ),
esc_html( get_the_date() ),
esc_attr( get_the_modified_date( 'c' ) ),
esc_html( get_the_modified_date() )
);
$posted_on = sprintf(
'' . esc_html_x( 'Published on %s', 'post date', 'toujours' ) . '',
'' . $time_string . ''
);
$byline = sprintf(
esc_html_x( 'by %s', 'post author', 'toujours' ),
'' . esc_html( get_the_author() ) . ''
);
echo '' . $posted_on . '' . $byline . ''; // WPCS: XSS OK.
}
endif;
if ( ! function_exists( 'toujours_comment_link' ) ) :
/**
* Prints a link to the comments
*/
function toujours_comment_link() {
if ( ! is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) {
echo '';
comments_popup_link( esc_html__( 'Leave a comment', 'toujours' ), esc_html__( '1 Comment', 'toujours' ), esc_html__( '% Comments', 'toujours' ) );
echo '';
}
}
endif;
if ( ! function_exists( 'toujours_post_format' ) ) :
function toujours_post_format() {
$format = get_post_format();
$formats = get_theme_support( 'post-formats' );
$postformat = '';
if ( $format && in_array( $format, $formats[0] ) ) {
echo sprintf( '%3$s•', // WPCS: XSS OK.
esc_url( get_post_format_link( $format ) ),
sprintf( esc_attr_x( 'All %1$s posts', 'post format archives link', 'toujours' ), get_post_format_string( $format ) ),
esc_html( get_post_format_string( $format ) ) );
}
}
endif;
if ( ! function_exists( 'toujours_entry_footer' ) ) :
/**
* Prints HTML with meta information for the categories, tags and edit post link
*/
function toujours_entry_footer() {
toujours_post_format();
// Hide category and tag text for pages.
if ( 'post' === get_post_type() ) {
/* translators: used between list items, there is a space after the comma */
$categories_list = get_the_category_list( esc_html__( ', ', 'toujours' ) );
/* translators: used between list items, there is a space after the comma */
$tags_list = get_the_tag_list( '', esc_html__( ', ', 'toujours' ) );
if ( $categories_list && toujours_categorized_blog() ) {
printf( '' . esc_html__( 'Categories %1$s', 'toujours' ) . '', $categories_list ); // WPCS: XSS OK.
// if both categories and tags are present, add a divider
if ( $tags_list && ! is_wp_error( $tags_list ) ) {
echo '•';
}
}
if ( $tags_list && ! is_wp_error( $tags_list ) ) {
printf( '' . esc_html__( 'Tags %1$s', 'toujours' ) . '', $tags_list ); // WPCS: XSS OK.
}
}
edit_post_link(
sprintf(
/* translators: %s: Name of current post */
esc_html__( 'Edit %s', 'toujours' ),
the_title( '"', '"', false )
),
'•',''
);
}
endif;
/**
* Returns true if a blog has more than 1 category.
*
* @return bool
*/
function toujours_categorized_blog() {
if ( false === ( $all_the_cool_cats = get_transient( 'toujours_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 = is_countable( $all_the_cool_cats ) ? count( $all_the_cool_cats ) : 0;
set_transient( 'toujours_categories', $all_the_cool_cats );
}
if ( $all_the_cool_cats > 1 ) {
// This blog has more than 1 category so toujours_categorized_blog should return true.
return true;
} else {
// This blog has only 1 category so toujours_categorized_blog should return false.
return false;
}
}
/**
* Flush out the transients used in toujours_categorized_blog.
*/
function toujours_category_transient_flusher() {
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
return;
}
// Like, beat it. Dig?
delete_transient( 'toujours_categories' );
}
add_action( 'edit_category', 'toujours_category_transient_flusher' );
add_action( 'save_post', 'toujours_category_transient_flusher' );