<?php

if ( ! defined( 'ABSPATH' ) ) exit;

$gridpress_terms_class = '';

if ( isset($gridpress_card_data['type']) && $gridpress_card_data['type'] === 'post' ) {

    if (
        isset($gridpress_display_settings['top_filter_tax']) &&
        ! empty($gridpress_display_settings['top_filter_tax'])
    ) {

        $gridpress_taxonomy = $gridpress_display_settings['top_filter_tax'];

        $gridpress_terms_class = apply_filters(
            'gridpress_card_item_term_classes',
            '',
            $gridpress_taxonomy,
            $gridpress_card_data['id']
        );
    }
}

/**
 * SAFE CLASS BUILDING
 */
$gridpress_class_array = array('jc-cards');

if ( ! empty($gridpress_terms_class) ) {
    $gridpress_class_array[] = sanitize_html_class($gridpress_terms_class);
}

$gridpress_class_attr = implode(' ', $gridpress_class_array);
?>
<div class="<?php echo esc_attr($gridpress_class_attr); ?>">
    <div class="jc-cards-image">
        <a href="<?php echo esc_url($gridpress_card_data['url']); ?>">
            <img
                src="<?php echo esc_url($gridpress_card_data['imag_url']); ?>"
                alt="<?php echo esc_attr($gridpress_card_data['title']); ?>"
            >
        </a>
    </div>
    <strong class="jc-cards-title">
        <a href="<?php echo esc_url($gridpress_card_data['url']); ?>">
            <?php echo esc_html($gridpress_card_data['short_title']); ?>
        </a>
    </strong>
</div>