<?php
/** 
 * Elementor 
 * @since 1.0.0
*/
class Dexen_single_project_info extends \Elementor\Widget_Base {
    public function get_name() {
        return 'dexen_single_project_info';
    }
    public function get_title(){
        return esc_html__( 'Dexen project info', 'plugin-name' );
    }
    public function get_icon(){
        return 'fa fa-object-ungroup';
    }
    public function get_categories(){
        return [ 'dexencore' ];
    }
    protected function _register_controls() {
        $this->start_controls_section(
            'single_post_img',
            [
                'label' => esc_html__( 'single project info list', 'plugin-name' ),
                'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
            ]
        );
        $repeater = new \Elementor\Repeater();
        $repeater->add_control(
            'single_post_img_bg', [
                'label' => __( 'info title', 'plugin-domain' ),
                'type' => \Elementor\Controls_Manager::TEXT,
            ]
        );
        $repeater->add_control(
            'single_post_img_content', [
                'label' => __( 'info content', 'plugin-domain' ),
                'type' => \Elementor\Controls_Manager::TEXT,
            ]
        );
        $this->add_control(
			'single_post_img_list',
			[
				'label'   => __( 'info 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 ) : ?>
            <div class="project-details__feature thm-gray-bg">
                <?php foreach ( $single_post_img_list as $item ) {
                    $img_url = $item['single_post_img_bg'];
                    $img_content = $item['single_post_img_content'];
                ?>
                    <div class="project-details__feature-item">
                        <div class="project-details__feature-name">
                            <?php echo wp_kses_post( $img_url ); ?>
                        </div>
                        <div class="project-details__feature-option">
                            <?php echo wp_kses_post( $img_content ); ?>
                        </div>
                    </div>
                <?php } ?>
            </div>
        <?php endif; 
    }
}

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