str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $wp_query->max_num_pages
) );
}
endif;
if ( ! function_exists( 'alleria_post_nav' ) ) :
/**
* Display navigation to next/previous post when applicable.
*/
function alleria_post_nav() {
// Don't print empty markup if there's nowhere to navigate.
$previous = ( is_attachment() ) ? get_post( get_post()->post_parent ) : get_adjacent_post( false, '', true );
$next = get_adjacent_post( false, '', false );
if ( ! $next && ! $previous ) {
return;
}
?>
%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(
_x( 'Posted on %s', 'post date', 'alleria' ),
'' . $time_string . ''
);
$byline = sprintf(
_x( 'by %s', 'post author', 'alleria' ),
'' . esc_html( get_the_author() ) . ''
);
echo '' . $posted_on . ' ' . $byline . '';
}
endif;
if ( ! function_exists( 'alleria_entry_footer' ) ) :
/**
* Prints HTML with meta information for the categories, tags and comments.
*/
function alleria_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 */
/* translators: used between list items, there is a space after the comma */
$tags_list = get_the_tag_list( '', __( ', ', 'alleria' ) );
if ( $tags_list ) {
printf( '' . __( '%1$s', 'alleria' ) . '', $tags_list );
}
}
}
endif;
/**
* Returns true if a blog has more than 1 category.
*
* @return bool
*/
function alleria_categorized_blog() {
if ( false === ( $all_the_cool_cats = get_transient( 'alleria_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( 'alleria_categories', $all_the_cool_cats );
}
if ( $all_the_cool_cats > 1 ) {
// This blog has more than 1 category so alleria_categorized_blog should return true.
return true;
} else {
// This blog has only 1 category so alleria_categorized_blog should return false.
return false;
}
}
if ( ! function_exists( 'alleria_the_attached_image' ) ) :
/**
* Print the attached image with a link to the next attached image.
*
* @since Twenty Fourteen 1.0
*/
function alleria_the_attached_image() {
$post = get_post();
/**
* Filter the default Twenty Fourteen attachment size.
*
* @since Twenty Fourteen 1.0
*
* @param array $dimensions {
* An array of height and width dimensions.
*
* @type int $height Height of the image in pixels. Default 810.
* @type int $width Width of the image in pixels. Default 810.
* }
*/
$attachment_size = apply_filters( 'alleria_attachment_size', array( 810, 810 ) );
$next_attachment_url = wp_get_attachment_url();
/*
* Grab the IDs of all the image attachments in a gallery so we can get the URL
* of the next adjacent image in a gallery, or the first image (if we're
* looking at the last image in a gallery), or, in a gallery of one, just the
* link to that image file.
*/
$attachment_ids = get_posts( array(
'post_parent' => $post->post_parent,
'fields' => 'ids',
'numberposts' => -1,
'post_status' => 'inherit',
'post_type' => 'attachment',
'post_mime_type' => 'image',
'order' => 'ASC',
'orderby' => 'menu_order ID',
) );
// If there is more than 1 attachment in a gallery...
if ( count( $attachment_ids ) > 1 ) {
foreach ( $attachment_ids as $attachment_id ) {
if ( $attachment_id == $post->ID ) {
$next_id = current( $attachment_ids );
break;
}
}
// get the URL of the next image attachment...
if ( $next_id ) {
$next_attachment_url = get_attachment_link( $next_id );
}
// or get the URL of the first image attachment.
else {
$next_attachment_url = get_attachment_link( array_shift( $attachment_ids ) );
}
}
printf( '%2$s',
esc_url( $next_attachment_url ),
wp_get_attachment_image( $post->ID, $attachment_size )
);
}
endif;
/**
* Flush out the transients used in alleria_categorized_blog.
*/
function alleria_category_transient_flusher() {
// Like, beat it. Dig?
delete_transient( 'alleria_categories' );
}
add_action( 'edit_category', 'alleria_category_transient_flusher' );
add_action( 'save_post', 'alleria_category_transient_flusher' );