<?php
/**
 * The template part for displaying post
 * @package Multipurpose Magazine
 * @subpackage multipurpose_magazine
 * @since 1.0
 */
?>
<?php 
  $multipurpose_magazine_archive_year   = get_the_time('Y'); 
  $multipurpose_magazine_archive_month = get_the_time('m'); 
  $multipurpose_magazine_archive_day   = get_the_time('d'); 

  $alignment = get_theme_mod('multipurpose_magazine_blog_post_alignment', 'left');
?>
<article class="blog-sec blogger animated fadeInDown wow zoomInLeft delay-1000 p-2 mb-4 <?php echo esc_attr($alignment); ?>-align">
  <?php if ($alignment == 'image_content') { ?>
    <div class="row m-0">
      <?php if (has_post_thumbnail()&& get_theme_mod('multipurpose_magazine_featured_image',true) == true) { ?>
        <div class="mainimage col-lg-5 col-md-12">
            <?php the_post_thumbnail(); ?>
        
          <?php if( get_theme_mod( 'multipurpose_magazine_metafields_date',true) != '') { ?>
            <div class="post-info p-3">
              <a href="<?php echo esc_url( get_day_link( $multipurpose_magazine_archive_year , $multipurpose_magazine_archive_month, $multipurpose_magazine_archive_day)); ?>">
                <div class="dateday"><?php echo esc_html( get_the_date( 'd') ); ?></div>
                <hr class="metahr m-0 p-0">
                <div class="month mt-1"><?php echo esc_html( get_the_date( 'M' ) ); ?></div>
                <div class="year"><?php echo esc_html( get_the_date( 'Y' ) ); ?></div>
              <span class="screen-reader-text"><?php echo esc_html( get_the_date() ); ?></span></a>
            </div>
          <?php }?>

        </div>
      <?php } ?>
      <div class="<?php echo (has_post_thumbnail()) ? 'col-lg-7 col-md-12' : 'col-lg-12 col-md-12'; ?>">
        <h2><a href="<?php echo esc_url(get_permalink() ); ?>"><?php the_title(); ?><span class="screen-reader-text"><?php the_title(); ?></span></a></h2>
        <?php if( get_theme_mod( 'multipurpose_magazine_metafields_author',true) != '' || get_theme_mod( 'multipurpose_magazine_metafields_comment',true) != '' || get_theme_mod( 'multipurpose_magazine_metafields_time',true) != '') { ?> 
          <div class="metabox py-2">  
            <?php if( get_theme_mod( 'multipurpose_magazine_metafields_author',true) != '') { ?>
              <i class="<?php echo esc_attr(get_theme_mod('multipurpose_magazine_postauthor_icon',"fa fa-user pe-2" )); ?>"></i><a href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' )) ); ?>"><span class="entry-author pe-3"> <?php the_author(); ?></span><span class="screen-reader-text"><?php the_author(); ?></span></a>
            <?php }?>
            <?php if( get_theme_mod( 'multipurpose_magazine_metafields_comment',true) != '') { ?>
              <i class="<?php echo esc_attr(get_theme_mod('multipurpose_magazine_postcomment_icon',"fa fa-comments pe-2" )); ?>"></i><span class="entry-comments pe-3"> <?php comments_number( __('0 Comments','multipurpose-magazine'), __('0 Comments','multipurpose-magazine'), __('% Comments','multipurpose-magazine') ); ?></span> 
            <?php }?>
            <?php if( get_theme_mod( 'multipurpose_magazine_metafields_time',true) != '') { ?>
              <i class="<?php echo esc_attr(get_theme_mod('multipurpose_magazine_posttime_icon',"fa fa-clock pe-2" )); ?>"></i> <span class="entry-comments pe-3"> <?php echo esc_html( get_the_time() ); ?></span>
            <?php }?>  
          </div>  
        <?php }?>
        <?php if(get_theme_mod('multipurpose_magazine_blog_post_content') == 'Full Content'){ ?>
          <?php the_content(); ?>
        <?php }
        if(get_theme_mod('multipurpose_magazine_blog_post_content', 'Excerpt Content') == 'Excerpt Content'){ ?>
          <?php if(get_the_excerpt()) { ?>
            <div class="entry-content"><p class="mb-0"><?php $multipurpose_magazine_excerpt = get_the_excerpt(); echo esc_html( multipurpose_magazine_string_limit_words( $multipurpose_magazine_excerpt, esc_attr(get_theme_mod('multipurpose_magazine_post_excerpt_number','20')))); ?> <?php echo esc_html( get_theme_mod('multipurpose_magazine_button_excerpt_suffix','...') ); ?></p></div>
          <?php }?>
        <?php }?>
        <?php if ( get_theme_mod('multipurpose_magazine_blog_button_text','Read Full') != '' ) {?>
          <div class="blogbtn mt-3">
            <a href="<?php echo esc_url( get_permalink() );?>" class="blogbutton-small"><?php echo esc_html( get_theme_mod('multipurpose_magazine_blog_button_text',__('Read Full', 'multipurpose-magazine')) ); ?><span class="screen-reader-text"><?php echo esc_html( get_theme_mod('multipurpose_magazine_blog_button_text',__('Read Full', 'multipurpose-magazine')) ); ?></span></a>
          </div>
        <?php }?>
      </div>
    </div>
  <?php } else { ?>
    <!-- Default Layout -->
    <?php if(has_post_thumbnail() && get_theme_mod('multipurpose_magazine_featured_image',true) == true) { ?>
      <div class="mainimage">
        <?php the_post_thumbnail(); ?>      
      </div>
      <?php if( get_theme_mod( 'multipurpose_magazine_metafields_date',true) != '') { ?>
        <div class="post-info p-3">
          <a href="<?php echo esc_url( get_day_link( $multipurpose_magazine_archive_year , $multipurpose_magazine_archive_month, $multipurpose_magazine_archive_day)); ?>">
            <div class="dateday"><?php echo esc_html( get_the_date( 'd') ); ?></div>
            <hr class="metahr m-0 p-0">
            <div class="month mt-1"><?php echo esc_html( get_the_date( 'M' ) ); ?></div>
            <div class="year"><?php echo esc_html( get_the_date( 'Y' ) ); ?></div>
          <span class="screen-reader-text"><?php echo esc_html( get_the_date() ); ?></span></a>
        </div>
      <?php }?>
    <?php }?>
    <h2><a href="<?php echo esc_url(get_permalink() ); ?>"><?php the_title(); ?><span class="screen-reader-text"><?php the_title(); ?></span></a></h2>
    <?php if( get_theme_mod( 'multipurpose_magazine_metafields_author',true) != '' || get_theme_mod( 'multipurpose_magazine_metafields_comment',true) != '' || get_theme_mod( 'multipurpose_magazine_metafields_time',true) != '') { ?> 
      <div class="metabox py-2">  
        <?php if( get_theme_mod( 'multipurpose_magazine_metafields_author',true) != '') { ?>
          <i class="<?php echo esc_attr(get_theme_mod('multipurpose_magazine_postauthor_icon',"fa fa-user pe-2" )); ?>"></i><a href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' )) ); ?>"><span class="entry-author pe-3"> <?php the_author(); ?></span><span class="screen-reader-text"><?php the_author(); ?></span></a>
        <?php }?>
        <?php if( get_theme_mod( 'multipurpose_magazine_metafields_comment',true) != '') { ?>
          <i class="<?php echo esc_attr(get_theme_mod('multipurpose_magazine_postcomment_icon',"fa fa-comments pe-2" )); ?>"></i><span class="entry-comments pe-3"> <?php comments_number( __('0 Comments','multipurpose-magazine'), __('0 Comments','multipurpose-magazine'), __('% Comments','multipurpose-magazine') ); ?></span> 
        <?php }?>
        <?php if( get_theme_mod( 'multipurpose_magazine_metafields_time',true) != '') { ?>
          <i class="<?php echo esc_attr(get_theme_mod('multipurpose_magazine_posttime_icon',"fa fa-clock pe-2" )); ?>"></i> <span class="entry-comments pe-3"> <?php echo esc_html( get_the_time() ); ?></span>
        <?php }?>  
      </div>  
    <?php }?>
    <?php if(get_theme_mod('multipurpose_magazine_blog_post_content') == 'Full Content'){ ?>
      <?php the_content(); ?>
    <?php }
    if(get_theme_mod('multipurpose_magazine_blog_post_content', 'Excerpt Content') == 'Excerpt Content'){ ?>
      <?php if(get_the_excerpt()) { ?>
        <div class="entry-content"><p class="mb-0"><?php $multipurpose_magazine_excerpt = get_the_excerpt(); echo esc_html( multipurpose_magazine_string_limit_words( $multipurpose_magazine_excerpt, esc_attr(get_theme_mod('multipurpose_magazine_post_excerpt_number','20')))); ?> <?php echo esc_html( get_theme_mod('multipurpose_magazine_button_excerpt_suffix','...') ); ?></p></div>
      <?php }?>
    <?php }?>
    <?php if ( get_theme_mod('multipurpose_magazine_blog_button_text','Read Full') != '' ) {?>
      <div class="blogbtn mt-3">
        <a href="<?php echo esc_url( get_permalink() );?>" class="blogbutton-small"><?php echo esc_html( get_theme_mod('multipurpose_magazine_blog_button_text',__('Read Full', 'multipurpose-magazine')) ); ?><span class="screen-reader-text"><?php echo esc_html( get_theme_mod('multipurpose_magazine_blog_button_text',__('Read Full', 'multipurpose-magazine')) ); ?></span></a>
      </div>
    <?php }?>
  <?php } ?> 
</article>