PluginProbe
weForms – Easy Drag & Drop Contact Form Builder For WordPress / 1.1.1
weForms – Easy Drag & Drop Contact Form Builder For WordPress v1.1.1
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
← All changes | includes/fields/class-field-text.php +92 -154 1.6.211.1.1 View file →
@@ -1,154 +1,92 @@
1 -<?php
2 -
3 -/**
4 - * Text Field Class
5 - */
6 -class WeForms_Form_Field_Text extends WeForms_Field_Contract {
7 -
8 - public 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 int $form_id
19 - *
20 - * @return void
21 - */
22 - public function render( $field_settings, $form_id ) {
23 - $value = $field_settings['default'];
24 - $form_settings = weforms()->form->get( $form_id )->get_settings();
25 - $use_theme_css = isset( $form_settings['use_theme_css'] ) ? $form_settings['use_theme_css'] : 'wpuf-style';
26 - ?>
27 - <li <?php $this->print_list_attributes( $field_settings ); ?>>
28 - <?php $this->print_label( $field_settings, $form_id ); ?>
29 -
30 - <div class="wpuf-fields">
31 - <input
32 - class="textfield <?php echo 'wpuf_' . esc_attr( $field_settings['name'] ) . '_' . esc_attr( $form_id ); ?>"
33 - id="<?php echo esc_attr( $field_settings['name'] ) . '_' . esc_attr( $form_id ); ?>"
34 - type="text"
35 - data-duplicate="<?php echo esc_attr( $field_settings['duplicate'] ) ? esc_attr( $field_settings['duplicate'] ) : 'no'; ?>"
36 - data-required="<?php echo esc_attr( $field_settings['required'] ) ?>"
37 - data-type="text" name="<?php echo esc_attr( $field_settings['name'] ); ?>"
38 - placeholder="<?php echo esc_attr( $field_settings['placeholder'] ); ?>"
39 - value="<?php echo esc_attr( $value ); ?>"
40 - size="<?php echo esc_attr( $field_settings['size'] ); ?>"
41 - data-style="<?php echo esc_attr( $use_theme_css ); ?>"
42 - />
43 -
44 - <span class="wpuf-wordlimit-message wpuf-help"></span>
45 - <?php $this->help_text( $field_settings ); ?>
46 - </div>
47 - <?php
48 - if ( isset( $field_settings['word_restriction'] ) && $field_settings['word_restriction'] ) {
49 - $this->check_word_restriction_func(
50 - $field_settings['word_restriction'],
51 - 'no',
52 - $field_settings['name'] . '_' . $form_id
53 - );
54 - }
55 -
56 - $mask_option = isset( $field_settings['mask_options'] ) ? $field_settings['mask_options'] : '';
57 -
58 - if ( $mask_option ) {
59 - ?>
60 - <script>
61 - jQuery(document).ready(function($) {
62 - var text_field = $( "input[name*=<?php echo esc_attr( $field_settings['name'] ); ?>]" );
63 - switch ( '<?php echo esc_attr( $mask_option ); ?>' ) {
64 - case 'us_phone':
65 - text_field.mask('(999) 999-9999');
66 - break;
67 - case 'date':
68 - text_field.mask('99/99/9999');
69 - break;
70 - case 'tax_id':
71 - text_field.mask('99-9999999');
72 - break;
73 - case 'ssn':
74 - text_field.mask('999-99-9999');
75 - break;
76 - case 'zip':
77 - text_field.mask('99999');
78 - break;
79 - default:
80 - break;
81 - }
82 - });
83 - </script>
84 - <?php
85 - } ?>
86 - </li>
87 - <?php
88 - }
89 -
90 - /**
91 - * Get field options setting
92 - *
93 - * @return array
94 - */
95 - public function get_options_settings() {
96 - $default_options = $this->get_default_option_settings();
97 - $default_text_options = $this->get_default_text_option_settings( true );
98 - $check_duplicate = [
99 - [
100 - 'name' => 'duplicate',
101 - 'title' => 'No Duplicates',
102 - 'type' => 'checkbox',
103 - 'is_single_opt' => true,
104 - 'options' => [
105 - 'no' => __( 'Unique Values Only', 'weforms' ),
106 - ],
107 - 'default' => '',
108 - 'section' => 'advanced',
109 - 'priority' => 23,
110 - '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' ),
111 - ],
112 - ];
113 -
114 - $text_options = array_merge( $default_options, $default_text_options, $check_duplicate );
115 -
116 - return apply_filters( 'weforms_text_field_option_settings', $text_options );
117 - }
118 -
119 - /**
120 - * Get the field props
121 - *
122 - * @return array
123 - */
124 - public function get_field_props() {
125 - $defaults = $this->default_attributes();
126 - $props = [
127 - 'word_restriction' => '',
128 - 'duplicate' => '',
129 - ];
130 -
131 - return array_merge( $defaults, $props );
132 - }
133 -
134 - /**
135 - * Prepare entry
136 - *
137 - * @param $field
138 - *
139 - * @return mixed
140 - */
141 - public function prepare_entry( $field, $args = [] ) {
142 - if( empty( $_POST[ '_wpnonce' ] ) ) {
143 - wp_send_json_error( __( 'Unauthorized operation', 'weforms' ) );
144 - }
145 -
146 - if ( ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['_wpnonce'] ) ), 'wpuf_form_add' ) ) {
147 - wp_send_json_error( __( 'Unauthorized operation', 'weforms' ) );
148 - }
149 -
150 - $args = ! empty( $args ) ? $args : weforms_clean( $_POST );
151 -
152 - return sanitize_text_field( trim( $args[$field['name']] ) );
153 - }
154 -}
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-required="<?php echo $field_settings['required'] ?>"
34 + data-type="text" name="<?php echo esc_attr( $field_settings['name'] ); ?>"
35 + placeholder="<?php echo esc_attr( $field_settings['placeholder'] ); ?>"
36 + value="<?php echo esc_attr( $value ) ?>"
37 + size="<?php echo esc_attr( $field_settings['size'] ) ?>"
38 + />
39 +
40 + <span class="wpuf-wordlimit-message wpuf-help"></span>
41 + <?php $this->help_text( $field_settings ); ?>
42 + </div>
43 + <?php
44 + if ( isset( $field_settings['word_restriction'] ) && $field_settings['word_restriction'] ) {
45 + $this->check_word_restriction_func(
46 + $field_settings['word_restriction'],
47 + 'no',
48 + $field_settings['name'] . '_' . $form_id
49 + );
50 + }
51 + ?>
52 + </li>
53 + <?php
54 + }
55 +
56 + /**
57 + * Get field options setting
58 + *
59 + * @return array
60 + */
61 + public function get_options_settings() {
62 + $default_options = $this->get_default_option_settings();
63 + $default_text_options = $this->get_default_text_option_settings( true );
64 +
65 + return array_merge( $default_options, $default_text_options );
66 + }
67 +
68 + /**
69 + * Get the field props
70 + *
71 + * @return array
72 + */
73 + public function get_field_props() {
74 + $defaults = $this->default_attributes();
75 + $props = array(
76 + 'word_restriction' => '',
77 + );
78 +
79 + return array_merge( $defaults, $props );
80 + }
81 +
82 + /**
83 + * Prepare entry
84 + *
85 + * @param $field
86 + *
87 + * @return mixed
88 + */
89 + public function prepare_entry( $field ) {
90 + return sanitize_text_field( trim( $_POST[$field['name']] ) );
91 + }
92 +}