| @@ -40,9 +40,9 @@ | ||
| 40 | 40 | * |
| 41 | 41 | * @return string Widget title. |
| 42 | 42 | */ |
| 43 | 43 | public function get_title() { |
| 44 | - return esc_html__( 'Google Maps', 'elementor' ); | |
| 44 | + return __( 'Google Maps', 'elementor' ); | |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | /** |
| 48 | 48 | * Get widget icon. |
| @@ -87,31 +87,9 @@ | ||
| 87 | 87 | public function get_keywords() { |
| 88 | 88 | return [ 'google', 'map', 'embed', 'location' ]; |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - protected function is_dynamic_content(): bool { | |
| 92 | - return false; | |
| 93 | - } | |
| 94 | - | |
| 95 | 91 | /** |
| 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 | 92 | * Register google maps widget controls. |
| 115 | 93 | * |
| 116 | 94 | * Adds different input fields to allow the user to change and customize the widget settings. |
| 117 | 95 | * |
| @@ -121,38 +99,17 @@ | ||
| 121 | 99 | protected function register_controls() { |
| 122 | 100 | $this->start_controls_section( |
| 123 | 101 | 'section_map', |
| 124 | 102 | [ |
| 125 | - 'label' => esc_html__( 'Google Maps', 'elementor' ), | |
| 103 | + 'label' => __( 'Map', 'elementor' ), | |
| 126 | 104 | ] |
| 127 | 105 | ); |
| 128 | 106 | |
| 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' ); | |
| 107 | + $default_address = __( 'London Eye, London, United Kingdom', 'elementor' ); | |
| 151 | 108 | $this->add_control( |
| 152 | 109 | 'address', |
| 153 | 110 | [ |
| 154 | - 'label' => esc_html__( 'Location', 'elementor' ), | |
| 111 | + 'label' => __( 'Location', 'elementor' ), | |
| 155 | 112 | 'type' => Controls_Manager::TEXT, |
| 156 | 113 | 'dynamic' => [ |
| 157 | 114 | 'active' => true, |
| 158 | 115 | 'categories' => [ |
| @@ -158,11 +115,8 @@ | ||
| 158 | 115 | 'categories' => [ |
| 159 | 116 | TagsModule::POST_META_CATEGORY, |
| 160 | 117 | ], |
| 161 | 118 | ], |
| 162 | - 'ai' => [ | |
| 163 | - 'active' => false, | |
| 164 | - ], | |
| 165 | 119 | 'placeholder' => $default_address, |
| 166 | 120 | 'default' => $default_address, |
| 167 | 121 | 'label_block' => true, |
| 168 | 122 | ] |
| @@ -170,9 +124,9 @@ | ||
| 170 | 124 | |
| 171 | 125 | $this->add_control( |
| 172 | 126 | 'zoom', |
| 173 | 127 | [ |
| 174 | - 'label' => esc_html__( 'Zoom', 'elementor' ), | |
| 128 | + 'label' => __( 'Zoom', 'elementor' ), | |
| 175 | 129 | 'type' => Controls_Manager::SLIDER, |
| 176 | 130 | 'default' => [ |
| 177 | 131 | 'size' => 10, |
| 178 | 132 | ], |
| @@ -188,9 +142,9 @@ | ||
| 188 | 142 | |
| 189 | 143 | $this->add_responsive_control( |
| 190 | 144 | 'height', |
| 191 | 145 | [ |
| 192 | - 'label' => esc_html__( 'Height', 'elementor' ), | |
| 146 | + 'label' => __( 'Height', 'elementor' ), | |
| 193 | 147 | 'type' => Controls_Manager::SLIDER, |
| 194 | 148 | 'range' => [ |
| 195 | 149 | 'px' => [ |
| 196 | 150 | 'min' => 40, |
| @@ -195,10 +149,14 @@ | ||
| 195 | 149 | 'px' => [ |
| 196 | 150 | 'min' => 40, |
| 197 | 151 | 'max' => 1440, |
| 198 | 152 | ], |
| 153 | + 'vh' => [ | |
| 154 | + 'min' => 0, | |
| 155 | + 'max' => 100, | |
| 156 | + ], | |
| 199 | 157 | ], |
| 200 | - 'size_units' => [ 'px', 'em', 'rem', 'vh', 'custom' ], | |
| 158 | + 'size_units' => [ 'px', 'vh' ], | |
| 201 | 159 | 'selectors' => [ |
| 202 | 160 | '{{WRAPPER}} iframe' => 'height: {{SIZE}}{{UNIT}};', |
| 203 | 161 | ], |
| 204 | 162 | ] |
| @@ -203,14 +161,23 @@ | ||
| 203 | 161 | ], |
| 204 | 162 | ] |
| 205 | 163 | ); |
| 206 | 164 | |
| 165 | + $this->add_control( | |
| 166 | + 'view', | |
| 167 | + [ | |
| 168 | + 'label' => __( 'View', 'elementor' ), | |
| 169 | + 'type' => Controls_Manager::HIDDEN, | |
| 170 | + 'default' => 'traditional', | |
| 171 | + ] | |
| 172 | + ); | |
| 173 | + | |
| 207 | 174 | $this->end_controls_section(); |
| 208 | 175 | |
| 209 | 176 | $this->start_controls_section( |
| 210 | 177 | 'section_map_style', |
| 211 | 178 | [ |
| 212 | - 'label' => esc_html__( 'Google Maps', 'elementor' ), | |
| 179 | + 'label' => __( 'Map', 'elementor' ), | |
| 213 | 180 | 'tab' => Controls_Manager::TAB_STYLE, |
| 214 | 181 | ] |
| 215 | 182 | ); |
| 216 | 183 | |
| @@ -217,9 +184,9 @@ | ||
| 217 | 184 | $this->start_controls_tabs( 'map_filter' ); |
| 218 | 185 | |
| 219 | 186 | $this->start_controls_tab( 'normal', |
| 220 | 187 | [ |
| 221 | - 'label' => esc_html__( 'Normal', 'elementor' ), | |
| 188 | + 'label' => __( 'Normal', 'elementor' ), | |
| 222 | 189 | ] |
| 223 | 190 | ); |
| 224 | 191 | |
| 225 | 192 | $this->add_group_control( |
| @@ -233,9 +200,9 @@ | ||
| 233 | 200 | $this->end_controls_tab(); |
| 234 | 201 | |
| 235 | 202 | $this->start_controls_tab( 'hover', |
| 236 | 203 | [ |
| 237 | - 'label' => esc_html__( 'Hover', 'elementor' ), | |
| 204 | + 'label' => __( 'Hover', 'elementor' ), | |
| 238 | 205 | ] |
| 239 | 206 | ); |
| 240 | 207 | |
| 241 | 208 | $this->add_group_control( |
| @@ -248,13 +215,12 @@ | ||
| 248 | 215 | |
| 249 | 216 | $this->add_control( |
| 250 | 217 | 'hover_transition', |
| 251 | 218 | [ |
| 252 | - 'label' => esc_html__( 'Transition Duration', 'elementor' ) . ' (s)', | |
| 219 | + 'label' => __( 'Transition Duration', 'elementor' ), | |
| 253 | 220 | 'type' => Controls_Manager::SLIDER, |
| 254 | 221 | 'range' => [ |
| 255 | 222 | 'px' => [ |
| 256 | - 'min' => 0, | |
| 257 | 223 | 'max' => 3, |
| 258 | 224 | 'step' => 0.1, |
| 259 | 225 | ], |
| 260 | 226 | ], |
| @@ -289,32 +255,14 @@ | ||
| 289 | 255 | if ( 0 === absint( $settings['zoom']['size'] ) ) { |
| 290 | 256 | $settings['zoom']['size'] = 10; |
| 291 | 257 | } |
| 292 | 258 | |
| 293 | - $api_key = esc_html( get_option( 'elementor_google_maps_api_key' ) ); | |
| 294 | - | |
| 295 | - $params = [ | |
| 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&t=m&z=%2$d&output=embed&iwloc=near" title="%3$s" aria-label="%3$s"></iframe></div>', | |
| 296 | 261 | rawurlencode( $settings['address'] ), |
| 297 | 262 | 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&zoom=%2$d'; | |
| 304 | - } else { | |
| 305 | - $url = 'https://maps.google.com/maps?q=%1$s&t=m&z=%2$d&output=embed&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 | |
| 263 | + esc_attr( $settings['address'] ) | |
| 264 | + ); | |
| 317 | 265 | } |
| 318 | 266 | |
| 319 | 267 | /** |
| 320 | 268 | * Render google maps widget output in the editor. |
| @@ -324,14 +272,5 @@ | ||
| 324 | 272 | * @since 2.9.0 |
| 325 | 273 | * @access protected |
| 326 | 274 | */ |
| 327 | 275 | 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 | 276 | } |