Current File : /home/mdkeenpw/www/wp-content/plugins/logistik-core/addons/widgets/logistik-features.php
<?php
use \Elementor\Widget_Base;
use \Elementor\Controls_Manager;
use \Elementor\Group_Control_Typography;
use \Elementor\Utils;
use \Elementor\Group_Control_Image_Size;
use \Elementor\Group_Control_Box_Shadow;
use \Elementor\Group_Control_Border;
use \Elementor\Repeater;
/**
 *
 * Features Widget .
 *
 */
class logistik_Features extends Widget_Base {

	public function get_name() {
		return 'logistikfeatures';
	}

	public function get_title() {
		return __( 'Features', 'logistik' );
	}

	public function get_icon() {
		return 'themeholy-icon';
    }

	public function get_categories() {
		return [ 'logistik' ];
	}


	protected function register_controls() {


		 $this->start_controls_section(
			'section_title_section',
			[
				'label'		 	=> __( 'Features', 'logistik' ),
				'tab' 			=> Controls_Manager::TAB_CONTENT,
				
			]
        );

		$this->add_control(
			'layout_style',
			[
				'label' 		=> __( 'Layout Style', 'logistik' ),
				'type' 			=> Controls_Manager::SELECT,
				'default' 		=> '1',
				'options' 		=> [
					'1'  		=> __( 'Style One', 'logistik' ),					
					'2'  		=> __( 'Style Two', 'logistik' ),					
					'3'  		=> __( 'Style Three', 'logistik' ),					
				],
			]
		);

		$this->add_control(
            'shape',
            [
                'label'     => __( 'Shape', 'logistik' ),
                'type'      => Controls_Manager::MEDIA,
                'dynamic' 		=> [
					'active' 		=> true,
				],
				'condition'	=> [
					'layout_style' => ['2'],
				]
            ]
        );

		$repeater = new Repeater();

		$repeater->add_control(
            'image',
            [
                'label'     => __( 'Image / Icon', 'logistik' ),
                'type'      => Controls_Manager::MEDIA,
                'dynamic' 		=> [
					'active' 		=> true,
				],
            ]
        );

		$repeater->add_control(
			'title',
			[
				'label' 	=> __( 'Title', 'logistik' ),
                'type' 		=> Controls_Manager::TEXTAREA,
                'rows' 		=> 2,
                'default'  	=> __( '', 'logistik' )
			]
        );

		$repeater->add_control(
			'desc',
			[
				'label' 	=> __( 'Description', 'logistik' ),
                'type' 		=> Controls_Manager::TEXTAREA,
                'rows' 		=> 4,
                'default'  	=> __( 'Description here', 'logistik' )
			]
        );

		$this->add_control(
			'features_lists',
			[
				'label' 		=> __( 'Features', 'logistik' ),
				'type' 			=> Controls_Manager::REPEATER,
				'fields' 		=> $repeater->get_controls(),
				'default' 		=> [
					[
						'title'    => __( 'Our Mission', 'logistik' ),
					],
				],
				// 'condition'	=> [
				// 	'layout_style' => ['1', '2'],
				// ]
			]
		);


		$this->add_control(
			'features',
			[
				'label' 	=> __( 'Feature Lists', 'logistik' ),
                'type' 		=> Controls_Manager::WYSIWYG,
                'default'  	=> __( 'Morbi condimentum congue dui', 'logistik' ),
				'condition'	=> [
					'layout_style' => ['1'],
				]
			]
        );

		$this->add_control(
			'button_text',
			[
				'label' 	=> __( 'Button Text', 'logistik' ),
                'type' 		=> Controls_Manager::TEXT,
                'label_block' => true,
                'default'  	=> __( 'Button Text', 'logistik' ),
				'condition'	=> [
					'layout_style' => ['1'],
				]
			]
        );

        $this->add_control(
			'button_link',
			[
				'label' 		=> __( 'Link', 'logistik' ),
				'type' 			=> Controls_Manager::URL,
				'placeholder' 	=> __( 'https://your-link.com', 'logistik' ),
				'show_external' => true,
				'default' 		=> [
					'url' 			=> '#',
					'is_external' 	=> false,
					'nofollow' 		=> false,
				],
				'condition'	=> [
					'layout_style' => ['1'],
				]
			]
		);

        $this->end_controls_section();


        //---------------------------------------
			//Style Section Start
		//---------------------------------------
		
		//---------------------------------------Title Style---------------------------------------//
		$this->start_controls_section(
			'title_style',
			[
				'label' 	=> __( 'Title Style', 'tayde' ),
				'tab' 		=> Controls_Manager::TAB_STYLE,
			]
		);

		$this->add_control(
			'title_color',
			[
				'label' 		=> __( 'Color', 'tayde' ),
				'type' 			=> Controls_Manager::COLOR,
				'selectors' 	=> [
					'{{WRAPPER}} .th-title' => 'color: {{VALUE}} !important',
                ],
			]
        );

        $this->add_group_control(
			Group_Control_Typography::get_type(),
			[
				'name' 		=> 'title_typography',
				'label' 	=> __( 'Typography', 'tayde' ),
                'selector' 	=> '{{WRAPPER}} .th-title',
			]
        );
        $this->add_responsive_control(
			'title_margin',
			[
				'label' 		=> __( 'Margin', 'tayde' ),
				'type' 			=> Controls_Manager::DIMENSIONS,
				'size_units' 	=> [ 'px', '%', 'em' ],
				'selectors' 	=> [
					'{{WRAPPER}} .th-title' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                ]
			]
        );

        $this->add_responsive_control(
			'title_padding',
			[
				'label' 		=> __( 'Padding', 'tayde' ),
				'type' 			=> Controls_Manager::DIMENSIONS,
				'size_units' 	=> [ 'px', '%', 'em' ],
				'selectors' 	=> [
					'{{WRAPPER}} .th-title' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                ]
			]
		);
		$this->end_controls_section();

		//---------------------------------------Description Style---------------------------------------//
		$this->start_controls_section(
			'desc_style',
			[
				'label' 	=> __( 'Description Style', 'logistik' ),
				'tab' 		=> Controls_Manager::TAB_STYLE,
			]
		);

		$this->add_control(
			'desc_color',
			[
				'label' 		=> __( 'Color', 'logistik' ),
				'type' 			=> Controls_Manager::COLOR,
				'selectors' 	=> [
					'{{WRAPPER}} .th-desc' => 'color: {{VALUE}}',
				],
			]
		);

		$this->add_group_control(
			Group_Control_Typography::get_type(),
			[
				'name' 		=> 'desc_typography',
				'label' 	=> __( 'Typography', 'logistik' ),
				'selector' 	=> '{{WRAPPER}} .th-desc',
			]
		);

		$this->add_responsive_control(
			'desc_margin',
			[
				'label' 		=> __( 'Margin', 'logistik' ),
				'type' 			=> Controls_Manager::DIMENSIONS,
				'size_units' 	=> [ 'px', '%', 'em' ],
				'selectors' 	=> [
					'{{WRAPPER}} .th-desc' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				]
			]
		);

		$this->add_responsive_control(
			'desc_padding',
			[
				'label' 		=> __( 'Padding', 'logistik' ),
				'type' 			=> Controls_Manager::DIMENSIONS,
				'size_units' 	=> [ 'px', '%', 'em' ],
				'selectors' 	=> [
					'{{WRAPPER}} .th-desc' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				]
			]
		);

		$this->end_controls_section();


	}

