PluginProbe
Virtue/Ascend/Pinnacle Toolkit / 3.7
Virtue/Ascend/Pinnacle Toolkit v3.7
trunk 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 3.1 3.2 3.3 3.4 3.7 3.8 All 47 releases
virtue-toolkit / template-contact.php

template-contact.php in Virtue/Ascend/Pinnacle Toolkit 3.7, at template-contact.php

242 lines 9.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 Template Name: Contact
4 */
5 get_header();
6 global $post, $pinnacle;
7 $form = get_post_meta( $post->ID, '_kad_contact_form', true );
8 $map = get_post_meta( $post->ID, '_kad_contact_map', true );
9 $pageemail = get_post_meta( $post->ID, '_kad_contact_form_email', true );
10 $form_math = get_post_meta( $post->ID, '_kad_contact_form_math', true );
11 if ($form == 'yes') { ?>
12 <script type="text/javascript">jQuery(document).ready(function ($) {$.extend($.validator.messages, {
13 required: "<?php echo __('This field is required.', 'virtue-toolkit'); ?>",
14 email: "<?php echo __('Please enter a valid email address.', 'virtue-toolkit'); ?>",
15 });
16 $("#contactForm").validate();
17 });</script>
18 <script type="text/javascript" src="<?php echo get_template_directory_uri(); ?>/assets/js/jquery.validate-ck.js"></script>
19 <?php }
20 if ($map == 'yes') { ?>
21 <?php $address = get_post_meta( $post->ID, '_kad_contact_address', true );
22 $maptype = get_post_meta( $post->ID, '_kad_contact_maptype', true );
23 $height = get_post_meta( $post->ID, '_kad_contact_mapheight', true );
24 $mapzoom = get_post_meta( $post->ID, '_kad_contact_zoom', true );
25 if(isset($pinnacle['google_map_api']) && !empty($pinnacle['google_map_api'])) {
26 $gmap_api = $pinnacle['google_map_api'];
27 } else {
28 $gmap_api = 'AIzaSyBt7JOCM4XQTEi9jzdqB8alFc1Vm_3mbfQ';
29 }
30 if(!empty($height)) {
31 $mapheight = $height;
32 } else {
33 $mapheight = 300;
34 }
35 if(!empty($mapzoom)) {
36 $zoom = $mapzoom;
37 } else {
38 $zoom = 15;
39 } ?>
40 <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=<?php echo esc_attr($gmap_api);?>"></script>
41 <script type="text/javascript">
42 jQuery(window).load(function() {
43 jQuery('#map_address').gmap3({
44 map: {
45 address:"<?php echo esc_js($address);?>",
46 options: {
47 zoom:<?php echo esc_js($zoom);?>,
48 draggable: true,
49 mapTypeControl: true,
50 mapTypeId: google.maps.MapTypeId.<?php echo esc_js($maptype);?>,
51 scrollwheel: false,
52 panControl: true,
53 rotateControl: false,
54 scaleControl: true,
55 streetViewControl: true,
56 zoomControl: true
57 }
58 },
59 marker:{
60 values:[
61 {
62 address: "<?php echo esc_js($address);?>",
63 data:"<div class='mapinfo'>'<?php echo esc_js($address);?>'</div>",
64 },
65 ],
66 options:{
67 draggable: false,
68 },
69 events:{
70 click: function(marker, event, context){
71 var map = jQuery(this).gmap3("get"),
72 infowindow = jQuery(this).gmap3({get:{name:"infowindow"}});
73 if (infowindow){
74 infowindow.open(map, marker);
75 infowindow.setContent(context.data);
76 } else {
77 jQuery(this).gmap3({
78 infowindow:{
79 anchor:marker,
80 options:{content: context.data}
81 }
82 });
83 }
84 },
85 closeclick: function(){
86 var infowindow = jQuery(this).gmap3({get:{name:"infowindow"}});
87 if (infowindow){
88 infowindow.close();
89 }
90 }
91 }
92 }
93 });
94 });
95 </script>
96
97 <?php
98 echo '<style type="text/css" media="screen">#map_address {height:'.$mapheight.'px;}</style>';
99 }
100 if(isset($_POST['submitted'])) {
101 if(isset($form_math) && $form_math == 'yes') {
102 $math_answer = trim($_POST['kad_captcha']);
103 if(md5($math_answer) != $_POST['hval']) {
104 $kad_captchaError = __('Check your math.', 'virtue-toolkit');
105 $hasError = true;
106 }
107 }
108 if(trim($_POST['contactName']) === '') {
109 $nameError = __('Please enter your name.', 'virtue-toolkit');
110 $hasError = true;
111 } else {
112 $name = trim($_POST['contactName']);
113 }
114
115 if(trim($_POST['email']) === '') {
116 $emailError = __('Please enter your email address.', 'virtue-toolkit');
117 $hasError = true;
118 } else if (!is_email($_POST['email'])) {
119 $emailError = __('You entered an invalid email address.', 'virtue-toolkit');
120 $hasError = true;
121 } else {
122 $email = trim($_POST['email']);
123 }
124
125 if(trim($_POST['comments']) === '') {
126 $commentError = __('Please enter a message.', 'virtue-toolkit');
127 $hasError = true;
128 } else {
129 if(function_exists('stripslashes')) {
130 $comments = stripslashes(trim($_POST['comments']));
131 } else {
132 $comments = trim($_POST['comments']);
133 }
134 }
135
136 if(!isset($hasError)) {
137 $name = wp_filter_kses( $name );
138 $email = wp_filter_kses( $email );
139 $comments = wp_filter_kses( $comments );
140
141 if (isset($pageemail)) {
142 $emailTo = $pageemail;
143 } else {
144 $emailTo = get_option('admin_email');
145 }
146 $sitename = get_bloginfo('name');
147 $subject = '['.$sitename . ' ' . __("Contact", "kadencetoolkit").'] '. __("From", "kadencetoolkit") . ' ' . $name;
148 $body = __('Name', 'virtue-toolkit').": $name \n\n";
149 $body .= __('Email', 'virtue-toolkit').": $email \n\n";
150 $body .= __('Comments', 'virtue-toolkit').":\n $comments";
151 $headers = 'Reply-To: ' . $name . '<' . $email . '>' . "\r\n";
152
153 wp_mail($emailTo, $subject, $body, $headers);
154 $emailSent = true;
155 }
156
157 } ?>
158 <?php get_template_part('templates/page', 'header'); ?>
159 <?php if ($map == 'yes') { ?>
160 <div id="map_address">
161 </div>
162 <?php } ?>
163
164 <div id="content" class="container">
165 <div class="row">
166 <?php if ($form == 'yes') { ?>
167 <div id="main" class="main col-md-5" role="main">
168 <div class="postclass pageclass">
169 <?php } else { ?>
170 <div id="main" class="main col-md-12" role="main">
171 <div class="postclass pageclass">
172 <?php } ?>
173 <?php get_template_part('templates/content', 'page'); ?>
174 </div>
175 </div>
176 <?php if ($form == 'yes') { ?>
177 <div class="contactformcase col-md-7">
178 <?php
179 $contactformtitle = get_post_meta( $post->ID, '_kad_contact_form_title', true );
180 if (!empty($contactformtitle)) {
181 echo '<h3>'. $contactformtitle .'</h3>';
182 }
183 if(isset($emailSent) && $emailSent == true) { ?>
184 <div class="thanks">
185 <p><?php _e('Thanks, your email was sent successfully.', 'virtue-toolkit');?></p>
186 </div>
187 <?php } else { ?>
188 <?php if(isset($hasError) || isset($captchaError)) { ?>
189 <p class="error"><?php _e('Sorry, an error occured.', 'virtue-toolkit');?><p>
190 <?php } ?>
191
192 <form action="<?php the_permalink(); ?>" id="contactForm" method="post">
193 <div class="contactform">
194 <p>
195 <label for="contactName"><b><?php _e('Name:', 'virtue-toolkit');?></b></label>
196 <?php if(isset($nameError)) { ?>
197 <span class="error"><?php echo esc_html($nameError);?></span>
198 <?php } ?>
199
200 <input type="text" name="contactName" id="contactName" value="<?php if(isset($_POST['contactName'])) echo esc_attr($_POST['contactName']);?>" class="required requiredField full" />
201
202 </p>
203
204 <p>
205 <label for="email"><b><?php _e('Email:', 'virtue-toolkit'); ?></b></label>
206 <?php if(isset($emailError)) { ?>
207 <span class="error"><?php echo esc_html($emailError);?></span>
208 <?php } ?>
209 <input type="text" name="email" id="email" value="<?php if(isset($_POST['email'])) echo esc_attr($_POST['email']);?>" class="required requiredField email full" />
210 </p>
211
212 <p><label for="commentsText"><b><?php _e('Message:', 'virtue-toolkit'); ?></b></label>
213 <?php if(isset($commentError)) { ?>
214 <span class="error"><?php echo esc_html($commentError);?></span>
215 <?php } ?>
216 <textarea name="comments" id="commentsText" rows="10" class="required requiredField"><?php if(isset($_POST['comments'])) { if(function_exists('stripslashes')) { echo esc_textarea(stripslashes($_POST['comments'])); } else { echo esc_textarea($_POST['comments']); } } ?></textarea>
217 </p>
218 <?php if(isset($form_math) && $form_math == 'yes') { ?>
219 <?php $one = rand(5, 50);
220 $two = rand(1, 9);
221 $result = md5($one + $two); ?>
222 <p>
223 <label for="kad_captcha"><b><?php echo $one.' + '.$two; ?> = </b></label>
224 <input type="text" name="kad_captcha" id="kad_captcha" class="required requiredField kad_captcha kad-quarter" />
225 <?php if(isset($kad_captchaError)) { ?><label class="error"><?php echo esc_html($kad_captchaError);?></label><?php } ?>
226 <input type="hidden" name="hval" id="hval" value="<?php echo esc_attr($result);?>" />
227 </p>
228 <?php } ?>
229 <p>
230 <input type="submit" class="kad-btn kad-btn-primary" id="submit" tabindex="5" value="<?php _e('Send Email', 'virtue-toolkit'); ?>" ></input>
231 </p>
232 </div><!-- /.contactform-->
233 <input type="hidden" name="submitted" id="submitted" value="true" />
234 </form>
235 <?php } ?>
236 </div><!--contactform-->
237 <?php } ?>
238 <?php get_sidebar(); ?>
239 </div><!-- /.row-->
240 </div><!-- /.content -->
241 </div><!-- /.wrap -->
242 <?php get_footer(); ?>