<?php
/**
 * Elementor
 *
 * @since 1.0.0
 */
class Dexen_single_project extends \Elementor\Widget_Base {
	public function get_name() {
		return 'dexen_single_project';
	}
	public function get_title() {
		return esc_html__( 'Dexen img gallery', 'plugin-name' );
	}
	public function get_icon() {
		return 'fa fa-object-ungroup';
	}
	public function get_categories() {
		return array( 'dexencore' );
	}
	protected function _register_controls() {
		$this->start_controls_section(
			'single_post_img',
			array(
				'label' => esc_html__( 'single project img list', 'plugin-name' ),
				'tab'   => \Elementor\Controls_Manager::TAB_CONTENT,
			)
		);
		$repeater = new \Elementor\Repeater();
		$repeater->add_control(
			'single_post_img_bg',
			array(
				'label'   => __( 'Background image', 'plugin-domain' ),
				'type'    => \Elementor\Controls_Manager::MEDIA,
				'default' => array(
					'url' => \Elementor\Utils::get_placeholder_image_src(),
				),
			)
		);
		$this->add_control(
			'single_post_img_list',
			array(
				'label'  => __( 'img List', 'dexen-core' ),
				'type'   => \Elementor\Controls_Manager::REPEATER,
				'fields' => $repeater->get_controls(),
			)
		);
		$this->end_controls_section();
	}
	protected function render() {
		$settings             = $this->get_settings_for_display();
		$single_post_img_list = $settings['single_post_img_list'];
		?>
		<?php if ( $single_post_img_list ) : ?>
			<section class="project-details ">
				<div class="container">
					<div class="row-3-col">
						<?php
						foreach ( $single_post_img_list as $item ) {

							$img_url = ( $item['single_post_img_bg']['id'] != '' ) ? wp_get_attachment_url( $item['single_post_img_bg']['id'], 'full' ) : $item['single_post_img_bg']['url'];
							?>
							<div class="col-3-col content-margin-30">
								<img src="<?php echo esc_attr( $img_url ); ?>" alt="Awesome Image">
							</div>
						<?php } ?>
					</div>
				</div>
			</section>
			<?php
		endif;
	}
}

\Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \Dexen_single_project() );
