<?php
/**
 * The template part for displaying services
 * @package Blogger Base
 * @subpackage blogger_base
 * @since 1.0
 */
?>
<?php 
  $archive_year  = get_the_time('Y'); 
  $archive_month = get_the_time('m'); 
  $archive_day   = get_the_time('d'); 
?>
<?php 
    $blogger_hub_grid_columns = get_theme_mod('blogger_hub_grid_columns', '3');
    if ($blogger_hub_grid_columns == '2') {
      $blogger_hub_column_class = 'col-lg-6 col-md-6';
    } elseif ($blogger_hub_grid_columns == '4') {
      $blogger_hub_column_class = 'col-lg-3 col-md-6';
    } elseif ($blogger_hub_grid_columns == '3') {
      $blogger_hub_column_class = 'col-lg-4 col-md-4';
    }
?>
<div class="<?php echo esc_attr($blogger_hub_column_class); ?>">
    <div class="grid-sec p-3 mb-4 text-center">
        <div class="mainimage">
            <?php 
                if(has_post_thumbnail() && get_theme_mod('blogger_hub_grid_post_featured_image',true) == true) { 
                  the_post_thumbnail(); 
                }
            ?>
        </div>
        <h2 class="mb-0"><a href="<?php echo esc_url(get_permalink() ); ?>"><?php the_title(); ?><span class="screen-reader-text"><?php the_title(); ?></span></a></h2>
        <hr class="post-hr mx-auto mb-2 mt-0">  
        <div class="grid-post-info py-2">
            <?php if(get_theme_mod('blogger_hub_grid_post_date',true)==1){ ?>
              <div class="grid-post-info py-2">
                <i class="<?php echo esc_attr(get_theme_mod('blogger_hub_grid_post_date_icon',"fa fa-calendar pe-1" )); ?>"></i><a href="<?php echo esc_url( get_day_link( $archive_year, $archive_month, $archive_day)); ?>"><span class="entry-date"><?php echo esc_html( get_the_date() ); ?></span><span class="screen-reader-text"><?php echo esc_html( get_the_date() ); ?></span></a>
              </div>
            <?php }?>
          <?php if(get_theme_mod('blogger_hub_grid_post_author',true)==1){ ?>
            <i class="<?php echo esc_attr(get_theme_mod('blogger_hub_grid_post_author_icon',"fa fa-user pe-1" )); ?>"></i><a href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' )) ); ?>"><span class="entry-author me-3"> <?php the_author(); ?></span><span class="screen-reader-text"><?php the_author(); ?></span></a>
          <?php }?>
          <?php if(get_theme_mod('blogger_hub_grid_post_comment',true)==1){ ?>
            <i class="<?php echo esc_attr(get_theme_mod('blogger_hub_grid_post_comment_icon',"fa fa-comments pe-1" )); ?>"></i><span class="entry-comments me-3"> <?php comments_number( __('0 Comments','blogger-hub'), __('0 Comments','blogger-hub'), __('% Comments','blogger-hub') ); ?></span> 
          <?php }?> 
          <?php if( get_theme_mod( 'blogger_hub_grid_post_time',true) != '') { ?>
            <i class="<?php echo esc_attr(get_theme_mod('blogger_hub_grid_post_time_icon',"fa fa-clock pe-1" )); ?>"></i><span class="entry-comments me-3"> <?php echo esc_html( get_the_time() ); ?></span>
          <?php }?>
        </div>            
        <div class="entry-content">
	        		<p>
			          <?php $blogger_hub_theme_lay = get_theme_mod( 'blogger_hub_grid_post_content','Excerpt Content');
				          if($blogger_hub_theme_lay == 'Full Content'){ ?>
				            <?php the_content(); ?>
				          <?php }
				          if($blogger_hub_theme_lay == 'Excerpt Content'){ ?>
				            <?php if(get_the_excerpt()) { ?>
				              <?php $blogger_hub_excerpt = get_the_excerpt(); echo esc_html( blogger_hub_string_limit_words( $blogger_hub_excerpt, esc_attr(get_theme_mod('blogger_hub_grid_excerpt_number','20')))); ?> <?php echo esc_html( get_theme_mod('blogger_hub_grid_excerpt_suffix','...') ); ?>
				            <?php }?>
				          <?php }?>
			        </p>
	      </div>
        <?php if ( get_theme_mod('blogger_hub_grid_button_text','READ MORE') != '' ) {?>
            <div class="blogbtn">
                <a href="<?php echo esc_url( get_permalink() );?>" class="blogbutton-small hvr-sweep-to-right"><?php echo esc_html( get_theme_mod('blogger_hub_grid_button_text',__('READ MORE', 'blogger-base')) ); ?><span class="screen-reader-text"><?php echo esc_html( get_theme_mod('blogger_hub_grid_button_text',__('READ MORE', 'blogger-base')) ); ?></span></a>
            </div>
        <?php }?>
        <?php if(get_theme_mod('blogger_hub_metafields_tags',true)==1){ ?>
            <p class="post_tag"><?php
                if( $tags = get_the_tags() ) {
                    echo '<span class="meta-sep"></span>';
                    foreach( $tags as $content_tag ) {
                        $sep = ( $content_tag === end( $tags ) ) ? '' : ' ';
                        echo '<a href="' . esc_url(get_term_link( $content_tag, $content_tag->taxonomy )) . '">#' . esc_html($content_tag->name) . '</a>' . esc_html($sep);
                    }
                } ?>
            </p>
        <?php }?>
    </div>
</div>