'' . esc_html__( 'Previous Page', 'alkane' ) . '',
'next_text' => '' . esc_html__( 'Next Page', 'alkane' ) . '',
'before_page_number' => '' . esc_html__( 'Page', 'alkane' ) . ' ',
) );
}
endif;
if ( ! function_exists( 'alkane_the_post_pagination' ) ) :
/**
* Previous/next post navigation.
*
* @return void
*/
function alkane_the_post_pagination() {
// Previous/next post navigation @since 4.1.0.
the_post_navigation( array(
'next_text' => '' . esc_html__( 'Next', 'alkane' ) . ' ' . '%title',
'prev_text' => '' . esc_html__( 'Prev', 'alkane' ) . ' ' . '%title',
) );
}
endif;
if ( ! function_exists( 'alkane_posted_on' ) ) :
/**
* Prints HTML with meta information for the current post-date/time and author.
*/
function alkane_posted_on( $before = '', $after = '' ) {
// No need to display date for sticky posts
if ( alkane_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', 'alkane' ),
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( 'alkane_posted_on_html', $html );
echo $html; // WPCS: XSS OK.
}
endif;
if ( ! function_exists( 'alkane_posted_by' ) ) :
/**
* Prints author.
*/
function alkane_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(
esc_html_x( 'by %s', 'post author', 'alkane' ),
$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( 'alkane_posted_by_html', $html );
echo $html; // WPCS: XSS OK.
}
endif;
if ( ! function_exists( 'alkane_sticky_post' ) ) :
/**
* Prints HTML label for the sticky post.
*/
function alkane_sticky_post( $before = '', $after = '' ) {
// Sticky Post Validation
if ( ! alkane_has_sticky_post() ) {
return;
}
// Sticky Post HTML
$html = sprintf( '%1$s',
esc_html_x( 'Featured', 'sticky post label', 'alkane' )
);
// 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( 'alkane_sticky_post_html', $html );
echo $html; // WPCS: XSS OK.
}
endif;
if ( ! function_exists( 'alkane_post_edit_link' ) ) :
/**
* Prints post edit link.
*
* @return void
*/
function alkane_post_edit_link( $before = '', $after = '' ) {
// Post edit link Validation
if ( alkane_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', 'alkane' )
);
// 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( 'alkane_post_edit_link_html', $html );
echo $html; // WPCS: XSS OK.
}
}
endif;
if ( ! function_exists( 'alkane_post_first_category' ) ) :
/**
* Prints first category for the current post.
*
* @return void
*/
function alkane_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( 'alkane_post_first_category_html', $html, $categories );
echo $html; // WPCS: XSS OK.
}
}
endif;
if ( ! function_exists( 'alkane_entry_footer' ) ) :
/**
* Prints HTML with meta information for the categories, tags and comments.
*/
function alkane_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.', 'alkane' ) );
if ( $categories_list && alkane_categorized_blog() ) {
printf( '' . esc_html__( 'Posted in %1$s', 'alkane' ) . '', $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.', 'alkane' ) );
if ( $tags_list ) {
printf( '' . esc_html__( 'Tagged %1$s', 'alkane' ) . '', $tags_list ); // WPCS: XSS OK.
}
}
edit_post_link( sprintf( esc_html__( 'Edit %1$s', 'alkane' ), '' . the_title_attribute( 'echo=0' ) . '' ), '', '' );
}
endif;
/**
* Returns true if a blog has more than 1 category.
*
* @return bool
*/
function alkane_categorized_blog() {
if ( false === ( $all_the_cool_cats = get_transient( 'alkane_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( 'alkane_categories', $all_the_cool_cats );
}
if ( $all_the_cool_cats > 1 ) {
// This blog has more than 1 category so alkane_categorized_blog should return true.
return true;
} else {
// This blog has only 1 category so alkane_categorized_blog should return false.
return false;
}
}
/**
* Flush out the transients used in alkane_categorized_blog.
*/
function alkane_category_transient_flusher() {
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
return;
}
// Like, beat it. Dig?
delete_transient( 'alkane_categories' );
}
add_action( 'edit_category', 'alkane_category_transient_flusher' );
add_action( 'save_post', 'alkane_category_transient_flusher' );
if ( ! function_exists( 'alkane_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 string $size Size of the image.
* @return void
*/
function alkane_post_thumbnail( $size = 'alkane-featured' ) {
// Post Thumbnail HTML
$html = '';
// Post Thumbnail Validation
if ( alkane_has_post_thumbnail() ) {
// Post Thumbnail HTML
$html = sprintf( '',
esc_attr( esc_url( get_the_permalink() ) ),
alkane_post_thumbnail_background( 'alkane-featured', false )
);
}
/**
* Filters the Post Thumbnail HTML.
*
* @param string $html Post Thumbnail HTML.
*/
$html = apply_filters( 'alkane_post_thumbnail_html', $html );
// Print HTML
if ( ! empty ( $html ) ) {
echo $html; // WPCS: XSS OK.
}
}
endif;
/**
* Post Thumbnail as Background
*
* @param string $size Size of the image.
* @return void
*/
function alkane_post_thumbnail_background( $size = 'alkane-site-hero', $echo = true ) {
// Post thumbnail check
if ( ! alkane_has_post_thumbnail() ) {
return;
}
// Global
global $post;
// Post thumbnail attributes
$image_attributes = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), $size );
// Post thumbnail background
$post_thumbnail_background = sprintf( 'style="background-image: url(%1$s);"', esc_attr( esc_url( $image_attributes[0] ) ) );
// Return || Echo
if ( true === $echo ) {
echo $post_thumbnail_background;
} else {
return $post_thumbnail_background;
}
}
/**
* A helper conditional function.
* Whether there is a post thumbnail and post is not password protected.
*
* @return bool
*/
function alkane_has_post_thumbnail() {
/**
* Post Thumbnail Filter
* @return bool
*/
return apply_filters( 'alkane_has_post_thumbnail', (bool) ( ! post_password_required() && has_post_thumbnail() ) );
}
/**
* A helper conditional function.
* Post is Sticky or Not
*
* @return bool
*/
function alkane_has_sticky_post() {
/**
* Sticky Post Filter
* @return bool
*/
return apply_filters( 'alkane_has_sticky_post', (bool) ( is_sticky() && is_home() && ! is_paged() ) );
}
/**
* A helper conditional function.
* Post has Edit link or Not
*
* @return bool
*/
function alkane_has_post_edit_link() {
/**
* Post Edit Link Filter
* @return bool
*/
$post_edit_link = get_edit_post_link();
return apply_filters( 'alkane_has_post_edit_link', (bool) ( ! empty( $post_edit_link ) ) );
}
/**
* A helper conditional function.
* Theme has Excerpt or Not
*
* @return bool
*/
function alkane_has_excerpt() {
// Post Excerpt
$post_excerpt = get_the_excerpt();
/**
* Excerpt Filter
* @return bool
*/
return apply_filters( 'alkane_has_excerpt', (bool) ! empty ( $post_excerpt ) );
}
/**
* A helper conditional function.
* Theme has Sidebar or Not
*
* @return bool
*/
function alkane_has_sidebar() {
/**
* Sidebar Filter
* @return bool
*/
return apply_filters( 'alkane_has_sidebar', (bool) is_active_sidebar( 'sidebar-1' ) );
}
/**
* Display the layout classes.
*
* @param string $section - Name of the section to retrieve the classes
* @return void
*/
function alkane_layout_class( $section = 'content' ) {
// Sidebar Position
$sidebar_position = alkane_mod( 'alkane_sidebar_position' );
if ( ! alkane_has_sidebar() ) {
$sidebar_position = 'no';
}
// Layout Skeleton
$layout_skeleton = array(
'content' => array(
'content' => 'col-xxl-12',
),
'content-sidebar' => array(
'content' => 'col-12 col-sm-12 col-md-12 col-lg-8 col-xl-8 col-xxl-8',
'sidebar' => 'col-12 col-sm-12 col-md-12 col-lg-4 col-xl-4 col-xxl-4',
),
'sidebar-content' => array(
'content' => 'col-12 col-sm-12 col-md-12 col-lg-8 col-xl-8 col-xxl-8 push-lg-4 push-xl-4 push-xxl-4',
'sidebar' => 'col-12 col-sm-12 col-md-12 col-lg-4 col-xl-4 col-xxl-4 pull-lg-8 pull-xl-8 pull-xxl-8',
),
'sidebar-content-rtl' => array(
'content' => 'col-12 col-sm-12 col-md-12 col-lg-8 col-xl-8 col-xxl-8 pull-lg-4 pull-xl-4 pull-xxl-4',
'sidebar' => 'col-12 col-sm-12 col-md-12 col-lg-4 col-xl-4 col-xxl-4 push-lg-8 push-xl-8 push-xxl-8',
),
);
// Layout Classes
switch( $sidebar_position ) {
case 'no':
$layout_classes = $layout_skeleton['content']['content'];
break;
case 'left':
$layout_classes = ( 'sidebar' === $section )? $layout_skeleton['sidebar-content']['sidebar'] : $layout_skeleton['sidebar-content']['content'];
if ( is_rtl() ) {
$layout_classes = ( 'sidebar' === $section )? $layout_skeleton['sidebar-content-rtl']['sidebar'] : $layout_skeleton['sidebar-content-rtl']['content'];
}
break;
case 'right':
default:
$layout_classes = ( 'sidebar' === $section )? $layout_skeleton['content-sidebar']['sidebar'] : $layout_skeleton['content-sidebar']['content'];
}
echo esc_attr( $layout_classes );
}