theme-elements
6 months ago
accordion.php
6 months ago
audio.php
6 months ago
before-after.php
6 months ago
button.php
6 months ago
carousel-navigation.php
6 months ago
circle-chart.php
6 months ago
contact-box.php
6 months ago
contact-form.php
6 months ago
custom-list.php
6 months ago
divider.php
6 months ago
gallery.php
6 months ago
gmap.php
6 months ago
heading-modern.php
6 months ago
icon.php
6 months ago
image.php
6 months ago
mailchimp.php
6 months ago
modern-button.php
6 months ago
products-grid.php
6 months ago
quote.php
6 months ago
recent-comments.php
6 months ago
recent-posts-grid-carousel.php
6 months ago
recent-posts-land-style.php
6 months ago
recent-posts-masonry.php
6 months ago
recent-posts-tiles-carousel.php
6 months ago
recent-posts-tiles.php
6 months ago
recent-posts-timeline.php
6 months ago
recent-products.php
6 months ago
responsive-table.php
6 months ago
search.php
6 months ago
staff.php
6 months ago
svg.php
6 months ago
tabs.php
6 months ago
testimonial.php
6 months ago
text.php
6 months ago
touch-slider.php
6 months ago
video.php
6 months ago
gmap.php
276 lines
| 1 | <?php |
| 2 | namespace Auxin\Plugin\CoreElements\Elementor\Elements; |
| 3 | |
| 4 | use Elementor\Widget_Base; |
| 5 | use Elementor\Controls_Manager; |
| 6 | |
| 7 | |
| 8 | if ( ! defined( 'ABSPATH' ) ) { |
| 9 | exit; // Exit if accessed directly. |
| 10 | } |
| 11 | |
| 12 | /** |
| 13 | * Elementor 'Map' widget. |
| 14 | * |
| 15 | * Elementor widget that displays an 'Map'. |
| 16 | * |
| 17 | * @since 1.0.0 |
| 18 | */ |
| 19 | class Gmap extends Widget_Base { |
| 20 | |
| 21 | /** |
| 22 | * Get widget name. |
| 23 | * |
| 24 | * Retrieve 'Map' widget name. |
| 25 | * |
| 26 | * @since 1.0.0 |
| 27 | * @access public |
| 28 | * |
| 29 | * @return string Widget name. |
| 30 | */ |
| 31 | public function get_name() { |
| 32 | return 'aux_gmap'; |
| 33 | } |
| 34 | |
| 35 | /** |
| 36 | * Get widget title. |
| 37 | * |
| 38 | * Retrieve 'Map' widget title. |
| 39 | * |
| 40 | * @since 1.0.0 |
| 41 | * @access public |
| 42 | * |
| 43 | * @return string Widget title. |
| 44 | */ |
| 45 | public function get_title() { |
| 46 | return __( 'Map', 'auxin-elements' ); |
| 47 | } |
| 48 | |
| 49 | public function has_widget_inner_wrapper(): bool { |
| 50 | return ! \Elementor\Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' ); |
| 51 | } |
| 52 | |
| 53 | |
| 54 | /** |
| 55 | * Get widget icon. |
| 56 | * |
| 57 | * Retrieve 'Map' widget icon. |
| 58 | * |
| 59 | * @since 1.0.0 |
| 60 | * @access public |
| 61 | * |
| 62 | * @return string Widget icon. |
| 63 | */ |
| 64 | public function get_icon() { |
| 65 | return 'eicon-google-maps auxin-badge'; |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * Get widget categories. |
| 70 | * |
| 71 | * Retrieve 'Map' widget icon. |
| 72 | * |
| 73 | * @since 1.0.0 |
| 74 | * @access public |
| 75 | * |
| 76 | * @return string Widget icon. |
| 77 | */ |
| 78 | public function get_categories() { |
| 79 | return array( 'auxin-core' ); |
| 80 | } |
| 81 | |
| 82 | /** |
| 83 | * Register 'Map' widget controls. |
| 84 | * |
| 85 | * Adds different input fields to allow the user to change and customize the widget settings. |
| 86 | * |
| 87 | * @since 1.0.0 |
| 88 | * @access protected |
| 89 | */ |
| 90 | protected function register_controls() { |
| 91 | |
| 92 | /*-----------------------------------------------------------------------------------*/ |
| 93 | /* map_section |
| 94 | /*-----------------------------------------------------------------------------------*/ |
| 95 | |
| 96 | $this->start_controls_section( |
| 97 | 'map_section', |
| 98 | array( |
| 99 | 'label' => __('Map', 'auxin-elements' ), |
| 100 | ) |
| 101 | ); |
| 102 | |
| 103 | $this->add_control( |
| 104 | 'latitude', |
| 105 | array( |
| 106 | 'label' => __('Latitude','auxin-elements' ), |
| 107 | 'description' => __('Latitude location over the map.', 'auxin-elements' ), |
| 108 | 'type' => Controls_Manager::TEXT, |
| 109 | 'default' => '52' |
| 110 | ) |
| 111 | ); |
| 112 | |
| 113 | $this->add_control( |
| 114 | 'longitude', |
| 115 | array( |
| 116 | 'label' => __('Longitude','auxin-elements' ), |
| 117 | 'description' => __('Longitude location over the map.', 'auxin-elements' ), |
| 118 | 'type' => Controls_Manager::TEXT, |
| 119 | 'default' => '14' |
| 120 | ) |
| 121 | ); |
| 122 | |
| 123 | $this->add_control( |
| 124 | 'marker_info', |
| 125 | array( |
| 126 | 'label' => __('Marker info','auxin-elements' ), |
| 127 | 'description' => __('Marker popup text, leave it empty if you don\'t need it.', 'auxin-elements' ), |
| 128 | 'type' => Controls_Manager::TEXT, |
| 129 | ) |
| 130 | ); |
| 131 | |
| 132 | $this->add_control( |
| 133 | 'attach_id', |
| 134 | array( |
| 135 | 'label' => __('Marker Icon','auxin-elements' ), |
| 136 | 'description' => __('Pick a small icon for gmaps marker.', 'auxin-elements' ), |
| 137 | 'type' => Controls_Manager::MEDIA, |
| 138 | ) |
| 139 | ); |
| 140 | |
| 141 | |
| 142 | $this->end_controls_section(); |
| 143 | |
| 144 | |
| 145 | /*-----------------------------------------------------------------------------------*/ |
| 146 | /* general_section |
| 147 | /*-----------------------------------------------------------------------------------*/ |
| 148 | |
| 149 | $this->start_controls_section( |
| 150 | 'general_section', |
| 151 | array( |
| 152 | 'label' => __('General', 'auxin-elements' ), |
| 153 | 'tab' => Controls_Manager::TAB_STYLE, |
| 154 | ) |
| 155 | ); |
| 156 | |
| 157 | $this->add_control( |
| 158 | 'type', |
| 159 | array( |
| 160 | 'label' => __('Map type', 'auxin-elements'), |
| 161 | 'type' => Controls_Manager::SELECT, |
| 162 | 'default' => 'ROADMAP', |
| 163 | 'options' => array( |
| 164 | 'ROADMAP' => __('Roadmap', 'auxin-elements' ), |
| 165 | 'Satelite' => __('Satelite' , 'auxin-elements' ), |
| 166 | ) |
| 167 | ) |
| 168 | ); |
| 169 | |
| 170 | $this->add_control( |
| 171 | 'height', |
| 172 | array( |
| 173 | 'label' => __('Height','auxin-elements' ), |
| 174 | 'type' => Controls_Manager::TEXT, |
| 175 | 'default' => '700' |
| 176 | ) |
| 177 | ); |
| 178 | |
| 179 | $this->add_control( |
| 180 | 'style', |
| 181 | array( |
| 182 | 'label' => __('Map style','auxin-elements' ), |
| 183 | 'description' => __('This feild allow you to customize the presentation of the standard Google base maps. You can find many preset styles in ', 'auxin-elements' ) . |
| 184 | '<a href="https://snazzymaps.com/" target="_blank">' . __('this website.', 'auxin-elements' ) . '</a>' , |
| 185 | 'type' => Controls_Manager::TEXTAREA , |
| 186 | 'condition' => array( |
| 187 | 'type' => array( 'ROADMAP' ), |
| 188 | ) |
| 189 | ) |
| 190 | ); |
| 191 | |
| 192 | $this->add_control( |
| 193 | 'show_mapcontrols', |
| 194 | array( |
| 195 | 'label' => __('Navigation control','auxin-elements' ), |
| 196 | 'description' => __('Show navigation control on map.','auxin-elements' ), |
| 197 | 'type' => Controls_Manager::SWITCHER, |
| 198 | 'label_on' => __( 'On', 'auxin-elements' ), |
| 199 | 'label_off' => __( 'Off', 'auxin-elements' ), |
| 200 | 'return_value' => 'yes', |
| 201 | 'default' => 'yes' |
| 202 | ) |
| 203 | ); |
| 204 | |
| 205 | $this->add_control( |
| 206 | 'zoom', |
| 207 | array( |
| 208 | 'label' => __('Zoom','auxin-elements' ), |
| 209 | 'type' => Controls_Manager::TEXT, |
| 210 | 'default' => '4' |
| 211 | ) |
| 212 | ); |
| 213 | |
| 214 | $this->add_control( |
| 215 | 'zoom_wheel', |
| 216 | array( |
| 217 | 'label' => __('Zoom with mouse wheel','auxin-elements' ), |
| 218 | 'type' => Controls_Manager::SWITCHER, |
| 219 | 'label_on' => __( 'On', 'auxin-elements' ), |
| 220 | 'label_off' => __( 'Off', 'auxin-elements' ), |
| 221 | 'return_value' => '1', |
| 222 | 'default' => '0' |
| 223 | ) |
| 224 | ); |
| 225 | |
| 226 | $this->end_controls_section(); |
| 227 | } |
| 228 | |
| 229 | /** |
| 230 | * Render image box widget output on the frontend. |
| 231 | * |
| 232 | * Written in PHP and used to generate the final HTML. |
| 233 | * |
| 234 | * @since 1.0.0 |
| 235 | * @access protected |
| 236 | */ |
| 237 | protected function render() { |
| 238 | |
| 239 | $settings = $this->get_settings_for_display(); |
| 240 | |
| 241 | |
| 242 | $args = array( |
| 243 | 'type' => $settings['type'], |
| 244 | 'style' => $settings['style'], |
| 245 | 'height' => $settings['height'], |
| 246 | 'latitude' => $settings['latitude'], |
| 247 | 'longitude' => $settings['longitude'], |
| 248 | 'marker_info' => $settings['marker_info'], |
| 249 | 'show_mapcontrols' => $settings['show_mapcontrols'], |
| 250 | 'zoom' => $settings['zoom'], |
| 251 | 'zoom_wheel' => $settings['zoom_wheel'], |
| 252 | 'attach_id' => $settings['attach_id']['id'], |
| 253 | ); |
| 254 | |
| 255 | if( auxin_get_option( 'auxin_google_map_api_key' ) == '' ) { |
| 256 | ob_start(); |
| 257 | ?> |
| 258 | <div class="elementor-alert elementor-alert-danger" role="alert"> |
| 259 | <span class="elementor-alert-title"> |
| 260 | <?php esc_html_e( 'Google Maps API Key Is Missing.', 'auxin-elements' ); ?> |
| 261 | </span> |
| 262 | <span class="elementor-alert-description"> |
| 263 | <?php esc_html_e( 'In order to use google maps on your website, you have to create an api key and insert it in customizer "Google Maps API Key" field.', 'auxin-elements' ); ?> |
| 264 | </span> |
| 265 | </div> |
| 266 | <?php |
| 267 | echo ob_get_clean(); |
| 268 | return; |
| 269 | } |
| 270 | |
| 271 | // get the shortcode base blog page |
| 272 | echo auxin_widget_gmaps_callback( $args ); |
| 273 | } |
| 274 | |
| 275 | } |
| 276 |