<?php
$carousel_settings = kaitex_carousel_header($widget, array());

$img_size = $widget->get_setting('img_size', 'full');

if(isset($settings['team']) && !empty($settings['team']) && count($settings['team'])): ?>
    <div class="pxl-swiper-sliders pxl-team-carousel pxl-team-carousel1 pxl-parent-cursor pxl-drag-area" data-arrow="<?php echo esc_attr($carousel_settings['arrows']); ?>">
        <div class="pxl-carousel-inner">
            <div <?php pxl_print_html($widget->get_render_attribute_string( 'carousel' )); ?>>
                <div class="pxl-swiper-wrapper">
                    <?php foreach ($settings['team'] as $key => $value):
                        $title = isset($value['title']) ? $value['title'] : '';
                        $position = isset($value['position']) ? $value['position'] : '';
                        $image = isset($value['image']) ? $value['image'] : '';
                        $social = isset($value['social']) ? $value['social'] : '';
                        $link = isset($value['link']) ? $value['link'] : '';
                        $link_key = $widget->get_repeater_setting_key( 'title', 'value', $key );
                        if ( ! empty( $link['url'] ) ) {
                            $widget->add_render_attribute( $link_key, 'href', $link['url'] );

                            if ( $link['is_external'] ) {
                                $widget->add_render_attribute( $link_key, 'target', '_blank' );
                            }

                            if ( $link['nofollow'] ) {
                                $widget->add_render_attribute( $link_key, 'rel', 'nofollow' );
                            }
                        }
                        $link_attributes = $widget->get_render_attribute_string( $link_key );
                        ?>
                        <div class="pxl-swiper-slide">
                            <div class="pxl-item--inner <?php echo esc_attr($settings['pxl_animate']); ?>" data-wow-delay="<?php echo esc_attr($settings['pxl_animate_delay']); ?>ms" data-wow-duration="<?php echo esc_attr($settings['pxl_animate_duration']); ?>s">
                                <?php if(!empty($image['id'])) {
                                    $img = pxl_get_image_by_size( array(
                                        'attach_id'  => $image['id'],
                                        'thumb_size' => $img_size,
                                        'class' => 'no-lazyload',
                                    ));
                                    $thumbnail = $img['thumbnail'];?>
                                    <div class="pxl-item--image">
                                        <?php echo wp_kses_post($thumbnail); ?>
                                        <?php $team_social = json_decode($social, true);
                                        if(!empty($team_social)): ?>
                                            <div class="pxl-social--button">
                                                <i class="fal fa-plus"></i>
                                            </div>
                                            <div class="pxl-item--social">
                                                <?php foreach ($team_social as $value):
                                                    if(!empty($value['content'])) { ?>
                                                        <a aria-label="<?php echo pxl_print_html($value['content']); ?>" href="<?php echo esc_url($value['url']); ?>" target="_blank">
                                                            <?php echo pxl_print_html($value['content']); ?>
                                                        </a>
                                                    <?php }
                                                endforeach; ?>
                                            </div>
                                        <?php endif; ?>
                                    </div>
                                <?php } ?>
                                <div class="pxl-item--meta">
                                    <?php if (!empty($title)) : ?>
                                        <h4 class="pxl-item--title el-empty">
                                            <?php if ( ! empty( $link['url'] ) ) { ?><a aria-label="<?php echo pxl_print_html($title); ?>" <?php echo implode( ' ', [ $link_attributes ] ); ?>><?php } ?>
                                            <?php echo pxl_print_html($title); ?>
                                            <?php if ( ! empty( $link['url'] ) ) { ?></a><?php } ?>
                                        </h4>
                                    <?php endif; ?>
                                    <?php if (!empty($position)) : ?>
                                        <div class="pxl-item--position el-empty"><?php echo pxl_print_html($position); ?></div>
                                    <?php endif; ?>
                                </div>
                           </div>
                        </div>
                    <?php endforeach; ?>
                </div>
            </div>
            <?php kaitex_carousel_footer($carousel_settings['arrows'], $carousel_settings['arrows_style'], $carousel_settings['pagination'], $carousel_settings['bullets_style']); ?>
        </div>
    </div>
<?php endif; ?>
