<?php

/*
T-MMM-emplate Name: Contacts
*/
gp_add_html_class('horizontal-page no-scroll');
/**
 * Enqueue scripts required for displaying maps.
 */
gp_contacts_enqueue_google_maps();
get_header();
if (have_posts()) {
    the_post();
    $contacts_data = gp_contacts_get_data(get_the_ID());
    $has_map = gp_contacts_has_map(get_the_ID());
    // See gp_contacts_get_data() for the variables that are extracted.
    extract($contacts_data);
    $icon_image = $icon_image && !empty($icon_image) ? esc_url($icon_image) : '';
    if ($has_map) {
        $view_btn = '<a id="view-map" href="#" class="button icon-location">' . __('View map', 'gp') . '</a>';
    } else {
        $view_btn = '';
    }
    /**
     * Show Send Message button only if there is a [contact-form-7] short tag
     * in the content.
     */
    if (preg_match('/\\[contact\\-form\\-7.+?\\]/is', $post->post_content)) {
        $message_btn = '<a id="send-message" href="#" class="button icon-paper-plane">' . __('Send message', 'gp') . '</a>';
    } else {
        $message_btn = '';
Example #2
0
/**
 * Add Google Maps script, if API key is specified.
 */
function gp_contacts_enqueue_google_maps()
{
    global $post;
    /**
     * If current page has contacts template, then see if we need to enqueue
     * Google Maps script.
     */
    if ($post) {
        if (it_is_template($post->ID, 'template-contacts.php')) {
            if (gp_contacts_has_map($post->ID)) {
                $data = gp_contacts_get_data($post->ID);
                wp_enqueue_script('google-maps-api3', 'https://maps.googleapis.com/maps/api/js?key=' . $data['api'] . '&sensor=false');
                wp_enqueue_script('gp-maps', get_template_directory_uri() . '/js/maps.js', array('google-maps-api3', 'jquery'));
            }
        }
    }
}