File: /mnt/data/dreamssalon-wp/wp-content/plugins/dreamsalon-widgets/widgets/class-contact-location.php
<?php
/**
* DS Location Section Widget Class
*
* @since 1.0.0
*/
namespace dreamsalonelementor\Widgets;
use Elementor\Widget_Base;
use Elementor\Controls_Manager;
use Elementor\Repeater;
use Elementor\Utils;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
class DSLocationSection extends Widget_Base {
public function get_name() {
return 'dreamsalon-ds-location-section';
}
public function get_title() {
return __( 'DS Location Section', 'dreamsalon_elementor' );
}
public function get_icon() {
return 'eicon-map-pin';
}
public function get_categories() {
return [ 'dreamsalon' ];
}
protected function _register_controls() {
// ✅ Section: Title
$this->start_controls_section(
'section_content',
[
'label' => __( 'Content', 'dreamsalon_elementor' ),
]
);
$this->add_control(
'section_title',
[
'label' => __( 'Section Title', 'dreamsalon_elementor' ),
'type' => Controls_Manager::TEXT,
'default' => __( 'Our Office Locations', 'dreamsalon_elementor' ),
]
);
$this->end_controls_section();
// ✅ Section: Office Locations
$this->start_controls_section(
'section_locations',
[
'label' => __( 'Office Locations', 'dreamsalon_elementor' ),
]
);
$repeater = new Repeater();
$repeater->add_control(
'icon_class',
[
'label' => __( 'Icon Class (optional)', 'dreamsalon_elementor' ),
'type' => Controls_Manager::TEXT,
'default' => 'ti ti-map-pin',
'description' => __( 'Enter icon class (e.g., ti ti-map-pin or fa fa-map-marker)', 'dreamsalon_elementor' ),
]
);
$repeater->add_control(
'icon_image',
[
'label' => __( 'Custom Icon Image (optional)', 'dreamsalon_elementor' ),
'type' => Controls_Manager::MEDIA,
'default' => [
'url' => Utils::get_placeholder_image_src(),
],
]
);
$repeater->add_control(
'office_name',
[
'label' => __( 'Office Name', 'dreamsalon_elementor' ),
'type' => Controls_Manager::TEXT,
'default' => __( 'San Francisco, CA', 'dreamsalon_elementor' ),
]
);
$repeater->add_control(
'office_address',
[
'label' => __( 'Office Address', 'dreamsalon_elementor' ),
'type' => Controls_Manager::TEXTAREA,
'default' => __( '45 Oxford street, 3rd Floor New York, NSW 90001.', 'dreamsalon_elementor' ),
]
);
$this->add_control(
'locations',
[
'label' => __( 'Office Locations', 'dreamsalon_elementor' ),
'type' => Controls_Manager::REPEATER,
'fields' => $repeater->get_controls(),
'title_field' => '{{{ office_name }}}',
]
);
$this->end_controls_section();
// ✅ Section: Background Images
$this->start_controls_section(
'section_background',
[
'label' => __( 'Background Images', 'dreamsalon_elementor' ),
]
);
$this->add_control(
'bg_image_1',
[
'label' => __( 'Background Image 1', 'dreamsalon_elementor' ),
'type' => Controls_Manager::MEDIA,
'default' => [
'url' => Utils::get_placeholder_image_src(),
],
]
);
$this->add_control(
'bg_image_2',
[
'label' => __( 'Background Image 2', 'dreamsalon_elementor' ),
'type' => Controls_Manager::MEDIA,
'default' => [
'url' => Utils::get_placeholder_image_src(),
],
]
);
$this->end_controls_section();
}
protected function render() {
$settings = $this->get_settings_for_display();
?>
<!-- Location Section -->
<div class="location-section position-relative overflow-hidden">
<?php if ( ! empty( $settings['bg_image_1']['url'] ) ) : ?>
<img src="<?php echo esc_url( $settings['bg_image_1']['url'] ); ?>" alt="bg-1" class="img-fluid contact-us-bg-one d-none d-lg-flex">
<?php endif; ?>
<?php if ( ! empty( $settings['bg_image_2']['url'] ) ) : ?>
<img src="<?php echo esc_url( $settings['bg_image_2']['url'] ); ?>" alt="bg-2" class="img-fluid contact-us-bg-two d-none d-lg-flex">
<?php endif; ?>
<div class="container">
<?php if ( ! empty( $settings['section_title'] ) ) : ?>
<h2 class="text-center mb-5"><?php echo esc_html( $settings['section_title'] ); ?></h2>
<?php endif; ?>
<div class="row row-gap-3 justify-content-center">
<?php
if ( ! empty( $settings['locations'] ) ) :
$delay = 0.2;
foreach ( $settings['locations'] as $item ) :
?>
<div class="col-xl-4 col-lg-6 d-flex">
<div class="contact-item flex-fill wow fadeInUp" data-wow-delay="<?php echo esc_attr( $delay ); ?>s">
<div class="d-flex align-items-center">
<?php if ( ! empty( $item['icon_image']['url'] ) ) : ?>
<img src="<?php echo esc_url( $item['icon_image']['url'] ); ?>" alt="icon" class="me-3" style="width: 32px; height: auto;">
<?php elseif ( ! empty( $item['icon_class'] ) ) : ?>
<i class="<?php echo esc_attr( $item['icon_class'] ); ?> fs-24 me-3"></i>
<?php endif; ?>
<div>
<h3 class="title mb-2"><?php echo esc_html( $item['office_name'] ); ?></h3>
<p class="mb-0"><?php echo esc_html( $item['office_address'] ); ?></p>
</div>
</div>
</div>
</div>
<?php
$delay += 0.2;
endforeach;
endif;
?>
</div>
</div>
</div>
<!-- Location Section End -->
<?php
}
}