PluginProbe
Virtue/Ascend/Pinnacle Toolkit / 2.2
Virtue/Ascend/Pinnacle Toolkit v2.2
4.9.12.2 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 All 48 releases
virtue-toolkit / template-contact.php

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

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