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

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

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