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