about-widget.php
1 year ago
accordion-widget.php
1 year ago
accordion.php
1 year ago
attachment-url.php
1 year ago
audio.php
1 year ago
before-after.php
1 year ago
button.php
1 year ago
code.php
1 year ago
contact-box.php
1 year ago
contact-form.php
1 year ago
custom-list.php
6 months ago
divider.php
1 year ago
dropcap.php
1 year ago
facebook.php
1 year ago
flickr.php
1 year ago
gallery.php
1 year ago
gmap.php
1 year ago
highlight.php
1 year ago
image.php
1 year ago
instagram-feed.php
1 year ago
latest-posts-slider.php
1 year ago
popular-posts-widget.php
1 year ago
products-grid.php
1 year ago
quote.php
1 year ago
recent-posts-grid-carousel.php
1 year ago
recent-posts-land-style.php
1 year ago
recent-posts-masonry.php
1 year ago
recent-posts-tiles-carousel.php
1 year ago
recent-posts-tiles.php
1 year ago
recent-posts-timeline.php
1 year ago
recent-posts-widget.php
1 year ago
recent-products.php
1 year ago
related-posts.php
8 years ago
sample-element.php
1 year ago
search.php
1 year ago
socials-list.php
1 year ago
staff.php
1 year ago
tab-widget.php
1 year ago
tabs.php
1 year ago
testimonial.php
1 year ago
text.php
1 year ago
touch-slider.php
1 year ago
video.php
1 year ago
contact-box.php
474 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Contact box element |
| 4 | * |
| 5 | * |
| 6 | * @package Auxin |
| 7 | * @license LICENSE.txt |
| 8 | * @author averta |
| 9 | * @link http://phlox.pro/ |
| 10 | * @copyright (c) 2010-2025 averta |
| 11 | */ |
| 12 | |
| 13 | function get_auxin_contact_box( $master_array ) { |
| 14 | |
| 15 | $master_array['aux_contact_box'] = array( |
| 16 | 'name' => __("Contact Box", 'auxin-elements' ), |
| 17 | 'auxin_output_callback' => 'auxin_widget_contact_box', |
| 18 | 'base' => 'aux_contact_box', |
| 19 | 'description' => __('It adds a contact box element.', 'auxin-elements'), |
| 20 | 'class' => 'aux-widget-contact-box', |
| 21 | 'show_settings_on_create' => true, |
| 22 | 'weight' => 1, |
| 23 | 'category' => THEME_NAME, |
| 24 | 'group' => '', |
| 25 | 'admin_enqueue_js' => '', |
| 26 | 'admin_enqueue_css' => '', |
| 27 | 'front_enqueue_js' => '', |
| 28 | 'front_enqueue_css' => '', |
| 29 | 'icon' => 'aux-element aux-pb-icons-message-box', |
| 30 | 'custom_markup' => '', |
| 31 | 'js_view' => '', |
| 32 | 'html_template' => '', |
| 33 | 'deprecated' => '', |
| 34 | 'content_element' => '', |
| 35 | 'as_parent' => '', |
| 36 | 'as_child' => '', |
| 37 | 'params' => array( |
| 38 | array( |
| 39 | 'heading' => __('Title','auxin-elements'), |
| 40 | 'description' => __('Contact box title, leave it empty if you don`t need title.', 'auxin-elements'), |
| 41 | 'param_name' => 'title', |
| 42 | 'type' => 'textfield', |
| 43 | 'value' => '', |
| 44 | 'holder' => 'textfield', |
| 45 | 'class' => 'id', |
| 46 | 'admin_label' => false, |
| 47 | 'dependency' => '', |
| 48 | 'weight' => '', |
| 49 | 'group' => '' , |
| 50 | 'edit_field_class' => '' |
| 51 | ), |
| 52 | array( |
| 53 | 'heading' => __('Email','auxin-elements'), |
| 54 | 'description' => __('Contact box email address.', 'auxin-elements'), |
| 55 | 'param_name' => 'email', |
| 56 | 'type' => 'textfield', |
| 57 | 'value' => '', |
| 58 | 'holder' => '', |
| 59 | 'class' => 'title', |
| 60 | 'admin_label' => false, |
| 61 | 'dependency' => '', |
| 62 | 'weight' => '', |
| 63 | 'group' => '' , |
| 64 | 'edit_field_class' => '' |
| 65 | ), |
| 66 | array( |
| 67 | 'heading' => __('Telephone','auxin-elements'), |
| 68 | 'description' => __('Contact box phone number.', 'auxin-elements'), |
| 69 | 'param_name' => 'telephone', |
| 70 | 'type' => 'textfield', |
| 71 | 'value' => '', |
| 72 | 'holder' => '', |
| 73 | 'class' => 'telephone', |
| 74 | 'admin_label' => false, |
| 75 | 'weight' => '', |
| 76 | 'group' => '', |
| 77 | 'edit_field_class' => '' |
| 78 | ), |
| 79 | array( |
| 80 | 'heading' => __('Address','auxin-elements'), |
| 81 | 'description' => __('Contact box address.', 'auxin-elements'), |
| 82 | 'param_name' => 'address', |
| 83 | 'type' => 'textfield', |
| 84 | 'value' => '', |
| 85 | 'holder' => '', |
| 86 | 'class' => '', |
| 87 | 'admin_label' => false, |
| 88 | 'weight' => '', |
| 89 | 'group' => '', |
| 90 | 'edit_field_class' => '' |
| 91 | ), |
| 92 | array( |
| 93 | 'heading' => __('Show socials','auxin-elements'), |
| 94 | 'description' => __('Show site socials below the info.','auxin-elements'), |
| 95 | 'param_name' => 'show_socials', |
| 96 | 'type' => 'aux_switch', |
| 97 | 'def_value' => '', |
| 98 | 'value' => '1', |
| 99 | 'holder' => '', |
| 100 | 'class' => 'show_socials', |
| 101 | 'admin_label' => false, |
| 102 | 'dependency' => '', |
| 103 | 'weight' => '', |
| 104 | 'group' => '' , |
| 105 | 'edit_field_class' => '' |
| 106 | ), |
| 107 | array( |
| 108 | 'heading' => __('Show map','auxin-elements'), |
| 109 | 'description' => __('Show map above the info.','auxin-elements'), |
| 110 | 'param_name' => 'show_map', |
| 111 | 'type' => 'aux_switch', |
| 112 | 'def_value' => '', |
| 113 | 'value' => '1', |
| 114 | 'holder' => '', |
| 115 | 'class' => 'show_map', |
| 116 | 'admin_label' => false, |
| 117 | 'dependency' => '', |
| 118 | 'weight' => '', |
| 119 | 'group' => '' , |
| 120 | 'edit_field_class' => '' |
| 121 | ), |
| 122 | array( |
| 123 | 'heading' => __('Map position','auxin-elements'), |
| 124 | 'description' => __('Whether to show map above the contact details or below them.', 'auxin-elements'), |
| 125 | 'param_name' => 'map_position', |
| 126 | 'type' => 'dropdown', |
| 127 | 'value' => array( |
| 128 | 'down' => __('Below the contact details.', 'auxin-elements' ), |
| 129 | 'up' => __('Above the contact details.', 'auxin-elements' ) |
| 130 | ), |
| 131 | 'def_value' => 'down', |
| 132 | 'holder' => '', |
| 133 | 'class' => 'map_position', |
| 134 | 'admin_label' => false, |
| 135 | 'dependency' => array( |
| 136 | 'element' => 'show_map', |
| 137 | 'value' => '1' |
| 138 | ), |
| 139 | 'weight' => '', |
| 140 | 'group' => __( 'Map Options', 'auxin-elements' ), |
| 141 | 'edit_field_class' => '' |
| 142 | ), |
| 143 | array( |
| 144 | 'heading' => __('Map height','auxin-elements'), |
| 145 | 'description' => __('Height of the map in pixels.', 'auxin-elements'), |
| 146 | 'param_name' => 'height', |
| 147 | 'type' => 'textfield', |
| 148 | 'value' => '160', |
| 149 | 'def_value' => '160', |
| 150 | 'holder' => '', |
| 151 | 'class' => 'height', |
| 152 | 'admin_label' => false, |
| 153 | 'dependency' => array( |
| 154 | 'element' => 'show_map', |
| 155 | 'value' => '1' |
| 156 | ), |
| 157 | 'weight' => '', |
| 158 | 'group' => __( 'Map Options', 'auxin-elements' ), |
| 159 | 'edit_field_class' => '' |
| 160 | ), |
| 161 | array( |
| 162 | 'heading' => __('Latitude','auxin-elements'), |
| 163 | 'description' => __('Latitude location over the map.', 'auxin-elements'), |
| 164 | 'param_name' => 'latitude', |
| 165 | 'type' => 'textfield', |
| 166 | 'value' => '40.7', |
| 167 | 'holder' => '', |
| 168 | 'class' => '', |
| 169 | 'admin_label' => false, |
| 170 | 'dependency' => array( |
| 171 | 'element' => 'show_map', |
| 172 | 'value' => '1' |
| 173 | ), |
| 174 | 'weight' => '', |
| 175 | 'group' => __( 'Map Options', 'auxin-elements' ), |
| 176 | 'edit_field_class' => '' |
| 177 | ), |
| 178 | array( |
| 179 | 'heading' => __('Longitude','auxin-elements'), |
| 180 | 'description' => __('Longitude location over the map.', 'auxin-elements'), |
| 181 | 'param_name' => 'longitude', |
| 182 | 'type' => 'textfield', |
| 183 | 'value' => '-74', |
| 184 | 'holder' => '', |
| 185 | 'class' => '', |
| 186 | 'admin_label' => false, |
| 187 | 'dependency' => array( |
| 188 | 'element' => 'show_map', |
| 189 | 'value' => '1' |
| 190 | ), |
| 191 | 'weight' => '', |
| 192 | 'group' => __( 'Map Options', 'auxin-elements' ), |
| 193 | 'edit_field_class' => '' |
| 194 | ), |
| 195 | array( |
| 196 | 'heading' => __('Map type','auxin-elements'), |
| 197 | 'param_name' => 'type', |
| 198 | 'type' => 'dropdown', |
| 199 | 'def_value' => 'ROADMAP', |
| 200 | 'value' => array( 'ROADMAP' => __('ROADMAP', 'auxin-elements'), 'SATELLITE' => __('SATELLITE', 'auxin-elements') ), |
| 201 | 'holder' => '', |
| 202 | 'class' => 'type', |
| 203 | 'dependency' => array( |
| 204 | 'element' => 'show_map', |
| 205 | 'value' => '1' |
| 206 | ), |
| 207 | 'admin_label' => false, |
| 208 | 'weight' => '', |
| 209 | 'group' => __( 'Map Options', 'auxin-elements' ), |
| 210 | 'edit_field_class' => '' |
| 211 | ), |
| 212 | array( |
| 213 | 'heading' => __('Map style','auxin-elements'), |
| 214 | 'description' => __('This feild allows you to customize the presentation of the standard Google base maps. You can find many preset styles in ', 'auxin-elements') . |
| 215 | '<a href="https://snazzymaps.com/" target="_blank">' . __('this website.', 'auxin-elements') . '</a>' , |
| 216 | 'param_name' => 'style', |
| 217 | 'type' => 'textarea_raw_html', |
| 218 | 'def_value' => '', |
| 219 | 'value' => '', |
| 220 | 'holder' => '', |
| 221 | 'class' => 'style', |
| 222 | 'admin_label' => false, |
| 223 | 'dependency' => array( |
| 224 | // array( |
| 225 | 'element' => 'show_map', |
| 226 | 'value' => '1' |
| 227 | // ), |
| 228 | // @TODO: this kind of dependency is not working we should fix it later |
| 229 | // array( |
| 230 | // 'element' => 'type', |
| 231 | // 'value' => 'ROADMAP' |
| 232 | // ), |
| 233 | // 'relation'=> 'and' |
| 234 | ), |
| 235 | 'weight' => '', |
| 236 | 'group' => __( 'Map Options', 'auxin-elements' ), |
| 237 | 'edit_field_class' => '' |
| 238 | ), |
| 239 | array( |
| 240 | 'heading' => __('Marker info','auxin-elements'), |
| 241 | 'description' => __('Marker popup text, leave it empty if you don\'t need it.', 'auxin-elements'), |
| 242 | 'param_name' => 'marker_info', |
| 243 | 'type' => 'textfield', |
| 244 | 'value' => '', |
| 245 | 'def_value' => '', |
| 246 | 'holder' => '', |
| 247 | 'class' => 'marker_info', |
| 248 | 'admin_label' => false, |
| 249 | 'dependency' => array( |
| 250 | 'element' => 'show_map', |
| 251 | 'value' => '1' |
| 252 | ), |
| 253 | 'weight' => '', |
| 254 | 'group' => __( 'Map Options', 'auxin-elements' ), |
| 255 | 'edit_field_class' => '' |
| 256 | ), |
| 257 | array( |
| 258 | 'heading' => __('Navigation control','auxin-elements'), |
| 259 | 'description' => __('Show nacigation control on map.','auxin-elements'), |
| 260 | 'param_name' => 'show_mapcontrols', |
| 261 | 'type' => 'aux_switch', |
| 262 | 'def_value' => '', |
| 263 | 'value' => '0', |
| 264 | 'holder' => '', |
| 265 | 'class' => 'show_mapcontrols', |
| 266 | 'admin_label' => false, |
| 267 | 'dependency' => array( |
| 268 | 'element' => 'show_map', |
| 269 | 'value' => '1' |
| 270 | ), |
| 271 | 'weight' => '', |
| 272 | 'group' => __( 'Map Options', 'auxin-elements' ), |
| 273 | 'edit_field_class' => '' |
| 274 | ), |
| 275 | array( |
| 276 | 'heading' => __('Zoom','auxin-elements'), |
| 277 | 'description' => __('The initial resolution at which to display the map, between 1 to 20.', 'auxin-elements'), |
| 278 | 'param_name' => 'zoom', |
| 279 | 'type' => 'textfield', |
| 280 | 'value' => '10', |
| 281 | 'holder' => '', |
| 282 | 'class' => '', |
| 283 | 'admin_label' => false, |
| 284 | 'dependency' => array( |
| 285 | 'element' => 'show_map', |
| 286 | 'value' => '1' |
| 287 | ), |
| 288 | 'weight' => '', |
| 289 | 'group' => __( 'Map Options', 'auxin-elements' ), |
| 290 | 'edit_field_class' => '' |
| 291 | ), |
| 292 | array( |
| 293 | 'heading' => __('Zoom with mouse wheel','auxin-elements'), |
| 294 | 'description' => '', |
| 295 | 'param_name' => 'zoom_wheel', |
| 296 | 'type' => 'aux_switch', |
| 297 | 'def_value' => '', |
| 298 | 'value' => '0', |
| 299 | 'holder' => '', |
| 300 | 'class' => 'zoom_wheel', |
| 301 | 'admin_label' => false, |
| 302 | 'dependency' => array( |
| 303 | 'element' => 'show_map', |
| 304 | 'value' => '1' |
| 305 | ), |
| 306 | 'weight' => '', |
| 307 | 'group' => __( 'Map Options', 'auxin-elements' ), |
| 308 | 'edit_field_class' => '' |
| 309 | ), |
| 310 | array( |
| 311 | 'heading' => __('Extra class name','auxin-elements'), |
| 312 | 'description' => __('If you wish to style particular content element differently, then use this field to add a class name and then refer to it in your css file.', 'auxin-elements'), |
| 313 | 'param_name' => 'extra_classes', |
| 314 | 'type' => 'textfield', |
| 315 | 'value' => '', |
| 316 | 'def_value' => '', |
| 317 | 'holder' => '', |
| 318 | 'class' => 'extra_classes', |
| 319 | 'admin_label' => false, |
| 320 | 'dependency' => '', |
| 321 | 'weight' => '', |
| 322 | 'group' => '' , |
| 323 | 'edit_field_class' => '' |
| 324 | ) |
| 325 | ) |
| 326 | ); |
| 327 | |
| 328 | return $master_array; |
| 329 | } |
| 330 | |
| 331 | add_filter( 'auxin_master_array_shortcodes', 'get_auxin_contact_box', 10, 1 ); |
| 332 | |
| 333 | /** |
| 334 | * The front-end output of this element is returned by the following function |
| 335 | * |
| 336 | * @param array $atts The array containing the parsed values from shortcode, it should be same as defined params above. |
| 337 | * @param string $shortcode_content The shorcode content |
| 338 | * @return string The output of element markup |
| 339 | */ |
| 340 | function auxin_widget_contact_box( $atts, $shortcode_content = null ){ |
| 341 | |
| 342 | // Defining default attributes |
| 343 | $default_atts = array( |
| 344 | 'title' => '', // header title |
| 345 | 'style' => '', |
| 346 | 'show_map' => '1', |
| 347 | 'map_position' => 'down', |
| 348 | 'show_socials' => '1', |
| 349 | 'email' => '', |
| 350 | 'telephone' => '', |
| 351 | 'address' => '', |
| 352 | 'type' => 'ROADMAP', |
| 353 | 'zoom' => '10', |
| 354 | 'zoom_wheel' => '0', |
| 355 | 'marker_info' => '', |
| 356 | 'show_mapcontrols' => '0', |
| 357 | 'latitude' => 40.7, |
| 358 | 'longitude' => -74, |
| 359 | 'height' => 160, |
| 360 | |
| 361 | 'extra_classes' => '', // custom css class names for this element |
| 362 | 'custom_el_id' => '', |
| 363 | 'base_class' => 'aux-widget-contact-box' // base class name for container |
| 364 | ); |
| 365 | |
| 366 | $result = auxin_get_widget_scafold( $atts, $default_atts, $shortcode_content ); |
| 367 | extract( $result['parsed_atts'] ); |
| 368 | |
| 369 | // Validate the boolean variables |
| 370 | $show_socials = auxin_is_true( $show_socials ); |
| 371 | $zoom_wheel = auxin_is_true( $zoom_wheel ); |
| 372 | $show_mapcontrols = auxin_is_true( $show_mapcontrols ); |
| 373 | |
| 374 | ob_start(); |
| 375 | |
| 376 | // widget header ------------------------------ |
| 377 | echo wp_kses_post( $result['widget_header'] ); |
| 378 | echo wp_kses_post( $result['widget_title'] ); |
| 379 | |
| 380 | $contact_info = '<div class="aux-contact-details"><ul>'; |
| 381 | if( ! empty( $telephone ) ){ |
| 382 | $contact_info .= '<li class="phone"><i class="auxicon-phone-classic-on"></i><span class="info-text">'. esc_html( $telephone ) .'</span></li>'; |
| 383 | } |
| 384 | if( ! empty( $email ) ){ |
| 385 | $contact_info .= '<li class="email"><i class="auxicon-mail-3"></i><span class="info-text">'. antispambot( $email ) .'</span></li>'; |
| 386 | } |
| 387 | if( ! empty( $address ) ){ |
| 388 | $contact_info .= '<li class="address"><i class="auxicon-map-pin-streamline"></i><span class="info-text">'. esc_html( $address ) .'</span></li>'; |
| 389 | } |
| 390 | $contact_info .= '</ul>'; |
| 391 | if( $show_socials ) { |
| 392 | $contact_info .= auxin_get_the_socials(); |
| 393 | } |
| 394 | $contact_info .= '</div>'; |
| 395 | |
| 396 | // Print the contact info above the map if the position option is set to 'up' |
| 397 | if( 'down' !== $map_position ){ |
| 398 | echo wp_kses_post( $contact_info ); |
| 399 | } |
| 400 | |
| 401 | if( auxin_is_true( $show_map ) ) { |
| 402 | $mapid = uniqid("aux-map"); |
| 403 | $marker_title = ''; |
| 404 | |
| 405 | if ( empty( $style ) ) { |
| 406 | $style = auxin_get_gmap_style(); |
| 407 | } elseif ( base64_decode( $style, true ) === false) { |
| 408 | |
| 409 | } else { |
| 410 | $style = rawurldecode( base64_decode( strip_tags( $style ) ) ); |
| 411 | } |
| 412 | |
| 413 | ?> |
| 414 | <div id="<?php echo esc_attr( $mapid ); ?>" class="aux-map-wrapper <?php echo esc_attr( $extra_classes ); ?>" style="height:<?php echo esc_attr( $height ); ?>px" ></div> |
| 415 | <?php |
| 416 | } |
| 417 | |
| 418 | if( 'down' === $map_position ){ |
| 419 | echo wp_kses_post( $contact_info ); |
| 420 | } |
| 421 | |
| 422 | if( auxin_is_true( $show_map ) ) { |
| 423 | ?> |
| 424 | <script> |
| 425 | jQuery( function($) { |
| 426 | if(typeof GMaps != "function" || typeof google === "undefined"){ |
| 427 | console.info( "Please add google map API key in theme options. https://developers.google.com/maps/documentation/javascript/" ); |
| 428 | return; |
| 429 | } |
| 430 | var map = new GMaps({ |
| 431 | el: "#<?php echo esc_js( esc_attr( $mapid ) ); ?>", |
| 432 | lat: <?php echo floatval( $latitude ); ?>, |
| 433 | lng: <?php echo floatval( $longitude ); ?>, |
| 434 | zoom: <?php echo floatval( $zoom ); ?>, |
| 435 | scrollwheel: <?php echo $zoom_wheel ? '1' : '0'; ?>, |
| 436 | <?php if( $type == "SATELLITE" ){ ?> |
| 437 | mapTypeId: google.maps.MapTypeId.SATELLITE, |
| 438 | <?php } else { ?> |
| 439 | mapTypeId: google.maps.MapTypeId.ROADMAP, |
| 440 | <?php } if ( $show_mapcontrols == false ) { ?> |
| 441 | disableDefaultUI: true, |
| 442 | <?php } ?> |
| 443 | panControl : true |
| 444 | }); |
| 445 | |
| 446 | <?php if( $type == "ROADMAP" ){ ?> |
| 447 | map.addStyle({ |
| 448 | styledMapName:"Auxin custom style map", |
| 449 | styles: <?php echo ( auxin_is_json( $style ) ? $style : auxin_get_gmap_style() ); ?>, |
| 450 | mapTypeId: "aux_map_style" |
| 451 | }); |
| 452 | |
| 453 | map.setStyle("aux_map_style"); |
| 454 | <?php } ?> |
| 455 | map.addMarker({ |
| 456 | <?php if ( ! empty( $marker_info ) ) { ?> |
| 457 | infoWindow: { content: "<?php echo esc_js( esc_html( $marker_info ) ); ?>" }, |
| 458 | <?php } ?> |
| 459 | lat: <?php echo floatval( $latitude ); ?>, |
| 460 | lng: <?php echo floatval( $longitude ); ?> |
| 461 | }); |
| 462 | }); |
| 463 | |
| 464 | </script> |
| 465 | <?php |
| 466 | } |
| 467 | |
| 468 | |
| 469 | // widget footer ------------------------------ |
| 470 | echo wp_kses_post( $result['widget_footer'] ); |
| 471 | |
| 472 | return ob_get_clean(); |
| 473 | } |
| 474 |