	protected function render() {

        $settings = $this->get_settings_for_display();
        ?>

        <?php if( $settings['layout_style'] == '2' ): ?>
			<div class="row gy-4 justify-content-center">
				<?php  foreach( $settings['features_lists'] as $data ): ?>
                <div class="col-xl-4 col-lg-6 col-md-6">
                    <div class="feature-grid style4">
                        <div class="feature-grid_shape" data-bg-src="<?php echo esc_url($settings['shape']['url']); ?>"></div>
                        <div class="feature-grid_icon">
							<?php 
								echo logistik_img_tag( array(
									'url'   => esc_url( $data['image']['url']  ),
								));
							?>
                        </div>
                        <div>
							<h3 class="feature-grid_title th-title"><?php echo esc_html($data['title']) ?></h3>
                        	<p class="feature-grid_text th-desc"><?php echo esc_html($data['desc']) ?></p>
                        </div>
                    </div>
                </div>
  				<?php endforeach; ?>
            </div>

		<?php elseif( $settings['layout_style'] == '3' ): ?>
			<div class="achive-about-wrapper">
				<?php  foreach( $settings['features_lists'] as $data ): ?>
				<div class="achive-about">
					<div class="achive-about_icon">
						<?php 
							echo logistik_img_tag( array(
								'url'   => esc_url( $data['image']['url']  ),
							));
						?>
					</div>
					<div class="media-body">
						<h3 class="achive-about_title"><?php echo esc_html($data['title']) ?></h3>
					</div>
				</div>
				<?php endforeach; ?>
			</div>

    	<?php else: ?>
            <div class="achive-about-content">
                <div class="achive-about-wrapper">
                    <?php  foreach( $settings['features_lists'] as $data ): ?>
                    <div class="achive-about">
                        <div class="achive-about_icon">
                            <?php 
                                echo logistik_img_tag( array(
                                    'url'   => esc_url( $data['image']['url']  ),
                                ));
                            ?>
                        </div>
                        <div class="media-body">
                            <h3 class="achive-about_title th-title"><?php echo esc_html($data['title']) ?></h3>
                            <p class="achive-about_text th-desc"><?php echo esc_html($data['desc']) ?></p>
                        </div>
                    </div>
                    <?php endforeach; ?>
                </div>
                <div class="checklist">
                    <?php echo wp_kses_post($settings['features']) ?>
                </div>
                <div class="btn-group mt-30">
                    <a href="<?php echo esc_url( $settings['button_link']['url'] ); ?>" class="themeholy-btn blue-btn"><?php echo wp_kses_post( $settings['button_text'] ); ?></a>
                </div>
            </div>

		<?php endif;

	}

}