| 1 |
<?php |
| 2 |
/** |
| 3 |
* Elementor Property Map Widget. |
| 4 |
* |
| 5 |
* @since 1.0.0 |
| 6 |
*/ |
| 7 |
class Elementor_Property_Map_Widget extends \Elementor\Widget_Base { |
| 8 |
|
| 9 |
public function get_name() { |
| 10 |
return 'property-map'; |
| 11 |
} |
| 12 |
|
| 13 |
public function get_title() { |
| 14 |
return __( 'Map', 'propertyhive' ); |
| 15 |
} |
| 16 |
|
| 17 |
public function get_icon() { |
| 18 |
return 'eicon-google-maps'; |
| 19 |
} |
| 20 |
|
| 21 |
public function get_categories() { |
| 22 |
return [ 'property-hive' ]; |
| 23 |
} |
| 24 |
|
| 25 |
public function get_keywords() { |
| 26 |
return [ 'property hive', 'propertyhive', 'property', 'map', 'location', 'google map' ]; |
| 27 |
} |
| 28 |
|
| 29 |
protected function register_controls() { |
| 30 |
|
| 31 |
$this->start_controls_section( |
| 32 |
'settings_section', |
| 33 |
[ |
| 34 |
'label' => __( 'Map Settings', 'propertyhive' ), |
| 35 |
'tab' => \Elementor\Controls_Manager::TAB_CONTENT, |
| 36 |
] |
| 37 |
); |
| 38 |
|
| 39 |
$this->add_control( |
| 40 |
'height', |
| 41 |
[ |
| 42 |
'label' => __( 'Map Height', 'propertyhive' ) . ' (px)', |
| 43 |
'type' => \Elementor\Controls_Manager::TEXT, |
| 44 |
'input_type' => 'number', |
| 45 |
'default' => 400 |
| 46 |
] |
| 47 |
); |
| 48 |
|
| 49 |
$this->add_control( |
| 50 |
'zoom', |
| 51 |
[ |
| 52 |
'label' => __( 'Zoom', 'propertyhive' ), |
| 53 |
'type' => \Elementor\Controls_Manager::SLIDER, |
| 54 |
'default' => [ |
| 55 |
'size' => 14, |
| 56 |
], |
| 57 |
'range' => [ |
| 58 |
'px' => [ |
| 59 |
'min' => 1, |
| 60 |
'max' => 20, |
| 61 |
], |
| 62 |
], |
| 63 |
'separator' => 'before', |
| 64 |
] |
| 65 |
); |
| 66 |
|
| 67 |
$this->add_control( |
| 68 |
'scrollwheel', |
| 69 |
[ |
| 70 |
'label' => __( 'Scrollwheel Zoom', 'propertyhive' ), |
| 71 |
'type' => \Elementor\Controls_Manager::SELECT, |
| 72 |
'default' => 'true', |
| 73 |
'options' => array( |
| 74 |
'true' => __( 'True', 'propertyhive' ), |
| 75 |
'false' => __( 'False', 'propertyhive' ), |
| 76 |
), |
| 77 |
'separator' => 'before', |
| 78 |
] |
| 79 |
); |
| 80 |
|
| 81 |
$this->end_controls_section(); |
| 82 |
|
| 83 |
} |
| 84 |
|
| 85 |
protected function render() { |
| 86 |
|
| 87 |
global $property; |
| 88 |
|
| 89 |
$settings = $this->get_settings_for_display(); |
| 90 |
|
| 91 |
if ( !isset( $property->id ) ) { |
| 92 |
return; |
| 93 |
} |
| 94 |
|
| 95 |
$attributes = array(); |
| 96 |
if ( isset($settings['height']) && $settings['height'] != '' ) |
| 97 |
{ |
| 98 |
$attributes['height'] = $settings['height']; |
| 99 |
} |
| 100 |
if ( isset($settings['zoom']) && isset($settings['zoom']['size']) && $settings['zoom']['size'] != '' ) |
| 101 |
{ |
| 102 |
$attributes['zoom'] = $settings['zoom']['size']; |
| 103 |
} |
| 104 |
if ( isset($settings['scrollwheel']) && $settings['scrollwheel'] != '' ) |
| 105 |
{ |
| 106 |
$attributes['scrollwheel'] = $settings['scrollwheel']; |
| 107 |
} |
| 108 |
|
| 109 |
$attributes = apply_filters( 'propertyhive_elementor_property_map_attributes', $attributes ); |
| 110 |
|
| 111 |
get_property_map($attributes); |
| 112 |
|
| 113 |
} |
| 114 |
|
| 115 |
} |