<?php
/**
 * 
 * Template part for including posts design formate wise
 * @link https://codex.wordpress.org/Template_Hierarchy
 * 
 * @package Amyra Lite
 * @since 1.0 
 * 
 */

global $amyra_lite_i;
$amyra_lite_i++;

if ( is_home() || is_front_page() ) {    
    $blog_layout = amyra_lite_get_theme_mod('blog_layout');   
    
} elseif( is_author() ) {    
    $blog_layout                = 'list';    
    
} elseif ( is_category() || is_archive() || is_tag() ) {    
    $blog_layout = amyra_lite_get_theme_mod('cat_layout');   
    
} elseif( is_search() ) {    
    $blog_layout                = 'list';    
	
} 
?>

<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
  <?php 
	/* Grid and Masonry Layout */
    if ( $blog_layout == 'grid' || $blog_layout == 'masonry' ) { ?>       
				<div class="amyra-lite-post-grid-content <?php if ( !has_post_thumbnail() ) { echo 'no-thumb-image'; } ?>">
				<div class="amyra-lite-post-image-bg">  
					<?php get_template_part( 'template-parts/content', 'media' ); ?>
				</div>
				<header class="entry-header">
					
						<?php if (is_sticky()) : ?>
										<span class="sticky-label"><i class="fa fa-thumb-tack"></i><span class="sticky-label-text"><?php esc_html_e('Featured', 'amyra-lite'); ?></span></span>
						<?php endif; ?>
					   
						<?php the_title( '<h2 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h2>' ); ?>
								
						<?php if ( 'page' !== get_post_type() ) { amyra_lite_posted_on(); }  ?>
								
				</header><!-- .entry-header -->
				<?php
				if ( is_search() ) { ?>
						<div class="entry-summary">
				<?php    
						the_excerpt();
				} else { ?>
						<div class="entry-content">
				<?php             
						$ismore = ! empty( $post->post_content ) ? strpos( $post->post_content, '<!--more-->' ) : '';
						if ( ! empty( $ismore ) ) {
								/* translators: %s: Name of current post */
								the_content( sprintf(
												esc_html__( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'amyra-lite' ),
												get_the_title()
										) );
						} else {
								the_excerpt();				
						}
						wp_link_pages( array(
								'before' => '<div class="page-links">' . esc_html__( 'Pages:', 'amyra-lite' ),
								'after'  => '</div>',
						) );

				}
				 ?>
					<footer class="entry-footer">
							<?php amyra_lite_entry_footer(); ?>
					</footer><!-- .entry-footer -->
					
					</div><!-- .entry-content --><!-- .entry-summary -->
				</div>
        
    <?php } else if ( $blog_layout == 'list' ) {
	   /*List Layout */	
       $grid_class = amyra_lite_grid_column_class();

					?>

					<div class="post-list-wrap clearfix">
					<?php if ( has_post_thumbnail()) { ?>  
						<div class="amyra-lite-col-6 amyra-lite-img-left amyra-lite-columns">
								<?php get_template_part( 'template-parts/content', 'media' ); ?>
						</div>
					<?php } ?>  
					<div class="<?php echo $grid_class; ?> amyra-lite-columns">
							<header class="entry-header">
							 <?php if (is_sticky()) : ?>
									 <span class="sticky-label"><i class="fa fa-thumb-tack"></i><span class="sticky-label-text"><?php esc_html_e('Featured', 'amyra-lite'); ?></span></span>
									 <?php endif; ?>              
									 <?php the_title( '<h2 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h2>' ); ?>
									 <?php if ( 'page' !== get_post_type() ) { amyra_lite_posted_on(); }  ?>
							</header><!-- .entry-header -->

									<?php
									if ( is_search() ) {
											echo '<div class="entry-summary">';
											the_excerpt();
									} else {
											echo '<div class="entry-content">';
											$ismore = ! empty( $post->post_content ) ? strpos( $post->post_content, '<!--more-->' ) : '';
											if ( ! empty( $ismore ) ) {
													/* translators: %s: Name of current post */
													the_content( sprintf(
																	esc_html__( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'amyra-lite' ),
																	get_the_title()
															) );
											} else {
													the_excerpt();				
											}
											wp_link_pages( array(
													'before' => '<div class="page-links">' . esc_html__( 'Pages:', 'amyra-lite' ),
													'after'  => '</div>',
											) );

									}
								   ?>
									<footer class="entry-footer">
											<?php amyra_lite_entry_footer(); ?>
									</footer><!-- .entry-footer -->
									</div><!-- .entry-content --><!-- .entry-summary -->
							</div>
					</div><!-- .post-list-warp -->
        
    <?php } else if ( $blog_layout == 'list-alt' ) {       
		$grid_class =   'amyra-lite-col-12 amyra-lite-content-full';
		if( has_post_thumbnail()){
			if( $amyra_lite_i % 2 == 0 ) {     
				$grid_class =   'amyra-lite-col-6 amyra-lite-content-right';
			} else {
				$grid_class =   'amyra-lite-col-6 amyra-lite-content-left';
			}
		}
		if( $amyra_lite_i % 2 == 0 ) { ?> 
		<div class="post-list-alt-wrap clearfix">
			<?php  if ( has_post_thumbnail()) { ?>    
			<div class="amyra-lite-col-6 amyra-lite-img-left amyra-lite-columns">
				<div class="amyra-lite-post-image-bg">
					<?php get_template_part( 'template-parts/content', 'media' ); ?>
				 </div>   
			</div>
			<?php } ?>    
			<div class="<?php echo $grid_class; ?> amyra-lite-columns">
					<header class="entry-header">
					<?php if (is_sticky()) : ?>
									<span class="sticky-label"><i class="fa fa-thumb-tack"></i><span class="sticky-label-text"><?php esc_html_e('Featured', 'amyra-lite'); ?></span></span>
					<?php endif; ?>
						 <?php the_title( '<h2 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h2>' ); ?>
							   <?php if ( 'page' !== get_post_type() ) { amyra_lite_posted_on(); }  ?>
					 </header><!-- .entry-header -->

							<?php
							if ( is_search() ) {
									echo '<div class="entry-summary">';
									the_excerpt();
							} else {
									echo '<div class="entry-content">';
									$ismore = ! empty( $post->post_content ) ? strpos( $post->post_content, '<!--more-->' ) : '';
									if ( ! empty( $ismore ) ) {
											/* translators: %s: Name of current post */
											the_content( sprintf(
															esc_html__( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'amyra-lite' ),
															get_the_title()
													) );
									} else {
											the_excerpt();				
									}
									wp_link_pages( array(
											'before' => '<div class="page-links">' . esc_html__( 'Pages:', 'amyra-lite' ),
											'after'  => '</div>',
									) );

							}
							?>
							<footer class="entry-footer">
									<?php amyra_lite_entry_footer(); ?>
							</footer><!-- .entry-footer -->
						</div><!-- .entry-content --><!-- .entry-summary -->
					</div>
			</div><!-- .post-list-warp -->
		<?php } else { 	?>
			<div class="post-list-alt-wrap clearfix">
			<div class="<?php echo $grid_class; ?> amyra-lite-columns">
					<header class="entry-header">
							 <?php if (is_sticky()) : ?>
									<span class="sticky-label"><i class="fa fa-thumb-tack"></i><span class="sticky-label-text"><?php esc_html_e('Featured', 'amyra-lite'); ?></span></span>
							<?php endif; ?>                              
							<?php the_title( '<h2 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h2>' ); ?>
							<?php if ( 'page' !== get_post_type() ) { amyra_lite_posted_on(); }  ?>
					</header><!-- .entry-header -->

							<?php
							if ( is_search() ) {
									echo '<div class="entry-summary">';
									the_excerpt();
							} else {
									echo '<div class="entry-content">';
									$ismore = ! empty( $post->post_content ) ? strpos( $post->post_content, '<!--more-->' ) : '';
									if ( ! empty( $ismore ) ) {
											/* translators: %s: Name of current post */
											the_content( sprintf(
															esc_html__( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'amyra-lite' ),
															get_the_title()
													) );
									} else {
											the_excerpt();				
									}
									wp_link_pages( array(
											'before' => '<div class="page-links">' . esc_html__( 'Pages:', 'amyra-lite' ),
											'after'  => '</div>',
									) );

							}
							?>
							<footer class="entry-footer">
									<?php amyra_lite_entry_footer(); ?>
							</footer><!-- .entry-footer -->
						</div><!-- .entry-content --><!-- .entry-summary -->				
					</div>
					 <?php if (  has_post_thumbnail()) { ?>    
					<div class="amyra-lite-col-6 amyra-lite-img-right amyra-lite-columns">
						<div class="amyra-lite-post-image-bg">
									<?php get_template_part( 'template-parts/content', 'media' ); ?>
						</div>   
					</div>
					 <?php } ?>
					</div>	<!-- .post-list-warp -->	
		<?php } 
			}
?>
</article><!-- #post-## -->