PluginProbe
Virtue/Ascend/Pinnacle Toolkit / 2.9
Virtue/Ascend/Pinnacle Toolkit v2.9
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 2.9, at template-contact.php

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