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

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

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