Changeset 1355030
- Timestamp:
- 02/21/2016 03:25:40 AM (10 years ago)
- Location:
- simple-contact-form-basic/trunk
- Files:
-
- 3 edited
-
readme.txt (modified) (4 diffs)
-
simplecf-functions.php (modified) (7 diffs)
-
simplecf-main.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
simple-contact-form-basic/trunk/readme.txt
r1354595 r1355030 7 7 Requires at least: 4.3 8 8 Tested up to: 4.4 9 Stable tag: 1. 3.19 Stable tag: 1.4 10 10 11 11 Give website visitors an easy way to contact you, directly through your website, with a simple contact form. … … 19 19 Simple Contact Form (Basic) collects four pieces of information about the visitor: Name, Email, Phone Number, and the Message. The Name, Email, and Message are required for the form to be submitted and processed. As part of the processing, before the email is actually sent, data validation ensures that the required fields are provided, and that a valid email address has been given. This ensures you are able to respond to visitor requests, if needed. 20 20 21 Availabe in English and Spanish! (Disponible en las idiomas de Inglés y Español!) 22 21 23 22 24 == Installation == … … 26 28 3. Add the [simplecf] shortcode to any of your WordPress Pages, Posts, or Text Widget areas. 27 29 4. Add the "scfb_to" variable to the [simplecf] shortcode to define an alternative delivery email. For example: [simplecf scfb_to=jdoe@ncroud.com] would install a form on your WordPress page/blog and all submissions for that particular form would be sent to jdoe@ncroud.com instead of the WordPress administrator email. 30 5. Add the "scfb_lan" variable to the [simplecf] shortcode to define the language (es = Spanish; en = English). If nothing is specified, the form will default to English. For example: [simplecf scfb_lan=es] would install a form on your WordPress page/blog in the Spanish language. 28 31 29 32 … … 42 45 43 46 == Changelog == 47 48 = 1.4 = 49 50 Release Date: February 20, 2016 51 52 *Added support for the Spanish language. Simple Contact Form (Basic) can now be installed on your WordPress page/blog in either English or Spanish by using the "scfb_lan" variable in the [simplecf] shortcode. 44 53 45 54 = 1.3.1 = -
simple-contact-form-basic/trunk/simplecf-functions.php
r1322116 r1355030 2 2 /* 3 3 Simple Contact Form (Basic) 4 4 5 Copyright (C) 2015 nCroud Company, LLC 5 6 … … 18 19 */ 19 20 20 // Displays the HTML form. 21 function scfb_display_form() { 21 22 // Display the HTML form. 23 function scfb_display_form($lan) { 24 // define the form labels 25 if($lan == 'es') { 26 define('SCFB_NAME','Su Nombre'); 27 define('SCFB_MAIL','Su Correo Electrónico'); 28 define('SCFB_PHON','Su Teléfono'); 29 define('SCFB_NOTE','Su Mensaje'); 30 define('SCFB_SEND','Envía Mensaje'); 31 define('SCFB_MUST','necesario'); 32 } 33 else { 34 define('SCFB_NAME','Your Name'); 35 define('SCFB_MAIL','Your Email'); 36 define('SCFB_PHON','Your Phone'); 37 define('SCFB_NOTE','Your Message'); 38 define('SCFB_SEND','Send Message'); 39 define('SCFB_MUST','required'); 40 } 41 22 42 echo '<form action="' . esc_url($_SERVER['REQUEST_URI']) . '" method="post">'; 23 43 echo '<p>'; 24 echo 'Your Name (required) <br />';44 echo SCFB_NAME . ' (' . SCFB_MUST . ') <br />'; 25 45 echo '<input type="text" name="simplecf-name" pattern="[a-zA-Z0-9 ]+" value="' . (isset($_POST["simplecf-name"]) ? stripslashes($_POST["simplecf-name"]) : '') . '" size="40" />'; 26 46 echo '</p>'; 27 47 echo '<p>'; 28 echo 'Your Email (required) <br />';48 echo SCFB_MAIL . ' (' . SCFB_MUST . ') <br />'; 29 49 echo '<input type="email" name="simplecf-email" value="' . (isset($_POST["simplecf-email"]) ? stripslashes($_POST["simplecf-email"]) : '') . '" size="40" />'; 30 50 echo '</p>'; 31 51 echo '<p>'; 32 echo 'Phone Number<br />';52 echo SCFB_PHON . '<br />'; 33 53 echo '<input type="phone" name="simplecf-phone" pattern="[0-9\-]+" value="' . (isset($_POST["simplecf-phone"]) ? stripslashes($_POST["simplecf-phone"]) : '') . '" size="40" />'; 34 54 echo '</p>'; 35 55 echo '<p>'; 36 echo 'Your Message (required) <br />';56 echo SCFB_NOTE . ' (' . SCFB_MUST . ') <br />'; 37 57 echo '<textarea rows="10" cols="35" name="simplecf-message">' . (isset($_POST["simplecf-message"]) ? stripslashes($_POST["simplecf-message"]) : '') . '</textarea>'; 38 58 echo '</p>'; 39 echo '<p><input id="simplecf-submit" type="submit" name="simplecf-submit" value=" Send Message" /></p>';59 echo '<p><input id="simplecf-submit" type="submit" name="simplecf-submit" value="' . SCFB_SEND . '" /></p>'; 40 60 echo '</form>'; 41 61 } 42 62 43 // Deliver message to the WordPress Admin email address. 44 function scfb_deliver_mail($to) { 63 64 // Check the submission and deliver the message. 65 function scfb_deliver_mail($to,$lan) { 45 66 // define the delivery email address 46 67 $scfb_to = $to; 47 68 69 // define the user messages 70 if($lan == 'es') { 71 define('SCFB_MISSING','Faltan datos requeridos. Inténtelo de nuevo.'); 72 define('SCFB_INVALID','El correo electrónico no es válido.'); 73 define('SCFB_SUCCESS','Gracias para su mensaje. Responderemos pronto.'); 74 define('SCFB_UNKNOWN','Error inesperado.'); 75 } 76 else { 77 define('SCFB_MISSING','One or more required fields are missing. Please try again.'); 78 define('SCFB_INVALID','The email address is not valid.'); 79 define('SCFB_SUCCESS','Thank you for taking the time to send a message. Expect a response soon.'); 80 define('SCFB_UNKNOWN','An unexpected error occurred.'); 81 } 82 48 83 // if the submit button is clicked, send the email 49 84 if(isset($_POST['simplecf-submit'])) { 50 85 // check required fields are entered 51 86 if(empty($_POST['simplecf-name']) || empty($_POST['simplecf-email']) || empty($_POST['simplecf-message'])) { 52 echo '<p class="failure"> One or more required fields are missing. Please try again.</p>';87 echo '<p class="failure">' . SCFB_MISSING . '</p>'; 53 88 } 54 89 else { 55 56 90 // sanitize form values 57 91 $scfb_name = $_POST["simplecf-name"]; … … 60 94 $scfb_subject = '[SimpleCF]: ' . get_bloginfo() . ' Contact Form'; 61 95 $scfb_message = $_POST["simplecf-message"]; 62 96 63 97 // verify the email is valid and, if so, send the message 64 98 if(is_email($scfb_email)) { 65 99 $scfb_valid_email = $scfb_email; 66 100 67 101 // if the email is a valid format, verify the domain itself is valid 68 102 $scfb_domain = substr(strrchr($scfb_valid_email,'@'),1); 69 103 70 104 if(checkdnsrr($scfb_domain,'MX')) { 71 105 $scfb_headers = "From: $scfb_name <$scfb_valid_email>" . "\r\n"; 72 106 73 107 // If email has been processed for sending, display a success message 74 108 if(wp_mail($scfb_to,$scfb_subject,stripslashes($scfb_message),$scfb_headers)) { 75 echo '<p class="success"> Thank you for taking the time to send a message. Expect a response soon.</p>';76 109 echo '<p class="success">' . SCFB_SUCCESS . '</p>'; 110 77 111 // unset the form field variables 78 112 unset($_POST['simplecf-name']); … … 82 116 } 83 117 else { 84 echo '<p class="failure"> An unexpected error occurred.</p>';118 echo '<p class="failure">' . SCFB_UNKNOWN . '</p>'; 85 119 } 86 120 } … … 88 122 if(checkdnsrr($scfb_domain,'A')) { 89 123 $scfb_headers = "From: $scfb_name <$scfb_valid_email>" . "\r\n"; 90 124 91 125 // If email has been processed for sending, display a success message 92 126 if(wp_mail($scfb_to,$scfb_subject,stripslashes($scfb_message),$scfb_headers)) { 93 echo '<p class="success"> Thank you for taking the time to send a message. Expect a response soon.</p>';94 127 echo '<p class="success">' . SCFB_SUCCESS . '</p>'; 128 95 129 // unset the form field variables 96 130 unset($_POST['simplecf-name']); … … 100 134 } 101 135 else { 102 echo '<p class="failure"> An unexpected error occurred.</p>';136 echo '<p class="failure">' . SCFB_UNKNOWN . '</p>'; 103 137 } 104 138 } 105 139 else { 106 echo '<p class="failure"> The email address is not valid.</p>';140 echo '<p class="failure">' . SCFB_INVALID . '</p>'; 107 141 } 108 142 } 109 143 } 110 144 else { 111 echo '<p class="failure"> The email address is not valid.</p>';145 echo '<p class="failure">' . SCFB_INVALID . '</p>'; 112 146 } 113 147 } … … 115 149 } 116 150 151 117 152 // The function that powers the WordPress shortcode. 118 153 function scfb_shortcode($atts) { 119 154 ob_start(); 120 121 // if the email is not provided, use the administrator email 155 122 156 $scfb_vars = shortcode_atts(array( 157 158 // if the email is not provided, use the administrator email 123 159 'scfb_to' => get_option('admin_email'), 160 // if the language is not define, use english 161 'scfb_lan' => 'en' 162 124 163 ), $atts ); 125 126 scfb_deliver_mail($scfb_vars['scfb_to'] );127 scfb_display_form( );164 165 scfb_deliver_mail($scfb_vars['scfb_to'],$scfb_vars['scfb_lan']); 166 scfb_display_form($scfb_vars['scfb_lan']); 128 167 129 168 return ob_get_clean(); 130 169 } 170 131 171 132 172 // Register the default style sheet. -
simple-contact-form-basic/trunk/simplecf-main.php
r1354596 r1355030 4 4 Plugin URI: https://wordpress.org/plugins/simple-contact-form-basic/ 5 5 Description: A simple, yet powerful and effective contact form, that integrates easily into any WordPress site just by using a simple shortcode. Visitors can email you directly through your website, providing their name, email, phone, and message, so that you can respond quickly and easily. 6 Version: 1. 3.16 Version: 1.4 7 7 Author: nCroud 8 8 Author URI: http://www.ncroud.com/ … … 12 12 /* 13 13 Simple Contact Form (Basic) 14 14 15 Copyright (C) 2015 nCroud Company, LLC 15 16
Note: See TracChangeset
for help on using the changeset viewer.