PluginProbe
weForms – Easy Drag & Drop Contact Form Builder For WordPress / 1.2.9
weForms – Easy Drag & Drop Contact Form Builder For WordPress v1.2.9
1.6.7 1.6.8 1.6.9 1.6.12 1.6.13 1.6.14 1.6.15 1.6.16 1.6.17 1.6.18 1.6.19 1.6.2 1.6.20 1.6.21 1.6.22 1.6.23 1.6.24 1.6.25 1.6.26 1.6.27 1.6.28 1.6.3 1.6.4 1.6.5 1.6.6 All 74 releases
weforms / includes / fields / class-field-text.php

class-field-text.php in weForms – Easy Drag & Drop Contact Form Builder For WordPress 1.2.9, at includes/fields/class-field-text.php

136 lines 4.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Text Field Class
5 */
6 class WeForms_Form_Field_Text extends WeForms_Field_Contract {
7
8 function __construct() {
9 $this->name = __( 'Text', 'weforms' );
10 $this->input_type = 'text_field';
11 $this->icon = 'text-width';
12 }
13
14 /**
15 * Render the text field
16 *
17 * @param array $field_settings
18 * @param integer $form_id
19 *
20 * @return void
21 */
22 public function render( $field_settings, $form_id ) {
23 $value = $field_settings['default'];
24 ?>
25 <li <?php $this->print_list_attributes( $field_settings ); ?>>
26 <?php $this->print_label( $field_settings, $form_id ); ?>
27
28 <div class="wpuf-fields">
29 <input
30 class="textfield <?php echo 'wpuf_' . $field_settings['name'] . '_' . $form_id; ?>"
31 id="<?php echo $field_settings['name'] . '_' . $form_id; ?>"
32 type="text"
33 data-duplicate="<?php echo $field_settings['duplicate'] ? $field_settings['duplicate'] : 'no'; ?>"
34 data-required="<?php echo $field_settings['required'] ?>"
35 data-type="text" name="<?php echo esc_attr( $field_settings['name'] ); ?>"
36 placeholder="<?php echo esc_attr( $field_settings['placeholder'] ); ?>"
37 value="<?php echo esc_attr( $value ) ?>"
38 size="<?php echo esc_attr( $field_settings['size'] ) ?>"
39 />
40
41 <span class="wpuf-wordlimit-message wpuf-help"></span>
42 <?php $this->help_text( $field_settings ); ?>
43 </div>
44 <?php
45 if ( isset( $field_settings['word_restriction'] ) && $field_settings['word_restriction'] ) {
46 $this->check_word_restriction_func(
47 $field_settings['word_restriction'],
48 'no',
49 $field_settings['name'] . '_' . $form_id
50 );
51 }
52 ?>
53 </li>
54 <script>
55 jQuery(document).ready(function($){
56 var text_field = $( "input[name*=<?php echo esc_attr( $field_settings['name'] ); ?>]" );
57 switch ( '<?php echo $field_settings['mask_options']; ?>' ) {
58 case 'us_phone':
59 text_field.mask('(999) 999-9999');
60 break;
61 case 'date':
62 text_field.mask('99/99/9999');
63 break;
64 case 'tax_id':
65 text_field.mask('99-9999999');
66 break;
67 case 'ssn':
68 text_field.mask('999-99-9999');
69 break;
70 case 'zip':
71 text_field.mask('99999');
72 break;
73 default:
74 break;
75 }
76 });
77 </script>
78 <?php
79 }
80
81 /**
82 * Get field options setting
83 *
84 * @return array
85 */
86 public function get_options_settings() {
87 $default_options = $this->get_default_option_settings();
88 $default_text_options = $this->get_default_text_option_settings( true );
89 $check_duplicate = array(
90 array(
91 'name' => 'duplicate',
92 'title' => 'No Duplicates',
93 'type' => 'checkbox',
94 'is_single_opt' => true,
95 'options' => array(
96 'no' => __( 'Unique Values Only', 'weforms' )
97 ),
98 'default' => '',
99 'section' => 'advanced',
100 'priority' => 23,
101 'help_text' => __( 'Select this option to limit user input to unique values only. This will require that a value entered in a field does not currently exist in the entry database for that field.', 'weforms' ),
102 )
103 );
104
105 $text_options = array_merge( $default_options, $default_text_options, $check_duplicate );
106
107 return apply_filters( 'weforms_text_field_option_settings', $text_options );
108 }
109
110 /**
111 * Get the field props
112 *
113 * @return array
114 */
115 public function get_field_props() {
116 $defaults = $this->default_attributes();
117 $props = array(
118 'word_restriction' => '',
119 'duplicate' => '',
120 );
121
122 return array_merge( $defaults, $props );
123 }
124
125 /**
126 * Prepare entry
127 *
128 * @param $field
129 *
130 * @return mixed
131 */
132 public function prepare_entry( $field ) {
133 return sanitize_text_field( trim( $_POST[$field['name']] ) );
134 }
135 }
136