<?php
$html_id = pxl_get_element_id($settings);
if ( ! empty( $settings['link']['url'] ) ) {
    $widget->add_render_attribute( 'link_text', 'href', $settings['link']['url'] );

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

    if ( $settings['link']['nofollow'] ) {
        $widget->add_render_attribute( 'link_text', 'rel', 'nofollow' );
    }
}
?>
<div class="pxl-meta-box pxl-meta-box2">
    <div class="pxl-meta-inner">
    	<?php if(!empty($settings['image']['id'])) : 
            $image_size = !empty($settings['img_size']) ? $settings['img_size'] : '600x675'; 
            $img = pxl_get_image_by_size( array(
                'attach_id'  => $settings['image']['id'],
                'thumb_size' => $image_size,
            ));
            $thumbnail = $img['thumbnail'];
            ?>
            <div class="pxl-item--img <?php echo esc_attr($settings['pxl_animate']); ?>" data-wow-delay="<?php echo esc_attr($settings['pxl_animate_delay']); ?>ms">
                <div class="pxl-image">
                	<a class="pxl-image-link" <?php pxl_print_html($widget->get_render_attribute_string( 'link_text' )); ?>>
                		<?php echo pxl_print_html($thumbnail); ?>
                	</a>
                </div>
                <?php
				$is_new = \Elementor\Icons_Manager::is_migration_allowed();
				if(isset($settings['icons']) && !empty($settings['icons']) && count($settings['icons'])): ?>
				    <div class="pxl-social">
				        <span class="pxl-social--button">
				            <i class="fas fa-share-alt"></i>
				        </span>
				        <div class="pxl-social-inner">
				            <?php foreach ($settings['icons'] as $key => $value):
				                $icon_key = $widget->get_repeater_setting_key( 'pxl_icon', 'icons', $key );
				                $widget->add_render_attribute( $icon_key, [
				                    'class' => $value['pxl_icon'],
				                    'aria-hidden' => 'true',
				                ] );
				                $link_key = $widget->get_repeater_setting_key( 'icon_link', 'value', $key );
				                if ( ! empty( $value['icon_link']['url'] ) ) {
				                    $widget->add_render_attribute( $link_key, 'href', $value['icon_link']['url'] );

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

				                    if ( $value['icon_link']['nofollow'] ) {
				                        $widget->add_render_attribute( $link_key, 'rel', 'nofollow' );
				                    }
				                }
				                $link_attributes = $widget->get_render_attribute_string( $link_key ); ?>
				                <?php if ( ! empty( $value['pxl_icon'] ) ) : ?>
				                    <a class="elementor-repeater-item-<?php echo esc_attr($value['_id']); ?>" <?php echo implode( ' ', [ $link_attributes ] ); ?>>
				                        <?php if ( $is_new ):
				                            \Elementor\Icons_Manager::render_icon( $value['pxl_icon'], [ 'aria-hidden' => 'true' ] );
				                        elseif(!empty($value['pxl_icon'])): ?>
				                            <i class="<?php echo esc_attr( $value['pxl_icon'] ); ?>" aria-hidden="true"></i>
				                        <?php endif; ?>
				                    </a>
				                <?php endif; ?>
				            <?php endforeach; ?>
				        </div>
				    </div>
				<?php endif; ?>
            </div>
        <?php endif; ?>
        <div class="pxl-content-section">
        	<div class="pxl-item-content">
        		<div class="pxl-item-text">
	                <?php echo esc_attr($settings['text']); ?>
	            </div>
	            <div class="pxl-sub-title">
	                <?php echo esc_attr($settings['sub_title']); ?>
	            </div>
        	</div>
        	<div class="pxl-meta-button">
	            <a class="pxl-button-link" <?php pxl_print_html($widget->get_render_attribute_string( 'link_text' )); ?>>
	                <span class="pxl-btn-icon">
	                    <svg id="Layer_1" enable-background="new 0 0 20 20" height="512" viewBox="0 0 20 20" width="512" xmlns="http://www.w3.org/2000/svg"><path d="m12 2-1.4 1.4 5.6 5.6h-16.2v2h16.2l-5.6 5.6 1.4 1.4 8-8z" fill="rgb(0,0,0)"/></svg>
	                </span>
	            </a>
	        </div>
        </div>
    </div>
</div>