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 / page-contact.php

page-contact.php in Virtue/Ascend/Pinnacle Toolkit 2.9, at page-contact.php

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