<?php
/**
 * Template part for displaying posts
 *
 * @link https://codex.wordpress.org/Template_Hierarchy
 *
 * @package Prime Interior Designer
 */
?>

<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
	<div id="featured-posts" class="post-item ">
		<?php  
		$prime_interior_designer_img_setting  = prime_interior_designer_get_option( 'prime_interior_designer_post_feature_image_setting' );
		if ( $prime_interior_designer_img_setting ) : ?>
			<div class="featured-image">
				<?php if ( has_post_thumbnail() ) : ?>
					<?php the_post_thumbnail(); ?>
				<?php else : ?>
					<img src="<?php echo esc_url( get_stylesheet_directory_uri() . '/assets/images/default-header.png' ); ?>">
				<?php endif; ?>
				<a href="<?php the_permalink(); ?>" class="post-thumbnail-link"></a>
				<div class="entry-meta">
					<?php prime_interior_designer_posted_on(); ?>
				</div>
			</div>
		<?php endif; ?>

		<div class="entry-container">
			<header class="entry-header">
				<?php  
				$prime_interior_designer_title_setting  = prime_interior_designer_get_option( 'prime_interior_designer_post_title_setting' );
				if ( $prime_interior_designer_title_setting ){?>
					<h2 class="entry-title">
						<a href="<?php the_permalink();?>"><?php the_title();?></a>
				   </h2>
				<?php } ?>
			</header>
			<?php  
				$prime_interior_designer_meta_setting  = prime_interior_designer_get_option( 'prime_interior_designer_post_content_setting' );
				if ( $prime_interior_designer_meta_setting ){?>
				<div class="entry-content">
					<?php
						$prime_interior_designer_excerpt_length = prime_interior_designer_get_option('excerpt_length');
						    $content = get_the_content();
						    echo esc_html(wp_trim_words($content, $prime_interior_designer_excerpt_length));
					?>
				</div><!-- .entry-content -->
			<?php } ?>
			<?php  
			 $prime_interior_designer_button_setting  = prime_interior_designer_get_option( 'prime_interior_designer_post_button_setting' );
			 if ( $prime_interior_designer_button_setting ){?>
				<?php $prime_interior_designer_readmore_text = prime_interior_designer_get_option( 'readmore_text' );?>
				<?php if (!empty($prime_interior_designer_readmore_text) ) :?>
					<div class="read-more">
						<a href="<?php the_permalink();?>"><?php echo esc_html($prime_interior_designer_readmore_text);?> <i class="fas fa-arrow-right"></i> </a>
					</div><!-- .read-more -->
				<?php endif; ?>
		    <?php } ?>
		</div><!-- .entry-container -->
	</div><!-- .post-item -->
</article><!-- #post-## -->
