/
template-contacts.php
120 lines (91 loc) · 4.16 KB
/
template-contacts.php
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<?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 = '';
}
?>
<div id="main" class="site page-contacts"><?php
if ( gp_contacts_has_map( get_the_ID() ) ) : ?>
<div id="map" data-latitude="<?php echo esc_attr($latitude); ?>" data-longitude="<?php echo esc_attr($longitude); ?>"
data-icon-latitude="<?php echo esc_attr($icon_latitude); ?>" data-icon-longitude="<?php echo esc_attr($icon_longitude); ?>"
data-icon-image="<?php echo $icon_image; ?>"></div><?php
endif;
$map_dim_class = '';
if ( has_post_thumbnail() ) :
$map_dim_class = ' class="dim-image"';
$bg_image = it_get_post_thumbnail( get_the_ID(), 'gp-max' ); ?>
<div class="contacts-background" style="background-image: url(<?php echo esc_url( $bg_image ); ?>)"></div><?php
endif; ?>
<div id="map-dim"<?php echo $map_dim_class; ?>></div>
<div id="content" class="site-content">
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<div class="viewport">
<header class="entry-header">
<h1 class="entry-title"><?php the_title(); ?></h1>
</header>
<div class="entry-content"><?php
if ( $contacts ) : ?>
<div class="row-fluid">
<div class="span8"><?php
the_content();
if ( $message_btn || $view_btn ) : ?>
<p><?php echo $message_btn . $view_btn; ?></p><?php
endif ?>
</div>
<div class="span4">
<div class="contact-details">
<?php foreach ( $contacts as $contact ) : ?>
<h6><?php echo $contact['title']; ?></h6>
<p><?php echo nl2br( $contact['content'] ); ?></p>
<?php endforeach; ?>
</div>
</div>
</div><?php
else:
the_content();
if ( $message_btn || $view_btn ) : ?>
<p><?php echo $message_btn . $view_btn; ?></p><?php
endif;
endif; ?>
</div>
</div>
</article>
</div><?php
if ( $view_btn ) : ?>
<a id="close-map" href="#" class="button icon-cancel"><?php _e( 'Close', 'gp' ); ?></a><?php
endif;?>
</div><?php
if ( $message_btn ) : ?>
<div id="contacts-modal" class="reveal-modal">
<h1 class="entry-header"><?php _e( 'Send message', 'gp' ); ?></h1>
<div class="modal-contents"></div>
<a class="close-reveal-modal">×</a>
</div><?php
endif;
endif;
get_footer();