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 +105 -93 2.2 → 4.9.12.2 View file →
@@ -1,23 +1,33 @@
1 1 <?php
2 2 /*
3 3 Template Name: Contact
4 4 */
5 -get_header(); ?>
5 +get_header();
6 +global $post, $pinnacle;
7 + $form = get_post_meta( $post->ID, '_kad_contact_form', true );
8 + $map = get_post_meta( $post->ID, '_kad_contact_map', true );
9 + $pageemail = get_post_meta( $post->ID, '_kad_contact_form_email', true );
10 + $form_math = get_post_meta( $post->ID, '_kad_contact_form_math', true );
11 + if ($form == 'yes') { ?>
6 12 <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'); ?>",
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')); ?>",
9 15 });
10 16 $("#contactForm").validate();
11 17 });</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 );
18 + <script type="text/javascript" src="<?php echo VIRTUE_TOOLKIT_URL ?>assets/jquery.validate.js"></script>
19 + <?php }
14 20 if ($map == 'yes') { ?>
15 - <script type="text/javascript" src="https://maps.google.com/maps/api/js?sensor=false"></script>
16 21 <?php $address = get_post_meta( $post->ID, '_kad_contact_address', true );
17 22 $maptype = get_post_meta( $post->ID, '_kad_contact_maptype', true );
18 23 $height = get_post_meta( $post->ID, '_kad_contact_mapheight', true );
19 - $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 + }
20 30 if(!empty($height)) {
21 31 $mapheight = $height;
22 32 } else {
23 33 $mapheight = 300;
@@ -26,121 +36,124 @@
26 36 $zoom = $mapzoom;
27 37 } else {
28 38 $zoom = 15;
29 39 } ?>
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>
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>
85 96
86 97 <?php
87 98 echo '<style type="text/css" media="screen">#map_address {height:'.$mapheight.'px;}</style>';
88 99 }
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 100 if(isset($_POST['submitted'])) {
93 101 if(isset($form_math) && $form_math == 'yes') {
94 - if(md5($_POST['kad_captcha']) != $_POST['hval']) {
95 - $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');
96 105 $hasError = true;
97 106 }
98 107 }
99 108 if(trim($_POST['contactName']) === '') {
100 - $nameError = __('Please enter your name.', 'kadencetoolkit');
109 + $nameError = __('Please enter your name.', 'virtue-toolkit');
101 110 $hasError = true;
102 111 } else {
103 - $name = trim($_POST['contactName']);
112 + $name = sanitize_text_field($_POST['contactName']);
104 113 }
105 114
106 115 if(trim($_POST['email']) === '') {
107 - $emailError = __('Please enter your email address.', 'kadencetoolkit');
116 + $emailError = __('Please enter your email address.', 'virtue-toolkit');
108 117 $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');
118 + } else if (!is_email($_POST['email'])) {
119 + $emailError = __('You entered an invalid email address.', 'virtue-toolkit');
111 120 $hasError = true;
112 121 } else {
113 - $email = trim($_POST['email']);
122 + $email = sanitize_email($_POST['email']);
114 123 }
115 124
116 125 if(trim($_POST['comments']) === '') {
117 - $commentError = __('Please enter a message.', 'kadencetoolkit');
126 + $commentError = __('Please enter a message.', 'virtue-toolkit');
118 127 $hasError = true;
119 128 } else {
120 129 if(function_exists('stripslashes')) {
121 130 $comments = stripslashes(trim($_POST['comments']));
122 131 } else {
123 - $comments = trim($_POST['comments']);
132 + $comments = wp_kses_post($_POST['comments']);
124 133 }
125 134 }
126 135
127 136 if(!isset($hasError)) {
137 + $name = wp_filter_kses( $name );
138 + $email = wp_filter_kses( $email );
139 + $comments = wp_filter_kses( $comments );
140 +
128 141 if (isset($pageemail)) {
129 142 $emailTo = $pageemail;
130 143 } else {
131 144 $emailTo = get_option('admin_email');
132 145 }
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";
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";
139 152
140 - wp_mail($emailTo, $subject, $body, $headers);
141 - $emailSent = true;
142 - }
153 + wp_mail($emailTo, $subject, $body, $headers);
154 + $emailSent = true;
155 + }
143 156
144 157 } ?>
145 158 <?php get_template_part('templates/page', 'header'); ?>
146 159 <?php if ($map == 'yes') { ?>
@@ -149,10 +162,9 @@
149 162 <?php } ?>
150 163
151 164 <div id="content" class="container">
152 165 <div class="row">
153 - <?php $form = get_post_meta( $post->ID, '_kad_contact_form', true );
154 - if ($form == 'yes') { ?>
166 + <?php if ($form == 'yes') { ?>
155 167 <div id="main" class="main col-md-5" role="main">
156 168 <div class="postclass pageclass">
157 169 <?php } else { ?>
158 170 <div id="main" class="main col-md-12" role="main">
@@ -169,19 +181,19 @@
169 181 echo '<h3>'. $contactformtitle .'</h3>';
170 182 }
171 183 if(isset($emailSent) && $emailSent == true) { ?>
172 184 <div class="thanks">
173 - <p><?php _e('Thanks, your email was sent successfully.', 'kadencetoolkit');?></p>
185 + <p><?php _e('Thanks, your email was sent successfully.', 'virtue-toolkit');?></p>
174 186 </div>
175 187 <?php } else { ?>
176 188 <?php if(isset($hasError) || isset($captchaError)) { ?>
177 - <p class="error"><?php _e('Sorry, an error occured.', 'kadencetoolkit');?><p>
189 + <p class="error"><?php _e('Sorry, an error occured.', 'virtue-toolkit');?><p>
178 190 <?php } ?>
179 191
180 192 <form action="<?php the_permalink(); ?>" id="contactForm" method="post">
181 193 <div class="contactform">
182 194 <p>
183 - <label for="contactName"><b><?php _e('Name:', 'kadencetoolkit');?></b></label>
195 + <label for="contactName"><b><?php _e('Name:', 'virtue-toolkit');?></b></label>
184 196 <?php if(isset($nameError)) { ?>
185 197 <span class="error"><?php echo esc_html($nameError);?></span>
186 198 <?php } ?>
187 199
@@ -189,9 +201,9 @@
189 201
190 202 </p>
191 203
192 204 <p>
193 - <label for="email"><b><?php _e('Email:', 'kadencetoolkit'); ?></b></label>
205 + <label for="email"><b><?php _e('Email:', 'virtue-toolkit'); ?></b></label>
194 206 <?php if(isset($emailError)) { ?>
195 207 <span class="error"><?php echo esc_html($emailError);?></span>
196 208 <?php } ?>
197 209 <input type="text" name="email" id="email" value="<?php if(isset($_POST['email'])) echo esc_attr($_POST['email']);?>" class="required requiredField email full" />
@@ -196,13 +208,13 @@
196 208 <?php } ?>
197 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 210 </p>
199 211
200 - <p><label for="commentsText"><b><?php _e('Message:', 'kadencetoolkit'); ?></b></label>
212 + <p><label for="commentsText"><b><?php _e('Message:', 'virtue-toolkit'); ?></b></label>
201 213 <?php if(isset($commentError)) { ?>
202 214 <span class="error"><?php echo esc_html($commentError);?></span>
203 215 <?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>
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>
205 217 </p>
206 218 <?php if(isset($form_math) && $form_math == 'yes') { ?>
207 219 <?php $one = rand(5, 50);
208 220 $two = rand(1, 9);
@@ -214,9 +226,9 @@
214 226 <input type="hidden" name="hval" id="hval" value="<?php echo esc_attr($result);?>" />
215 227 </p>
216 228 <?php } ?>
217 229 <p>
218 - <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>
219 231 </p>
220 232 </div><!-- /.contactform-->
221 233 <input type="hidden" name="submitted" id="submitted" value="true" />
222 234 </form>