Changeset 687822
- Timestamp:
- 03/27/2013 02:05:14 AM (13 years ago)
- Location:
- proper-contact-form/trunk
- Files:
-
- 6 edited
-
README.md (modified) (3 diffs)
-
css/admin.css (modified) (1 diff)
-
inc/FormBuilder.php (modified) (10 diffs)
-
proper-contact-form.php (modified) (11 diffs)
-
readme.txt (modified) (3 diffs)
-
settings.php (modified) (21 diffs)
Legend:
- Unmodified
- Added
- Removed
-
proper-contact-form/trunk/README.md
r610257 r687822 1 P roper Contact Platform1 PROPER Contact Form 2 2 ================= 3 3 … … 6 6 At the moment, this simply creates a contact form with the shortcode [proper_contact_form]. There is a settings page to tinker with a few of the options, and allows you to validate and submit to a new page to help with goal tracking in analytics. 7 7 8 This will eventually be submitted to the WordPress repo, most likely after the first feature listed below. There are a bazillion contact form plugins out there but nothing I've ever liked using or extending. I usually just code my own but I want a bit of flexibility for clients and projects, h ance this.8 This will eventually be submitted to the WordPress repo, most likely after the first feature listed below. There are a bazillion contact form plugins out there but nothing I've ever liked using or extending. I usually just code my own but I want a bit of flexibility for clients and projects, hence this. 9 9 10 10 Planned features, in order: … … 12 12 1) Custom forms using shortcodes - this appears to be the easiest way to create forms both in the content, using the shortcode tag, and in the template, using `do_shortcut()`. We're working on the best way to balance flexibility, functionality, and ease-of-use. 13 13 14 2) Storing form submissions - since we're pushing changes to the database from a public form, we have to be very careful here. I've tested a proof of concept in a few places but want to make sure it's solid before I release it. 15 16 3) TinyLetter and Mailchimp integration - at some point, since I use these so often in my other projects. 14 2) TinyLetter and Mailchimp integration - at some point, since I use these so often in my other projects. -
proper-contact-form/trunk/css/admin.css
r646683 r687822 1 1 @charset "UTF-8"; 2 2 /* CSS Document */ 3 #proper-contact-options {width: 60%; min-width: 400px}3 #proper-contact-options {width: 80%; min-width: 400px} 4 4 #proper-contact-options th, #proper-contact-options td {display: table-cell; border-bottom: 1px solid #f1f1f1; padding: 10px;} 5 5 #proper-contact-options th {text-align: left; font-size: 1.1em; font-weight: bold;} -
proper-contact-form/trunk/inc/FormBuilder.php
r610257 r687822 12 12 13 13 // Make sure a submit button is output 14 private $has_submit = false;14 private $has_submit = FALSE; 15 15 16 16 // Constructor to set basic form attributes 17 function __construct($action = '', $args = false) {17 function __construct($action = '', $args = FALSE) { 18 18 19 19 $defaults = array( … … 24 24 'id' => '', 25 25 'markup' => 'html', 26 'novalidate' => false, 27 'add_nonce' => false, 28 'add_honeypot' => true, 26 'novalidate' => FALSE, 27 'add_nonce' => FALSE, 28 'add_honeypot' => TRUE, 29 'submit_text' => 'Submit' 29 30 ); 30 31 … … 46 47 47 48 case 'method': 48 if (! in_array($val, array('post', 'get'))) return false;49 if (! in_array($val, array('post', 'get'))) return FALSE; 49 50 break; 50 51 51 52 case 'enctype': 52 if (! in_array($val, array('application/x-www-form-urlencoded', 'multipart/form-data'))) return false;53 if (! in_array($val, array('application/x-www-form-urlencoded', 'multipart/form-data'))) return FALSE; 53 54 break; 54 55 55 56 case 'markup': 56 if (! in_array($val, array('html', 'xhtml'))) return false;57 if (! in_array($val, array('html', 'xhtml'))) return FALSE; 57 58 break; 58 59 59 60 case 'class': 60 61 case 'id': 61 if (! $this->_check_valid_attr($val)) return false;62 if (! $this->_check_valid_attr($val)) return FALSE; 62 63 break; 63 64 64 65 case 'novalidate': 65 66 case 'add_honeypot': 66 if (! is_bool($val)) return false;67 if (! is_bool($val)) return FALSE; 67 68 break; 68 69 69 70 case 'add_nonce': 70 if (! is_string($val) && !is_bool($val)) return false;71 if (! is_string($val) && !is_bool($val)) return FALSE; 71 72 break; 72 73 73 74 default: 74 return false;75 return FALSE; 75 76 76 77 endswitch; … … 78 79 $this->form[$key] = $val; 79 80 80 return true;81 return TRUE; 81 82 82 83 } … … 100 101 'max' => '', 101 102 'step' => '', 102 'autofocus' => false,103 'checked' => false,104 'required' => false,105 'add_label' => true,103 'autofocus' => FALSE, 104 'checked' => FALSE, 105 'required' => FALSE, 106 'add_label' => TRUE, 106 107 'options' => array(), 107 108 'wrap_tag' => 'div', … … 123 124 function add_inputs($arr) { 124 125 125 if (!is_array($arr)) return false;126 if (!is_array($arr)) return FALSE; 126 127 127 128 foreach ($arr as $field) : … … 132 133 133 134 // Parse the inputs and build the form HTML 134 function build_form($echo = true) {135 function build_form($echo = TRUE) { 135 136 136 137 $output = ' … … 163 164 $this->add_input('WordPress nonce', array( 164 165 'value' => wp_create_nonce($this->form['add_nonce']), 165 'add_label' => false,166 'add_label' => FALSE, 166 167 'type' => 'hidden' 167 168 )); … … 223 224 224 225 case 'submit': 225 $this->has_submit = true;226 break;226 $this->has_submit = TRUE; 227 $val['value'] = $val['label']; 227 228 228 229 default : … … 292 293 private function _check_valid_attr($string) { 293 294 294 $result = true;295 $result = TRUE; 295 296 296 297 // Check $name for correct characters -
proper-contact-form/trunk/proper-contact-form.php
r660317 r687822 1 <?php 1 <?php 2 2 3 3 /* … … 5 5 Plugin URI: http://theproperweb.com/shipped/wp/proper-contact-form 6 6 Description: A better contact form processor 7 Version: 0.9. 37 Version: 0.9.5 8 8 Author: PROPER Development 9 9 Author URI: http://theproperweb.com … … 15 15 16 16 function proper_contact_form($atts, $content = NULL) { 17 17 18 18 if (isset($_SESSION['propercfp_sent']) && $_SESSION['propercfp_sent'] === 'yes') : 19 19 unset($_SESSION['propercfp_sent']); 20 20 return ' 21 21 <div class="proper_contact_form_wrap"> 22 <h2>'.proper_ get_key('propercfp_label_submit').'</h2>22 <h2>'.proper_contact_get_key('propercfp_label_submit').'</h2> 23 23 </div>'; 24 24 endif; 25 25 26 26 // FormBuilder 27 27 require_once(plugin_dir_path( __FILE__ ) . '/inc/FormBuilder.php'); 28 28 29 29 $form = new ThatFormBuilder; 30 30 31 31 $form->set_att('id', 'proper_contact_form_' . get_the_id()); 32 32 $form->set_att('class', array('proper_contact_form')); 33 33 $form->set_att('add_nonce', get_bloginfo('admin_email')); 34 if (proper_contact_get_key('propercfp_html5_no_validate') === '') { 35 $form->set_att('novalidate', TRUE); 36 } 37 34 38 35 39 // Add name field if selected on the settings page 36 if( proper_ get_key('propercfp_name_field') ) :37 $required = proper_ get_key('propercfp_name_field') === 'req' ? TRUE : FALSE;38 $form->add_input(stripslashes(proper_ get_key('propercfp_label_name')), array(40 if( proper_contact_get_key('propercfp_name_field') ) : 41 $required = proper_contact_get_key('propercfp_name_field') === 'req' ? TRUE : FALSE; 42 $form->add_input(stripslashes(proper_contact_get_key('propercfp_label_name')), array( 39 43 'required' => $required, 40 'wrap_class' => isset($_SESSION['cfp_contact_errors']['contact-name']) ? array('form_field_wrap', 'error') : array('form_field_wrap') 44 'wrap_class' => isset($_SESSION['cfp_contact_errors']['contact-name']) 45 ? array('form_field_wrap', 'error') 46 : array('form_field_wrap') 41 47 ), 'contact-name'); 42 48 endif; 43 49 44 50 // Add email field if selected on the settings page 45 if( proper_ get_key('propercfp_email_field') ) :46 $required = proper_ get_key('propercfp_email_field') === 'req' ? TRUE : FALSE;47 $form->add_input(stripslashes(proper_ get_key('propercfp_label_email')), array(51 if( proper_contact_get_key('propercfp_email_field') ) : 52 $required = proper_contact_get_key('propercfp_email_field') === 'req' ? TRUE : FALSE; 53 $form->add_input(stripslashes(proper_contact_get_key('propercfp_label_email')), array( 48 54 'required' => $required, 49 55 'type' => 'email', 50 'wrap_class' => isset($_SESSION['cfp_contact_errors']['contact-email']) ? array('form_field_wrap', 'error') : array('form_field_wrap') 56 'wrap_class' => isset($_SESSION['cfp_contact_errors']['contact-email']) 57 ? array('form_field_wrap', 'error') 58 : array('form_field_wrap') 51 59 ), 'contact-email'); 52 60 endif; 53 61 54 62 // Add phone field if selected on the settings page 55 if( proper_get_key('propercfp_phone_field') ) : 56 $required = proper_get_key('propercfp_phone_field') === 'req' ? TRUE : FALSE; 57 $form->add_input(stripslashes(proper_get_key('propercfp_label_phone')), array( 58 'required' => $required 63 if( proper_contact_get_key('propercfp_phone_field') ) : 64 $required = proper_contact_get_key('propercfp_phone_field') === 'req' ? TRUE : FALSE; 65 $form->add_input(stripslashes(proper_contact_get_key('propercfp_label_phone')), array( 66 'required' => $required, 67 'wrap_class' => isset( $_SESSION['cfp_contact_errors']['contact-phone'] ) 68 ? array ( 'form_field_wrap', 'error' ) 69 : array ( 'form_field_wrap' ) 59 70 ), 'contact-phone'); 60 71 endif; 61 72 62 73 // Add reasons drop-down 63 $reasons = trim(proper_ get_key('propercfp_reason'));64 if(!empty($reasons)) :65 $options = proper_get_textarea_opts($reasons);66 if (!empty($options))67 array_unshift($options, 'Select one...');68 $form->add_input(stripslashes(proper_get_key('propercfp_label_reason')), array(69 'type' => 'select',70 'options' => $options71 ), 'contact-reasons');72 endif; 73 74 $reasons = trim(proper_contact_get_key('propercfp_reason')); 75 $options = proper_get_textarea_opts( $reasons ); 76 if (!empty($options)) { 77 array_unshift($options, 'Select one...'); 78 $form->add_input(stripslashes(proper_contact_get_key('propercfp_label_reason')), array( 79 'type' => 'select', 80 'options' => $options 81 ), 'contact-reasons'); 82 } 83 84 74 85 // Comment field 75 $form->add_input(stripslashes(proper_ get_key('propercfp_label_comment')), array(86 $form->add_input(stripslashes(proper_contact_get_key('propercfp_label_comment')), array( 76 87 'required' => TRUE, 77 88 'type' => 'textarea', 78 89 'wrap_class' => isset($_SESSION['cfp_contact_errors']['question-or-comment']) ? array('form_field_wrap', 'error') : array('form_field_wrap') 79 90 ), 'question-or-comment'); 80 81 // IP Address 82 $form->add_input('Contact IP', array( 83 'type' => 'hidden', 84 'value' => isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '' 85 )); 86 91 92 // Submit button 93 $form->add_input( proper_contact_get_key( 'propercfp_label_submit_btn' ), array( 94 'type' => 'submit' 95 ), 'submit'); 96 87 97 // Referring site 88 98 $form->add_input('Contact Referrer', array( … … 90 100 'value' => isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '' 91 101 )); 92 102 93 103 // Referring page 94 104 if (isset($_REQUEST['src']) || isset($_REQUEST['ref'])) : … … 98 108 )); 99 109 endif; 100 110 101 111 $errors = ''; 102 112 if (isset($_SESSION['cfp_contact_errors']) && !empty($_SESSION['cfp_contact_errors'])) : … … 104 114 unset($_SESSION['cfp_contact_errors']); 105 115 endif; 106 116 107 117 return ' 108 118 <div class="proper_contact_form_wrap"> 109 119 ' . $errors . $form->build_form(FALSE) . ' 110 120 </div>'; 111 121 112 122 } 113 123 add_shortcode( 'proper_contact_form', 'proper_contact_form' ); 114 124 115 125 function cfp_process_contact() { 116 126 117 127 // If POST, nonce and honeypot are not set, escape 118 128 if (empty($_POST)) return; 119 129 if (! isset($_POST['wordpress-nonce'])) return; 120 130 if (! isset($_POST['honeypot'])) return; 121 131 122 132 // Session variable for form errors 123 133 $_SESSION['cfp_contact_errors'] = array(); 124 134 125 135 // If nonce is not passed or honeypot is not empty, escape 126 if (! wp_verify_nonce($_POST['wordpress-nonce'], get_bloginfo('admin_email'))) 127 $_SESSION['cfp_contact_errors']['nonce'] = 'Invalid form submission!'; 128 129 if (! empty($_POST['honeypot'])) 130 $_SESSION['cfp_contact_errors']['honeypot'] = 'No spam please!'; 131 136 if (! wp_verify_nonce($_POST['wordpress-nonce'], get_bloginfo('admin_email'))) { 137 $_SESSION['cfp_contact_errors']['nonce'] = 'Nonce failed!'; 138 } 139 140 if (! empty($_POST['honeypot'])) { 141 $_SESSION['cfp_contact_errors']['honeypot'] = 'Form submission failed!'; 142 } 143 132 144 $body = " 133 *** Contact form submission on " . get_bloginfo('name') . " (" . site_url() . ") \n\n";134 145 *** Contact form submission on " . get_bloginfo('name') . " (" . site_url() . ") *** \n\n"; 146 135 147 // Sanitize and validate name 136 148 $contact_name = isset($_POST['contact-name']) ? sanitize_text_field(trim($_POST['contact-name'])) : ''; 137 if (proper_ get_key('propercfp_name_field') === 'req' && empty($contact_name))138 $_SESSION['cfp_contact_errors']['contact-name'] = 'Enter your name';139 else140 $body .= "141 Name: $contact_name\n"; 142 149 if (proper_contact_get_key('propercfp_name_field') === 'req' && empty($contact_name)) { 150 $_SESSION['cfp_contact_errors']['contact-name'] = proper_contact_get_key('propercfp_label_err_name'); 151 } elseif ( !empty( $contact_name ) ) { 152 $body .= stripslashes( proper_contact_get_key( 'propercfp_label_name' ) ) . ": $contact_name \r"; 153 } 154 143 155 // Sanitize and validate email 144 156 $contact_email = isset($_POST['contact-email']) ? sanitize_email($_POST['contact-email']) : ''; 145 if (proper_ get_key('propercfp_email_field') === 'req' && ! filter_var($contact_email, FILTER_VALIDATE_EMAIL) )146 $_SESSION['cfp_contact_errors']['contact-email'] = 'Enter a valid email';147 elseif (!empty($contact_email))148 $body .= "149 Email: $contact_email\r 150 Email search: https://www.google.com/#q=$contact_email\n"; 151 157 if (proper_contact_get_key('propercfp_email_field') === 'req' && ! filter_var($contact_email, FILTER_VALIDATE_EMAIL) ) { 158 $_SESSION['cfp_contact_errors']['contact-email'] = proper_contact_get_key('propercfp_label_err_email'); 159 } elseif (!empty($contact_email)) { 160 $body .= stripslashes( proper_contact_get_key( 'propercfp_label_email' ) ) . ": $contact_email \r 161 Google: https://www.google.com/#q=$contact_email \r"; 162 } 163 152 164 // Sanitize phone number 153 165 $contact_phone = isset($_POST['contact-phone']) ? sanitize_text_field($_POST['contact-phone']) : ''; 154 if (proper_ get_key('propercfp_phone_field') === 'req' && empty($contact_phone) )155 $_SESSION['cfp_contact_errors']['contact-phone'] = 'Please enter a phone number';156 elseif (!empty($contact_phone))157 $body .= "158 Phone: $contact_phone\n"; 159 166 if (proper_contact_get_key('propercfp_phone_field') === 'req' && empty($contact_phone) ) { 167 $_SESSION['cfp_contact_errors']['contact-phone'] = proper_contact_get_key('propercfp_label_err_phone'); 168 } elseif (!empty($contact_phone)) { 169 $body .= stripslashes( proper_contact_get_key( 'propercfp_label_phone' ) ) . ": $contact_phone \r"; 170 } 171 160 172 // Sanitize contact reason 161 173 $contact_reason = isset($_POST['contact-reasons']) ? strip_tags($_POST['contact-reasons']) : ''; 162 if (!empty($contact_reason)) 163 $body .= "164 Reason for contacting: $contact_reason\n"; 165 174 if (!empty($contact_reason)) { 175 $body .= stripslashes( proper_contact_get_key( 'propercfp_label_reason' ) ) . ": $contact_reason \r"; 176 } 177 166 178 // Sanitize and validate comments 167 179 $contact_comment = sanitize_text_field(trim($_POST['question-or-comment'])); 168 if (empty($contact_comment)) 169 $_SESSION['cfp_contact_errors']['question-or-comment'] = 'Enter your question or comment';170 else171 $body .= " 172 Comment/question: " . stripslashes($contact_comment) . "\n"; 173 180 if (empty($contact_comment)) { 181 $_SESSION['cfp_contact_errors']['question-or-comment'] = proper_contact_get_key('propercfp_label_err_no_content'); 182 } else { 183 $body .= "\n\n" . stripslashes( proper_contact_get_key( 'propercfp_label_comment' ) ) . ": " . stripslashes($contact_comment) . " \n\n"; 184 } 185 174 186 // Sanitize and validate IP 175 $contact_ip = filter_var( $_POST['contact-ip'], FILTER_VALIDATE_IP);176 if (!empty($contact_ip)) 177 $body .= " 178 IP address: $contact_ip \r179 IP search: http://whatismyipaddress.com/ip/$contact_ip\n"; 180 187 $contact_ip = filter_var( $_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP); 188 if (!empty($contact_ip)) { 189 $body .= "IP address: $contact_ip \r 190 IP search: http://whatismyipaddress.com/ip/$contact_ip \n\n"; 191 } 192 181 193 // Sanitize and prepare referrer 182 194 $contact_referrer = sanitize_text_field($_POST['contact-referrer']); 183 if (!empty($contact_referrer)) 184 $body .= " 185 Came from: $contact_referrer\n"; 186 187 $body .= ' 188 Sent from page: ' . get_permalink(get_the_id()); 189 195 if (!empty($contact_referrer)) { 196 $body .= "Came from: $contact_referrer \r"; 197 } 198 199 $body .= 'Sent from page: ' . get_permalink(get_the_id()); 200 190 201 if (empty($_SESSION['cfp_contact_errors'])) : 191 202 192 $site_email = proper_ get_key('propercfp_email');203 $site_email = proper_contact_get_key('propercfp_email'); 193 204 $site_name = get_bloginfo('name'); 194 205 206 if ( empty( $contact_name ) ) { 207 $contact_name = !empty( $contact_email ) ? $contact_email : '[None given]'; 208 } 209 210 if ( empty( $contact_email ) ) { 211 $contact_email = $site_email; 212 } 213 214 $headers = array(); 195 215 $headers[] = "From: $contact_name <$contact_email>"; 196 216 $headers[] = "Reply-To: $contact_email"; 197 $headers[] = 'X-Mailer: PHP/' . phpversion(); 198 217 199 218 wp_mail($site_email, 'Contact on ' . $site_name, $body, $headers); 200 201 // Should a confirm email be sent? 202 $confirm_body = stripslashes(trim(proper_get_key('propercfp_confirm_email'))); 203 if (!empty($confirm_body)) : 219 220 // Should a confirm email be sent? 221 $confirm_body = stripslashes(trim(proper_contact_get_key('propercfp_confirm_email'))); 222 if (!empty($confirm_body) && !empty( $contact_email ) ) : 223 $headers = array (); 204 224 $headers[] = "From: $site_name <$site_email>"; 205 225 $headers[] = "Reply-To: $site_email"; 206 $headers[] = 'X-Mailer: PHP/' . phpversion(); 207 wp_mail($contact_email, 'Your contact on ' . get_bloginfo('name'), $confirm_body, $headers); 226 wp_mail($contact_email, proper_contact_get_key( 'propercfp_label_submit' ) . ' - ' . get_bloginfo('name'), $confirm_body, $headers); 208 227 endif; 209 228 210 229 // Should the entry be stored in the DB? 211 if (proper_ get_key('propercfp_store') === 'yes') :230 if (proper_contact_get_key('propercfp_store') === 'yes') : 212 231 $new_post_id = wp_insert_post(array( 213 232 'post_type' => 'proper_contact', 214 'post_title' => date('l, M j, Y', time()) . ' by "' . $contact_name . '"',233 'post_title' => date('l, M j, Y', time()) . ( empty( $contact_name ) ? '' : ' by "' . $contact_name . '"'), 215 234 'post_content' => $body, 216 235 'post_author' => 1, 217 236 'post_status' => 'private' 218 237 )); 219 if (isset($contact_email) && !empty($contact_email)) add_post_meta($new_post_id, 'Contact email', $contact_email); 238 if (isset($contact_email) && !empty($contact_email)) { 239 add_post_meta($new_post_id, 'Contact email', $contact_email); 240 } 220 241 endif; 221 242 222 243 // Should the user get redirected? 223 if( proper_ get_key('propercfp_result_url')) :224 $redirect_id = proper_ get_key('propercfp_result_url');244 if( proper_contact_get_key('propercfp_result_url')) : 245 $redirect_id = proper_contact_get_key('propercfp_result_url'); 225 246 $redirect = get_permalink($redirect_id); 226 247 wp_redirect($redirect); … … 228 249 $_SESSION['propercfp_sent'] = 'yes'; 229 250 endif; 230 231 endif; 232 251 252 endif; 253 233 254 } 234 255 add_action('template_redirect', 'cfp_process_contact'); … … 241 262 include('settings.php'); 242 263 243 if (! function_exists('proper_get_key')) : 244 function proper_get_key($id) { 245 global $propercfp_options; 246 if (isset($propercfp_options[$id])) return $propercfp_options[$id]; 247 else return ''; 248 } 249 endif; 264 function proper_contact_get_key($id) { 265 global $propercfp_options, $plugin_options; 266 return isset( $propercfp_options[$id] ) ? $propercfp_options[$id] : $plugin_options[$id][4]; 267 } 250 268 251 269 … … 256 274 wp_register_style( 'proper_contact_styles', plugins_url('css/front.css', __FILE__)); 257 275 wp_enqueue_style( 'proper_contact_styles' ); 258 } 259 260 if (proper_ get_key('propercfp_css') === 'yes')276 } 277 278 if (proper_contact_get_key('propercfp_css') === 'yes') 261 279 add_action('wp_enqueue_scripts', 'proper_contact_styles'); 262 263 280 281 264 282 /* 265 283 Store submissions in the DB … … 277 295 'view_item' => __('View Contact'), 278 296 'not_found' => __('No Contacts found'), 279 'not_found_in_trash' => __('No Contacts found in Trash'), 297 'not_found_in_trash' => __('No Contacts found in Trash'), 280 298 'parent_item_colon' => '', 281 299 'menu_name' => 'Contacts' … … 293 311 'menu_icon' => plugin_dir_url(__FILE__) . '/images/person.png', 294 312 'supports' => array( 'title', 'editor', 'custom-fields') 295 ); 313 ); 296 314 register_post_type('proper_contact',$args); 297 315 } 298 316 299 if (proper_ get_key('propercfp_store') === 'yes')317 if (proper_contact_get_key('propercfp_store') === 'yes') 300 318 add_action( 'init', 'proper_contact_content_type' ); 301 302 319 -
proper-contact-form/trunk/readme.txt
r652705 r687822 1 1 === Proper Contact Form === 2 Contributors: properwp 2 Contributors: properwp, joshcanhelp 3 3 Donate link: 4 4 Tags: contact, contact form 5 5 Requires at least: 3.0 6 Tested up to: 3.5 7 Stable tag: 0.9. 36 Tested up to: 3.5.1 7 Stable tag: 0.9.5 8 8 9 9 Creates a flexible, secure contact form on your WP site … … 18 18 - Create an auto-respond email 19 19 - Redirect contact submissions to a new page (helpful for goal tracking) 20 - Store contacts in the admin21 - Over-ride label names 20 - Store contacts in the database 21 - Over-ride label names and error messages 22 22 23 The current, basic functionality will not change but, in a future version, WP users will be able to add custom forms with validation quickly and easily. 23 Features in the works: 24 25 - Additional style options 26 - Complete internationalization 27 - Ability to add custom fields to the form 24 28 25 29 Get the absolute latest at the [Github repo](https://github.com/joshcanhelp/proper-contact-form). … … 46 50 == Changelog == 47 51 52 = 0.9.5 = 53 * Added text fields for error messages and submit button 54 * Added a setting to use HTML5 validation 55 * Changed to use custom label fields for email notification 56 * Changed to use the "Text to show when form is submitted..." text for the confirmation email subject 57 * Changed the email notification format slightly 58 * Setting better default text and information throughout 59 * Fixed the missing error formatting for the phone number field 60 48 61 = 0.9.3 = 49 62 * Fixed name requirement issue -
proper-contact-form/trunk/settings.php
r646683 r687822 14 14 global $plugin_options; 15 15 $plugin_options = array( 16 array(16 'head1' => array( 17 17 'Fields to show', 18 18 '', … … 21 21 '', 22 22 ), 23 array(23 'propercfp_name_field' => array( 24 24 'Name', 25 25 'propercfp_name_field', … … 33 33 ), 34 34 ), 35 array(35 'propercfp_email_field' => array( 36 36 'Email address', 37 37 'propercfp_email_field', … … 45 45 ), 46 46 ), 47 array(47 'propercfp_phone_field' => array( 48 48 'Phone number', 49 49 'propercfp_phone_field', … … 57 57 ), 58 58 ), 59 array(59 'propercfp_reason' => array( 60 60 '"Reason for contacting" options', 61 61 'propercfp_reason', … … 64 64 '', 65 65 ), 66 array(66 'head2' => array( 67 67 'Form processing options', 68 68 '', … … 71 71 '', 72 72 ), 73 array(73 'propercfp_email' => array( 74 74 'Default contact submission email', 75 75 'propercfp_email', … … 78 78 get_bloginfo('admin_email') 79 79 ), 80 array(80 'propercfp_result_url' => array( 81 81 '"Thank You" URL', 82 82 'propercfp_result_url', … … 86 86 proper_get_content_array() 87 87 ), 88 array(88 'propercfp_css' => array( 89 89 'Add styles to the site', 90 90 'propercfp_css', 91 'Checking this box will add styles to the form. By de afult, this is off so you can add your own styles.',91 'Checking this box will add styles to the form. By default, this is off so you can add your own styles.', 92 92 'checkbox', 93 93 '', 94 94 ), 95 array(95 'propercfp_store' => array( 96 96 'Store submissions in the database', 97 97 'propercfp_store', … … 100 100 '', 101 101 ), 102 array(103 'Send email confirmation <br />to form submitter',102 'propercfp_confirm_email' => array( 103 'Send email confirmation to form submitter', 104 104 'propercfp_confirm_email', 105 'Adding text here will send an email to the form submitter. ',105 'Adding text here will send an email to the form submitter. The email uses the "Text to show when form is submitted..." field below as the subject line.', 106 106 'textarea', 107 107 '', 108 108 ), 109 array(109 'head3' => array( 110 110 'Text overrides', 111 111 '', … … 114 114 '', 115 115 ), 116 array(116 'propercfp_label_name' => array( 117 117 'Name field label', 118 118 'propercfp_label_name', … … 121 121 'Your full name' 122 122 ), 123 array(123 'propercfp_label_email' => array( 124 124 'Email field label', 125 125 'propercfp_label_email', … … 128 128 'Your email address' 129 129 ), 130 array(130 'propercfp_label_phone' => array( 131 131 'Phone field label<br />(if activated above)', 132 132 'propercfp_label_phone', … … 135 135 'Your phone number' 136 136 ), 137 array(137 'propercfp_label_reason' => array( 138 138 'Reason for contacting label<br />(if activated above)', 139 139 'propercfp_label_reason', … … 142 142 'Reason for contacting' 143 143 ), 144 array(144 'propercfp_label_comment' => array( 145 145 'Comment field label', 146 146 'propercfp_label_comment', … … 149 149 'Question or comment' 150 150 ), 151 array( 152 'Submit complete text<br />(if "Thank You" URL above is not set)', 151 'propercfp_label_submit_btn' => array( 152 'Submit button text', 153 'propercfp_label_submit_btn', 154 '', 155 'text', 156 'Submit' 157 ), 158 'propercfp_label_submit' => array( 159 'Successful form submission text', 153 160 'propercfp_label_submit', 154 ' ',161 'This text is used on the page if no "Thank You" URL is set above. This is also used as the confirmation email title, if one is set to send out.', 155 162 'text', 156 163 'Thank you for your contact!' 157 164 ), 158 165 'head4' => array( 166 'HTML5 validation', 167 '', 168 '', 169 'title', 170 '', 171 ), 172 'propercfp_html5_no_validate' => array( 173 'Use HTML5 validation', 174 'propercfp_html5_no_validate', 175 '', 176 'checkbox', 177 'yes' 178 ), 179 'head5' => array ( 180 'Error Messages (if not using HTML5 validation)', 181 '', 182 '', 183 'title', 184 '', 185 ), 186 'propercfp_label_err_name' => array( 187 'Error message if name required and missing', 188 'propercfp_label_err_name', 189 '', 190 'text', 191 'Enter your name' 192 ), 193 'propercfp_label_err_email' => array( 194 'Error message if E-mail required and missing', 195 'propercfp_label_err_email', 196 '', 197 'text', 198 'Enter a valid email' 199 ), 200 'propercfp_label_err_phone' => array( 201 'Error message if phone required and missing', 202 'propercfp_label_err_phone', 203 '', 204 'text', 205 'Please enter a phone number' 206 ), 207 'propercfp_label_err_no_content' => array( 208 'Error message if post content is missing', 209 'propercfp_label_err_no_content', 210 '', 211 'text', 212 'Enter your question or comment' 213 ) 159 214 ); 160 215 … … 186 241 } 187 242 188 add_submenu_page('options-general.php', "P roper Contact Form Options", "ProperContact", 'edit_themes', 'pcfp-admin', 'proper_contact_admin');243 add_submenu_page('options-general.php', "PROPER Contact settings", "PROPER Contact", 'edit_themes', 'pcfp-admin', 'proper_contact_admin'); 189 244 190 245 } … … 200 255 201 256 <div class="wrap" id="proper-contact-options"> 202 <h1>Proper Contact Form Settings</h1> 257 258 <h2>PROPER Contact Form Settings</h2> 203 259 204 260 <?php … … 206 262 if (is_readable($doc_file)) echo file_get_contents($doc_file) 207 263 ?> 208 209 <?php 210 // Show the "saved" message 211 if ( !empty($_REQUEST['saved']) ) : 212 ?> 213 214 <div id="message" class="updated fade"> 215 <p><strong>Proper Contact Form <?php echo __('settings saved.','thematic') ?></strong></p> 264 265 <?php if ( !empty( $_REQUEST['saved'] ) ) : ?> 266 <div id="setting-error-settings_updated" class="updated settings-error"> 267 <p><strong>PROPER Contact Form <?php echo __( 'settings saved.', 'properwp' ) ?></strong></p> 216 268 </div> 217 218 269 <?php endif ?> 219 270 220 271 <form method="post"> 221 272 <table cellpadding="0" cellspacing="0"> 273 <tr> 274 <td> 275 <p><input name="save" type="submit" value="Save changes" class="button-primary"></p> 276 </td> 277 </tr> 222 278 223 279 <?php … … 264 320 <tr> 265 321 <td colspan="2" class="header"> 266 <h3 ><?php echo $opt_name ?></h3>322 <h3 style="font-size: 1.6em"><?php echo $opt_name ?></h3> 267 323 </td> 268 324 </tr> … … 419 475 <input name="save" type="submit" value="Save changes" class="button-primary"> 420 476 <input type="hidden" name="action" value="save" > 421 422 <?php if (isset($propercfp_options['last-panel'])) : ?>423 <input type="hidden" id="proper-show-panel" name="panel" value="<?php echo $propercfp_options['last-panel'] ?>" >424 <?php else : ?>425 <input type="hidden" id="proper-show-panel" name="panel" value="header" >426 <?php endif; ?>427 477 </p> 428 478
Note: See TracChangeset
for help on using the changeset viewer.