281 lines
5.6 KiB
PHP
281 lines
5.6 KiB
PHP
<?php
|
|
/**
|
|
* 2007-2022 Leotheme
|
|
*
|
|
* NOTICE OF LICENSE
|
|
*
|
|
* LeoElements is module help you can build content for your shop
|
|
*
|
|
* DISCLAIMER
|
|
*
|
|
* @author Leotheme <leotheme@gmail.com>
|
|
* @copyright 2007-2022 Leotheme
|
|
* @license http://leotheme.com - prestashop template provider
|
|
*/
|
|
|
|
namespace LeoElements;
|
|
|
|
use LeoElements\Modules\DynamicTags\Module as TagsModule;
|
|
use LeoElements\Leo_Helper;
|
|
|
|
if ( ! defined( '_PS_VERSION_' ) ) {
|
|
exit; // Exit if accessed directly.
|
|
}
|
|
|
|
/**
|
|
* Elementor google maps widget.
|
|
*
|
|
* Elementor widget that displays an embedded google map.
|
|
*
|
|
* @since 1.0.0
|
|
*/
|
|
class Widget_Google_Maps extends Widget_Base {
|
|
|
|
/**
|
|
* Get widget name.
|
|
*
|
|
* Retrieve google maps widget name.
|
|
*
|
|
* @since 1.0.0
|
|
* @access public
|
|
*
|
|
* @return string Widget name.
|
|
*/
|
|
public function get_name() {
|
|
return 'google_maps';
|
|
}
|
|
|
|
/**
|
|
* Get widget title.
|
|
*
|
|
* Retrieve google maps widget title.
|
|
*
|
|
* @since 1.0.0
|
|
* @access public
|
|
*
|
|
* @return string Widget title.
|
|
*/
|
|
public function get_title() {
|
|
return Leo_Helper::__( 'Google Maps', 'elementor' );
|
|
}
|
|
|
|
/**
|
|
* Get widget icon.
|
|
*
|
|
* Retrieve google maps widget icon.
|
|
*
|
|
* @since 1.0.0
|
|
* @access public
|
|
*
|
|
* @return string Widget icon.
|
|
*/
|
|
public function get_icon() {
|
|
return 'eicon-google-maps';
|
|
}
|
|
|
|
/**
|
|
* Get widget categories.
|
|
*
|
|
* Retrieve the list of categories the google maps widget belongs to.
|
|
*
|
|
* Used to determine where to display the widget in the editor.
|
|
*
|
|
* @since 2.0.0
|
|
* @access public
|
|
*
|
|
* @return array Widget categories.
|
|
*/
|
|
public function get_categories() {
|
|
return [ 'basic' ];
|
|
}
|
|
|
|
/**
|
|
* Get widget keywords.
|
|
*
|
|
* Retrieve the list of keywords the widget belongs to.
|
|
*
|
|
* @since 1.0.0
|
|
* @access public
|
|
*
|
|
* @return array Widget keywords.
|
|
*/
|
|
public function get_keywords() {
|
|
return [ 'google', 'map', 'embed', 'location' ];
|
|
}
|
|
|
|
/**
|
|
* Register google maps widget controls.
|
|
*
|
|
* Adds different input fields to allow the user to change and customize the widget settings.
|
|
*
|
|
* @since 1.0.0
|
|
* @access protected
|
|
*/
|
|
protected function _register_controls() {
|
|
$this->start_controls_section(
|
|
'section_map',
|
|
[
|
|
'label' => Leo_Helper::__( 'Map', 'elementor' ),
|
|
]
|
|
);
|
|
|
|
$default_address = Leo_Helper::__( 'London Eye, London, United Kingdom', 'elementor' );
|
|
$this->add_control(
|
|
'address',
|
|
[
|
|
'label' => Leo_Helper::__( 'Location', 'elementor' ),
|
|
'type' => Controls_Manager::TEXT,
|
|
'placeholder' => $default_address,
|
|
'default' => $default_address,
|
|
'label_block' => true,
|
|
]
|
|
);
|
|
|
|
$this->add_control(
|
|
'zoom',
|
|
[
|
|
'label' => Leo_Helper::__( 'Zoom', 'elementor' ),
|
|
'type' => Controls_Manager::SLIDER,
|
|
'default' => [
|
|
'size' => 10,
|
|
],
|
|
'range' => [
|
|
'px' => [
|
|
'min' => 1,
|
|
'max' => 20,
|
|
],
|
|
],
|
|
'separator' => 'before',
|
|
]
|
|
);
|
|
|
|
$this->add_responsive_control(
|
|
'height',
|
|
[
|
|
'label' => Leo_Helper::__( 'Height', 'elementor' ),
|
|
'type' => Controls_Manager::SLIDER,
|
|
'range' => [
|
|
'px' => [
|
|
'min' => 40,
|
|
'max' => 1440,
|
|
],
|
|
],
|
|
'selectors' => [
|
|
'{{WRAPPER}} iframe' => 'height: {{SIZE}}{{UNIT}};',
|
|
],
|
|
]
|
|
);
|
|
|
|
$this->add_control(
|
|
'view',
|
|
[
|
|
'label' => Leo_Helper::__( 'View', 'elementor' ),
|
|
'type' => Controls_Manager::HIDDEN,
|
|
'default' => 'traditional',
|
|
]
|
|
);
|
|
|
|
$this->end_controls_section();
|
|
|
|
$this->start_controls_section(
|
|
'section_map_style',
|
|
[
|
|
'label' => Leo_Helper::__( 'Map', 'elementor' ),
|
|
'tab' => Controls_Manager::TAB_STYLE,
|
|
]
|
|
);
|
|
|
|
$this->start_controls_tabs( 'map_filter' );
|
|
|
|
$this->start_controls_tab( 'normal',
|
|
[
|
|
'label' => Leo_Helper::__( 'Normal', 'elementor' ),
|
|
]
|
|
);
|
|
|
|
$this->add_group_control(
|
|
Group_Control_Css_Filter::get_type(),
|
|
[
|
|
'name' => 'css_filters',
|
|
'selector' => '{{WRAPPER}} iframe',
|
|
]
|
|
);
|
|
|
|
$this->end_controls_tab();
|
|
|
|
$this->start_controls_tab( 'hover',
|
|
[
|
|
'label' => Leo_Helper::__( 'Hover', 'elementor' ),
|
|
]
|
|
);
|
|
|
|
$this->add_group_control(
|
|
Group_Control_Css_Filter::get_type(),
|
|
[
|
|
'name' => 'css_filters_hover',
|
|
'selector' => '{{WRAPPER}}:hover iframe',
|
|
]
|
|
);
|
|
|
|
$this->add_control(
|
|
'hover_transition',
|
|
[
|
|
'label' => Leo_Helper::__( 'Transition Duration', 'elementor' ),
|
|
'type' => Controls_Manager::SLIDER,
|
|
'range' => [
|
|
'px' => [
|
|
'max' => 3,
|
|
'step' => 0.1,
|
|
],
|
|
],
|
|
'selectors' => [
|
|
'{{WRAPPER}} iframe' => 'transition-duration: {{SIZE}}s',
|
|
],
|
|
]
|
|
);
|
|
|
|
$this->end_controls_tab();
|
|
|
|
$this->end_controls_tabs();
|
|
|
|
$this->end_controls_section();
|
|
}
|
|
|
|
/**
|
|
* Render google maps widget output on the frontend.
|
|
*
|
|
* Written in PHP and used to generate the final HTML.
|
|
*
|
|
* @since 1.0.0
|
|
* @access protected
|
|
*/
|
|
protected function render() {
|
|
$settings = $this->get_settings_for_display();
|
|
|
|
if ( empty( $settings['address'] ) ) {
|
|
return;
|
|
}
|
|
|
|
if ( 0 === abs( (int) $settings['zoom']['size'] ) ) {
|
|
$settings['zoom']['size'] = 10;
|
|
}
|
|
|
|
printf(
|
|
'<div class="elementor-custom-embed"><iframe frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://maps.google.com/maps?q=%s&t=m&z=%d&output=embed&iwloc=near" aria-label="%s"></iframe></div>',
|
|
rawurlencode( $settings['address'] ),
|
|
abs( (int) $settings['zoom']['size'] ),
|
|
Leo_Helper::esc_attr( $settings['address'] )
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Render google maps widget output in the editor.
|
|
*
|
|
* Written as a Backbone JavaScript template and used to generate the live preview.
|
|
*
|
|
* @since 1.0.0
|
|
* @access protected
|
|
*/
|
|
protected function _content_template() {}
|
|
}
|