PluginProbe
Property Hive / 2.3.0
Property Hive v2.3.0
2.3.1 2.3.0 2.2.6 2.2.5 2.2.4 2.2.3 2.2.2 1.4.46 1.4.47 1.4.48 1.4.49 1.4.5 1.4.50 1.4.51 1.4.52 1.4.53 1.4.54 1.4.55 1.4.56 1.4.57 1.4.58 1.4.59 1.4.6 1.4.60 1.4.61 All 261 releases
propertyhive / includes / elementor-widgets / property-map-link.php

property-map-link.php in Property Hive 2.3.0, at includes/elementor-widgets/property-map-link.php

189 lines 4.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Elementor Property Map Link Widget.
4 *
5 * @since 1.0.0
6 */
7 class Elementor_Property_Map_Link_Widget extends \Elementor\Widget_Base {
8
9 public function get_name() {
10 return 'property-map-link';
11 }
12
13 public function get_title() {
14 return __( 'Map Link', '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 'style_section',
33 [
34 'label' => __( 'Map Link Settings', 'propertyhive' ),
35 'tab' => \Elementor\Controls_Manager::TAB_STYLE,
36 ]
37 );
38
39 $this->add_control(
40 'map_link_type',
41 [
42 'type' => \Elementor\Controls_Manager::SELECT,
43 'label' => esc_html__( 'Link Type', 'propertyhive' ),
44 'options' => [
45 '_blank' => 'Open map in new window',
46 'embedded' => 'Open embedded map in lightbox',
47 'iframe' => 'Open iframe map in lightbox',
48 ],
49 'default' => '_blank',
50 ]
51 );
52
53 $this->add_group_control(
54 \Elementor\Group_Control_Typography::get_type(),
55 [
56 'name' => 'typography',
57 'label' => __( 'Typography', 'propertyhive' ),
58 'global' => [
59 'default' => \Elementor\Core\Kits\Documents\Tabs\Global_Typography::TYPOGRAPHY_PRIMARY,
60 ],
61 'selector' => '{{WRAPPER}} a',
62 ]
63 );
64
65 $this->add_control(
66 'color',
67 [
68 'label' => __( 'Colour', 'propertyhive' ),
69 'type' => \Elementor\Controls_Manager::COLOR,
70 'global' => [
71 'default' => \Elementor\Core\Kits\Documents\Tabs\Global_Colors::COLOR_PRIMARY,
72 ],
73 'selectors' => [
74 '{{WRAPPER}} a' => 'color: {{VALUE}}',
75 ],
76 ]
77 );
78
79 $this->add_control(
80 'text_align',
81 [
82 'label' => __( 'Alignment', 'propertyhive' ),
83 'type' => \Elementor\Controls_Manager::CHOOSE,
84 'options' => [
85 'left' => [
86 'title' => __( 'Left', 'propertyhive' ),
87 'icon' => 'eicon-text-align-left',
88 ],
89 'center' => [
90 'title' => __( 'Center', 'propertyhive' ),
91 'icon' => 'eicon-text-align-center',
92 ],
93 'right' => [
94 'title' => __( 'Right', 'propertyhive' ),
95 'icon' => 'eicon-text-align-right',
96 ],
97 ],
98 'default' => 'center',
99 'toggle' => true,
100 'selectors' => [
101 '{{WRAPPER}}' => 'text-align: {{VALUE}}',
102 ],
103 ]
104 );
105
106 $this->add_control(
107 'background_color',
108 [
109 'label' => __( 'Background Colour', 'propertyhive' ),
110 'type' => \Elementor\Controls_Manager::COLOR,
111 'global' => [
112 'default' => \Elementor\Core\Kits\Documents\Tabs\Global_Colors::COLOR_SECONDARY,
113 ],
114 'selectors' => [
115 '{{WRAPPER}} a' => 'background: {{VALUE}}',
116 ],
117 ]
118 );
119
120 $this->add_control(
121 'padding',
122 [
123 'label' => __( 'Link Padding', 'propertyhive' ),
124 'type' => \Elementor\Controls_Manager::DIMENSIONS,
125 'size_units' => [ 'px' ],
126 'selectors' => [
127 '{{WRAPPER}} a' => 'display:inline-block; padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
128 ],
129 'default' => [
130 'top' => 5,
131 'right' => 5,
132 'bottom' => 5,
133 'left' => 5,
134 'isLinked' => true,
135 ],
136 ]
137 );
138
139 $this->end_controls_section();
140
141 }
142
143 protected function render() {
144
145 global $property;
146
147 $settings = $this->get_settings_for_display();
148
149 if ( !isset($property->id) ) {
150 return;
151 }
152
153 if ( $property->latitude == '' || $property->longitude == '' || $property->latitude == '0' || $property->longitude == '0' )
154 {
155 return;
156 }
157
158 $link_type = ( isset($settings['map_link_type']) && !empty($settings['map_link_type']) ) ? $settings['map_link_type'] : '_blank';
159
160 switch ($link_type)
161 {
162 case "_blank":
163 {
164 echo '<a href="https://www.google.com/maps/?q=' . (float)$property->latitude . ',' . (float)$property->longitude . '&ll=' . (float)$property->latitude . ',' . (float)$property->longitude . '" target="_blank">' . esc_html(__( 'View Map', 'propertyhive' )) . '</a>';
165 break;
166 }
167 case "embedded":
168 {
169 echo '<a href="#map_lightbox" data-fancybox>' . esc_html(__( 'View Map', 'propertyhive' )) . '</a>';
170
171 echo '<div id="map_lightbox" style="display:none; width:90%; max-width:800px;">';
172 echo do_shortcode('[property_map]');
173 echo '</div>';
174 break;
175 }
176 case "iframe":
177 {
178 echo '<a
179 href="#"
180 data-fancybox
181 data-type="iframe"
182 data-src="https://maps.google.com/?output=embed&amp;f=q&amp;q=' . (float)$property->latitude . ',' . (float)$property->longitude . '&amp;ll=' . (float)$property->latitude . ',' . (float)$property->longitude . '&amp;layer=t&amp;hq=&amp;t=m&amp;z=15"
183 >' . esc_html(__( 'View Map', 'propertyhive' )) . '</a>';
184 break;
185 }
186 }
187
188 }
189 }