<?php global $post; ?>
<div class="container wid_article_blog mb-3">
    <?php if (1 == $wid_header): ?>
    <header style="padding:1rem 0 1rem 0;">
        <div class="header-widget-prod">
            <div class="row">
            <div class="d-block d-md-none col-12">
                    <div class="header-widget-img">
                        <?php echo wp_get_attachment_image( $settings['wid_header_top_image']['id'], 'thumbnail' ); ?>
                    </div>
                </div>
                <div class="col-12 col-md-7">
                    <div class="content-header">
                        <h2><?php echo $settings['title']; ?></h2>
                        <?php echo $settings['des_title']; ?>
                        <?php
                            if ($settings['title_show_more']):
                                echo '<a class="bth-new" title="' . $settings['title_show_more'] . '" href="' . $settings['more_link']['url'] . '">';
                                echo $settings['title_show_more'];
                                echo "</a>";
                            endif;
                        ?>
                    </div>
                </div>
                <div class="d-none d-md-block col-5">
                    <div class="header-widget-img">
                        <?php echo wp_get_attachment_image( $settings['wid_header_top_image']['id'], 'thumbnail' ); ?>
                    </div>
                </div>
            </div>
         </div>
    </header>
    <?php endif; if(3 == $wid_header): ?>
    <div class="row wid_header_3">
        <div class="title_area_pro col-8 col-md-6">
                <div class="per_title_area">
                  <?php \Elementor\Icons_Manager::render_icon($settings['wid_header_icon'], ['aria-hidden' => 'true']); ?>
                    <h2>
                        <a href="<?php echo $settings['more_link']['url']; ?>">
                        <b>
                            <?php echo $settings['title']; ?>
                        </b>
                        </a>
                    </h2>
                    <small><?php echo $settings['title_english']; ?></small>
                </div>
            </div>
        <div class="col-4 col-md-6">
        <?php
            if ($settings['title_show_more']):
                echo '<a class="bth-new" title="' . $settings['title_show_more'] . '" href="' . $settings['more_link']['url'] . '">';
                echo $settings['title_show_more'];
                echo "</a>";
            endif;
        ?>
        </div>
    </div>
    <?php endif; ?>
<section class="row" style="padding-top:1rem">
<div class="col-12">
<div class="<?php if (1 == $settings['wid_show_slides']): echo 'slider-tamis'; else: echo 'row'; endif; ?>" data-slick='{"slidesToShow": <?php echo $settings['wid_slidesToShow']; ?>,"slidesToScroll": <?php echo $settings['wid_slidesToScroll']; ?>,"dots":<?php if ('true' == $settings['wid_dots']): echo 'true'; else: echo 'false'; endif; ?>,"autoplay": <?php if ('true' == $settings['wid_autoplay']): echo 'true'; else: echo 'false'; endif; ?>,"autoplaySpeed":<?php echo $settings['wid_autoplaySpeed']; ?>,"speed":<?php echo $settings['wid_Speed']; ?>}'>
  <?php while ( $all_posts->have_posts() ) :
  $all_posts->the_post(); ?>
    <div class="wid-item-pad <?php if (2 == $settings['wid_show_slides']): echo 'col-' . $settings['wid_show_gride_columns_mobile'] .  ' col-sm-6 '.  ' col-md-4 ' . ' col-lg-' . $settings['wid_show_gride_columns_desktop']; endif; ?>">
    <article <?php post_class('wpcap-post'); ?> >
      <a href="<?php the_permalink(); ?>" class="arch__body__item">
        <figure class="arch__body__item_img">
          <div class="show_overfull"></div>
          <?php if ('yes' == $settings['wid_article_blog_comment_show']) : ?>
            <span class="post-comments"><?php echo get_comments_number('', '', '%' ); ?>
            <i class="fal fa-comment"></i></span>
              <?php endif; if ('yes' == $settings['wid_article_blog_tag_show']) : ?>
                <span class="post_tag_types">
                <?php
                    $tag_types = get_post_meta($post->ID, 'tag_types', true);
                    if ($tag_types == 'podcatch') {
                    echo '<i class="fal fa-microphone"></i>';
                    } elseif ($tag_types == 'video') {
                    echo '<i class="fal fa-play"></i>';
                    } elseif ($tag_types == 'images') {
                    echo '<i class="fal fa-camera-retro"></i>';
                    } elseif ($tag_types == 'survey') {
                    echo '<i class="fal fa-ballot-check"></i>';
                    }
                    echo '</span>';
                endif;
                  if (has_post_thumbnail()) {
                    the_post_thumbnail(array(300, 300), array('alt' => '' . get_the_title(), 'title' => '' . get_the_title() . ''));
                  } else { ?>
            <img src="<?php print(get_template_directory_uri()); ?>/assets/images/thumb.gif" width="60" height="60"
              alt="<?php _e('Image not found', 'tamis'); ?>" title="<?php _e('Image not found', 'tamis'); ?>">
            <?php } ?>
        </figure>
        <h2 class="item__txt">
          <span><?php the_title(); ?></span>
        </h2>
        <?php if ('yes' == $settings['wid_article_blog_description']): ?>
        <div class="item_description">
          <p>
            <?php
              $excerpt = get_the_excerpt();
              $excerpt = substr($excerpt, 0, 280);
              $result = substr($excerpt, 0, strrpos($excerpt, ' '));
              echo $result;
            ?>
          </p>
        </div>
        <?php endif; if ('yes' == $settings['wid_article_blog_time_and_avatar_show']): ?>
        <div class="item__details">
          <div class="user-profile-stat-wrapper">
            <?php 
            if ('yes' == $settings['wid_article_blog_avatar_img_show']):
             echo get_avatar(get_the_author_meta('ID'), 32);
            endif;if ('yes' == $settings['wid_article_blog_avatar_name_show']): ?>
            <span class="item__details--author"><?php the_author(); ?></span>
            <?php endif; ?>
          </div>
          <?php if ('yes' == $settings['wid_article_blog_time_show']): ?>
          <time class="item__details--date">
            <i class="fal fa-clock"></i><?php echo human_time_diff(get_the_time('U'), current_time('timestamp')) . ' پیش'; ?>
          </time>
          <?php endif; ?>
        </div>
        <?php endif; if ('yes' == $settings['wid_article_blog_red_more_bth_show']): ?>
        <div class="blogcard__btns">
          <button class="btn btn--orange btn--md" href="" title="<?php echo $settings['title_article_more']; ?>"><?php echo $settings['title_article_more']; ?></button>
        </div>
        <?php endif; ?>
      </a>
      </article>
    </div>
<?php endwhile;?>
</div>
</div>
</section>
</div>
