| 1: | <?php |
| 2: | |
| 3: | |
| 4: | |
| 5: | |
| 6: | |
| 7: | |
| 8: | |
| 9: | |
| 10: | |
| 11: | |
| 12: | |
| 13: | if ( ! defined( 'ABSPATH' ) ) { |
| 14: | exit; |
| 15: | } |
| 16: | |
| 17: | |
| 18: | |
| 19: | |
| 20: | |
| 21: | |
| 22: | |
| 23: | |
| 24: | |
| 25: | |
| 26: | |
| 27: | |
| 28: | function epl_shortcode_googlemap_callback( $atts, $content = null ) { |
| 29: | global $property; |
| 30: | |
| 31: | $id = 0; |
| 32: | |
| 33: | if ( ! is_null( $property ) ) { |
| 34: | $id = $property->post->ID; |
| 35: | } |
| 36: | |
| 37: | $defaults = array( |
| 38: | 'width' => '100%', |
| 39: | 'height' => '350px', |
| 40: | 'zoom' => '17', |
| 41: | 'q' => '', |
| 42: | 'cord' => '', |
| 43: | 'suburb_mode' => 0, |
| 44: | ); |
| 45: | |
| 46: | $attributes = shortcode_atts( |
| 47: | $defaults, |
| 48: | $atts |
| 49: | ); |
| 50: | |
| 51: | if ( empty( $attributes['cord'] ) && empty( $attributes['q'] ) ) { |
| 52: | return ''; |
| 53: | } |
| 54: | |
| 55: | if ( ! is_epl_post() ) { |
| 56: | |
| 57: | epl_shortcode_googlemap_enqueue(); |
| 58: | } |
| 59: | |
| 60: | return '<div class="epl-tab-section epl-section-map epl-default-map-wrapper"> |
| 61: | <div style="width:' . esc_attr( $attributes['width'] ) . '; height:' . esc_attr( $attributes['height'] ) . '" data-suburb_mode="' . esc_attr( $attributes['suburb_mode'] ) . '" data-cord="' . esc_attr( $attributes['cord'] ) . '" data-zoom="' . esc_attr( $attributes['zoom'] ) . '" data-id="' . esc_attr( $id ) . '" data-address="' . esc_attr( $attributes['q'] ) . '" class="epl-map-shortcode" id="epl-default-map"></div> |
| 62: | </div>'; |
| 63: | } |
| 64: | add_shortcode( 'listing_map', 'epl_shortcode_googlemap_callback' ); |
| 65: | |
| 66: | |
| 67: | |
| 68: | |
| 69: | |
| 70: | |
| 71: | |
| 72: | |
| 73: | function epl_shortcode_googlemap_enqueue() { |
| 74: | |
| 75: | $googleapiurl = 'https://maps.googleapis.com/maps/api/js?v=3.exp&callback=Function.prototype&loading=async'; |
| 76: | $epl_google_api_key = epl_get_option( 'epl_google_api_key' ); |
| 77: | if ( ! empty( $epl_google_api_key ) ) { |
| 78: | $googleapiurl = $googleapiurl . '&key=' . epl_get_option( 'epl_google_api_key' ); |
| 79: | } |
| 80: | |
| 81: | if ( epl_get_option( 'epl_disable_google_api' ) !== 'on' ) { |
| 82: | wp_enqueue_script( 'epl-google-map-v-3', $googleapiurl, array(), EPL_PROPERTY_VER, false ); |
| 83: | } |
| 84: | } |
| 85: | |