Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Custom template tags for this theme.
- *
- * Eventually, some of the functionality here could be replaced by core features.
- *
- * @package annina
- */
- if ( ! function_exists( 'annina_post_nav' ) ) :
- /**
- * Display navigation to next/previous post when applicable.
- */
- function annina_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;
- }
- ?>
- <nav class="navigation post-navigation" role="navigation">
- <h1 class="screen-reader-text"><?php esc_html_e( 'Post navigation', 'annina' ); ?></h1>
- <div class="nav-links">
- <?php
- next_post_link( '<div class="nav-previous">%link</div>', '<div class="meta-nav" title="%title" aria-hidden="true"><i class="fa fa-angle-left spaceRight"></i><span>' . esc_html__( 'Prev', 'annina' ) . '</span></div> ' . '<span class="screen-reader-text">' . esc_html__( 'Prev', 'annina' ) . '</span> ' );
- previous_post_link( '<div class="nav-next">%link</div>', '<div class="meta-nav" title="%title" aria-hidden="true"><span>' . esc_html__( 'Next', 'annina' ) . '</span><i class="fa fa-angle-right spaceLeft"></i></div> ' . '<span class="screen-reader-text">' . esc_html__( 'Next', 'annina' ) . '</span> ' );
- ?>
- </div><!-- .nav-links -->
- </nav><!-- .navigation -->
- <?php
- }
- endif;
- if ( ! function_exists( 'annina_posted_on' ) ) :
- /**
- * Prints HTML with meta information for the current post-date/time and author.
- */
- $posted_on = '<a href="' . esc_url( get_permalink() ) . '" rel="bookmark"></a>';
- echo '<span class="posted-on"></span>'; // WPCS: XSS OK.
- if ( 'post' == get_post_type() && is_single() ) {
- /* translators: used between list items, there is a space after the comma */
- $categories_list = get_the_category_list( esc_html__( ' / ', 'annina' ) );
- if ( $categories_list && annina_categorized_blog() ) {
- echo '<span class="cat-links"><i class="fa fa-folder-open-o spaceLeftRight" aria-hidden="true"></i>' . $categories_list . '</span>';
- }
- }
- if ( ! function_exists( 'annina_entry_footer' ) ) :
- /**
- * Prints HTML with meta information for the categories, tags and comments.
- */
- function annina_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 */
- $tags_list = get_the_tag_list( '', esc_html__( ' / ', 'annina' ) );
- if ( $tags_list ) {
- echo '<span class="tags-links"><i class="fa fa-tags spaceRight" aria-hidden="true"></i>' . $tags_list . '</span>';
- }
- }
- edit_post_link( esc_html__( 'Edit', 'annina' ), '<span class="edit-link"><i class="fa fa-wrench spaceRight" aria-hidden="true"></i>', '</span>' );
- }
- endif;
- /**
- * Returns true if a blog has more than 1 category.
- *
- * @return bool
- */
- function annina_categorized_blog() {
- $all_the_cool_cats = get_transient( 'annina_categories' );
- if ( false === $all_the_cool_cats ) {
- // Create an array of all the categories that are attached to posts.
- $categories = 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( $categories );
- set_transient( 'annina_categories', $all_the_cool_cats );
- }
- return $all_the_cool_cats > 1;
- }
- /**
- * Flush out the transients used in annina_categorized_blog.
- */
- function annina_category_transient_flusher() {
- if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
- return;
- }
- // Like, beat it. Dig?
- delete_transient( 'annina_categories' );
- }
- add_action( 'edit_category', 'annina_category_transient_flusher' );
- add_action( 'save_post', 'annina_category_transient_flusher' );
Advertisement
Add Comment
Please, Sign In to add comment