<?php

use Elementor\Utils;

$settings = $args['settings'];

echo '<div data-id="id-' . $post_id . '" class="col-md-4 col-lg-4 tfl-grid-item ' . $style . '">';

echo '<article id="post-' . $post_id . '" class="' . join(' ', get_post_class('', $post_id)) . '">';

if ($thumbnail_exists = has_post_thumbnail()) {
    $entry_image = '<div class="tfl-project-image">';
    $image_setting = [
        'id' => get_post_thumbnail_id($post_id),
    ];
    $thumbnail_html = tfl_get_image_html(
        $image_setting,
        'thumbnail_size',
        $settings,
        true
    );
    if ($settings['image_linkable'] == 'yes') {
        $thumbnail_html = '<a href="' . get_the_permalink() . '"' . $target . '>' . $thumbnail_html . '</a>';
    }
    $entry_image .= apply_filters(
        'tfl_posts_grid_thumbnail_html',
        $thumbnail_html,
        $image_setting,
        $settings
    );

    $categories = get_the_category(get_the_ID());


    $image_info = '<div class="tfl-content">';
    $image_info .= '<div class="tfl-wrap-cats"><i class="far fa-folder-open"></i>';
    foreach ($categories as $cat) {
        $image_info .= '<a href="' . get_category_link($cat->term_id) . '">' . $cat->name . '</a>';
        break;
    }
    $image_info .= '</div>';


    $image_info .= '<' . Utils::validate_html_tag($settings['title_tag']) . ' class="tfl-post-title"><a href="' . get_permalink() . '" title="' . get_the_title() . '" rel="bookmark"' . $target . '>' . get_the_title() . '</a></' . Utils::validate_html_tag($settings['title_tag']) . '>';




    $image_info .= '</div><!-- .tfl-image-info -->';




    $image_info .= '<div class="tfl-entry-info">';
    $image_info .= '<div class="meta-content">';
    $image_info .= tfl_entry_published();
    $image_info .= '<span class="comment-num"><i class="far fa-comments"></i>';
    $image_info .= esc_html__('COM ','themesflat').'('.get_comments_number().')';
    $image_info .= '</span>';
    $image_info .= '</div>';
    $image_info .= '</div>';


    $entry_image .= apply_filters(
        'tfl_posts_grid_image_info',
        $image_info,
        $post_id,
        $settings
    );
    $entry_image .= '</div>';


    echo apply_filters(
        'tfl_posts_grid_entry_image',
        $entry_image,
        $image_setting,
        $settings
    );
}



echo '</article><!-- .hentry -->';
echo '</div>';

