<?php
/**
 * Style 1 template.
 *
 * @link       https://dcatl.diviaccessories.com/
 * @since      1.0.0
 *
 * @package    WordPress
 * @subpackage display-category-and-taxonomy-list
 */

namespace DCATL\Template;

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

$term_link = get_term_link( $term );
if ( is_wp_error( $term_link ) ) {
	return;
}

$image_id             = absint( get_term_meta( $term->term_id, 'dcatl_term_image', true ) );
$hide_title           = ! empty( $settings['dcatl_hide_title'] );
$hide_divider         = ! empty( $settings['dcatl_hide_divider'] );
$hide_description     = ! empty( $settings['dcatl_hide_description'] );
$hide_button          = ! empty( $settings['dcatl_hide_button'] );
$hide_counter         = ! empty( $settings['dcatl_hide_counter'] );
$enable_image_overlay = ! empty( $settings['dcatl_enable_wrapper_overlay'] );
?>
<li>
	<?php if ( $image_id && wp_attachment_is_image( $image_id ) ) { ?>
		<div class="dcatl-term-image-wrapper">
			<?php
			echo wp_get_attachment_image(
				$image_id,
				'full',
				false,
				array(
					'class' => 'dcatl-term-image',
					'alt'   => esc_attr( $term->name ),
				)
			);
			?>
		</div>
	<?php } ?>

	<div class="dcatl-term-item">
		<?php if ( ! $hide_counter ) { ?>
			<div class="dcatl-term-badge"><span><?php echo esc_html( number_format_i18n( $term->count ) ); ?></span></div>
		<?php } ?>

		<?php if ( ! $hide_title ) { ?>
			<div class="dcatl-term-title-wrapper">
				<h3 class="dcatl-term-title <?php echo esc_attr( $hide_divider ? 'dcatl-term-title-hide-divider' : '' ); ?>">
					<a href="<?php echo esc_url( $term_link ); ?>"><?php echo esc_html( $term->name ); ?></a>
				</h3>
			</div>
		<?php } ?>

		<?php if ( ! $hide_description && '' !== trim( $term->description ) ) { ?>
			<div class="dcatl-term-description">
				<p><?php echo esc_html( $term->description ); ?></p>
			</div>
		<?php } ?>

		<?php if ( ! $hide_button ) { ?>
			<div class="dcatl-term-button-wrapper">
				<a class="dcatl-term-button" href="<?php echo esc_url( $term_link ); ?>">
					<?php esc_html_e( 'Read More', 'display-category-and-taxonomy-list' ); ?>
				</a>
			</div>
		<?php } ?>

		<?php if ( $enable_image_overlay ) { ?>
			<div class="dcatl-color-overlay" aria-hidden="true"></div>
		<?php } ?>
	</div>
</li>
