'' . esc_html__( 'Previous Page', 'allium' ) . '',
'next_text' => '' . esc_html__( 'Next Page', 'allium' ) . '',
'before_page_number' => '' . esc_html__( 'Page', 'allium' ) . ' ',
) );
}
endif;
if ( ! function_exists( 'allium_the_post_pagination' ) ) :
/**
* Previous/next post navigation.
*
* @return void
*/
function allium_the_post_pagination() {
// Previous/next post navigation @since 4.1.0.
the_post_navigation( array(
'next_text' => '' . esc_html__( 'Next', 'allium' ) . ' ' . '%title',
'prev_text' => '' . esc_html__( 'Prev', 'allium' ) . ' ' . '%title',
) );
}
endif;
if ( ! function_exists( 'allium_posted_on' ) ) :
/**
* Prints HTML with meta information for the current post-date/time and author.
*/
function allium_posted_on( $before = '', $after = '' ) {
// No need to display date for sticky posts
if ( allium_has_sticky_post() ) {
return;
}
// Time String
$time_string = '';
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
$posted_on = sprintf( '%1$s%3$s',
esc_html_x( 'Posted on', 'post date', 'allium' ),
esc_url( get_permalink() ),
$time_string
);
// Posted On HTML
$html = '' . $posted_on . ''; // // WPCS: XSS OK.
// Posted On HTML Before After
$html = $before . $html . $after; // WPCS: XSS OK.
/**
* Filters the Posted On HTML.
*
* @param string $html Posted On HTML.
*/
$html = apply_filters( 'allium_posted_on_html', $html );
echo $html; // WPCS: XSS OK.
}
endif;
if ( ! function_exists( 'allium_posted_by' ) ) :
/**
* Prints author.
*/
function allium_posted_by( $before = '', $after = '' ) {
// Global Post
global $post;
// We need to get author meta data from both inside/outside the loop.
$post_author_id = get_post_field( 'post_author', $post->ID );
// Post Author
$post_author = sprintf( '%2$s',
esc_url( get_author_posts_url( get_the_author_meta( 'ID', $post_author_id ) ) ),
esc_html( get_the_author_meta( 'display_name', $post_author_id ) )
);
// Byline
$byline = sprintf(
/* translators: %s: post author */
esc_html_x( 'by %s', 'post author', 'allium' ),
$post_author
);
// Posted By HTML
$html = '' . $byline . ''; // WPCS: XSS OK.
// Posted By HTML Before After
$html = $before . $html . $after; // WPCS: XSS OK.
/**
* Filters the Posted By HTML.
*
* @param string $html Posted By HTML.
*/
$html = apply_filters( 'allium_posted_by_html', $html );
echo $html; // WPCS: XSS OK.
}
endif;
if ( ! function_exists( 'allium_sticky_post' ) ) :
/**
* Prints HTML label for the sticky post.
*/
function allium_sticky_post( $before = '', $after = '' ) {
// Sticky Post Validation
if ( ! allium_has_sticky_post() ) {
return;
}
// Sticky Post HTML
$html = sprintf( '%1$s',
esc_html_x( 'Featured', 'sticky post label', 'allium' )
);
// Sticky Post HTML Before After
$html = $before . $html . $after; // WPCS: XSS OK.
/**
* Filters the Sticky Post HTML.
*
* @param string $html Sticky Post HTML.
*/
$html = apply_filters( 'allium_sticky_post_html', $html );
echo $html; // WPCS: XSS OK.
}
endif;
if ( ! function_exists( 'allium_post_edit_link' ) ) :
/**
* Prints post edit link.
*
* @return void
*/
function allium_post_edit_link( $before = '', $after = '' ) {
// Post edit link Validation
if ( allium_has_post_edit_link() ) {
// Post Edit Link
$post_edit_link = sprintf( '%1$s%3$s',
esc_html( the_title_attribute( 'echo=0' ) ),
esc_url( get_edit_post_link() ),
esc_html_x( 'Edit', 'post edit link label', 'allium' )
);
// Post Edit Link HTML
$html = '' . $post_edit_link . '';
// Post Edit Link HTML Before After
$html = $before . $html . $after; // WPCS: XSS OK.
/**
* Filters the Post Edit Link HTML.
*
* @param string $html Post Edit Link HTML.
*/
$html = apply_filters( 'allium_post_edit_link_html', $html );
echo $html; // WPCS: XSS OK.
}
}
endif;
if ( ! function_exists( 'allium_post_first_category' ) ) :
/**
* Prints first category for the current post.
*
* @return void
*/
function allium_post_first_category( $before = '', $after = '' ) {
// An array of categories to return for the post.
$categories = get_the_category();
if ( $categories[0] ) {
// Post First Category HTML
$html = sprintf( '%3$s',
esc_attr( esc_url( get_category_link( $categories[0]->term_id ) ) ),
esc_attr( $categories[0]->cat_name ),
esc_html( $categories[0]->cat_name )
);
// Post First Category HTML Before After
$html = $before . $html . $after; // WPCS: XSS OK.
/**
* Filters the Post First Category HTML.
*
* @param string $html Post First Category HTML.
* @param array $categories An array of categories to return for the post.
*/
$html = apply_filters( 'allium_post_first_category_html', $html, $categories );
echo $html; // WPCS: XSS OK.
}
}
endif;
if ( ! function_exists( 'allium_read_more_link' ) ) :
/**
* Prints Read More Link.
*/
function allium_read_more_link() {
// Read More Label
$read_more_label = allium_mod( 'allium_read_more_label' );
// Read More Link
$read_more_link = sprintf( '%2$s',
esc_url( get_permalink() ),
esc_html( $read_more_label )
);
// Read More HTML
$html = '
' . $read_more_link . '
'; // // WPCS: XSS OK.
/**
* Filters the Read More HTML.
*
* @param string $html Read More HTML.
*/
$html = apply_filters( 'allium_read_more_html', $html );
echo $html; // WPCS: XSS OK.
}
endif;
if ( ! function_exists( 'allium_entry_footer' ) ) :
/**
* Prints HTML with meta information for the categories, tags and comments.
*/
function allium_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 */
$categories_list = get_the_category_list( _x(', ', 'Used between category, there is a space after the comma.', 'allium' ) );
if ( $categories_list && allium_categorized_blog() ) {
printf(
/* translators: 1: posted in label. 2: list of categories. */
'%1$s %2$s',
esc_html__( 'Posted in:', 'allium' ),
$categories_list
); // WPCS: XSS OK.
}
/* translators: used between list items, there is a space after the comma */
$tags_list = get_the_tag_list( '', _x(', ', 'Used between tag, there is a space after the comma.', 'allium' ) );
if ( $tags_list ) {
printf(
/* translators: 1: posted in label. 2: list of tags. */
'%1$s %2$s',
esc_html__( 'Tags:', 'allium' ),
$tags_list
); // WPCS: XSS OK.
}
}
// Edit post link.
edit_post_link(
sprintf(
wp_kses(
/* translators: %s: Name of current post. Only visible to screen readers. */
__( 'Edit %s', 'allium' ),
array(
'span' => array(
'class' => array(),
),
)
),
get_the_title()
),
'',
''
);
}
endif;
/**
* Returns true if a blog has more than 1 category.
*
* @return bool
*/
function allium_categorized_blog() {
if ( false === ( $all_the_cool_cats = get_transient( 'allium_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( 'allium_categories', $all_the_cool_cats );
}
if ( $all_the_cool_cats > 1 ) {
// This blog has more than 1 category so allium_categorized_blog should return true.
return true;
} else {
// This blog has only 1 category so allium_categorized_blog should return false.
return false;
}
}
/**
* Flush out the transients used in allium_categorized_blog.
*/
function allium_category_transient_flusher() {
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
return;
}
// Like, beat it. Dig?
delete_transient( 'allium_categories' );
}
add_action( 'edit_category', 'allium_category_transient_flusher' );
add_action( 'save_post', 'allium_category_transient_flusher' );
if ( ! function_exists( 'allium_post_thumbnail' ) ) :
/**
* Display an optional post thumbnail.
*
* Wraps the post thumbnail in an anchor element on index
* views, or a div element when on single views.
*
* @param array $args
* @return void
*/
function allium_post_thumbnail( $args = array() ) {
// Defaults
$defaults = array (
'size' => 'allium-featured',
'class' => 'entry-image-wrapper',
);
// Parse incoming $args into an array and merge it with $defaults
$args = wp_parse_args( $args, $defaults );
// Post Thumbnail HTML
$html = '';
// Post Thumbnail Validation
if ( allium_has_post_thumbnail() ) {
// Post Thumbnail HTML
$html = sprintf( '