<?php



use Elementor\Widget_Base;
use Elementor\Controls_Manager;

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


class Phonenumberkaveh extends Widget_Base{

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

  public function get_title(){
    return esc_html__( 'Phone Number Element', 'kavehTheme' );
  }

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

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

  protected function register_controls(){
    
    $this->start_controls_section(
        'contentphonenumberkaveh',
        [
          'label' => esc_html__( 'Element Content', 'kavehTheme' ),
                  'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
        ]
      );
      $this->add_control(
        'pish1phonenumberkaveh',
        [
            'label' => esc_html__( 'First Prefix', 'kavehTheme' ),
            'type' => \Elementor\Controls_Manager::TEXT,
            'default' => esc_html__( '021', 'kavehTheme' ),
        ]
    ); 
    $this->add_control(
      'shomare1phonenumberkaveh',
      [
          'label' => esc_html__( 'First Number', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::TEXT,
          'default' => esc_html__( '12345678', 'kavehTheme' ),
      ]
  ); 
  $this->add_control(
    'pish2phonenumberkaveh',
    [
        'label' => esc_html__( 'Second Prefix', 'kavehTheme' ),
        'type' => \Elementor\Controls_Manager::TEXT,
        'default' => esc_html__( '021', 'kavehTheme' ),
    ]
); 
$this->add_control(
  'shomare2phonenumberkaveh',
  [
      'label' => esc_html__( 'Second Number', 'kavehTheme' ),
      'type' => \Elementor\Controls_Manager::TEXT,
      'default' => esc_html__( '12345678', 'kavehTheme' ),
  ]
);
$this->add_control(
  'titlephonenumberkaveh',
  [
      'label' => esc_html__( 'Title', 'kavehTheme' ),
      'type' => \Elementor\Controls_Manager::TEXT,
      'default' => esc_html__( 'Quick Support', 'kavehTheme' ),
  ]
); 
$this->add_control(
  'showimgphonenumberkaveh',
  [
    'label' => esc_html__( 'Show Background Image?', 'kavehTheme' ),
    'type' => \Elementor\Controls_Manager::SWITCHER,
    'yes' => esc_html__( 'Yes', 'kavehTheme' ),
    'no' => esc_html__( 'No', 'kavehTheme' ),
    'return_value' => 'yes',
    'default' => 'no',
  ]
);
$this->add_control(
  'imgphonenumberkaveh',
  [
    'label' => esc_html__( 'Background Image', 'kavehTheme' ),
    'type' => \Elementor\Controls_Manager::MEDIA,
    'selectors' => [
      '{{WRAPPER}} .footer-two-phone::after' =>
          'background: url({{URL}}) 0 0 no-repeat',
  ],
    'condition' => [
      'showimgphonenumberkaveh' => 'yes',
    ],
  ]
);

       $this->end_controls_section();
       $this->start_controls_section(
        'style_phonenumberkaveh',
        [
          'label' => esc_html__( 'Title Styles', 'kavehTheme' ),
          'tab' => \Elementor\Controls_Manager::TAB_STYLE,
        ]
      );
      $this->add_control(
        'pishphonenumberkaveh',
        [
          'label' => esc_html__( 'Prefix Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .footer-two-phone div span' => 'color: {{VALUE}}',
          ],
        ]
      );
      $this->add_group_control(
        \Elementor\Group_Control_Typography::get_type(),
        [
          'name' => 'pishtypephonenumberkaveh',
          'label' => esc_html__( 'Prefix Typography', 'kavehTheme' ),
          'selector' => '{{WRAPPER}} .footer-two-phone div span',
        ]
      );
      $this->add_control(
        'shomarephonenumberkaveh',
        [
          'label' => esc_html__( 'Number Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .footer-two-phone div' => 'color: {{VALUE}}',
          ],
        ]
      );
      $this->add_group_control(
        \Elementor\Group_Control_Typography::get_type(),
        [
          'name' => 'shomaretypephonenumberkaveh',
          'label' => esc_html__( 'Number Typography', 'kavehTheme' ),
          'selector' => '{{WRAPPER}} .footer-two-phone div',
        ]
      );
      $this->add_control(
        'titlestphonenumberkaveh',
        [
          'label' => esc_html__( 'Title Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .footer-two-phone > span' => 'color: {{VALUE}}',
          ],
        ]
      );
      $this->add_group_control(
        \Elementor\Group_Control_Typography::get_type(),
        [
          'name' => 'titletypephonenumberkaveh',
          'label' => esc_html__( 'Title Typography', 'kavehTheme' ),
          'selector' => '{{WRAPPER}} .footer-two-phone > span',
        ]
      );
      
      $this->add_control(
        'widthiconphonenumberkaveh',
        [
          'label' => esc_html__( 'Width', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::SLIDER,
          'size_units' => [ 'px' ],
          'condition' => [
            'showimgphonenumberkaveh' =>'yes',
          ],
          'range' => [
            'px' => [
              'min' => 0,
              'max' => 1000,
              'step' => 1,
            ],
          ],
          'selectors' => [
            '{{WRAPPER}} .footer-two-phone::after' => 'width: {{SIZE}}{{UNIT}};',
          ],
        ]
      );
      $this->add_control(
        'heighticonphonenumberkaveh',
        [
          'label' => esc_html__( 'Height', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::SLIDER,
          'size_units' => [ 'px' ],
          'condition' => [
            'showimgphonenumberkaveh' =>'yes',
          ],
          'range' => [
            'px' => [
              'min' => 0,
              'max' => 1000,
              'step' => 1,
            ],
          ],
          'selectors' => [
            '{{WRAPPER}} .footer-two-phone::after' => 'height: {{SIZE}}{{UNIT}};',
          ],
        ]
      );
      $this->add_control(
        'topiconphonenumberkaveh',
        [
          'label' => esc_html__( 'Top Spacing', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::SLIDER,
          'size_units' => [ 'px' ],
          'condition' => [
            'showimgphonenumberkaveh' =>'yes',
          ],
          'range' => [
            'px' => [
              'min' => 0,
              'max' => 1000,
              'step' => 1,
            ],
          ],
          'selectors' => [
            '{{WRAPPER}} .footer-two-phone::after' => 'top: {{SIZE}}{{UNIT}};',
          ],
        ]
      );
      $this->end_controls_section();
      
          
        }


  protected function render(){
    $settings = $this->get_settings_for_display();
  
?>

        <div class="footer-two-phone position-relative">
          <a href="tel:<?php echo  esc_html($settings['pish1phonenumberkaveh']); echo  esc_html($settings['shomare1phonenumberkaveh']); ?>"><div> <span><?php echo  esc_html($settings['pish1phonenumberkaveh']); ?></span><?php echo  esc_html($settings['shomare1phonenumberkaveh']); ?></div></a>
          <a href="tel:<?php echo  esc_html($settings['pish2phonenumberkaveh']); echo  esc_html($settings['shomare2phonenumberkaveh']); ?>"> <div> <span><?php echo  esc_html($settings['pish2phonenumberkaveh']); ?></span><?php echo  esc_html($settings['shomare2phonenumberkaveh']); ?></div></a>
          <span class="text-right d-block"><?php echo  esc_html($settings['titlephonenumberkaveh']); ?></span>
        </div>
    <?php
  }


}
