<?php
/**
 *
 * @package Luzuk Premium
 */

if (get_theme_mod('dinero_blog_enable', true) == true) { ?>

  <div class="blog-area text-center" id="blog">
    <div class="blog-bg"></div>
      <div class="<?php if(get_theme_mod('dinero_blog_section_width','Box Width') == 'Box Width'){ ?>container <?php } elseif(get_theme_mod('dinero_blog_section_width','Box Width') == 'Full Width'){ ?> container-fluid <?php }?>">
     <?php
      $dinero_blog_page_id = get_theme_mod('dinero_blog_page'); 
      $dinero_blog_maintitle = get_theme_mod('dinero_blog_maintitle', 'NEWS & BLOG');
      $dinero_blog_subtitle = get_theme_mod('dinero_blog_subtitle', 'READ OUR LATEST POST');
    
     ?>
        <?php if($dinero_blog_maintitle || $dinero_blog_subtitle){ ?>
          <div class="dinero-section-head"  style="text-align : <?php if(get_theme_mod('dinero_blog_head_align','Center') == 'Center'){ ?> center <?php } elseif(get_theme_mod('dinero_blog_head_align','Left') == 'Left'){ ?> left <?php } elseif(get_theme_mod('dinero_blog_head_align','Right') == 'Right'){ ?> right <?php } ?> ">
            
            <?php if($dinero_blog_maintitle){ ?>
              <h2><?php echo ($dinero_blog_maintitle);  ?></h2>
              <?php }?>
               <?php if( get_theme_mod('dinero_blog_head_icon_enable','No') == 'Yes'){ ?>
                  <div class="dinero-section-head-icon">
                  <i class="<?php echo esc_attr(get_theme_mod('dinero_blog_head_icon', 'fa fa-bell')); ?>"></i>
                </div>
                <?php }?>
            <h3><?php echo ($dinero_blog_subtitle);  ?></h3>       
          </div>
        <?php }?>

				<div class="dinero-blog-area-wrap">
						<div class="dinero-blog-posts">
							<div class="row">

						<?php 
						$blog_post_count = get_theme_mod('blog_post_count', 3);
						$blog_cat_exclude = get_theme_mod('blog_cat_exclude');
						$blog_cat_exclude = explode(',', $blog_cat_exclude);
						$args = array(
							'posts_per_page' => absint($blog_post_count),
							'category__not_in' => $blog_cat_exclude
						);
						$query = new WP_Query($args);
						if($query -> have_posts()):
							while($query -> have_posts()) : $query -> the_post();
								$luzuk_image = wp_get_attachment_image_src(get_post_thumbnail_id() , 'total-blog-thumb');
								?>
								<?php 
								if(has_post_thumbnail()){
									$img = esc_url($luzuk_image[0]);
								}
								if(empty($luzuk_image)){
									$img = get_template_directory_uri().'/images/blog.jpg';
								}
								?>
								<div class="dinero-blog-post col-md-4 col-sm-6 col-xs-12 <?php echo esc_attr(get_theme_mod('dinero_blog_box_onload_effects','wow zoomIn')); ?>" data-wow-duration="2s" style="text-align : <?php if(get_theme_mod('dinero_facility_box_align','Left') == 'Left'){ ?> left <?php } elseif(get_theme_mod('dinero_facility_box_align','Center') == 'Center'){ ?> center <?php } elseif(get_theme_mod('dinero_facility_box_align','Right') == 'Right'){ ?> right <?php } ?> ">
									<div class="dinero-box-area-S">
										
											<a href="<?php the_permalink(); ?>">
												<div class="dinero-blog-thumbnail">
												<img class="blog-img" src="<?php echo $img; ?>" alt="<?php the_title(); ?>" style="height: <?php echo esc_attr(get_theme_mod('dinero_blog_post_image_height','250')) ?>px;"> 
												</div>
											</a>
										
										<div class="dinero-blog-single">
											<div class="dinero-blog-date section-area-text">
                         <?php echo get_the_date( 'j' ); ?> <?php echo get_the_date( 'M' ); ?>
												<br>
												<?php echo get_the_date( 'Y' ); ?>
                      </div>
											<a href="<?php the_permalink(); ?>"><h4 class="inner-area-title"><?php the_title(); ?></h4></a>
											<p><?php $dinero_excerpt = get_the_excerpt(); echo esc_html( dinero_string_limit_words( $dinero_excerpt, esc_attr(get_theme_mod('dinero_blog_post_excerpt','15')) ) ); ?></p>
											<div class="dinero-blog-comment">
											Comment : <i class="fa fa-comment-o" aria-hidden="true"></i> <?php echo $my_var = get_comments_number(); ?>
											</div>
										</div>
											<div class="clearfix"></div>
										</div>
									</div>
									<?php
							endwhile;
						endif;
						wp_reset_postdata();
						?>

						<div class="clearfix"></div>
									</div>
										<div class="clearfix"></div>
									</div>
								</div>

					</div>
						<div class="clearfix"></div>
					</div>	
<script>
  jQuery.noConflict();
  $(function(){
    function blogsingleHeight(){
      var ht = 0;
      $('.blog-area .blog-single').each(function(i){
        var tHt = $(this).height();
        if(ht<tHt){
          ht=tHt;
        }
      });
      $('.blog-area .blog-single').height(ht+'px');
    }
    blogsingleHeight();
  });
  $( window ).resize(function(){
    blogsingleHeight();
  });
</script>
<?php }