1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
function epl_property_map_default_callback( $args ) {
$defaults = array(
'width' => '100%',
'height' => '350px',
'zoom' => '17',
);
$args = wp_parse_args( $args, apply_filters( 'epl_map_display_defaults', $defaults ) );
global $property;
$api_key = epl_get_option( 'epl_google_api_key' );
$show_warning = apply_filters( 'epl_show_map_key_warning', true );
if ( empty( $api_key ) ) {
if ( $show_warning && is_user_logged_in() && current_user_can( 'administrator' ) ) {
epl_map_api_key_warning();
}
return;
}
if ( 'yes' === $property->get_property_meta( 'property_address_display' ) ) {
$address = epl_property_get_the_full_address();
$address = apply_filters( 'epl_map_address', $address );
$coordinates = $property->get_property_meta( 'property_address_coordinates' );
echo do_shortcode( '[listing_map zoom=14 width="' . $args['width'] . '" height="' . $args['height'] . '" zoom="' . $args['zoom'] . '" cord="' . $coordinates . '" q="' . $address . '"]' );
} else {
$address = $property->get_property_meta( 'property_address_suburb' ) . ', ';
$address .= $property->get_property_meta( 'property_address_state' ) . ', ';
$address .= $property->get_property_meta( 'property_address_postal_code' );
$address = apply_filters( 'epl_map_address', $address );
echo do_shortcode( '[listing_map zoom=14 suburb_mode=1 q="' . $address . '"]' );
}
}
add_action( 'epl_property_map', 'epl_property_map_default_callback' );
function epl_map_api_key_warning() { ?>
<div class="epl-danger epl-warning-map-key">
<p><?php esc_html_e( 'Ensure you have set a Google Maps API Key from Dashboard > Easy Property Listings > Settings.', 'easy-property-listings' ); ?>
<em><?php esc_html_e( 'Note: This message is only displayed to logged in administrators.', 'easy-property-listings' ); ?></em>
</p>
</div>
<?php
}