<?php
$default_settings = [
    'download' => '',
    'box_title'    => '',
    'style_box' => 'box-nomarl',
    'ct_animate' => '',
];
$settings = array_merge($default_settings, $settings);
extract($settings);
?>
<?php if(isset($download) && !empty($download) && count($download)): ?>
    <div class="ct-download layout1 <?php echo esc_attr($style_box.' '.$ct_animate); ?>">
        <?php if ( $box_title ) { ?>
            <h3 class="entry-title">
                <?php echo esc_attr($box_title); ?>    
            </h3>
        <?php } ?>
        <?php foreach ($download as $key => $ct_download):
        	$link_key = $widget->get_repeater_setting_key( 'title', 'download', $key );
        	if ( ! empty( $ct_download['link']['url'] ) ) {
			    $widget->add_render_attribute( $link_key, 'href', $ct_download['link']['url'] );

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

			    if ( $ct_download['link']['nofollow'] ) {
			        $widget->add_render_attribute( $link_key, 'rel', 'nofollow' );
			    }
			}
			$link_attributes = $widget->get_render_attribute_string( $link_key );
        	?>
            <div class="item--download">
            	<a <?php echo implode( ' ', [ $link_attributes ] ); ?>>
	            	<?php ct_print_html(nl2br($ct_download['title'])); ?>
	            	<?php if(!empty($ct_download['file_type'])) : ?>
	            		<span class="download-file-type"><?php echo esc_attr($ct_download['file_type']); ?></span>
	            	<?php endif; ?>
	            </a>
           </div>
        <?php endforeach; ?>
    </div>
<?php endif; ?>
