<?php



use Elementor\Widget_Base;
use Elementor\Controls_Manager;

if (!defined('ABSPATH')) exit; // Exit if accessed directly


class Brandsgridkaveh extends Widget_Base{

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

  public function get_title(){
    return esc_html__( 'Grid Brands Element', 'kavehTheme' );
  }

  public function get_icon(){
    return 'eicon-archive-posts';
  }

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

  protected function register_controls(){
    
    $this->start_controls_section(
        'contentbrandsgridkaveh',
        [
          'label' => esc_html__( 'Element Content', 'kavehTheme' ),
                  'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
        ]
      );
        $repeater = new \Elementor\Repeater();
        $repeater->add_control(
          'brandlogobrandsgridkaveh',
          [
            'label' => esc_html__( 'Brand Image', 'kavehTheme' ),
            'type' => \Elementor\Controls_Manager::MEDIA,
            'default' => [
              'url' => \Elementor\Utils::get_placeholder_image_src(),
            ],
          ]
          );
          $repeater->add_control(
            'sociallinkbrandsgridkaveh',
            [
                'label' => esc_html__( 'Link', 'kavehTheme' ),
                'type' => \Elementor\Controls_Manager::TEXT,
                'default' => esc_html__( '#', 'kavehTheme' ),
        
            ]
        );
        $this->add_control(
          'listbrandsgridkaveh',
          [
            'label' => esc_html__( 'Social Networks', 'kavehTheme' ),
            'type' => \Elementor\Controls_Manager::REPEATER,
            'fields' => $repeater->get_controls(),
            'default' => [
              [
                'sociallinkbrandsgridkaveh' => esc_html__( '#', 'kavehTheme' ),
              ],
          ]
          ]
        
        ); 
        $this->end_controls_section();
        $this->start_controls_section(
          'style1_brandsgridkaveh',
          [
            'label' => esc_html__( 'Style', 'kavehTheme' ),
            'tab' => \Elementor\Controls_Manager::TAB_STYLE,
          ]
        ); 
        $this->add_control(
          'imgsizebrandsgridkaveh',
          [
            'label' => esc_html__( 'Image Size', 'kavehTheme' ),
            'type' => \Elementor\Controls_Manager::SLIDER,
            'size_units' => [ 'px', '%' ],
            'range' => [
              'px' => [
                'min' => 0,
                'max' => 200,
                'step' => 1,
              ],
              '%' => [
                'min' => 0,
                'max' => 100,
              ],
            ],
            'selectors' => [
              '{{WRAPPER}} .footer-namad li a img' => 'height: {{SIZE}}{{UNIT}};',
            ],
          ]
        );
        $this->add_control(
          'beforecolorbrandsgridkaveh',
          [
            'label' => esc_html__( 'Top Line Color', 'kavehTheme' ),
            'type' => \Elementor\Controls_Manager::COLOR,
            'selectors' => [
              '{{WRAPPER}} .footer-four .footer-namad::after' => 'background-color: {{VALUE}}',
              '{{WRAPPER}} .footer-four-news-letter::after' => 'background-color: {{VALUE}}',
            ],
          ]
        );
        $this->end_controls_section();
        }


  protected function render(){
    $settings = $this->get_settings_for_display();
    $clsid = $this->get_id();
  
?>
          <div class="footer-four">
            <ul class="footer-namad d-flex align-items-center flex-wrap flex-sm-nowrap">
                <?php
                if ( $settings['listbrandsgridkaveh'] ) {
                foreach (  $settings['listbrandsgridkaveh'] as $item ) {
                ?>
              <li>
                <a href="<?php echo  esc_url($item['sociallinkbrandsgridkaveh']); ?>">
                  <img src="<?php echo esc_url($item['brandlogobrandsgridkaveh']['url']); ?>" alt="<?php echo esc_attr(\Elementor\Control_Media::get_image_alt( $item['brandlogobrandsgridkaveh'] )); ?>" />
                </a>
              </li>
                <?php
                  }
                }
                  ?>
            </ul>
          </div>
    <?php
  }


}
