PluginProbe
Elementor Website Builder – more than just a page builder / 3.2.3
Elementor Website Builder – more than just a page builder v3.2.3
4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 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 All 451 releases
elementor / includes / widgets / google-maps.php

google-maps.php in Elementor Website Builder – more than just a page builder 3.2.3, at includes/widgets/google-maps.php

277 lines 5.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 __( '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 /**
92 * Register google maps widget controls.
93 *
94 * Adds different input fields to allow the user to change and customize the widget settings.
95 *
96 * @since 3.1.0
97 * @access protected
98 */
99 protected function register_controls() {
100 $this->start_controls_section(
101 'section_map',
102 [
103 'label' => __( 'Map', 'elementor' ),
104 ]
105 );
106
107 $default_address = __( 'London Eye, London, United Kingdom', 'elementor' );
108 $this->add_control(
109 'address',
110 [
111 'label' => __( 'Location', 'elementor' ),
112 'type' => Controls_Manager::TEXT,
113 'dynamic' => [
114 'active' => true,
115 'categories' => [
116 TagsModule::POST_META_CATEGORY,
117 ],
118 ],
119 'placeholder' => $default_address,
120 'default' => $default_address,
121 'label_block' => true,
122 ]
123 );
124
125 $this->add_control(
126 'zoom',
127 [
128 'label' => __( 'Zoom', 'elementor' ),
129 'type' => Controls_Manager::SLIDER,
130 'default' => [
131 'size' => 10,
132 ],
133 'range' => [
134 'px' => [
135 'min' => 1,
136 'max' => 20,
137 ],
138 ],
139 'separator' => 'before',
140 ]
141 );
142
143 $this->add_responsive_control(
144 'height',
145 [
146 'label' => __( 'Height', 'elementor' ),
147 'type' => Controls_Manager::SLIDER,
148 'range' => [
149 'px' => [
150 'min' => 40,
151 'max' => 1440,
152 ],
153 'vh' => [
154 'min' => 0,
155 'max' => 100,
156 ],
157 ],
158 'size_units' => [ 'px', 'vh' ],
159 'selectors' => [
160 '{{WRAPPER}} iframe' => 'height: {{SIZE}}{{UNIT}};',
161 ],
162 ]
163 );
164
165 $this->add_control(
166 'view',
167 [
168 'label' => __( 'View', 'elementor' ),
169 'type' => Controls_Manager::HIDDEN,
170 'default' => 'traditional',
171 ]
172 );
173
174 $this->end_controls_section();
175
176 $this->start_controls_section(
177 'section_map_style',
178 [
179 'label' => __( 'Map', 'elementor' ),
180 'tab' => Controls_Manager::TAB_STYLE,
181 ]
182 );
183
184 $this->start_controls_tabs( 'map_filter' );
185
186 $this->start_controls_tab( 'normal',
187 [
188 'label' => __( 'Normal', 'elementor' ),
189 ]
190 );
191
192 $this->add_group_control(
193 Group_Control_Css_Filter::get_type(),
194 [
195 'name' => 'css_filters',
196 'selector' => '{{WRAPPER}} iframe',
197 ]
198 );
199
200 $this->end_controls_tab();
201
202 $this->start_controls_tab( 'hover',
203 [
204 'label' => __( 'Hover', 'elementor' ),
205 ]
206 );
207
208 $this->add_group_control(
209 Group_Control_Css_Filter::get_type(),
210 [
211 'name' => 'css_filters_hover',
212 'selector' => '{{WRAPPER}}:hover iframe',
213 ]
214 );
215
216 $this->add_control(
217 'hover_transition',
218 [
219 'label' => __( 'Transition Duration', 'elementor' ),
220 'type' => Controls_Manager::SLIDER,
221 'range' => [
222 'px' => [
223 'max' => 3,
224 'step' => 0.1,
225 ],
226 ],
227 'selectors' => [
228 '{{WRAPPER}} iframe' => 'transition-duration: {{SIZE}}s',
229 ],
230 ]
231 );
232
233 $this->end_controls_tab();
234
235 $this->end_controls_tabs();
236
237 $this->end_controls_section();
238 }
239
240 /**
241 * Render google maps widget output on the frontend.
242 *
243 * Written in PHP and used to generate the final HTML.
244 *
245 * @since 1.0.0
246 * @access protected
247 */
248 protected function render() {
249 $settings = $this->get_settings_for_display();
250
251 if ( empty( $settings['address'] ) ) {
252 return;
253 }
254
255 if ( 0 === absint( $settings['zoom']['size'] ) ) {
256 $settings['zoom']['size'] = 10;
257 }
258
259 printf(
260 '<div class="elementor-custom-embed"><iframe frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://maps.google.com/maps?q=%1$s&amp;t=m&amp;z=%2$d&amp;output=embed&amp;iwloc=near" title="%3$s" aria-label="%3$s"></iframe></div>',
261 rawurlencode( $settings['address'] ),
262 absint( $settings['zoom']['size'] ),
263 esc_attr( $settings['address'] )
264 );
265 }
266
267 /**
268 * Render google maps widget output in the editor.
269 *
270 * Written as a Backbone JavaScript template and used to generate the live preview.
271 *
272 * @since 2.9.0
273 * @access protected
274 */
275 protected function content_template() {}
276 }
277