PluginProbe ʕ •ᴥ•ʔ
Elementor Website Builder – more than just a page builder / 4.1.0-beta3
Elementor Website Builder – more than just a page builder v4.1.0-beta3
4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 3.22.0-dev1 4.0.0-beta3 3.22.0-dev2 4.0.0-beta4 3.22.0-dev3 4.0.0-beta5 3.22.0-dev4 4.0.0-dev1 3.22.0-dev5 4.0.0-dev2 3.22.0-dev6 4.0.0-dev3 3.22.1 4.0.0-dev4 3.22.2 4.0.0-dev5 3.22.3 4.0.1 3.23.0 4.0.2 3.23.0-beta1 3.23.0-beta2 3.23.0-beta3 3.23.0-beta4 3.23.0-beta5 3.23.0-beta6 3.23.0-dev1 3.23.0-dev2 3.23.0-dev3 3.23.0-dev4 3.23.0-dev5 3.23.0-dev6 3.23.1 3.23.2 3.23.3 3.23.4 3.24.0 3.24.0-beta1 3.24.0-beta2 3.24.0-beta3 3.24.0-dev1 3.24.0-dev2 3.24.0-dev3 3.24.1 3.24.2 3.24.3 3.24.4 3.24.5 3.24.6 3.24.7 3.24.8 3.25.0 3.25.0-beta1 3.25.0-beta2 3.25.0-beta3 3.25.0-dev1 3.25.0-dev2 3.25.0-dev3 3.25.1 3.25.10 3.25.11 3.25.2 3.25.3 3.25.4 3.25.5 3.25.6 3.25.7 3.25.8 3.25.9 3.26.0 3.26.0-beta1 3.26.0-beta2 3.26.0-beta3 3.26.0-beta4 3.26.0-beta5 3.26.0-dev1 3.26.0-dev2 3.26.0-dev3 3.26.0-dev4 3.26.0-dev5 3.26.1 3.26.2 3.26.3 3.26.4 3.26.5 3.27.0 3.27.0-beta1 3.27.0-beta2 3.27.0-dev1 3.27.0-dev2 3.27.1 3.27.2 3.27.3 3.27.4 3.27.5 3.27.6 3.27.7 3.28.0 3.28.0-beta1 3.28.0-beta2 3.28.0-beta3 3.28.0-dev1 3.28.0-dev2 3.28.0-dev3 3.28.1 3.28.2 3.28.3 3.28.4 3.29.0 3.29.0-beta1 trunk 3.29.0-beta2 3.0.0 3.29.0-beta3 3.0.1 3.29.0-beta4 3.0.10 3.29.0-dev1 3.0.11 3.29.0-dev2 3.0.12 3.29.0-dev3 3.0.13 3.29.0-dev4 3.0.14 3.29.1 3.0.15 3.29.2 3.0.16 3.3.0 3.0.2 3.3.1 3.0.3 3.30.0 3.0.4 3.30.0-beta1 3.0.5 3.30.0-beta2 3.0.6 3.30.0-beta3 3.0.7 3.30.0-dev1 3.0.8 3.30.0-dev2 3.0.8.1 3.30.0-dev3 3.0.9 3.30.1 3.1.0 3.30.2 3.1.0-beta1 3.30.3 3.1.0-beta2 3.30.4 3.1.0-beta3 3.31.0 3.1.0-beta4 3.31.0-beta1 3.1.0-dev1 3.31.0-beta2 3.1.0-dev2 3.31.0-dev1 3.1.0-dev3 3.31.0-dev2 3.1.1 3.31.1 3.1.2 3.31.2 3.1.3 3.31.3 3.1.4 3.31.4 3.10.0 3.31.5 3.10.0-dev1 3.32.0 3.10.1 3.32.0-beta1 3.10.2 3.32.0-beta2 3.11.0 3.32.0-beta3 3.11.0-beta1 3.32.0-dev1 3.11.0-beta2 3.32.0-dev2 3.11.0-beta3 3.32.0-dev3 3.11.0-dev1 3.32.1 3.11.0-dev2 3.32.2 3.11.0-dev3 3.32.3 3.11.1 3.32.4 3.11.2 3.32.5 3.11.3 3.33.0 3.11.4 3.33.0-beta1 3.11.5 3.33.0-beta2 3.12.0 3.33.0-beta3 3.12.1 3.33.0-beta4 3.12.2 3.33.0-dev1 3.13.0 3.33.0-dev2 3.13.0-beta1 3.33.0-dev3 3.13.0-beta2 3.33.0-dev4 3.13.0-beta3 3.33.1 3.13.0-dev3 3.33.2 3.13.0-dev4 3.33.3 3.13.1 3.33.4 3.13.2 3.33.5 3.13.3 3.33.6 3.13.4 3.34.0 3.14.0 3.34.0-beta1 3.14.0-beta1 3.34.0-beta2 3.14.0-beta2 3.34.0-beta3 3.14.0-beta3 3.34.0-dev1 3.14.0-beta4 3.34.0-dev2 3.14.0-beta5 3.34.1 3.14.1 3.34.2 3.15.0 3.34.3 3.15.1 3.34.4 3.15.2 3.35.0 3.15.3 3.35.0-beta1 3.16.0 3.35.0-beta2 3.16.0-beta3 3.35.0-beta3 3.16.0-beta4 3.35.0-beta4 3.16.0-dev1 3.35.0-dev1 3.16.0-dev2 3.35.0-dev2 3.16.1 3.35.0-dev3 3.16.2 3.35.0-dev4 3.16.3 3.35.1 3.16.4 3.35.2 3.16.5 3.35.3 3.16.6 3.35.4 3.17.0 3.35.5 3.17.0-dev2 3.35.6 3.17.0-dev3 3.35.7 3.17.0-dev4 3.35.8 3.17.1 3.35.9 3.17.2 3.4.0 3.17.3 3.4.0-dev7 3.18.0 3.4.0-dev8 3.18.0-beta1 3.4.0-dev9 3.18.0-beta2 3.4.1 3.18.0-beta3 3.4.2 3.18.0-beta4 3.4.3 3.18.0-dev1 3.4.4 3.18.1 3.4.5 3.18.2 3.4.6 3.18.3 3.4.7 3.19.0 3.4.8 3.19.0-beta1 3.5.0 3.19.0-beta2 3.5.0-beta1 3.19.0-beta3 3.5.0-beta2 3.19.0-beta4 3.5.0-beta3 3.19.0-beta5 3.5.0-beta4 3.19.0-beta6 3.5.0-beta5 3.19.0-dev1 3.5.0-beta7 3.19.0-dev2 3.5.0-beta8 3.19.0-dev3 3.5.0-dev8 3.19.0-dev4 3.5.0-dev9 3.19.0-dev5 3.5.1 3.19.0-dev6 3.5.2 3.19.1 3.5.3 3.19.2 3.5.4 3.19.3 3.5.5 3.19.4 3.5.6 3.2.0 3.6.0 3.2.1 3.6.0-beta1 3.2.2 3.6.0-beta2 3.2.3 3.6.0-beta3 3.2.4 3.6.0-beta4 3.2.5 3.6.0-beta5 3.20.0 3.6.0-dev1 3.20.0-beta1 3.6.0-dev10 3.20.0-beta2 3.6.1 3.20.0-beta3 3.6.2 3.20.0-beta4 3.6.3 3.20.0-dev1 3.6.4 3.20.0-dev2 3.6.5 3.20.0-dev3 3.6.6 3.20.0-dev4 3.6.7 3.20.1 3.6.8 3.20.2 3.7.0 3.20.3 3.7.0-beta1 3.20.4 3.7.0-beta2 3.21.0 3.7.0-beta3 3.21.0-beta1 3.7.0-beta4 3.21.0-beta2 3.7.0-dev1 3.21.0-beta3 3.7.1 3.21.0-dev1 3.7.2 3.21.0-dev2 3.7.3 3.21.0-dev3 3.7.4 3.21.1 3.7.5 3.21.2 3.7.6 3.21.3 3.7.7 3.21.4 3.7.8 3.21.5 3.8.0 3.21.6 3.8.0-beta1 3.21.7 3.8.0-beta2 3.21.8 3.8.0-beta3 3.22.0 3.8.1 3.22.0-beta1 3.9.0 3.22.0-beta2 3.9.1 3.22.0-beta3 3.9.2 3.22.0-beta4 4.0.0 3.22.0-beta5 4.0.0-beta1 3.22.0-beta6 4.0.0-beta2
elementor / includes / widgets / google-maps.php
elementor / includes / widgets Last commit date
traits 5 months ago accordion.php 2 weeks ago alert.php 2 weeks ago audio.php 2 weeks ago button.php 2 weeks ago common-base.php 2 weeks ago common-optimized.php 1 year ago common.php 1 year ago counter.php 2 weeks ago divider.php 2 weeks ago google-maps.php 2 weeks ago heading.php 2 weeks ago html.php 2 weeks ago icon-box.php 2 weeks ago icon-list.php 2 weeks ago icon.php 2 weeks ago image-box.php 2 weeks ago image-carousel.php 2 weeks ago image-gallery.php 2 weeks ago image.php 2 weeks ago inner-section.php 2 years ago menu-anchor.php 2 weeks ago progress.php 2 weeks ago rating.php 2 weeks ago read-more.php 2 weeks ago shortcode.php 2 weeks ago sidebar.php 1 year ago social-icons.php 2 weeks ago spacer.php 2 weeks ago star-rating.php 2 weeks ago tabs.php 2 weeks ago testimonial.php 2 weeks ago text-editor.php 2 weeks ago toggle.php 2 weeks ago video.php 2 weeks ago wordpress.php 1 year ago
google-maps.php
338 lines
1 <?php
2 namespace Elementor;
3
4 use Elementor\Modules\DynamicTags\Module as TagsModule;
5
6 if ( ! defined( 'ABSPATH' ) ) {
7 exit; // Exit if accessed directly.
8 }
9
10 /**
11 * Elementor google maps widget.
12 *
13 * Elementor widget that displays an embedded google map.
14 *
15 * @since 1.0.0
16 */
17 class Widget_Google_Maps extends Widget_Base {
18
19 /**
20 * Get widget name.
21 *
22 * Retrieve google maps widget name.
23 *
24 * @since 1.0.0
25 * @access public
26 *
27 * @return string Widget name.
28 */
29 public function get_name() {
30 return 'google_maps';
31 }
32
33 /**
34 * Get widget title.
35 *
36 * Retrieve google maps widget title.
37 *
38 * @since 1.0.0
39 * @access public
40 *
41 * @return string Widget title.
42 */
43 public function get_title() {
44 return esc_html__( 'Google Maps', 'elementor' );
45 }
46
47 /**
48 * Get widget icon.
49 *
50 * Retrieve google maps widget icon.
51 *
52 * @since 1.0.0
53 * @access public
54 *
55 * @return string Widget icon.
56 */
57 public function get_icon() {
58 return 'eicon-google-maps';
59 }
60
61 /**
62 * Get widget categories.
63 *
64 * Retrieve the list of categories the google maps widget belongs to.
65 *
66 * Used to determine where to display the widget in the editor.
67 *
68 * @since 2.0.0
69 * @access public
70 *
71 * @return array Widget categories.
72 */
73 public function get_categories() {
74 return [ 'basic' ];
75 }
76
77 /**
78 * Get widget keywords.
79 *
80 * Retrieve the list of keywords the widget belongs to.
81 *
82 * @since 2.1.0
83 * @access public
84 *
85 * @return array Widget keywords.
86 */
87 public function get_keywords() {
88 return [ 'google', 'map', 'embed', 'location' ];
89 }
90
91 protected function is_dynamic_content(): bool {
92 return false;
93 }
94
95 /**
96 * Get style dependencies.
97 *
98 * Retrieve the list of style dependencies the widget requires.
99 *
100 * @since 3.24.0
101 * @access public
102 *
103 * @return array Widget style dependencies.
104 */
105 public function get_style_depends(): array {
106 return [ 'widget-google_maps' ];
107 }
108
109 public function has_widget_inner_wrapper(): bool {
110 return ! Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' );
111 }
112
113 /**
114 * Register google maps widget controls.
115 *
116 * Adds different input fields to allow the user to change and customize the widget settings.
117 *
118 * @since 3.1.0
119 * @access protected
120 */
121 protected function register_controls() {
122 $this->start_controls_section(
123 'section_map',
124 [
125 'label' => esc_html__( 'Google Maps', 'elementor' ),
126 ]
127 );
128
129 if ( Plugin::$instance->editor->is_edit_mode() ) {
130 $api_key = get_option( 'elementor_google_maps_api_key' );
131
132 if ( ! $api_key ) {
133 $this->add_control(
134 'api_key_notification',
135 [
136 'type' => Controls_Manager::ALERT,
137 'alert_type' => 'info',
138 'content' => sprintf(
139 /* translators: 1: Integration settings link open tag, 2: Create API key link open tag, 3: Link close tag. */
140 esc_html__( 'Set your Google Maps API Key in Elementor\'s %1$sIntegrations Settings%3$s page. Create your key %2$shere.%3$s', 'elementor' ),
141 '<a href="' . Settings::get_settings_tab_url( 'integrations' ) . '" target="_blank">',
142 '<a href="https://developers.google.com/maps/documentation/embed/get-api-key" target="_blank">',
143 '</a>'
144 ),
145 ]
146 );
147 }
148 }
149
150 $default_address = esc_html__( 'London Eye, London, United Kingdom', 'elementor' );
151 $this->add_control(
152 'address',
153 [
154 'label' => esc_html__( 'Location', 'elementor' ),
155 'type' => Controls_Manager::TEXT,
156 'dynamic' => [
157 'active' => true,
158 'categories' => [
159 TagsModule::POST_META_CATEGORY,
160 ],
161 ],
162 'ai' => [
163 'active' => false,
164 ],
165 'placeholder' => $default_address,
166 'default' => $default_address,
167 'label_block' => true,
168 ]
169 );
170
171 $this->add_control(
172 'zoom',
173 [
174 'label' => esc_html__( 'Zoom', 'elementor' ),
175 'type' => Controls_Manager::SLIDER,
176 'default' => [
177 'size' => 10,
178 ],
179 'range' => [
180 'px' => [
181 'min' => 1,
182 'max' => 20,
183 ],
184 ],
185 'separator' => 'before',
186 ]
187 );
188
189 $this->add_responsive_control(
190 'height',
191 [
192 'label' => esc_html__( 'Height', 'elementor' ),
193 'type' => Controls_Manager::SLIDER,
194 'range' => [
195 'px' => [
196 'min' => 40,
197 'max' => 1440,
198 ],
199 ],
200 'size_units' => [ 'px', 'em', 'rem', 'vh', 'custom' ],
201 'selectors' => [
202 '{{WRAPPER}} iframe' => 'height: {{SIZE}}{{UNIT}};',
203 ],
204 ]
205 );
206
207 $this->end_controls_section();
208
209 $this->start_controls_section(
210 'section_map_style',
211 [
212 'label' => esc_html__( 'Google Maps', 'elementor' ),
213 'tab' => Controls_Manager::TAB_STYLE,
214 ]
215 );
216
217 $this->start_controls_tabs( 'map_filter' );
218
219 $this->start_controls_tab( 'normal',
220 [
221 'label' => esc_html__( 'Normal', 'elementor' ),
222 ]
223 );
224
225 $this->add_group_control(
226 Group_Control_Css_Filter::get_type(),
227 [
228 'name' => 'css_filters',
229 'selector' => '{{WRAPPER}} iframe',
230 ]
231 );
232
233 $this->end_controls_tab();
234
235 $this->start_controls_tab( 'hover',
236 [
237 'label' => esc_html__( 'Hover', 'elementor' ),
238 ]
239 );
240
241 $this->add_group_control(
242 Group_Control_Css_Filter::get_type(),
243 [
244 'name' => 'css_filters_hover',
245 'selector' => '{{WRAPPER}}:hover iframe',
246 ]
247 );
248
249 $this->add_control(
250 'hover_transition',
251 [
252 'label' => esc_html__( 'Transition Duration', 'elementor' ) . ' (s)',
253 'type' => Controls_Manager::SLIDER,
254 'range' => [
255 'px' => [
256 'min' => 0,
257 'max' => 3,
258 'step' => 0.1,
259 ],
260 ],
261 'selectors' => [
262 '{{WRAPPER}} iframe' => 'transition-duration: {{SIZE}}s',
263 ],
264 ]
265 );
266
267 $this->end_controls_tab();
268
269 $this->end_controls_tabs();
270
271 $this->end_controls_section();
272 }
273
274 /**
275 * Render google maps widget output on the frontend.
276 *
277 * Written in PHP and used to generate the final HTML.
278 *
279 * @since 1.0.0
280 * @access protected
281 */
282 protected function render() {
283 $settings = $this->get_settings_for_display();
284
285 if ( empty( $settings['address'] ) ) {
286 return;
287 }
288
289 if ( 0 === absint( $settings['zoom']['size'] ) ) {
290 $settings['zoom']['size'] = 10;
291 }
292
293 $api_key = esc_html( get_option( 'elementor_google_maps_api_key' ) );
294
295 $params = [
296 rawurlencode( $settings['address'] ),
297 absint( $settings['zoom']['size'] ),
298 ];
299
300 if ( $api_key ) {
301 $params[] = $api_key;
302
303 $url = 'https://www.google.com/maps/embed/v1/place?key=%3$s&q=%1$s&amp;zoom=%2$d';
304 } else {
305 $url = 'https://maps.google.com/maps?q=%1$s&amp;t=m&amp;z=%2$d&amp;output=embed&amp;iwloc=near';
306 }
307
308 ?>
309 <div class="elementor-custom-embed">
310 <iframe loading="lazy"
311 src="<?php echo esc_url( vsprintf( $url, $params ) ); ?>"
312 title="<?php echo esc_attr( $settings['address'] ); ?>"
313 aria-label="<?php echo esc_attr( $settings['address'] ); ?>"
314 ></iframe>
315 </div>
316 <?php
317 }
318
319 /**
320 * Render google maps widget output in the editor.
321 *
322 * Written as a Backbone JavaScript template and used to generate the live preview.
323 *
324 * @since 2.9.0
325 * @access protected
326 */
327 protected function content_template() {}
328
329 public function render_markdown(): string {
330 $settings = $this->get_settings_for_display();
331 $address = Utils::html_to_plain_text( $settings['address'] ?? '' );
332 if ( empty( $address ) ) {
333 return '';
334 }
335 return '[Map: ' . $address . '](https://maps.google.com/maps?q=' . rawurlencode( $address ) . ')';
336 }
337 }
338