<?php
if ( ! defined( 'ABSPATH' ) ) exit;

$gridpress_terms_class = '';

/**
 * TAX CLASS FILTER
 */
if (
    isset($gridpress_card_data['type']) &&
    $gridpress_card_data['type'] === 'post' &&
    !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_terms_class,
        $gridpress_taxonomy,
        $gridpress_card_data['id']
    );
}

/**
 * SAFE CLASS BUILD
 */
$gridpress_classes = trim(
    'jc-cards'
    . (!empty($gridpress_terms_class) ? ' ' . sanitize_html_class($gridpress_terms_class) : '')
);
$gridpress_card_url   = isset( $gridpress_card_data['url'] ) ? sanitize_url( (string) $gridpress_card_data['url'] ) : '';
$gridpress_image_url  = isset( $gridpress_card_data['imag_url'] ) ? sanitize_url( (string) $gridpress_card_data['imag_url'] ) : '';
$gridpress_card_title = isset( $gridpress_card_data['title'] ) ? sanitize_text_field( (string) $gridpress_card_data['title'] ) : '';

$gridpress_classes = isset( $gridpress_classes )
	? sanitize_html_class( (string) $gridpress_classes )
	: '';
?>
<div class="<?php echo esc_attr( $gridpress_classes ); ?>">
	<a href="<?php echo esc_url( $gridpress_card_url ); ?>">
		<img
			src="<?php echo esc_url( $gridpress_image_url ); ?>"
			alt="<?php echo esc_attr( $gridpress_card_title ); ?>"
		/>
	</a>
</div>