Current File : /home/n742ef5/royalanteam.com/wp-content/plugins/myhome-core/src/Elementor/QuickViewTab.php |
<?php
namespace Tangibledesign\MyHome\Elementor;
use Elementor\Controls_Manager;
use Elementor\Core\Kits\Documents\Tabs\Tab_Base;
use Elementor\Group_Control_Typography;
use Elementor\Repeater;
class QuickViewTab extends Tab_Base
{
public function get_id(): string
{
return 'myhome-quick-view';
}
public function get_title(): string
{
return esc_html__('Quick View', 'myhome-core');
}
public function get_group(): string
{
return 'theme-style';
}
public function get_icon(): string
{
return 'fas fa-paint-brush';
}
protected function register_tab_controls(): void
{
$this->start_controls_section(
'myhome_quick_view',
[
'label' => esc_html__('MyHome Quick View', 'myhome-core'),
'tab' => $this->get_id(),
]
);
$this->addMetaControls();
$this->addCategoryControls();
$this->addNameControls();
$this->addAddressControls();
$this->addPrimaryValueControls();
$this->addAttributeControls();
$this->addDescriptionControls();
$this->addButtonControls();
$this->addCloseButtonControls();
$this->end_controls_section();
}
private function addCategoryFieldsControl(): void
{
$options = ['featured' => esc_html__('Featured', 'myhome-core')];
foreach (tdf_simple_text_value_fields() as $field) {
$options[tdf_prefix() . '_' . $field->getId()] = $field->getName();
}
$fields = new Repeater();
$fields->add_control(
'field',
[
'label' => esc_html__('Field', 'myhome-core'),
'type' => Controls_Manager::SELECT,
'options' => $options,
]
);
$this->add_control(
'myhome_quick_view_categories',
[
'label' => esc_html__('Categories', 'myhome-core'),
'type' => Controls_Manager::REPEATER,
'fields' => $fields->get_controls(),
'prevent_empty' => false,
]
);
}
/** @noinspection DuplicatedCode */
private function addAttributeFieldsControl(): void
{
$options = [];
foreach (tdf_simple_text_value_fields() as $field) {
$options[tdf_prefix() . '_' . $field->getId()] = $field->getName();
}
$fields = new Repeater();
$fields->add_control(
'icon',
[
'label' => esc_html__('Icon', 'myhome-core'),
'type' => Controls_Manager::ICONS,
]
);
$fields->add_control(
'field',
[
'label' => esc_html__('Field', 'myhome-core'),
'type' => Controls_Manager::SELECT,
'options' => $options,
]
);
$fields->add_control(
'text_before',
[
'label' => esc_html__('Text Before', 'myhome-core'),
'type' => Controls_Manager::TEXT,
]
);
$fields->add_control(
'text_after',
[
'label' => esc_html__('Text After', 'myhome-core'),
'type' => Controls_Manager::TEXT,
]
);
$this->add_control(
'myhome_quick_view_attributes',
[
'label' => esc_html__('Attributes', 'myhome-core'),
'type' => Controls_Manager::REPEATER,
'fields' => $fields->get_controls(),
'prevent_empty' => false,
]
);
}
private function addAttributeControls(): void
{
$this->add_control(
'myhome_quick_view_attributes_heading',
[
'label' => esc_html__('Attributes', 'myhome-core'),
'type' => Controls_Manager::HEADING,
]
);
$this->addAttributeFieldsControl();
$this->add_control(
'myhome_quick_view_attributes_color',
[
'label' => esc_html__('Color', 'myhome-core'),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .myhome-attribute' => 'color: {{VALUE}};',
]
]
);
$this->add_control(
'myhome_quick_view_attributes_bg',
[
'label' => esc_html__('Background', 'myhome-core'),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .myhome-attribute' => 'background-color: {{VALUE}};',
]
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'label' => esc_html__('Typography', 'myhome-core'),
'name' => 'myhome_quick_view_attributes_typo',
'selector' => '{{WRAPPER}} .myhome-attribute',
]
);
$this->add_responsive_control(
'myhome_quick_view_attributes_padding',
[
'label' => esc_html__('Padding', 'myhome-core'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px'],
'selectors' => [
'{{WRAPPER}} .myhome-attribute' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
}
private function addPrimaryValueControls(): void
{
$this->add_control(
'myhome_quick_view_primary_value_heading',
[
'label' => esc_html__('Primary Value', 'myhome-core'),
'type' => Controls_Manager::HEADING,
]
);
$this->add_control(
'myhome_quick_view_primary_value_color',
[
'label' => esc_html__('Color', 'myhome-core'),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .myhome-quick-view__main-value' => 'color: {{VALUE}};',
]
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'label' => esc_html__('Typography', 'myhome-core'),
'name' => 'myhome_quick_view_primary_value_typo',
'selector' => '{{WRAPPER}} .myhome-quick-view__main-value',
]
);
}
private function addAddressControls(): void
{
$this->add_control(
'myhome_quick_view_address_heading',
[
'label' => esc_html__('Address', 'myhome-core'),
'type' => Controls_Manager::HEADING,
]
);
$this->add_control(
'myhome_quick_view_address_icon_color',
[
'label' => esc_html__('Icon Color', 'myhome-core'),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .myhome-quick-view__address-icon path' => 'fill: {{VALUE}};',
]
]
);
$this->add_control(
'myhome_quick_view_address_color',
[
'label' => esc_html__('Color', 'myhome-core'),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .myhome-quick-view__address' => 'color: {{VALUE}};',
]
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'label' => esc_html__('Typography', 'myhome-core'),
'name' => 'myhome_quick_view_address_typo',
'selector' => '{{WRAPPER}} .myhome-quick-view__address',
]
);
}
private function addCategoryControls(): void
{
$this->add_control(
'myhome_quick_view_category_heading',
[
'label' => esc_html__('Category', 'myhome-core'),
'type' => Controls_Manager::HEADING,
]
);
$this->addCategoryFieldsControl();
$this->add_control(
'myhome_quick_view_category_color',
[
'label' => esc_html__('Color', 'myhome-core'),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .myhome-quick-view-wrapper .myhome-listing-attribute-v3' => 'color: {{VALUE}};',
]
]
);
$this->add_control(
'myhome_quick_view_category_bg',
[
'label' => esc_html__('Background', 'myhome-core'),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .myhome-quick-view-wrapper .myhome-listing-attribute-v3' => 'background-color: {{VALUE}};',
]
]
);
$this->add_control(
'myhome_quick_view_category_border',
[
'label' => esc_html__('Border', 'myhome-core'),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .myhome-quick-view-wrapper .myhome-listing-attribute-v3' => 'border-color: {{VALUE}};',
]
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'label' => esc_html__('Typography', 'myhome-core'),
'name' => 'myhome_quick_view_category_typo',
'selector' => '{{WRAPPER}} .myhome-quick-view-wrapper .myhome-listing-attribute-v3',
]
);
}
private function addNameControls(): void
{
$this->add_control(
'myhome_quick_view_name_heading',
[
'label' => esc_html__('Name', 'myhome-core'),
'type' => Controls_Manager::HEADING,
]
);
$this->add_control(
'myhome_quick_view_name_color',
[
'label' => esc_html__('Color', 'myhome-core'),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .myhome-quick-view__heading' => 'color: {{VALUE}};',
]
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'label' => esc_html__('Typography', 'myhome-core'),
'name' => 'myhome_quick_view_name_typo',
'selector' => '{{WRAPPER}} .myhome-quick-view__heading',
]
);
}
private function addMetaControls(): void
{
$this->add_control(
'myhome_quick_view_meta_heading',
[
'label' => esc_html__('Meta data', 'myhome-core'),
'type' => Controls_Manager::HEADING,
]
);
$this->add_control(
'myhome_quick_view_meta_icon_color',
[
'label' => esc_html__('Icon color', 'myhome-core'),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .myhome-quick-view__meta-icon path' => 'fill: {{VALUE}};',
]
]
);
$this->add_control(
'myhome_quick_view_meta_color',
[
'label' => esc_html__('Color', 'myhome-core'),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .myhome-quick-view__meta' => 'color: {{VALUE}};',
]
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'label' => esc_html__('Typography', 'myhome-core'),
'name' => 'myhome_quick_view_meta_typo',
'selector' => '{{WRAPPER}} .myhome-quick-view__meta',
]
);
}
private function addButtonControls(): void
{
$this->add_control(
'myhome_quick_view_button_heading',
[
'label' => esc_html__('Button', 'myhome-core'),
'type' => Controls_Manager::HEADING,
]
);
$this->add_control(
'myhome_quick_view_button_color',
[
'label' => esc_html__('Color', 'myhome-core'),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .myhome-quick-view .myhome-button' => 'color: {{VALUE}};',
]
]
);
$this->add_control(
'myhome_quick_view_button_bg',
[
'label' => esc_html__('Background', 'myhome-core'),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .myhome-quick-view .myhome-button' => 'background-color: {{VALUE}};',
]
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'label' => esc_html__('Typography', 'myhome-core'),
'name' => 'myhome_quick_view_button_typo',
'selector' => '{{WRAPPER}} .myhome-quick-view .myhome-button',
]
);
}
private function addDescriptionControls(): void
{
$this->add_control(
'myhome_quick_view_description_heading',
[
'label' => esc_html__('Description', 'myhome-core'),
'type' => Controls_Manager::HEADING,
]
);
$this->add_control(
'myhome_quick_view_description_color',
[
'label' => esc_html__('Color', 'myhome-core'),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .myhome-quick-view__description' => 'color: {{VALUE}};',
]
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'label' => esc_html__('Typography', 'myhome-core'),
'name' => 'myhome_quick_view_description_typo',
'selector' => '{{WRAPPER}} .myhome-quick-view__description',
]
);
}
private function addCloseButtonControls(): void
{
$this->add_control(
'myhome_quick_view_close_button_heading',
[
'label' => esc_html__('Close Button', 'myhome-core'),
'type' => Controls_Manager::HEADING,
]
);
$this->add_control(
'myhome_quick_view_close_button_color',
[
'label' => esc_html__('Color', 'myhome-core'),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .myhome-quick-view__close path' => 'fill: {{VALUE}};',
]
]
);
$this->add_control(
'myhome_quick_view_close_button_bg',
[
'label' => esc_html__('Background', 'myhome-core'),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .myhome-quick-view__close' => 'background-color: {{VALUE}};',
]
]
);
$this->add_responsive_control(
'myhome_quick_view_close_button_size',
[
'label' => esc_html__('Size', 'myhome-core'),
'type' => Controls_Manager::SLIDER,
'size_units' => ['px'],
'range' => [
'px' => [
'min' => 10,
'max' => 100,
],
],
'selectors' => [
'{{WRAPPER}} .myhome-quick-view__close' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'myhome_quick_view_close_button_icon_size',
[
'label' => esc_html__('Icon Size', 'myhome-core'),
'type' => Controls_Manager::SLIDER,
'size_units' => ['px'],
'range' => [
'px' => [
'min' => 10,
'max' => 100,
],
],
'selectors' => [
'{{WRAPPER}} .myhome-quick-view__close svg' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};',
],
]
);
}
}