<?php
    $enable_category = get_theme_mod('crt_manage_enable_category_one_section');
    $heading = get_theme_mod('crt_manage_category_one_headline', 'Trending Topics');
    $tax = get_theme_mod('crt_manage_category_one_list');
?>

<section id="topic-tax" class="topic-tax">
    <div class="container position-relative">
        <?php crt_manage_section_link( 'Category' ); ?>
        <div class="row">
            <div class="col-12">
                <h2 class="topic-tax__heading"><?php echo esc_html($heading); ?></h2>
                <div class="topic-tax__list">
                <?php if(!empty($tax)): ?>
                    <?php foreach ( $tax as $tax_id ) :
                        $term = get_term($tax_id);
                        $count = $term->count;
                        $name = $term->name;
                        $term_link = get_term_link($term);
                        $thumbnail_url = get_term_meta($tax_id, 'crt_manage_tax_image', true);
                    ?>
                        <div class="topic-tax__item">
                            <a href="<?php echo esc_attr($term_link); ?>">
                                <img class="lazy" data-src="<?php echo esc_attr($thumbnail_url); ?>" alt="<?php echo esc_attr($name); ?>" />
                                <div class="topic-tax__content">
                                    <h3 class="topic-tax__name"><?php echo esc_html($name); ?></h3>
                                </div>
                            </a>
                        </div>
                    <?php endforeach;  ?>
                <?php endif; ?>
                </div>
            </div>
        </div>
    </div>
</section>
