<?php
/**
 * Custom template tags for this theme.
 *
 * Eventually, some of the functionality here could be replaced by core features.
 *
 * @package zev
 */


/**
 * Prints HTML with meta information for the current post-date/time, post categories and author.
 */

function themesflat_widget_layout($columns) {
	$layout = array();
	switch ($columns) {
		case 1:
			$layout = array(12);
			break;
		case 2:
			$layout = array(6,6);
			break;
		case 3:
			$layout = array(3,3,6);
			break;
		case 4:
			$layout = array(3,2,3,4);
			break;
		case 5:
			$layout = array(3,3,3,3);
			break;
		case 6:
			$layout = array(2,2,2,2,2);
			break;
		default:
			$layout = array(12);
			break;
		
	}
	return $layout;
}

if ( ! function_exists( 'themesflat_posted_on' ) ) :
function themesflat_posted_on( $layout = '' ) { ?>	
	<ul class="post-meta meta-left">
		<?php if ($layout == 'blog-grid' || $layout == ''):?>
		<li class="post-date">
			<?php
			echo esc_html__(  'Date : ', 'zev' );
			$archive_year  = get_the_time('Y'); 
			$archive_month = get_the_time('m'); 
			$archive_day   = get_the_time('d'); 
			?>
			<a href="<?php echo esc_url(get_day_link( $archive_year, $archive_month, $archive_day)); ?>"><?php echo esc_html(get_the_date());?></a>
		</li>	
		<?php endif; ?>

		<?php if ($layout == 'blog-list'):?>
		<li class="post-author">
			<i class="fas fa-pencil-alt"></i>
			<span class="author">
				<a href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) )) ?>" title="<?php echo esc_attr( sprintf( esc_html__( 'View all posts by %s', 'zev' ), get_the_author() ) ) ?>" rel="author"><?php echo esc_html__('Post by ', 'zev') . get_the_author() ?></a>
			</span>			
		</li>
		<li class="post-category">
			<i class="fas fa-folder-open"></i><span class="category"><?php the_category( ', ' ); ?></span>
		</li>
		<li class="post-comments">
			<i class="fas fa-comments"></i>				
			<span class="comment"><?php comments_popup_link(esc_html__('Comments (0)', 'zev'), esc_html__('Comment (1)', 'zev'), esc_html__('Comments (%)', 'zev')); ?></span>
		</li>	
		<?php endif; ?>		
	</ul>
	<?php
}
endif;

if ( ! function_exists( 'themesflat_posted_category' ) ) :
function themesflat_posted_category( $layout = '' ) { 	
	if ( has_category() ) {
		echo '<div class="post-categories">'.esc_html__("In - ",'zev');
			the_category( ', ' );
		echo '</div>';
	}	
}
endif;

if ( ! function_exists( 'themesflat_entry_footer' ) ) :
/**
 * Prints HTML with meta information for the categories, tags and comments.
 */
function themesflat_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( '', ', ' );
		if ( $tags_list && is_single() ) {
			printf( '<div class="tags-links"><h5>Tags:</h5>' . esc_html__( ' %1$s', 'zev' ) . '</div>', 
				$tags_list );
		}			
	}
}
endif;

if ( ! function_exists( 'themesflat_post_navigation' ) ) :
function themesflat_post_navigation() {
	// 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 posts-navigation" role="navigation">
		<h2 class="screen-reader-text"><?php esc_html_e( 'Post navigation', 'zev' ); ?></h2>
		<ul class="nav-links clearfix">
			<?php
			if ( is_attachment() ) :
				previous_post_link( '<li>%link</li>', sprintf( '<span class="meta-nav">%s</span> %%title', esc_html__( 'Published In', 'zev' ) ) );
			else :
				previous_post_link( '<li class="previous-post">%link</li>', sprintf( '<span class="meta-nav">%s</span> %%title', esc_html__( 'Prev Post', 'zev' ) ) );
				next_post_link( '<li class="next-post">%link</li>', sprintf( '<span class="meta-nav">%s</span> %%title', esc_html__( 'Next Post', 'zev' ) ) );
			endif;
			?>
		</ul><!-- .nav-links -->
	</nav><!-- .navigation -->
	<?php
}
endif;