Changeset 1007570
- Timestamp:
- 10/14/2014 10:26:08 PM (11 years ago)
- Location:
- proper-contact-form/trunk
- Files:
-
- 3 edited
-
inc/PhpFormBuilder.php (modified) (3 diffs)
-
proper-contact-form.php (modified) (5 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
proper-contact-form/trunk/inc/PhpFormBuilder.php
r965163 r1007570 1 1 <?php 2 2 3 // v 0.8. 53 // v 0.8.6 4 4 5 5 class PhpFormBuilder { 6 6 7 7 // Stores all form inputs 8 private $inputs = array(); 9 8 private $inputs = array(); 9 10 10 // Stores all form attributes 11 private $form = array(); 12 13 // Make sure a submit button is output11 private $form = array(); 12 13 // Does this form have a submit value? 14 14 private $has_submit = false; 15 16 // Constructor to set basic form attributes 17 function __construct($action = '', $args = false) { 18 15 16 /** 17 * Constructor function to set form action and attributes 18 * 19 * @param string $action 20 * @param bool $args 21 */ 22 function __construct( $action = '', $args = false ) { 23 24 // Default form attributes 19 25 $defaults = array( 20 'action' => $action,21 'method' => 'post',22 'enctype' => 'application/x-www-form-urlencoded',23 'class' => array(),24 'id' => '',25 'markup' => 'html',26 'novalidate' => false,27 'add_nonce' => false,26 'action' => $action, 27 'method' => 'post', 28 'enctype' => 'application/x-www-form-urlencoded', 29 'class' => array(), 30 'id' => '', 31 'markup' => 'html', 32 'novalidate' => false, 33 'add_nonce' => false, 28 34 'add_honeypot' => true, 29 35 'form_element' => true, 36 'add_submit' => true 30 37 ); 31 32 if ($args) { 33 $settings = array_merge($defaults, $args); 34 } 38 39 // Merge with arguments, if present 40 if ( $args ) { 41 $settings = array_merge( $defaults, $args ); 42 } // Otherwise, use the defaults wholesale 35 43 else { 36 44 $settings = $defaults; 37 45 } 38 39 foreach ($settings as $key => $val) { 46 47 // Iterate through and save each option 48 foreach ( $settings as $key => $val ) { 40 49 // Try setting with user-passed setting 41 50 // If not, try the default with the same key name 42 if (!$this->set_att($key, $val)) { 43 $this->set_att($key, $defaults[$key]); 44 } 45 } 46 47 } 48 49 // Set attributes for the form and special fields 50 function set_att($key, $val) { 51 52 switch ($key) : 53 51 if ( ! $this->set_att( $key, $val ) ) { 52 $this->set_att( $key, $defaults[ $key ] ); 53 } 54 } 55 } 56 57 /** 58 * Validate and set form 59 * 60 * @param string $key A valid key; switch statement ensures validity 61 * @param string | bool $val A valid value; validated for each key 62 * 63 * @return bool 64 */ 65 function set_att( $key, $val ) { 66 67 switch ( $key ) : 68 69 case 'action': 70 break; 71 54 72 case 'method': 55 if (! in_array($val, array('post', 'get'))) return false; 56 break; 57 73 if ( ! in_array( $val, array( 'post', 'get' ) ) ) { 74 return false; 75 } 76 break; 77 58 78 case 'enctype': 59 if (! in_array($val, array('application/x-www-form-urlencoded', 'multipart/form-data'))) return false; 60 break; 61 79 if ( ! in_array( $val, array( 'application/x-www-form-urlencoded', 'multipart/form-data' ) ) ) { 80 return false; 81 } 82 break; 83 62 84 case 'markup': 63 if (! in_array($val, array('html', 'xhtml'))) return false; 64 break; 65 85 if ( ! in_array( $val, array( 'html', 'xhtml' ) ) ) { 86 return false; 87 } 88 break; 89 66 90 case 'class': 67 91 case 'id': 68 if (! $this->_check_valid_attr($val)) return false; 69 break; 70 92 if ( ! $this->_check_valid_attr( $val ) ) { 93 return false; 94 } 95 break; 96 71 97 case 'novalidate': 72 98 case 'add_honeypot': 73 99 case 'form_element': 74 if (! is_bool($val)) return false; 75 break; 76 100 case 'add_submit': 101 if ( ! is_bool( $val ) ) { 102 return false; 103 } 104 break; 105 77 106 case 'add_nonce': 78 if (! is_string($val) && !is_bool($val)) return false; 79 break; 80 81 default: 107 if ( ! is_string( $val ) && ! is_bool( $val ) ) { 108 return false; 109 } 110 break; 111 112 default: 82 113 return false; 83 114 84 115 endswitch; 85 86 $this->form[ $key] = $val;87 116 117 $this->form[ $key ] = $val; 118 88 119 return true; 89 90 } 91 92 // Add an input to the queue 93 function add_input($label, $args = '', $slug = '') { 94 95 if (empty($args)) { 120 121 } 122 123 /** 124 * Add an input field to the form for outputting later 125 * 126 * @param string $label 127 * @param string $args 128 * @param string $slug 129 */ 130 function add_input( $label, $args = '', $slug = '' ) { 131 132 if ( empty( $args ) ) { 96 133 $args = array(); 97 134 } 98 135 99 if (empty($slug)) { 100 $slug = $this->_make_slug($label); 101 } 102 136 // Create a valid id or class attribute 137 if ( empty( $slug ) ) { 138 $slug = $this->_make_slug( $label ); 139 } 140 103 141 $defaults = array( 104 'type' => 'text', 105 'name' => $slug, 106 'id' => $slug, 107 'label' => $label, 108 'value' => '', 109 'placeholder' => '', 110 'class' => array(), 111 'min' => '', 112 'max' => '', 113 'step' => '', 114 'autofocus' => false, 115 'checked' => false, 116 'required' => false, 117 'add_label' => true, 118 'options' => array(), 119 'wrap_tag' => 'div', 120 'wrap_class' => array('form_field_wrap'), 121 'wrap_id' => '', 122 'wrap_style' => '' 123 142 'type' => 'text', 143 'name' => $slug, 144 'id' => $slug, 145 'label' => $label, 146 'value' => '', 147 'placeholder' => '', 148 'class' => array(), 149 'min' => '', 150 'max' => '', 151 'step' => '', 152 'autofocus' => false, 153 'checked' => false, 154 'selected' => false, 155 'required' => false, 156 'add_label' => true, 157 'options' => array(), 158 'wrap_tag' => 'div', 159 'wrap_class' => array( 'form_field_wrap' ), 160 'wrap_id' => '', 161 'wrap_style' => '', 162 'before_html' => '', 163 'after_html' => '', 164 'request_populate' => true 124 165 ); 125 166 126 167 // Combined defaults and arguments 127 168 // Arguments override defaults 128 $args = array_merge($defaults, $args); 129 130 $this->inputs[$slug] = $args; 131 132 } 133 134 // Add multiple inputs to the queue 135 function add_inputs($arr) { 136 137 if (!is_array($arr)) return false; 138 139 foreach ($arr as $field) : 140 $this->add_input($field[0], isset($field[1]) ? $field[1] : '', isset($field[2]) ? $field[2] : ''); 141 endforeach; 142 143 } 144 145 // Parse the inputs and build the form HTML 146 function build_form($echo = true) { 169 $args = array_merge( $defaults, $args ); 170 $this->inputs[ $slug ] = $args; 171 172 } 173 174 /** 175 * Add multiple inputs to the input queue 176 * 177 * @param $arr 178 * 179 * @return bool 180 */ 181 function add_inputs( $arr ) { 182 183 if ( ! is_array( $arr ) ) { 184 return false; 185 } 186 187 foreach ( $arr as $field ) { 188 $this->add_input( 189 $field[0], isset( $field[1] ) ? $field[1] : '', 190 isset( $field[2] ) ? $field[2] : '' 191 ); 192 } 193 194 return true; 195 } 196 197 /** 198 * Build the HTML for the form based on the input queue 199 * 200 * @param bool $echo Should the HTML be echoed or returned? 201 * 202 * @return string 203 */ 204 function build_form( $echo = true ) { 147 205 148 206 $output = ''; … … 151 209 $output .= '<form method="' . $this->form['method'] . '"'; 152 210 153 if ( !empty($this->form['enctype'])) {211 if ( ! empty( $this->form['enctype'] ) ) { 154 212 $output .= ' enctype="' . $this->form['enctype'] . '"'; 155 213 } 156 214 157 if ( !empty($this->form['action'])) {215 if ( ! empty( $this->form['action'] ) ) { 158 216 $output .= ' action="' . $this->form['action'] . '"'; 159 217 } 160 218 161 if ( !empty($this->form['id'])) {219 if ( ! empty( $this->form['id'] ) ) { 162 220 $output .= ' id="' . $this->form['id'] . '"'; 163 221 } 164 165 if ( count($this->form['class']) > 0) {166 $output .= $this->_output_classes( $this->form['class']);167 } 168 169 if ( $this->form['novalidate']) {222 223 if ( count( $this->form['class'] ) > 0 ) { 224 $output .= $this->_output_classes( $this->form['class'] ); 225 } 226 227 if ( $this->form['novalidate'] ) { 170 228 $output .= ' novalidate'; 171 229 } … … 173 231 $output .= '>'; 174 232 } 175 176 if ($this->form['add_honeypot']) 177 $this->add_input('Leave blank to submit', array( 178 'name' => 'honeypot', 179 'slug' => 'honeypot', 180 'id' => 'form_honeypot', 181 'wrap_tag' => 'div', 182 'wrap_class' => array('form_field_wrap', 'hidden'), 183 'wrap_id' => '', 184 'wrap_style' => 'display: none' 185 )); 186 187 if ($this->form['add_nonce'] && function_exists('wp_create_nonce')) 188 $this->add_input('WordPress nonce', array( 189 'value' => wp_create_nonce($this->form['add_nonce']), 190 'add_label' => false, 191 'type' => 'hidden' 192 )); 193 194 foreach ($this->inputs as $key => $val) : 195 233 234 // Add honeypot anti-spam field 235 if ( $this->form['add_honeypot'] ) { 236 $this->add_input( 'Leave blank to submit', array( 237 'name' => 'honeypot', 238 'slug' => 'honeypot', 239 'id' => 'form_honeypot', 240 'wrap_tag' => 'div', 241 'wrap_class' => array( 'form_field_wrap', 'hidden' ), 242 'wrap_id' => '', 243 'wrap_style' => 'display: none', 244 'request_populate' => false 245 ) ); 246 } 247 248 // Add a WordPress nonce field 249 if ( $this->form['add_nonce'] && function_exists( 'wp_create_nonce' ) ) { 250 $this->add_input( 'WordPress nonce', array( 251 'value' => wp_create_nonce( $this->form['add_nonce'] ), 252 'add_label' => false, 253 'type' => 'hidden', 254 'request_populate' => false 255 ) ); 256 } 257 258 // Iterate through the input queue and add input HTML 259 foreach ( $this->inputs as $val ) : 260 196 261 $min_max_range = $element = $end = $attr = $field = $label_html = ''; 197 198 // Set the field value to incoming 199 $val['value'] = isset($_REQUEST[$val['name']]) && !empty($_REQUEST[$val['name']]) ? 200 $_REQUEST[$val['name']] : 201 $val['value']; 202 203 switch ($val['type']) : 204 262 263 // Automatic population of values using $_REQUEST data 264 if ( $val['request_populate'] && isset( $_REQUEST[ $val['name'] ] ) ) { 265 266 // Can this field be populated directly? 267 if ( ! in_array( $val['type'], array( 'html', 'title', 'radio', 'checkbox', 'select', 'submit' ) ) ) { 268 $val['value'] = $_REQUEST[ $val['name'] ]; 269 } 270 } 271 272 // Automatic population for checkboxes and radios 273 if ( 274 $val['request_populate'] && 275 ( $val['type'] == 'radio' || $val['type'] == 'checkbox' ) && 276 empty( $val['options'] ) 277 ) { 278 $val['checked'] = isset( $_REQUEST[ $val['name'] ] ) ? true : $val['checked']; 279 } 280 281 switch ( $val['type'] ) { 282 205 283 case 'html': 206 284 $element = ''; 207 $end = $val['label'];285 $end = $val['label']; 208 286 break; 209 287 210 288 case 'title': 211 289 $element = ''; 212 $end = '290 $end = ' 213 291 <h3>' . $val['label'] . '</h3>'; 214 292 break; 215 293 216 294 case 'textarea': 217 295 $element = 'textarea'; 218 $end = '>' . $val['value'] . '</textarea>';296 $end = '>' . $val['value'] . '</textarea>'; 219 297 break; 220 298 221 299 case 'select': 222 300 $element = 'select'; 223 $end = '>' . $this->_output_options_select($val['options']) . ' 224 </select>'; 301 $end .= '>'; 302 foreach ( $val['options'] as $key => $opt ) { 303 $opt_insert = ''; 304 if ( 305 // Is this field set to automatically populate? 306 $val['request_populate'] && 307 308 // Do we have $_REQUEST data to use? 309 isset( $_REQUEST[ $val['name'] ] ) && 310 311 // Are we currently outputting the selected value? 312 $_REQUEST[ $val['name'] ] === $key 313 ) { 314 $opt_insert = ' selected'; 315 316 // Does the field have a default selected value? 317 } else if ( $val['selected'] === $key ) { 318 $opt_insert = ' selected'; 319 } 320 $end .= '<option value="' . $key . '"' . $opt_insert . '>' . $opt . '</option>'; 321 } 322 $end .= '</select>'; 225 323 break; 226 324 325 case 'radio': 227 326 case 'checkbox': 228 if (count($val['options']) > 0) : 327 328 // Special case for multiple check boxes 329 if ( count( $val['options'] ) > 0 ) : 229 330 $element = ''; 230 $end = $this->_output_options_checkbox($val['options'], $val['name']); 231 $label_html = '<p class="checkbox_header">' . $val['label'] . '</p>'; 331 foreach ( $val['options'] as $key => $opt ) { 332 $slug = $this->_make_slug( $opt ); 333 $end .= sprintf( 334 '<input type="%s" name="%s[]" value="%s" id="%s"', 335 $val['type'], 336 $val['name'], 337 $key, 338 $slug 339 ); 340 if ( 341 // Is this field set to automatically populate? 342 $val['request_populate'] && 343 344 // Do we have $_REQUEST data to use? 345 isset( $_REQUEST[ $val['name'] ] ) && 346 347 // Is the selected item(s) in the $_REQUEST data? 348 in_array( $key, $_REQUEST[ $val['name'] ] ) 349 ) { 350 $end .= ' checked'; 351 } 352 $end .= $this->field_close(); 353 $end .= ' <label for="' . $slug . '">' . $opt . '</label>'; 354 } 355 $label_html = '<div class="checkbox_header">' . $val['label'] . '</div>'; 356 break; 232 357 endif; 233 break; 234 235 case 'radio': 236 if (count($val['options']) > 0) : 237 $element = ''; 238 $end = $this->_output_options_radios($val['options'], $val['name']); 239 $label_html = '<p class="checkbox_header">' . $val['label'] . '</p>'; 240 endif; 241 break; 242 243 case 'range': 244 case 'number': 245 $min_max_range .= !empty($val['min']) ? ' min="' . $val['min'] . '"' : ''; 246 $min_max_range .= !empty($val['max']) ? ' max="' . $val['max'] . '"' : ''; 247 $min_max_range .= !empty($val['step']) ? ' step="' . $val['step'] . '"' : ''; 248 249 case 'submit': 250 $this->has_submit = true; 251 358 359 // Used for all text fields (text, email, url, etc), single radios, single checkboxes, and submit 252 360 default : 253 361 $element = 'input'; 254 362 $end .= ' type="' . $val['type'] . '" value="' . $val['value'] . '"'; 255 $end .= $val['checked'] ? ' selected' : '';363 $end .= $val['checked'] ? ' checked' : ''; 256 364 $end .= $this->field_close(); 257 365 break; 258 259 endswitch; 260 261 $id = !empty($val['id']) ? ' id="' . $val['id'] . '"' : ''; 262 263 $class = $this->_output_classes($val['class']); 366 367 } 368 369 // Added a submit button, no need to auto-add one 370 if ( $val['type'] === 'submit' ) { 371 $this->has_submit = true; 372 } 373 374 // Special number values for range and number types 375 if ( $val['type'] === 'range' || $val['type'] === 'number' ) { 376 $min_max_range .= ! empty( $val['min'] ) ? ' min="' . $val['min'] . '"' : ''; 377 $min_max_range .= ! empty( $val['max'] ) ? ' max="' . $val['max'] . '"' : ''; 378 $min_max_range .= ! empty( $val['step'] ) ? ' step="' . $val['step'] . '"' : ''; 379 } 380 381 // Add an ID field, if one is present 382 $id = ! empty( $val['id'] ) ? ' id="' . $val['id'] . '"' : ''; 383 384 // Output classes 385 $class = $this->_output_classes( $val['class'] ); 386 387 // Special HTML5 fields, if set 264 388 $attr .= $val['autofocus'] ? ' autofocus' : ''; 265 389 $attr .= $val['checked'] ? ' checked' : ''; 266 390 $attr .= $val['required'] ? ' required' : ''; 267 391 268 392 // Build the label 269 if ( !empty($label_html)) :393 if ( ! empty( $label_html ) ) { 270 394 $field .= $label_html; 271 elseif ($val['add_label'] && $val['type'] != 'hidden' && $val['type'] != 'submit' && $val['type'] != 'title' && $val['type'] != 'html') : 272 $val['label'] .= $val['required'] ? ' <strong>*</strong>' : ''; 273 $field .= ' 274 <label for="' . $val['id'] . '">' . $val['label'] . '</label>'; 275 endif; 276 277 if (!empty($element)) 278 $field .= ' 279 <' . $element . $id . ' name="' . $val['name'] . '"' . $min_max_range .$class. $attr . $end; 280 else 395 } elseif ( $val['add_label'] && ! in_array( $val['type'], array( 'hidden', 'submit', 'title', 'html' ) ) ) { 396 if ( $val['required'] ) { 397 $val['label'] .= ' <strong>*</strong>'; 398 } 399 $field .= '<label for="' . $val['id'] . '">' . $val['label'] . '</label>'; 400 } 401 402 // An $element was set in the $val['type'] switch statement above so use that 403 if ( ! empty( $element ) ) { 404 if ( $val['type'] === 'checkbox' ) { 405 $field = ' 406 <' . $element . $id . ' name="' . $val['name'] . '"' . $min_max_range . $class . $attr . $end . 407 $field; 408 } else { 409 $field .= ' 410 <' . $element . $id . ' name="' . $val['name'] . '"' . $min_max_range . $class . $attr . $end; 411 } 412 // Not a form element 413 } else { 281 414 $field .= $end; 282 415 } 416 283 417 // Parse and create wrap, if needed 284 if ($val['type'] != 'hidden' && $val['type'] != 'html' && !empty($val['wrap_tag'])) : 285 286 $wrap_before = ' 287 <' . $val['wrap_tag']; 288 $wrap_before .= count($val['wrap_class']) > 0 ? $this->_output_classes($val['wrap_class']) : ''; 289 $wrap_before .= !empty($val['wrap_style']) ? ' style="' . $val['wrap_style'] . '"' : ''; 290 $wrap_before .= !empty($val['wrap_id']) ? ' id="' . $val['wrap_id'] . '"' : ''; 291 $wrap_before .= '>'; 292 293 $wrap_after = ' 294 </' . $val['wrap_tag'] . '>'; 295 418 if ( $val['type'] != 'hidden' && $val['type'] != 'html' ) : 419 420 $wrap_before = $val['before_html']; 421 if ( ! empty( $val['wrap_tag'] ) ) { 422 $wrap_before .= '<' . $val['wrap_tag']; 423 $wrap_before .= count( $val['wrap_class'] ) > 0 ? $this->_output_classes( $val['wrap_class'] ) : ''; 424 $wrap_before .= ! empty( $val['wrap_style'] ) ? ' style="' . $val['wrap_style'] . '"' : ''; 425 $wrap_before .= ! empty( $val['wrap_id'] ) ? ' id="' . $val['wrap_id'] . '"' : ''; 426 $wrap_before .= '>'; 427 } 428 429 $wrap_after = $val['after_html']; 430 if ( ! empty( $val['wrap_tag'] ) ) { 431 $wrap_after = '</' . $val['wrap_tag'] . '>' . $wrap_after; 432 } 433 296 434 $output .= $wrap_before . $field . $wrap_after; 297 else : 435 else : 298 436 $output .= $field; 299 437 endif; 300 301 endforeach; 302 303 if (! $this->has_submit) $output .= ' 304 <div class="form_field_wrap"> 305 <input type="submit" value="Submit" name="submit"> 306 </div>'; 307 438 439 endforeach; 440 441 // Auto-add submit button 442 if ( ! $this->has_submit && $this->form['add_submit'] ) { 443 $output .= '<div class="form_field_wrap"><input type="submit" value="Submit" name="submit"></div>'; 444 } 445 446 // Close the form tag if one was added 308 447 if ( $this->form['form_element'] ) { 309 448 $output .= '</form>'; 310 449 } 311 312 if ($echo) { 450 451 // Output or return? 452 if ( $echo ) { 313 453 echo $output; 314 } 315 else { 454 } else { 316 455 return $output; 317 456 } 318 319 } 320 321 // :FIXIT: Add validation for classes and ids 322 private function _check_valid_attr($string) { 323 457 } 458 459 // Easy way to auto-close fields, if necessary 460 function field_close() { 461 return $this->form['markup'] === 'xhtml' ? ' />' : '>'; 462 } 463 464 // Validates id and class attributes 465 // TODO: actually validate these things 466 private function _check_valid_attr( $string ) { 467 324 468 $result = true; 325 469 326 470 // Check $name for correct characters 327 471 // "^[a-zA-Z0-9_-]*$" 472 473 return $result; 474 475 } 476 477 // Create a slug from a label name 478 private function _make_slug( $string ) { 479 480 $result = ''; 481 482 $result = str_replace( '"', '', $string ); 483 $result = str_replace( "'", '', $result ); 484 $result = str_replace( '_', '-', $result ); 485 $result = preg_replace( '~[\W\s]~', '-', $result ); 486 487 $result = strtolower( $result ); 488 489 return $result; 490 491 } 492 493 // Parses and builds the classes in multiple places 494 private function _output_classes( $classes ) { 495 496 $output = ''; 497 328 498 329 return $result; 330 331 } 332 333 // Easy way to auto-close fields, if necessary 334 function field_close() { 335 336 return $this->form['markup'] === 'xhtml' ? ' />' : '>'; 337 338 } 339 340 341 // Create a slug from a label name 342 private function _make_slug($string) { 343 344 $result = ''; 345 346 $result = str_replace('"', '', $string); 347 $result = str_replace("'", '', $result); 348 $result = str_replace('_', '-', $result); 349 $result = preg_replace('~[\W\s]~', '-', $result); 350 351 $result = strtolower($result); 352 353 return $result; 354 355 } 356 357 // Parses and builds the classes in multiple places 358 private function _output_classes($arr) { 359 360 $output = ''; 361 362 499 if ( is_array( $classes ) && count( $classes ) > 0 ) { 363 500 $output .= ' class="'; 364 if(is_array($arr)) { 365 366 if (count($arr) > 0) : 367 368 foreach ($arr as $class) : 369 $output .= $class . ' '; 370 endforeach; 371 endif; 372 } 373 374 if(is_string($arr)) { 375 $output .= $arr . ' '; 376 } 377 501 foreach ( $classes as $class ) { 502 $output .= $class . ' '; 503 } 378 504 $output .= '"'; 379 505 } else if ( is_string( $classes ) ) { 506 $output .= ' class="' . $classes . '"'; 507 } 508 380 509 return $output; 381 382 } 383 384 // Builds the select input output 385 private function _output_options_select($arr) { 386 $output = ''; 387 foreach ($arr as $val => $opt) : 388 $output .= ' 389 <option value="' . $val . '">' . $opt . '</option>'; 390 endforeach; 391 return $output; 392 } 393 394 // Builds the radio button output 395 private function _output_options_radios($arr, $name) { 396 $output = ''; 397 foreach ($arr as $val => $opt) : 398 $slug = $this->_make_slug($opt); 399 $output .= ' 400 <input type="radio" name="' . $name . '[]" value="' . $val . '" id="' . $slug . '"'; 401 $output .= $this->form['markup'] === 'xhtml' ? ' />' : '>'; 402 $output .= ' 403 <label for="' . $slug . '">' . $opt . '</label>'; 404 endforeach; 405 return $output; 406 } 407 408 // Builds the multiple checkbox output 409 private function _output_options_checkbox($arr, $name) { 410 $output = ''; 411 foreach ($arr as $val => $opt) : 412 $slug = $this->_make_slug($opt); 413 $output .= ' 414 <input type="checkbox" name="' . $name . '[]" value="' . $val . '" id="' . $slug . '"'; 415 $output .= $this->form['markup'] === 'xhtml' ? ' />' : '>'; 416 $output .= ' 417 <label for="' . $slug . '">' . $opt . '</label>'; 418 endforeach; 419 return $output; 420 } 421 510 } 422 511 } -
proper-contact-form/trunk/proper-contact-form.php
r988456 r1007570 3 3 /* 4 4 Plugin Name: PROPER Contact Form 5 Plugin URI: http://theproperweb.com/ shipped/wp/proper-contact-form5 Plugin URI: http://theproperweb.com/product/proper-contact-form/ 6 6 Description: A better contact form processor 7 Version: 0.9.8. 57 Version: 0.9.8.6 8 8 Author: PROPER Web Development 9 9 Author URI: http://theproperweb.com … … 18 18 19 19 // Important constants 20 define( 'PROPER_CONTACT_VERSION', '0.9.8. 5' );20 define( 'PROPER_CONTACT_VERSION', '0.9.8.6' ); 21 21 define( 'PROPER_CONTACT_URL', plugin_dir_url( __FILE__ ) ); 22 22 … … 51 51 require_once( dirname( __FILE__ ) . '/inc/PhpFormBuilder.php' ); 52 52 } 53 $form = new PhpFormBuilder ;53 $form = new PhpFormBuilder(); 54 54 55 55 // TODO: make a better ID system … … 185 185 // Build the input with the correct label, options, and name 186 186 $form->add_input( 187 stripslashes( sanitize_text_field( proper_contact_get_key( 'propercfp_label_math' ) ) ) . " $num_1 + $num_2", 187 stripslashes( sanitize_text_field( proper_contact_get_key( 'propercfp_label_math' ) ) ) . 188 " $num_1 + $num_2", 188 189 array( 189 190 'required' => TRUE, 190 191 'wrap_class' => $wrap_classes, 191 ' use_request' => false192 'request_populate' => false 192 193 ), 193 194 'math-captcha' … … 199 200 'type' => 'hidden', 200 201 'value' => $sum, 201 ' use_request' => FALSE202 'request_populate' => false 202 203 ), 203 204 'math-captcha-sum' -
proper-contact-form/trunk/readme.txt
r988456 r1007570 5 5 Requires at least: 3.0 6 6 Tested up to: 4.0 7 Stable tag: 0.9.8. 57 Stable tag: 0.9.8.6 8 8 9 9 Creates a flexible, secure contact form on your WP site … … 48 48 49 49 == Changelog == 50 51 = 0.9.8.6 = 52 * Fixed the math captcha bug that required page reload 53 * Updated to latest PhpFormBuilder include (0.8.6) 50 54 51 55 = 0.9.8.5 =
Note: See TracChangeset
for help on using the changeset viewer.