Current File : /home/n742ef5/royalanteam.com/wp-content/plugins/myhome-core/src/Widgets/General/EmailWidget.php |
<?php
namespace Tangibledesign\MyHome\Widgets\General;
use Elementor\Controls_Manager;
use Tangibledesign\Framework\Widgets\Helpers\BaseGeneralWidget;
use Tangibledesign\Framework\Widgets\Helpers\Controls\TextAlignControl;
use Tangibledesign\MyHome\Widgets\Helpers\Controls\HasIconWithContainer;
use Tangibledesign\MyHome\Widgets\Helpers\Controls\LinkStyleControls;
class EmailWidget extends BaseGeneralWidget
{
use TextAlignControl;
use HasIconWithContainer;
use LinkStyleControls;
public function getKey(): string
{
return 'email';
}
public function getName(): string
{
return esc_html__('Email', 'myhome-core');
}
protected function register_controls(): void
{
$this->addContentSection();
$this->addGeneralStyleSection();
$this->addIconContainerStyleSection('.myhome-small-icon');
$this->addIconStyleSection('.myhome-small-icon');
$this->addEmailStyleSection();
}
private function addContentSection(): void
{
$this->startContentControlsSection();
$this->add_control(
'custom_email',
[
'label' => esc_html__('Email', 'myhome-core'),
'type' => Controls_Manager::TEXT,
]
);
$this->endControlsSection();
}
public function getEmail(): string
{
$email = (string)$this->get_settings_for_display('custom_email');
if (empty($email)) {
return tdf_settings()->getMail();
}
return $email;
}
private function addGeneralStyleSection(): void
{
$this->startStyleControlsSection();
$this->add_responsive_control(
'show_icon',
[
'label' => esc_html__('Display Icon', 'myhome-core'),
'type' => Controls_Manager::SELECT,
'options' => [
'block' => esc_html__('Show', 'myhome-core'),
'none' => esc_html__('Hide', 'myhome-core')
],
'default' => 'block',
'selectors' => [
'{{WRAPPER}} .myhome-small-data__icon' => 'display: {{VALUE}};'
]
]
);
$this->addTextAlignControl('.myhome-email-wrapper');
$this->endControlsSection();
}
private function addEmailStyleSection(): void
{
$this->startStyleControlsSection('email', esc_html__('Email', 'myhome-core'));
$this->addLinkStyleControls('.myhome-email');
$this->endControlsSection();
}
}