Add pluggable function wrappers to inc/template-tags.php
This commit is contained in:
parent
eda69c0385
commit
c75682937e
|
@ -7,11 +7,12 @@
|
|||
* @package understrap
|
||||
*/
|
||||
|
||||
if ( ! function_exists( 'understrap_posted_on' ) ) :
|
||||
|
||||
/**
|
||||
* Prints HTML with meta information for the current post-date/time and author.
|
||||
*/
|
||||
function understrap_posted_on() {
|
||||
if ( ! function_exists ( 'understrap_posted_on' ) ) {
|
||||
function understrap_posted_on() {
|
||||
$time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';
|
||||
if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
|
||||
$time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time><time class="updated" datetime="%3$s"> (%4$s) </time>';
|
||||
|
@ -31,14 +32,15 @@ function understrap_posted_on() {
|
|||
'<span class="author vcard"><a class="url fn n" href="' . esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . '">' . esc_html( get_the_author() ) . '</a></span>'
|
||||
);
|
||||
echo '<span class="posted-on">' . $posted_on . '</span><span class="byline"> ' . $byline . '</span>'; // WPCS: XSS OK.
|
||||
}
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( ! function_exists( 'understrap_entry_footer' ) ) :
|
||||
|
||||
/**
|
||||
* Prints HTML with meta information for the categories, tags and comments.
|
||||
*/
|
||||
function understrap_entry_footer() {
|
||||
if ( ! function_exists ( 'understrap_entry_footer' ) ) {
|
||||
function understrap_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 */
|
||||
|
@ -66,15 +68,17 @@ function understrap_entry_footer() {
|
|||
'<span class="edit-link">',
|
||||
'</span>'
|
||||
);
|
||||
}
|
||||
}
|
||||
endif;
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if a blog has more than 1 category.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function understrap_categorized_blog() {
|
||||
if ( ! function_exists ( 'understrap_categorized_blog' ) ) {
|
||||
function understrap_categorized_blog() {
|
||||
if ( false === ( $all_the_cool_cats = get_transient( 'understrap_categories' ) ) ) {
|
||||
// Create an array of all the categories that are attached to posts.
|
||||
$all_the_cool_cats = get_categories( array(
|
||||
|
@ -94,18 +98,22 @@ function understrap_categorized_blog() {
|
|||
// This blog has only 1 category so components_categorized_blog should return false.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Flush out the transients used in understrap_categorized_blog.
|
||||
*/
|
||||
function understrap_category_transient_flusher() {
|
||||
add_action( 'edit_category', 'understrap_category_transient_flusher' );
|
||||
add_action( 'save_post', 'understrap_category_transient_flusher' );
|
||||
|
||||
if ( ! function_exists ( 'understrap_category_transient_flusher' ) ) {
|
||||
function understrap_category_transient_flusher() {
|
||||
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
|
||||
return;
|
||||
}
|
||||
// Like, beat it. Dig?
|
||||
delete_transient( 'understrap_categories' );
|
||||
}
|
||||
}
|
||||
add_action( 'edit_category', 'understrap_category_transient_flusher' );
|
||||
add_action( 'save_post', 'understrap_category_transient_flusher' );
|
||||
|
||||
|
|
Reference in New Issue