PluginProbe
Elementor Website Builder – more than just a page builder / 3.0.7
Elementor Website Builder – more than just a page builder v3.0.7
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.0.7, at includes/widgets/google-maps.php

272 lines 5.2 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 1.0.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 ],
154 'selectors' => [
155 '{{WRAPPER}} iframe' => 'height: {{SIZE}}{{UNIT}};',
156 ],
157 ]
158 );
159
160 $this->add_control(
161 'view',
162 [
163 'label' => __( 'View', 'elementor' ),
164 'type' => Controls_Manager::HIDDEN,
165 'default' => 'traditional',
166 ]
167 );
168
169 $this->end_controls_section();
170
171 $this->start_controls_section(
172 'section_map_style',
173 [
174 'label' => __( 'Map', 'elementor' ),
175 'tab' => Controls_Manager::TAB_STYLE,
176 ]
177 );
178
179 $this->start_controls_tabs( 'map_filter' );
180
181 $this->start_controls_tab( 'normal',
182 [
183 'label' => __( 'Normal', 'elementor' ),
184 ]
185 );
186
187 $this->add_group_control(
188 Group_Control_Css_Filter::get_type(),
189 [
190 'name' => 'css_filters',
191 'selector' => '{{WRAPPER}} iframe',
192 ]
193 );
194
195 $this->end_controls_tab();
196
197 $this->start_controls_tab( 'hover',
198 [
199 'label' => __( 'Hover', 'elementor' ),
200 ]
201 );
202
203 $this->add_group_control(
204 Group_Control_Css_Filter::get_type(),
205 [
206 'name' => 'css_filters_hover',
207 'selector' => '{{WRAPPER}}:hover iframe',
208 ]
209 );
210
211 $this->add_control(
212 'hover_transition',
213 [
214 'label' => __( 'Transition Duration', 'elementor' ),
215 'type' => Controls_Manager::SLIDER,
216 'range' => [
217 'px' => [
218 'max' => 3,
219 'step' => 0.1,
220 ],
221 ],
222 'selectors' => [
223 '{{WRAPPER}} iframe' => 'transition-duration: {{SIZE}}s',
224 ],
225 ]
226 );
227
228 $this->end_controls_tab();
229
230 $this->end_controls_tabs();
231
232 $this->end_controls_section();
233 }
234
235 /**
236 * Render google maps widget output on the frontend.
237 *
238 * Written in PHP and used to generate the final HTML.
239 *
240 * @since 1.0.0
241 * @access protected
242 */
243 protected function render() {
244 $settings = $this->get_settings_for_display();
245
246 if ( empty( $settings['address'] ) ) {
247 return;
248 }
249
250 if ( 0 === absint( $settings['zoom']['size'] ) ) {
251 $settings['zoom']['size'] = 10;
252 }
253
254 printf(
255 '<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>',
256 rawurlencode( $settings['address'] ),
257 absint( $settings['zoom']['size'] ),
258 esc_attr( $settings['address'] )
259 );
260 }
261
262 /**
263 * Render google maps widget output in the editor.
264 *
265 * Written as a Backbone JavaScript template and used to generate the live preview.
266 *
267 * @since 2.9.0
268 * @access protected
269 */
270 protected function content_template() {}
271 }
272