<?php
if ( ! defined( 'ABSPATH' ) ) { exit; } // Exit if accessed directly

?>
<div class="rivax-horizontal-tags">
    <?php if( $settings['title'] ): ?>
        <div class="title-wrapper"><?php echo esc_html($settings['title']); ?></div>
    <?php endif; ?>
    <div class="content-wrapper swiper">
        <div class="items-wrapper swiper-wrapper">
            <?php
            $terms = get_terms( array(
                'taxonomy'   => $settings['source'],
                'hide_empty' => false,
                'fields' => 'id=>name',
                'orderby' => 'count',
                'order' => 'DESC',
                'number' => absint($settings['count']) ?? 15,
            ) );

            if ( ! empty( $terms ) && ! is_wp_error( $terms ) ){
                foreach (  $terms as $id => $term_name ) {
                    ?>
                    <div class="swiper-slide"><a <?php if( $settings['open_link_new_tab'] ) echo 'target="_blank"'; ?> href="<?php echo esc_url(get_term_link( $id )); ?>"><?php echo esc_html($term_name); ?></a></div>
                    <?php
                }
            }
            ?>
        </div>
    </div>
    <div class="arrows-wrapper">
        <a href="" class="carousel-nav-prev">
            <i class="ri-right-arrow-1"></i>
        </a>
        <a href="" class="carousel-nav-next">
            <i class="ri-right-arrow-1"></i>
        </a>
    </div>
</div>
