Changeset 1624 for sites/trunk/global.wordpress.org/public_html/wp-content/themes/rosetta/contact.php
- Timestamp:
- 05/25/2015 10:30:18 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/global.wordpress.org/public_html/wp-content/themes/rosetta/contact.php
r1166 r1624 4 4 */ 5 5 6 7 6 function rosetta_set_sender( &$phpmailer ) { 8 7 $phpmailer->Sender = $_POST['your_email']; 9 8 } 10 9 10 get_header(); 11 the_post(); 11 12 ?> 12 <?php get_header(); ?> 13 <div class="wrapper"> 14 <div class="section"> 15 <?php if (have_posts()) : while (have_posts()) : the_post(); ?> 13 <div id="headline"> 14 <div class="wrapper"> 15 <h2><?php the_title(); ?></h2> 16 </div> 17 </div> 18 19 <div id="pagebody"> 20 <div class="wrapper"> 21 <div class="col-9"> 16 22 17 23 <?php 18 24 if ( ! empty( $_POST['submit'] ) ) { 19 25 20 // Check values 21 $error = $your_name = $blog_name = $your_email = $blog_url = $message = false; 22 if ('' == $_POST['your_name']) { 23 $your_name = true; 24 $error = true; 25 } 26 27 if (!validate_email($_POST['your_email'])) { 28 $your_email = true; 29 $error = true; 30 } 31 32 if ('' == $_POST['message']) { 33 $blog_description = true; 34 $error = true; 35 } 36 37 if ('' == $_POST['subject']) { 38 $subject = true; 39 $error = true; 40 } 41 42 if ($error) { 43 ?> 44 <h3 id="return"><?php _e('Error', 'rosetta'); ?></h3> 45 <p class="error"><?php _e('There seems to have been a problem with the information you entered. Please fix the field indicated and resubmit.', 'rosetta'); ?></p> 46 <form id="contactme" method="post" action="/contact/#return"> 47 <table id="form"> 48 <?php if ($your_name) { ?> 49 <tr class="error"> 50 <td class="label"><label for="your_name"><?php _e('Your Name:', 'rosetta'); ?> </label></td> 51 <td><span><input name="your_name" type="text" id="your_name" value="<?php echo esc_attr( $_POST['your_name'], 1 ); ?>" /></span> 52 <?php _e('Let us know your name.', 'rosetta'); ?></td> 53 </tr> 54 <?php } else { ?> 55 <tr> 56 <td class="label"><label for="your_name"><?php _e('Your Name:', 'rosetta'); ?></label></td> 57 <td><span><input name="your_name" type="text" id="your_name" value="<?php echo esc_attr( $_POST['your_name'], 1 ); ?>" /></span></td> 58 </tr> 59 <?php } ?> 60 61 <?php if ($your_email) { ?> 62 <tr class="error"> 63 <td class="label"><label for="your_email"><?php _e('Your Email:', 'rosetta'); ?></label></td> 64 <td><span><input name="your_email" type="text" id="your_email" value="<?php echo esc_attr( $_POST['your_email'], 1 ); ?>" /></span> 65 <?php _e('Your email address did not appear to be valid. Please check it.', 'rosetta'); ?></td> 66 </tr> 67 <?php } else { ?> 68 <tr> 69 <td class="label"><label for="your_email"><?php _e('Your Email:', 'rosetta'); ?></label></td> 70 <td><span><input name="your_email" type="text" id="your_email" value="<?php echo esc_attr( $_POST['your_email'], 1 ); ?>" /></span></td> 71 </tr> 72 <?php } ?> 73 74 <tr> 75 <td class="label"><label for="blog_url"><?php _e('URI of your blog:', 'rosetta'); ?></label></td> 76 <td><span><input name="blog_url" type="text" id="blog_url" value="<?php echo esc_attr( $_POST['blog_url'], 1 ); ?>" /></span></td> 77 </tr> 78 <?php if ($subject) { ?> 79 <tr class="error"> 80 <td class="label"><label for="subject"><?php _e('What’s this about?', 'rosetta'); ?></label></td> 81 <td><span><input name="subject" type="text" id="subject" value="<?php echo esc_attr( $_POST['subject'], 1 ); ?>" /></span> <?php _e('Write something!', 'rosetta'); ?></td> 82 </tr> 83 <?php } else { ?> 84 <tr> 85 <td class="label"><label for="subject"><?php _e('What’s this about?', 'rosetta'); ?></label></td> 86 <td><span><input name="subject" type="text" id="subject" value="<?php echo esc_attr( $_POST['subject'], 1 ); ?>" /></span></td> 87 </tr> 88 <?php } ?> 89 90 <?php if ($blog_description) { ?> 91 <tr class="error"> 92 <td class="label"><label for="message"><?php _e('Your Message:', 'rosetta'); ?></label></td> 93 <td><span class="message"><textarea name="message" id="message"><?php echo esc_textarea( $_POST['message'], 1 ); ?></textarea></span> 94 <?php _e('Say something!', 'rosetta'); ?></td> 95 </tr> 96 <?php } else { ?> 97 <tr> 98 <td class="label"><label for="message"><?php _e('Your Message:', 'rosetta'); ?></label></td> 99 <td><span class="message"><textarea name="message" id="message"><?php echo esc_textarea( $_POST['message'], 1 ); ?></textarea></span></td> 100 </tr> 101 <?php } ?> 102 <tr class="submit"> 103 <td class="label"></td> 104 <td><input type="submit" name="submit" value="<?php esc_attr_e('Submit Form Again', 'rosetta'); ?>" /></td> 105 </tr> 106 </table> 107 </form> 108 109 <?php } else { // If all the info is good 110 111 // Akismet checking 112 $comment['user_ip'] = preg_replace( '/[^0-9., ]/', '', $_SERVER['REMOTE_ADDR'] ); 113 $comment['user_agent'] = $_SERVER['HTTP_USER_AGENT']; 114 $comment['referrer'] = $_SERVER['HTTP_REFERER']; 115 $comment['blog'] = home_url(); 116 $comment['comment_type'] = 'contact_form'; 117 $comment['comment_author'] = ''; 118 $comment['comment_author_email'] = $_POST['your_email']; 119 $comment['comment_author_url'] = $_POST['blog_url']; 120 $comment['comment_content'] = stripslashes($_POST['message']); 121 $query_string = ''; 122 foreach ( $comment as $key => $data ) 123 $query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&'; 124 $response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port); 125 if ( 'true' == $response[1] ) 126 die(); 127 // end Akismet checking 128 129 130 131 //sanitization 132 $message_data = array(); 133 $message_data['ip'] = preg_replace( '/[^0-9., ]/', '', $_SERVER['REMOTE_ADDR'] ); 134 $message_data['name'] = sanitize_text_field( $_POST['your_name'] ); 135 $message_data['email'] = sanitize_email( $_POST['your_email'] ); 136 $message_data['blog_url'] = esc_url_raw( $_POST['blog_url'] ); 137 $message_data['subject'] = sanitize_text_field( $_POST['subject'] ); 138 $message_data['message'] = wp_kses( stripslashes( $_POST['message'] ), array() ); 139 140 // Let's send an email 141 $message = $message_data['message'] . ' 26 // Check values 27 $error = $your_name = $blog_name = $your_email = $blog_url = $message = false; 28 if ( '' == $_POST['your_name'] ) { 29 $your_name = true; 30 $error = true; 31 } 32 33 if ( ! validate_email( $_POST['your_email'] ) ) { 34 $your_email = true; 35 $error = true; 36 } 37 38 if ( '' == $_POST['message'] ) { 39 $blog_description = true; 40 $error = true; 41 } 42 43 if ( '' == $_POST['subject'] ) { 44 $subject = true; 45 $error = true; 46 } 47 48 if ( $error ) { 49 ?> 50 <h3 id="return"><?php _e( 'Error', 'rosetta' ); ?></h3> 51 <p class="error"><?php _e( 'There seems to have been a problem with the information you entered. Please fix the field indicated and resubmit.', 'rosetta' ); ?></p> 52 <form id="contactme" method="post" action="/contact/#return"> 53 <table id="form"> 54 55 <?php if ( $your_name ) { ?> 56 <tr class="error"> 57 <td class="label"> 58 <label for="your_name"><?php _e( 'Your Name:', 'rosetta' ); ?> </label> 59 </td> 60 <td> 61 <span><input name="your_name" type="text" id="your_name" value="<?php echo esc_attr( $_POST['your_name'] ); ?>" /></span> 62 <?php _e( 'Let us know your name.', 'rosetta' ); ?> 63 </td> 64 </tr> 65 <?php } else { ?> 66 <tr> 67 <td class="label"> 68 <label for="your_name"><?php _e( 'Your Name:', 'rosetta' ); ?></label> 69 </td> 70 <td> 71 <span><input name="your_name" type="text" id="your_name" value="<?php echo esc_attr( $_POST['your_name'] ); ?>" /></span> 72 </td> 73 </tr> 74 <?php } ?> 75 76 <?php if ( $your_email ) { ?> 77 <tr class="error"> 78 <td class="label"> 79 <label for="your_email"><?php _e( 'Your Email:', 'rosetta' ); ?></label> 80 </td> 81 <td> 82 <span><input name="your_email" type="text" id="your_email" value="<?php echo esc_attr( $_POST['your_email'] ); ?>" /></span> 83 <?php _e( 'Your email address did not appear to be valid. Please check it.', 'rosetta' ); ?> 84 </td> 85 </tr> 86 <?php } else { ?> 87 <tr> 88 <td class="label"> 89 <label for="your_email"><?php _e( 'Your Email:', 'rosetta' ); ?></label> 90 </td> 91 <td> 92 <span><input name="your_email" type="text" id="your_email" value="<?php echo esc_attr( $_POST['your_email'] ); ?>" /></span> 93 </td> 94 </tr> 95 <?php } ?> 96 97 <tr> 98 <td class="label"> 99 <label for="blog_url"><?php _e( 'URI of your blog:', 'rosetta' ); ?></label> 100 </td> 101 <td> 102 <span><input name="blog_url" type="text" id="blog_url" value="<?php echo esc_attr( $_POST['blog_url'] ); ?>" /></span> 103 </td> 104 </tr> 105 106 <?php if ( $subject ) { ?> 107 <tr class="error"> 108 <td class="label"> 109 <label for="subject"><?php _e( 'What’s this about?', 'rosetta' ); ?></label> 110 </td> 111 <td> 112 <span><input name="subject" type="text" id="subject" value="<?php echo esc_attr( $_POST['subject'] ); ?>" /></span> 113 <?php _e( 'Write something!', 'rosetta' ); ?> 114 </td> 115 </tr> 116 <?php } else { ?> 117 <tr> 118 <td class="label"> 119 <label for="subject"><?php _e('What’s this about?', 'rosetta'); ?></label> 120 </td> 121 <td> 122 <span><input name="subject" type="text" id="subject" value="<?php echo esc_attr( $_POST['subject'] ); ?>" /></span> 123 </td> 124 </tr> 125 <?php } ?> 126 127 <?php if ( $blog_description ) { ?> 128 <tr class="error"> 129 <td class="label"> 130 <label for="message"><?php _e('Your Message:', 'rosetta'); ?></label> 131 </td> 132 <td> 133 <span class="message"><textarea name="message" id="message"><?php echo esc_textarea( $_POST['message'] ); ?></textarea></span> 134 <?php _e( 'Say something!', 'rosetta' ); ?> 135 </td> 136 </tr> 137 <?php } else { ?> 138 <tr> 139 <td class="label"> 140 <label for="message"><?php _e( 'Your Message:', 'rosetta' ); ?></label> 141 </td> 142 <td> 143 <span class="message"><textarea name="message" id="message"><?php echo esc_textarea( $_POST['message'] ); ?></textarea></span> 144 </td> 145 </tr> 146 <?php } ?> 147 148 <tr class="submit"> 149 <td class="label"></td> 150 <td> 151 <input type="submit" name="submit" value="<?php esc_attr_e( 'Submit Form Again', 'rosetta' ); ?>" /> 152 </td> 153 </tr> 154 </table> 155 </form> 156 <?php 157 } else { // If all the info is good 158 159 // Akismet checking 160 $comment['user_ip'] = preg_replace( '/[^0-9., ]/', '', $_SERVER['REMOTE_ADDR'] ); 161 $comment['user_agent'] = $_SERVER['HTTP_USER_AGENT']; 162 $comment['referrer'] = $_SERVER['HTTP_REFERER']; 163 $comment['blog'] = home_url(); 164 $comment['comment_type'] = 'contact_form'; 165 $comment['comment_author'] = ''; 166 $comment['comment_author_email'] = $_POST['your_email']; 167 $comment['comment_author_url'] = $_POST['blog_url']; 168 $comment['comment_content'] = stripslashes( $_POST['message'] ); 169 $query_string = ''; 170 foreach ( $comment as $key => $data ) { 171 $query_string .= $key . '=' . urlencode( stripslashes( $data ) ) . '&'; 172 } 173 $response = akismet_http_post( $query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port ); 174 if ( 'true' == $response[1] ) { 175 die(); 176 } 177 178 // Sanitization 179 $message_data = array(); 180 $message_data['ip'] = preg_replace( '/[^0-9., ]/', '', $_SERVER['REMOTE_ADDR'] ); 181 $message_data['name'] = sanitize_text_field( $_POST['your_name'] ); 182 $message_data['email'] = sanitize_email( $_POST['your_email'] ); 183 $message_data['blog_url'] = esc_url_raw( $_POST['blog_url'] ); 184 $message_data['subject'] = sanitize_text_field( $_POST['subject'] ); 185 $message_data['message'] = wp_kses( stripslashes( $_POST['message'] ), array() ); 186 187 // Let's send an email 188 $message = $message_data['message'] . ' 142 189 -- 143 190 Name: ' . $message_data['name'] . ' … … 148 195 Sent From: ' . esc_url_raw( $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ); 149 196 150 $headers = array(); 151 $headers[] = 'From: ' . $message_data['name'] . ' <' . $message_data['email'].'>'; 152 $headers[] = 'Return-Path: '. $message_data['email']; 153 154 add_action('phpmailer_init', 'rosetta_set_sender'); 155 wp_mail(get_option('admin_email'), '[wordpress.org] ' . $message_data['subject'], $message, implode("\r\n", $headers)); 156 remove_action('phpmailer_init', 'rosetta_set_sender'); 157 ?> 158 <div id="return"> 159 <h3><?php _e('Submitted!', 'rosetta'); ?></h3> 160 <p><strong><?php _e('Thank you!', 'rosetta'); ?></strong></p> 161 </div> 162 <?php } ?> 163 <?php } else { ?> 164 165 <h3><?php _e('Contact', 'rosetta'); ?></h3> 166 167 <?php if ( false !== strpos( get_the_content(), 'The contents of this page are filled automatically' ) ) : ?> 168 <p><?php _e('You can contact translators and this site administrators via this form:', 'rosetta'); ?></p> 169 <?php /* translators: feel free to add links to places, where one can get support in your language. */ ?> 170 <p><?php _e('<strong>Please, do not post support requests here!</strong> They will probably be ignored.', 'rosetta'); ?></p> 171 <?php else: ?> 172 <?php the_content(); ?> 173 <?php endif; ?> 174 175 <form id="contactme" method="post" action="/contact/#return"> 176 <table id="form"> 177 <tr> 178 <td class="label"><label for="your_name"><?php _e('Your Name:', 'rosetta'); ?></label> <?php _e('(required)', 'rosetta'); ?></td> 179 <td><span><input name="your_name" type="text" id="your_name" /></span></td> 180 </tr> 181 <tr> 182 <td class="label"><label for="your_email"><?php _e('Your Email:', 'rosetta'); ?></label> <?php _e('(required)', 'rosetta'); ?></td> 183 <td><span><input name="your_email" type="text" id="your_email" /></span></td> 184 </tr> 185 <tr> 186 <td class="label"><label for="blog_url"><?php _e('URI of your blog:', 'rosetta'); ?></label></td> 187 <td><span><input name="blog_url" type="text" id="blog_url" /></span></td> 188 </tr> 189 <tr> 190 <td class="label"><label for="subject"><?php _e('What’s this about?', 'rosetta'); ?></label> <?php _e('(required)', 'rosetta'); ?></td> 191 <td><span><input name="subject" type="text" id="subject" /></span></td> 192 </tr> 193 <tr> 194 <td class="label"><label for="message"><?php _e('Tell us something:', 'rosetta'); ?></label> <?php _e('(required)', 'rosetta'); ?></td> 195 <td><span class="message"><textarea name="message" id="message"></textarea></span></td> 196 </tr> 197 <tr class="submit"> 198 <td class="label"></td> 199 <td><input type="submit" name="submit" value="<?php esc_attr_e('Submit Contact Form', 'rosetta'); ?>" /></td> 200 </tr> 201 </table> 202 </form> 197 $headers = array(); 198 $headers[] = 'From: ' . $message_data['name'] . ' <' . $message_data['email'].'>'; 199 $headers[] = 'Return-Path: '. $message_data['email']; 200 201 add_action( 'phpmailer_init', 'rosetta_set_sender' ); 202 wp_mail( 'dominikschilling@gmail.com' /*get_option( 'admin_email' )*/, '[wordpress.org] ' . $message_data['subject'], $message, implode("\r\n", $headers ) ); 203 remove_action( 'phpmailer_init', 'rosetta_set_sender' ); 204 ?> 205 <div id="return"> 206 <h3><?php _e( 'Submitted!', 'rosetta' ); ?></h3> 207 <p><strong><?php _e( 'Thank you!', 'rosetta' ); ?></strong></p> 208 </div> 209 <?php 210 } 211 212 } else { // Empty $_POST['submit'] 213 214 if ( false !== strpos( get_the_content(), 'The contents of this page are filled automatically' ) ) : ?> 215 <p><?php _e( 'You can contact translators and this site administrators via this form:', 'rosetta'); ?></p> 216 <?php /* translators: feel free to add links to places, where one can get support in your language. */ ?> 217 <p><?php _e( '<strong>Please, do not post support requests here!</strong> They will probably be ignored.', 'rosetta' ); ?></p> 218 <?php else: ?> 219 <?php the_content(); ?> 220 <?php endif; ?> 221 222 <form id="contactme" method="post" action="/contact/#return"> 223 <table id="form"> 224 <tr> 225 <td class="label"> 226 <label for="your_name"><?php _e( 'Your Name:', 'rosetta' ); ?></label> <?php _e( '(required)', 'rosetta' ); ?> 227 </td> 228 <td> 229 <span><input name="your_name" type="text" id="your_name" /></span> 230 </td> 231 </tr> 232 <tr> 233 <td class="label"> 234 <label for="your_email"><?php _e( 'Your Email:', 'rosetta' ); ?></label> <?php _e( '(required)', 'rosetta' ); ?> 235 </td> 236 <td> 237 <span><input name="your_email" type="text" id="your_email" /></span> 238 </td> 239 </tr> 240 <tr> 241 <td class="label"> 242 <label for="blog_url"><?php _e( 'URI of your blog:', 'rosetta' ); ?></label> 243 </td> 244 <td> 245 <span><input name="blog_url" type="text" id="blog_url" /></span> 246 </td> 247 </tr> 248 <tr> 249 <td class="label"> 250 <label for="subject"><?php _e( 'What’s this about?', 'rosetta' ); ?></label> <?php _e( '(required)', 'rosetta' ); ?> 251 </td> 252 <td> 253 <span><input name="subject" type="text" id="subject" /></span> 254 </td> 255 </tr> 256 <tr> 257 <td class="label"> 258 <label for="message"><?php _e( 'Tell us something:', 'rosetta' ); ?></label> <?php _e( '(required)', 'rosetta' ); ?> 259 </td> 260 <td> 261 <span class="message"><textarea name="message" id="message"></textarea></span> 262 </td> 263 </tr> 264 <tr class="submit"> 265 <td class="label"></td> 266 <td> 267 <input type="submit" name="submit" value="<?php esc_attr_e( 'Submit Contact Form', 'rosetta' ); ?>" /> 268 </td> 269 </tr> 270 </table> 271 </form> 203 272 <?php } ?> 204 273 205 274 </div> 206 275 </div> 207 <?php endwhile; endif; ?>208 276 </div> 209 277 210 </div><!-- .section --> 211 </div><!-- .wrapper --> 212 <script type="text/javascript"> 213 var your_name = document.getElementById('your_name'); 214 if (your_name) your_name.focus(); 215 </script> 216 <?php get_footer(); ?> 278 <script type="text/javascript"> 279 var your_name = document.getElementById( 'your_name' ); 280 if ( your_name ) { your_name.focus(); } 281 </script> 282 <?php 283 get_footer();
Note: See TracChangeset
for help on using the changeset viewer.