|
@@ -16,2811 +16,3403 @@ |
|
16
|
16
|
* @subpackage userswp/admin/settings |
|
17
|
17
|
* @author GeoDirectory Team <info@wpgeodirectory.com> |
|
18
|
18
|
*/ |
|
19
|
19
|
class UsersWP_Form_Builder { |
|
20
|
|
- |
|
21
|
|
- public function uwp_form_builder($default_tab = 'account') |
|
22
|
|
- { |
|
20
|
+ |
|
21
|
+ public static function get_form_id() { |
|
22
|
+ $register_forms = (array) uwp_get_option( 'multiple_registration_forms', array() ); |
|
23
|
+ |
|
24
|
+ if ( isset( $_GET['form'] ) && ! empty( $_GET['form'] ) ) { |
|
25
|
+ $current_form_id = absint( $_GET['form'] ); |
|
26
|
+ } elseif ( ! empty( $register_forms ) ) { |
|
27
|
+ $default_form = array_filter( |
|
28
|
+ $register_forms, |
|
29
|
+ function ( $form ) { |
|
30
|
+ return (int) $form['id'] === 1; |
|
31
|
+ } |
|
32
|
+ ); |
|
33
|
+ |
|
34
|
+ $default_form = array_shift( $default_form ); |
|
35
|
+ |
|
36
|
+ if ( isset( $default_form['id'] ) ) { |
|
37
|
+ $current_form_id = (int) $default_form['id']; |
|
38
|
+ } else { |
|
39
|
+ $current_form = reset( $register_forms ); |
|
40
|
+ $current_form_id = isset( $current_form['id'] ) ? absint( $current_form['id'] ) : 1; |
|
41
|
+ } |
|
42
|
+ } |
|
43
|
+ |
|
44
|
+ return $current_form_id; |
|
45
|
+ } |
|
46
|
+ |
|
47
|
+ public static function output( $tab = '' ) { |
|
48
|
+ |
|
49
|
+ global $current_tab; |
|
50
|
+ |
|
51
|
+ do_action( 'uwp_form_builder_start' ); |
|
52
|
+ |
|
53
|
+ // Get current tab/section |
|
54
|
+ if ( $tab ) { |
|
55
|
+ $current_tab = sanitize_title( $tab ); |
|
56
|
+ } else { |
|
57
|
+ $current_tab = empty( $_GET['tab'] ) ? 'account' : sanitize_title( $_GET['tab'] ); |
|
58
|
+ } |
|
59
|
+ |
|
60
|
+ $form = ''; |
|
61
|
+ if ( isset( $_GET['form'] ) && ! empty( $_GET['form'] ) ) { |
|
62
|
+ $form = '&form=' . (int) $_GET['form']; |
|
63
|
+ } |
|
64
|
+ |
|
65
|
+ // Get tabs for the form builder page |
|
66
|
+ $tabs = apply_filters( |
|
67
|
+ 'uwp_form_builder_tabs_array', |
|
68
|
+ array( |
|
69
|
+ 'account' => __( 'Account', 'userswp' ), |
|
70
|
+ 'register' => __( 'Register', 'userswp' ), |
|
71
|
+ ) |
|
72
|
+ ); |
|
73
|
+ |
|
74
|
+ ?> |
|
75
|
+ <div class="wrap"> |
|
76
|
+ <nav class="nav-tab-wrapper uwp-nav-tab-wrapper"> |
|
77
|
+ <?php |
|
78
|
+ foreach ( $tabs as $name => $label ) { |
|
79
|
+ echo '<a href="' . esc_url( admin_url( 'admin.php?page=uwp_form_builder&tab=' . $name . $form ) ) . '" id="uwp-form-builder-' . esc_attr( $name ) . '" class="nav-tab ' . ( $current_tab == $name ? 'nav-tab-active' : '' ) . '">' . esc_html( $label ) . '</a>'; |
|
80
|
+ } |
|
81
|
+ do_action( 'uwp_form_builder_tabs' ); |
|
82
|
+ ?> |
|
83
|
+ </nav> |
|
84
|
+ <h1 class="screen-reader-text"><?php echo esc_html( $tabs[ $current_tab ] ); ?></h1> |
|
85
|
+ <?php |
|
86
|
+ do_action( 'uwp_form_builder_tabs_content', $current_tab, $tabs ); |
|
87
|
+ do_action( 'uwp_form_builder_tabs_' . $current_tab, $tabs ); |
|
88
|
+ do_action( 'uwp_extra_form_builder_content', $current_tab, $tabs ); |
|
89
|
+ ?> |
|
90
|
+ </div> |
|
91
|
+ <?php |
|
92
|
+ } |
|
93
|
+ |
|
94
|
+ public function uwp_form_builder( $default_tab = 'account' ) { |
|
23
|
95
|
ob_start(); |
|
24
|
|
- $form_type = (isset($_REQUEST['tab']) && $_REQUEST['tab'] != '') ? sanitize_text_field($_REQUEST['tab']) : $default_tab; |
|
96
|
+ $form_type = ( isset( $_GET['tab'] ) && $_GET['tab'] != '' ) ? sanitize_text_field( $_GET['tab'] ) : $default_tab; |
|
25
|
97
|
?> |
|
26
|
|
- <div class="uwp-panel-heading"> |
|
27
|
|
- <h3><?php echo apply_filters('uwp_form_builder_panel_head', ''); ?></h3> |
|
28
|
|
- </div> |
|
98
|
+ <div class="uwp-settings-wrap bsui"> |
|
29
|
99
|
|
|
30
|
|
- <div id="uwp_form_builder_container" class="clearfix"> |
|
31
|
|
- <div class="uwp-form-builder-frame"> |
|
32
|
|
- <div class="uwp-side-sortables" id="uwp-available-fields"> |
|
33
|
|
- <h3 class="hndle"> |
|
34
|
|
- <span> |
|
35
|
|
- <?php echo apply_filters('uwp_form_builder_available_fields_head', __('Add new form field', 'userswp'), $form_type); ?> |
|
36
|
|
- </span> |
|
37
|
|
- </h3> |
|
100
|
+ <div class="container-fluid p-0 mt-3"> |
|
101
|
+ <?php do_action( 'uwp_before_form_builder_content', $default_tab ); ?> |
|
38
|
102
|
|
|
39
|
|
- <p> |
|
40
|
|
- <?php |
|
41
|
|
- $note = sprintf(__('Click on any box below to add a field of that type on %s form. You must be use a fieldset to group your fields.', 'userswp'), $form_type); |
|
42
|
|
- echo apply_filters('uwp_form_builder_available_fields_note', $note, $form_type); |
|
43
|
|
- ?> |
|
44
|
|
- </p> |
|
103
|
+ <div id="uwp_form_builder_container" class="row"> |
|
104
|
+ <div class="col-md-6"> |
|
45
|
105
|
|
|
46
|
|
- <h3> |
|
47
|
|
- <?php _e('Setup New Field', 'userswp'); ?> |
|
48
|
|
- </h3> |
|
106
|
+ <!-- required for tabs to work --> |
|
107
|
+ <ul class="nav nav-tabs d-none " role="tablist"> |
|
108
|
+ <li class="nav-item" role="presentation"> |
|
109
|
+ <a class="nav-link active" id="uwp-fields-tab" data-toggle="tab" href="#uwp-available-fields" role="tab" aria-controls="home" aria-selected="true">1</a> |
|
110
|
+ </li> |
|
111
|
+ <li class="nav-item" role="presentation"> |
|
112
|
+ <a class="nav-link" id="uwp-field-settings-tab" data-toggle="tab" href="#uwp-field-settings" role="tab" aria-controls="profile" aria-selected="false">2</a> |
|
113
|
+ </li> |
|
114
|
+ </ul> |
|
115
|
+ <!-- required for tabs to work --> |
|
49
|
116
|
|
|
50
|
|
- <div class="inside"> |
|
51
|
|
- <div id="uwp-form-builder-tab" class="uwp-tabs-panel"> |
|
52
|
|
- <?php do_action('uwp_manage_available_fields', $form_type); ?> |
|
53
|
|
- </div> |
|
54
|
|
- </div> |
|
117
|
+ <div class="tab-content sticky-top" style="top: 40px;"> |
|
55
|
118
|
|
|
56
|
|
- <?php if ($form_type == 'account') { ?> |
|
57
|
|
- <h3> |
|
58
|
|
- <?php _e('Predefined Fields', 'userswp'); ?> |
|
59
|
|
- </h3> |
|
119
|
+ <div class="side-sortables side-sortables tab-pane fade show active card p-0 mw-100 w-100 border-0 shadow-sm" id="uwp-available-fields" role="tabpanel"> |
|
120
|
+ <div class="card border-0 shadow-sm mb-4 px-0 mw-100"> |
|
121
|
+ <div class="card-header bg-white"> |
|
122
|
+ <h3 class="h5 mb-0 text-dark py-0"> |
|
123
|
+ <span><?php echo apply_filters( 'uwp_form_builder_available_fields_head', __( 'Add new form field', 'userswp' ), $form_type ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></span> |
|
124
|
+ </h3> |
|
125
|
+ </div> |
|
126
|
+ <div class="card-body"> |
|
127
|
+ <p> |
|
128
|
+ <?php |
|
129
|
+ $note = sprintf( __( 'Click on any box below to add a field of that type on %s form. You must use a fieldset to group your fields.', 'userswp' ), $form_type ); |
|
130
|
+ echo apply_filters( 'uwp_form_builder_available_fields_note', $note, $form_type ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
131
|
+ ?> |
|
132
|
+ </p> |
|
133
|
+ <?php do_action( 'uwp_before_available_fields', $default_tab ); ?> |
|
60
|
134
|
|
|
61
|
|
- <div class="inside"> |
|
62
|
|
- <div id="uwp-form-builder-tab-predefined" class="uwp-tabs-panel"> |
|
63
|
|
- <?php do_action('uwp_manage_available_fields_predefined', $form_type); ?> |
|
135
|
+ <h4 class="h6 text-muted"><?php esc_html_e( 'Standard Fields', 'userswp' ); ?></h4> |
|
136
|
+ <div id="uwp-form-builder-tab" class="uwp-tabs-panel mb-4"> |
|
137
|
+ <?php do_action( 'uwp_manage_available_fields', $form_type ); ?> |
|
138
|
+ </div> |
|
139
|
+ |
|
140
|
+ <?php |
|
141
|
+ $predefined_fields = apply_filters( 'uwp_predefined_fields_tabs', array( 'account', 'profile-tabs' ) ); |
|
142
|
+ if ( in_array( $form_type, $predefined_fields ) ) { |
|
143
|
+ ?> |
|
144
|
+ <h4 class="h6 text-muted"><?php esc_html_e( 'Predefined Fields', 'userswp' ); ?></h4> |
|
145
|
+ <div id="uwp-form-builder-tab-predefined" class="uwp-tabs-panel mb-4"> |
|
146
|
+ <?php do_action( 'uwp_manage_available_fields_predefined', $form_type ); ?> |
|
147
|
+ </div> |
|
148
|
+ <?php |
|
149
|
+ } |
|
150
|
+ |
|
151
|
+ $custom_fields = apply_filters( 'uwp_custom_fields_tabs', array( 'account', 'profile-tabs' ) ); |
|
152
|
+ if ( in_array( $form_type, $custom_fields ) ) { |
|
153
|
+ ?> |
|
154
|
+ <h4 class="h6 text-muted"><?php esc_html_e( 'Custom Fields', 'userswp' ); ?></h4> |
|
155
|
+ <div id="uwp-form-builder-tab-custom" class="uwp-tabs-panel"> |
|
156
|
+ <?php do_action( 'uwp_manage_available_fields_custom', $form_type ); ?> |
|
157
|
+ </div> |
|
158
|
+ <?php |
|
159
|
+ } |
|
160
|
+ |
|
161
|
+ do_action( 'uwp_after_available_fields', $default_tab ); |
|
162
|
+ ?> |
|
64
|
163
|
</div> |
|
65
|
164
|
</div> |
|
66
|
|
- <?php } ?> |
|
67
|
|
- |
|
68
|
|
- </div> |
|
165
|
+ </div> |
|
69
|
166
|
|
|
70
|
167
|
|
|
71
|
|
- <div class="uwp-side-sortables" id="uwp-selected-fields"> |
|
168
|
+ <div class="side-sortables side-sortables tab-pane fade card p-0 mw-100 w-100 border-0 shadow-sm" id="uwp-field-settings" role="tabpanel"> |
|
169
|
+ <div class="card border-0 shadow-sm mb-4 px-0 mw-100"> |
|
170
|
+ <div class="card-header bg-white d-flex justify-content-between"> |
|
171
|
+ <h3 class="h5 mb-0 text-dark py-0"> |
|
172
|
+ <span><?php echo apply_filters( 'uwp_form_builder_available_fields_settings_head', __( 'Field Settings', 'userswp' ), $form_type ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></span> |
|
173
|
+ </h3> |
|
174
|
+ <?php |
|
175
|
+ global $aui_bs5; |
|
176
|
+ if ( $aui_bs5 ) { |
|
177
|
+ ?> |
|
178
|
+ <button type="button" class="btn-close align-self-center" aria-label="Close" onclick="uwp_tabs_close_settings(this);"></button> |
|
179
|
+ <?php } else { ?> |
|
180
|
+ <button type="button" class="close" aria-label="Close" onclick="uwp_tabs_close_settings(this);"> |
|
181
|
+ <span aria-hidden="true">×</span> |
|
182
|
+ </button> |
|
183
|
+ <?php } ?> |
|
184
|
+ </div> |
|
72
|
185
|
|
|
73
|
|
- <h3 class="hndle"> |
|
74
|
|
- <span> |
|
75
|
|
- <?php |
|
76
|
|
- $title = __('List of fields those will appear on add new listing form', 'userswp'); |
|
77
|
|
- echo apply_filters('uwp_form_builder_selected_fields_head', $title, $form_type); ?> |
|
78
|
|
- </span> |
|
79
|
|
- </h3> |
|
186
|
+ <form></form> <!-- required as chrome removes first empty form --> |
|
187
|
+ <form class="uwp-form-settings-form"> |
|
188
|
+ <div class="card-body scrollbars-ios" style="max-height: 70vh; overflow-y:auto;"> |
|
189
|
+ </div> |
|
190
|
+ </form> |
|
80
|
191
|
|
|
81
|
|
- <p> |
|
82
|
|
- <?php |
|
83
|
|
- $note = sprintf(__('Click to expand and view field related settings. You may drag and drop to arrange fields order on %s form too.', 'userswp'), $form_type); |
|
84
|
|
- echo apply_filters('uwp_form_builder_selected_fields_note', $note, $form_type); ?> |
|
85
|
|
- </p> |
|
192
|
+ <div class="card-footer text-right text-end"> |
|
86
|
193
|
|
|
87
|
|
- <div class="inside"> |
|
88
|
|
- <div id="uwp-form-builder-tab-selected" class="uwp-tabs-panel"> |
|
89
|
|
- <div class="field_row_main"> |
|
90
|
|
- <?php do_action('uwp_manage_selected_fields', $form_type); ?> |
|
194
|
+ </div> |
|
195
|
+ </div> |
|
91
|
196
|
</div> |
|
92
|
197
|
</div> |
|
93
|
198
|
</div> |
|
94
|
199
|
|
|
200
|
+ <div class="col-md-6 uwp-side-sortables" id="uwp-selected-fields"> |
|
201
|
+ <div class="card border-0 shadow-sm mb-4 px-0 mw-100"> |
|
202
|
+ <div class="card-header bg-white"> |
|
203
|
+ <h3 class="h5 mb-0 text-dark py-0"> |
|
204
|
+ <span> |
|
205
|
+ <?php |
|
206
|
+ $title = __( 'List of fields that will appear in the account form.', 'userswp' ); |
|
207
|
+ echo apply_filters( 'uwp_form_builder_selected_fields_head', $title, $form_type ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
208
|
+ ?> |
|
209
|
+ </span> |
|
210
|
+ </h3> |
|
211
|
+ </div> |
|
212
|
+ <div class="card-body"> |
|
213
|
+ <p> |
|
214
|
+ <?php |
|
215
|
+ $note = sprintf( __( 'Click to expand and view field related settings. You may drag and drop to arrange fields order on %s form too.', 'userswp' ), $form_type ); |
|
216
|
+ echo apply_filters( 'uwp_form_builder_selected_fields_note', $note, $form_type ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
217
|
+ ?> |
|
218
|
+ </p> |
|
219
|
+ <div id="uwp-form-builder-tab-selected" class="uwp-tabs-panel"> |
|
220
|
+ <div class="field_row_main"> |
|
221
|
+ <?php do_action( 'uwp_manage_selected_fields', $form_type ); ?> |
|
222
|
+ </div> |
|
223
|
+ </div> |
|
224
|
+ </div> |
|
225
|
+ </div> |
|
226
|
+ </div> |
|
227
|
+ |
|
95
|
228
|
</div> |
|
96
|
229
|
|
|
97
|
230
|
</div> |
|
98
|
231
|
</div> |
|
99
|
|
- |
|
100
|
232
|
<?php |
|
101
|
|
- $output = ob_get_contents(); |
|
102
|
|
- ob_end_clean(); |
|
103
|
|
- return $output; |
|
233
|
+ echo ob_get_clean(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
104
|
234
|
} |
|
105
|
235
|
|
|
106
|
|
- public function uwp_custom_available_fields($type = '', $form_type) |
|
107
|
|
- { |
|
108
|
|
- ?> |
|
109
|
|
- <input type="hidden" name="form_type" id="form_type" value="<?php echo $form_type; ?>"/> |
|
110
|
|
- <input type="hidden" name="manage_field_type" class="manage_field_type" value="custom_fields"> |
|
111
|
|
- <?php |
|
112
|
|
- if ($type == 'predefined') { |
|
113
|
|
- $fields = $this->uwp_form_fields_predefined($form_type); |
|
114
|
|
- }elseif ($type == 'custom') { |
|
115
|
|
- $fields = $this->uwp_form_fields_custom($form_type); |
|
116
|
|
- } else { |
|
117
|
|
- $fields = $this->uwp_form_fields($form_type); |
|
118
|
|
- ?> |
|
119
|
|
- <ul class="full uwp-tooltip-wrap"> |
|
120
|
|
- <li> |
|
121
|
|
- <div class="uwp-tooltip"> |
|
122
|
|
- <?php _e('This adds a section separator with a title.', 'userswp'); ?> |
|
123
|
|
- </div> |
|
124
|
|
- <a id="uwp-fieldset" |
|
125
|
|
- class="uwp-draggable-form-items uwp-fieldset" |
|
126
|
|
- href="javascript:void(0);" |
|
127
|
|
- data-field-custom-type="" |
|
128
|
|
- data-field-type="fieldset" |
|
129
|
|
- data-field-type-key="fieldset"> |
|
236
|
+ public function display_before_available_fields( $tab = '' ) { |
|
237
|
+ global $wpdb; |
|
130
|
238
|
|
|
131
|
|
- <i class="fas fa-long-arrow-alt-left " aria-hidden="true"></i> |
|
132
|
|
- <i class="fas fa-long-arrow-alt-right " aria-hidden="true"></i> |
|
133
|
|
- <?php _e('Fieldset (section separator)', 'userswp'); ?> |
|
134
|
|
- </a> |
|
135
|
|
- </li> |
|
136
|
|
- </ul> |
|
239
|
+ if ( empty( $tab ) || $tab == 'account' ) { |
|
240
|
+ $form_type = 'account'; |
|
241
|
+ $type = 'predefined'; |
|
242
|
+ ?> |
|
243
|
+ <h3 class="h6 text-muted"> |
|
244
|
+ <span> |
|
245
|
+ <?php |
|
246
|
+ echo apply_filters( 'uwp_form_builder_available_fields_head', __( 'Existing Fields', 'userswp' ), $form_type ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
137
|
247
|
|
|
138
|
|
- <?php |
|
139
|
|
- } |
|
248
|
+ $note = sprintf( __( 'Click on field to add it to the form. Existing fields are most used fields in all other forms.', 'userswp' ), $form_type ); |
|
249
|
+ $note_text = apply_filters( 'uwp_form_builder_existing_fields_note', $note, $form_type ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
250
|
+ echo uwp_help_tip( $note_text ); |
|
251
|
+ ?> |
|
252
|
+ </span> |
|
253
|
+ </h3> |
|
140
|
254
|
|
|
141
|
|
- if (!empty($fields)) { |
|
142
|
|
- ?> |
|
143
|
|
- <ul> |
|
144
|
|
- <?php |
|
145
|
|
- foreach ($fields as $id => $field) { |
|
146
|
|
- ?> |
|
147
|
|
- <li class="uwp-tooltip-wrap"> |
|
148
|
|
- <?php |
|
149
|
|
- if (isset($field['description']) && $field['description']) { |
|
150
|
|
- echo '<div class="uwp-tooltip">' . $field['description'] . '</div>'; |
|
151
|
|
- } ?> |
|
255
|
+ <div class="inside mb-4"> |
|
256
|
+ <div id="uwp-form-builder-tab-existing" class="uwp-tabs-panel"> |
|
257
|
+ <input type="hidden" name="form_type" id="form_type" value="<?php echo esc_attr( $form_type ); ?>"/> |
|
258
|
+ <input type="hidden" name="manage_field_type" class="manage_field_type" value="custom_fields"> |
|
259
|
+ <ul class="corex uwp-tabs-selected uwp_form_extras row row-cols-2 px-2"> |
|
260
|
+ <?php |
|
261
|
+ $form_id = self::get_form_id(); |
|
262
|
+ $table_name = uwp_get_table_prefix() . 'uwp_form_fields'; |
|
263
|
+ $existing_fields = $wpdb->get_results( 'select htmlvar_name from ' . $table_name . " where form_type ='" . $form_type . "' AND form_id = " . $form_id ); |
|
152
|
264
|
|
|
153
|
|
- <a id="uwp-<?php echo $id; ?>" |
|
154
|
|
- data-field-custom-type="<?php echo $type; ?>" |
|
155
|
|
- data-field-type-key="<?php echo $id; ?>" |
|
156
|
|
- data-field-type="<?php echo $field['field_type']; ?>" |
|
157
|
|
- class="uwp-draggable-form-items <?php echo $field['class']; ?>" |
|
158
|
|
- href="javascript:void(0);"> |
|
265
|
+ $existing_field_ids = array(); |
|
266
|
+ if ( ! empty( $existing_fields ) ) { |
|
267
|
+ foreach ( $existing_fields as $existing_field ) { |
|
268
|
+ $existing_field_ids[] = $existing_field->htmlvar_name; |
|
269
|
+ } |
|
270
|
+ } |
|
159
|
271
|
|
|
160
|
|
- <?php if (isset($field['icon']) && strpos($field['icon'], ' fa-') !== false) { |
|
161
|
|
- echo '<i class="' . $field['icon'] . '" aria-hidden="true"></i>'; |
|
162
|
|
- } elseif (isset($field['icon']) && $field['icon']) { |
|
163
|
|
- echo '<b style="background-image: url("' . $field['icon'] . '")"></b>'; |
|
164
|
|
- } else { |
|
165
|
|
- echo '<i class="fas fa-cog" aria-hidden="true"></i>'; |
|
166
|
|
- } ?> |
|
167
|
|
- <?php echo $field['name']; ?> |
|
168
|
|
- </a> |
|
169
|
|
- </li> |
|
170
|
|
- <?php |
|
171
|
|
- } |
|
172
|
|
- } else { |
|
173
|
|
- _e('There are no custom fields here yet.', 'userswp'); |
|
174
|
|
- } |
|
175
|
|
- ?> |
|
176
|
|
- </ul> |
|
272
|
+ $fields = $this->get_form_existing_fields( $form_type, 'array' ); |
|
177
|
273
|
|
|
178
|
|
- <?php |
|
274
|
+ if ( ! empty( $fields ) ) { |
|
275
|
+ foreach ( $fields as $id => $field ) { |
|
276
|
+ $display = ''; |
|
277
|
+ if ( in_array( $field['htmlvar_name'], $existing_field_ids ) ) { |
|
278
|
+ $display = 'display:none;'; |
|
279
|
+ } |
|
179
|
280
|
|
|
180
|
|
- } |
|
281
|
+ $style = 'style="' . $display . '"'; |
|
282
|
+ ?> |
|
283
|
+ <li class="uwp-tooltip-wrap col px-1"<?php echo ( $display ? ' style="' . esc_attr( $display ) . '"' : '' ); ?>> |
|
284
|
+ <a id="uwp-<?php echo esc_attr( $field['htmlvar_name'] ); ?>" |
|
285
|
+ data-field-custom-type="<?php echo esc_attr( $type ); ?>" |
|
286
|
+ data-field-type-key="<?php echo esc_attr( $field['htmlvar_name'] ); ?>" |
|
287
|
+ data-field-type="<?php echo esc_attr( $field['field_type'] ); ?>" |
|
288
|
+ class="uwp-draggable-form-itemsx btn btn-sm d-block m-0 btn-outline-gray text-dark text-start" |
|
289
|
+ href="javascript:void(0);"> |
|
181
|
290
|
|
|
182
|
|
- public function uwp_form_fields_predefined($type = '') { |
|
183
|
|
- $custom_fields = array(); |
|
291
|
+ <?php |
|
292
|
+ if ( isset( $field['field_icon'] ) && strpos( $field['field_icon'], ' fa-' ) !== false ) { |
|
293
|
+ echo '<i class="' . esc_attr( $field['field_icon'] ) . '" aria-hidden="true"></i>'; |
|
294
|
+ } elseif ( isset( $field['field_icon'] ) && $field['field_icon'] ) { |
|
295
|
+ echo '<b style="background-image: url("' . esc_url( $field['field_icon'] ) . '")"></b>'; |
|
296
|
+ } else { |
|
297
|
+ echo '<i class="fas fa-cog" aria-hidden="true"></i>'; |
|
298
|
+ } |
|
184
|
299
|
|
|
185
|
|
- |
|
300
|
+ echo ' ' . esc_attr( $field['site_title'] ); |
|
186
|
301
|
|
|
187
|
|
- // Country |
|
188
|
|
- $custom_fields['country'] = array( // The key value should be unique and not contain any spaces. |
|
189
|
|
- 'field_type' => 'select', |
|
190
|
|
- 'class' => 'uwp-country', |
|
191
|
|
- 'icon' => 'fas fa-map-marker-alt', |
|
192
|
|
- 'name' => __('Country', 'userswp'), |
|
193
|
|
- 'description' => __('Adds a input for Country field.', 'userswp'), |
|
194
|
|
- 'defaults' => array( |
|
195
|
|
- 'admin_title' => 'Country', |
|
196
|
|
- 'site_title' => 'Country', |
|
197
|
|
- 'htmlvar_name' => 'country', |
|
198
|
|
- 'is_active' => 1, |
|
199
|
|
- 'default_value' => '', |
|
200
|
|
- 'is_required' => 0, |
|
201
|
|
- 'option_values' => '', |
|
202
|
|
- 'required_msg' => '', |
|
203
|
|
- 'field_icon' => 'fas fa-map-marker-alt', |
|
204
|
|
- 'css_class' => '' |
|
205
|
|
- ) |
|
206
|
|
- ); |
|
302
|
+ if ( isset( $field['help_text'] ) && $field['help_text'] ) { |
|
303
|
+ echo uwp_help_tip( $field['help_text'] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
304
|
+ } |
|
305
|
+ ?> |
|
306
|
+ </a> |
|
307
|
+ </li> |
|
308
|
+ <?php |
|
309
|
+ } |
|
310
|
+ } |
|
311
|
+ ?> |
|
312
|
+ </ul> |
|
313
|
+ </div> |
|
314
|
+ </div> |
|
315
|
+ <?php |
|
316
|
+ } |
|
317
|
+ } |
|
207
|
318
|
|
|
208
|
|
- // Gender |
|
209
|
|
- $custom_fields['gender'] = array( // The key value should be unique and not contain any spaces. |
|
210
|
|
- 'field_type' => 'select', |
|
211
|
|
- 'class' => 'uwp-gender', |
|
212
|
|
- 'icon' => 'fas fa-user', |
|
213
|
|
- 'name' => __('Gender', 'userswp'), |
|
214
|
|
- 'description' => __('Adds a input for Gender field.', 'userswp'), |
|
215
|
|
- 'defaults' => array( |
|
216
|
|
- 'admin_title' => 'Gender', |
|
217
|
|
- 'site_title' => 'Gender', |
|
218
|
|
- 'htmlvar_name' => 'gender', |
|
219
|
|
- 'is_active' => 1, |
|
220
|
|
- 'default_value' => '', |
|
221
|
|
- 'is_required' => 0, |
|
222
|
|
- 'option_values' => __('Select Gender/,Male,Female,Other', 'userswp'), |
|
223
|
|
- 'required_msg' => '', |
|
224
|
|
- 'field_icon' => 'fas fa-user', |
|
225
|
|
- 'css_class' => '' |
|
226
|
|
- ) |
|
227
|
|
- ); |
|
319
|
+ public function get_form_existing_fields( $type = '', $output = '' ) { |
|
228
|
320
|
|
|
229
|
|
- // Mobile |
|
230
|
|
- $custom_fields['mobile'] = array( // The key value should be unique and not contain any spaces. |
|
231
|
|
- 'field_type' => 'phone', |
|
232
|
|
- 'class' => 'uwp-mobile', |
|
233
|
|
- 'icon' => 'fas fa-mobile-alt', |
|
234
|
|
- 'name' => __('Mobile', 'userswp'), |
|
235
|
|
- 'description' => __('Adds a input for Mobile field.', 'userswp'), |
|
236
|
|
- 'defaults' => array( |
|
237
|
|
- 'admin_title' => 'Mobile', |
|
238
|
|
- 'site_title' => 'Mobile', |
|
239
|
|
- 'htmlvar_name' => 'mobile', |
|
240
|
|
- 'is_active' => 1, |
|
241
|
|
- 'default_value' => '', |
|
242
|
|
- 'is_required' => 0, |
|
243
|
|
- 'required_msg' => '', |
|
244
|
|
- 'field_icon' => 'fas fa-mobile-alt', |
|
245
|
|
- 'css_class' => '' |
|
246
|
|
- ) |
|
247
|
|
- ); |
|
248
|
|
- |
|
321
|
+ global $wpdb; |
|
322
|
+ $custom_fields = array(); |
|
323
|
+ $table_name = uwp_get_table_prefix() . 'uwp_form_fields'; |
|
324
|
+ $register_forms = uwp_get_option( 'multiple_registration_forms' ); |
|
325
|
+ if ( 'array' == $output ) { |
|
326
|
+ $output = ARRAY_A; |
|
327
|
+ } else { |
|
328
|
+ $output = OBJECT; |
|
329
|
+ } |
|
330
|
+ if ( ! empty( $register_forms ) && is_array( $register_forms ) ) { |
|
331
|
+ foreach ( $register_forms as $key => $register_form ) { |
|
332
|
+ $form_ids[] = (int) $register_form['id']; |
|
333
|
+ } |
|
249
|
334
|
|
|
250
|
|
- return apply_filters('uwp_form_fields_predefined', $custom_fields, $type); |
|
251
|
|
- } |
|
335
|
+ if ( in_array( 1, $form_ids ) ) { |
|
336
|
+ $form_ids[] = 0; |
|
337
|
+ } |
|
252
|
338
|
|
|
253
|
|
- public function uwp_form_fields_custom($type = '') { |
|
254
|
|
- $custom_fields = array(); |
|
255
|
|
- return apply_filters('uwp_form_fields_custom', $custom_fields, $type); |
|
256
|
|
- } |
|
339
|
+ if ( isset( $form_ids ) && count( $form_ids ) > 0 ) { |
|
340
|
+ $form_ids_placeholder = array_fill( 0, count( $form_ids ), '%s' ); |
|
341
|
+ $form_ids_placeholder = implode( ', ', $form_ids_placeholder ); |
|
342
|
+ $query = 'SELECT * FROM ' . $table_name . " WHERE form_type = 'account' AND form_id IN (" . $form_ids_placeholder . ') ORDER BY sort_order ASC'; |
|
343
|
+ $custom_fields = $wpdb->get_results( $wpdb->prepare( $query, $form_ids ), $output ); |
|
344
|
+ } |
|
345
|
+ } |
|
257
|
346
|
|
|
258
|
|
- public function uwp_form_fields($type = '') { |
|
347
|
+ $custom_fields = uwp_get_unique_custom_fields( $custom_fields ); |
|
259
|
348
|
|
|
260
|
|
- $custom_fields = array( |
|
261
|
|
- 'text' => array( |
|
262
|
|
- 'field_type' => 'text', |
|
263
|
|
- 'class' => 'uwp-text', |
|
264
|
|
- 'icon' => 'fas fa-minus', |
|
265
|
|
- 'name' => __('Text', 'userswp'), |
|
266
|
|
- 'description' => __('Add any sort of text field, text or numbers', 'userswp') |
|
267
|
|
- ), |
|
268
|
|
- 'datepicker' => array( |
|
269
|
|
- 'field_type' => 'datepicker', |
|
270
|
|
- 'class' => 'uwp-datepicker', |
|
271
|
|
- 'icon' => 'fas fa-calendar-alt', |
|
272
|
|
- 'name' => __('Date', 'userswp'), |
|
273
|
|
- 'description' => __('Adds a date picker.', 'userswp') |
|
274
|
|
- ), |
|
275
|
|
- 'textarea' => array( |
|
276
|
|
- 'field_type' => 'textarea', |
|
277
|
|
- 'class' => 'uwp-textarea', |
|
278
|
|
- 'icon' => 'fas fa-bars', |
|
279
|
|
- 'name' => __('Textarea', 'userswp'), |
|
280
|
|
- 'description' => __('Adds a textarea', 'userswp') |
|
281
|
|
- ), |
|
282
|
|
- 'time' => array( |
|
283
|
|
- 'field_type' => 'time', |
|
284
|
|
- 'class' => 'uwp-time', |
|
285
|
|
- 'icon' => 'far fa-clock', |
|
286
|
|
- 'name' => __('Time', 'userswp'), |
|
287
|
|
- 'description' => __('Adds a time picker', 'userswp') |
|
288
|
|
- ), |
|
289
|
|
- 'checkbox' => array( |
|
290
|
|
- 'field_type' => 'checkbox', |
|
291
|
|
- 'class' => 'uwp-checkbox', |
|
292
|
|
- 'icon' => 'far fa-check-square', |
|
293
|
|
- 'name' => __('Checkbox', 'userswp'), |
|
294
|
|
- 'description' => __('Adds a checkbox', 'userswp') |
|
295
|
|
- ), |
|
296
|
|
- 'phone' => array( |
|
297
|
|
- 'field_type' => 'phone', |
|
298
|
|
- 'class' => 'uwp-phone', |
|
299
|
|
- 'icon' => 'fas fa-phone', |
|
300
|
|
- 'name' => __('Phone', 'userswp'), |
|
301
|
|
- 'description' => __('Adds a phone input', 'userswp') |
|
302
|
|
- ), |
|
303
|
|
- 'radio' => array( |
|
304
|
|
- 'field_type' => 'radio', |
|
305
|
|
- 'class' => 'uwp-radio', |
|
306
|
|
- 'icon' => 'far fa-dot-circle', |
|
307
|
|
- 'name' => __('Radio', 'userswp'), |
|
308
|
|
- 'description' => __('Adds a radio input', 'userswp') |
|
309
|
|
- ), |
|
310
|
|
- 'email' => array( |
|
311
|
|
- 'field_type' => 'email', |
|
312
|
|
- 'class' => 'uwp-email', |
|
313
|
|
- 'icon' => 'far fa-envelope', |
|
314
|
|
- 'name' => __('Email', 'userswp'), |
|
315
|
|
- 'description' => __('Adds a email input', 'userswp') |
|
316
|
|
- ), |
|
317
|
|
- 'select' => array( |
|
318
|
|
- 'field_type' => 'select', |
|
319
|
|
- 'class' => 'uwp-select', |
|
320
|
|
- 'icon' => 'far fa-caret-square-down', |
|
321
|
|
- 'name' => __('Select', 'userswp'), |
|
322
|
|
- 'description' => __('Adds a select input', 'userswp') |
|
323
|
|
- ), |
|
324
|
|
- 'multiselect' => array( |
|
325
|
|
- 'field_type' => 'multiselect', |
|
326
|
|
- 'class' => 'uwp-multiselect', |
|
327
|
|
- 'icon' => 'far fa-caret-square-down', |
|
328
|
|
- 'name' => __('Multi Select', 'userswp'), |
|
329
|
|
- 'description' => __('Adds a multiselect input', 'userswp') |
|
330
|
|
- ), |
|
331
|
|
- 'url' => array( |
|
332
|
|
- 'field_type' => 'url', |
|
333
|
|
- 'class' => 'uwp-url', |
|
334
|
|
- 'icon' => 'fas fa-link', |
|
335
|
|
- 'name' => __('URL', 'userswp'), |
|
336
|
|
- 'description' => __('Adds a url input', 'userswp') |
|
337
|
|
- ), |
|
338
|
|
- 'file' => array( |
|
339
|
|
- 'field_type' => 'file', |
|
340
|
|
- 'class' => 'uwp-file', |
|
341
|
|
- 'icon' => 'fas fa-file', |
|
342
|
|
- 'name' => __('File Upload', 'userswp'), |
|
343
|
|
- 'description' => __('Adds a file input', 'userswp') |
|
344
|
|
- ) |
|
345
|
|
- ); |
|
349
|
+ return apply_filters( 'uwp_form_existing_fields', $custom_fields, $type ); |
|
350
|
+ } |
|
346
|
351
|
|
|
347
|
|
- return apply_filters('uwp_form_fields', $custom_fields, $type); |
|
348
|
|
- } |
|
352
|
+ /** |
|
353
|
+ * Render the multiple registration form. |
|
354
|
+ * |
|
355
|
+ * @param string $tab Current tab. |
|
356
|
+ */ |
|
357
|
+ public function multiple_registration_form( $tab = '' ) { |
|
358
|
+ $default_tabs = array( 'account', 'register', 'profile-tabs' ); |
|
349
|
359
|
|
|
360
|
+ /** |
|
361
|
+ * Filter the tabs that should show the multiple registration form. |
|
362
|
+ * |
|
363
|
+ * @param array $default_tabs Default tabs. |
|
364
|
+ */ |
|
365
|
+ $tabs = apply_filters( 'uwp_multiple_registration_form_tabs', $default_tabs ); |
|
350
|
366
|
|
|
351
|
|
- public function uwp_manage_available_fields_predefined($form_type) { |
|
352
|
|
- switch ($form_type) { |
|
353
|
|
- case 'account': |
|
354
|
|
- $this->uwp_custom_available_fields('predefined', $form_type); |
|
355
|
|
- break; |
|
367
|
+ if ( ! in_array( $tab, $tabs, true ) ) { |
|
368
|
+ return; |
|
356
|
369
|
} |
|
357
|
|
- } |
|
358
|
370
|
|
|
359
|
|
- public function uwp_manage_available_fields_custom($form_type) { |
|
360
|
|
- switch ($form_type) { |
|
361
|
|
- case 'account': |
|
362
|
|
- $this->uwp_custom_available_fields('custom', $form_type); |
|
363
|
|
- break; |
|
364
|
|
- } |
|
365
|
|
- } |
|
371
|
+ $register_forms = (array) uwp_get_option( 'multiple_registration_forms', array() ); |
|
372
|
+ $current_form_id = self::get_form_id(); |
|
373
|
+ ?> |
|
374
|
+ <div class="row"> |
|
375
|
+ <div class="col-12"> |
|
376
|
+ <div class="card border-0 shadow-sm mb-3 px-0 mw-100"> |
|
377
|
+ <div class="card-body"> |
|
378
|
+ <input type="hidden" name="manage_field_form_id" class="manage_field_form_id" id="manage_field_form_id" value="<?php echo absint( $current_form_id ); ?>"> |
|
379
|
+ <?php |
|
380
|
+ if ( ! empty( $register_forms ) && is_array( $register_forms ) && count( $register_forms ) > 1 ) { |
|
381
|
+ $register_tab = admin_url( "admin.php?page=uwp_form_builder&tab={$tab}" ); |
|
366
|
382
|
|
|
367
|
|
- public function uwp_manage_available_fields($form_type) { |
|
368
|
|
- switch ($form_type) { |
|
369
|
|
- case 'account': |
|
370
|
|
- $this->uwp_custom_available_fields('', $form_type); |
|
371
|
|
- break; |
|
372
|
|
- } |
|
373
|
|
- } |
|
383
|
+ ?> |
|
384
|
+ <div class="d-flex align-items-center"> |
|
385
|
+ <label class="form-label h1"> |
|
386
|
+ <i class="fas fa-user me-3 iconbox border-0 fill rounded-circle transition-all btn-translucent-info iconsmallmedium"></i> |
|
387
|
+ <?php esc_html_e( 'Select user type', 'userswp' ); ?> |
|
388
|
+ </label> |
|
389
|
+ <div class="ms-3 col-6"> |
|
390
|
+ <select onChange="window.location.replace(jQuery(this).val());" name="form_select" id="multiple_registration_select" class="form-select form-select-lgx"> |
|
391
|
+ <?php |
|
392
|
+ foreach ( $register_forms as $form ) : |
|
393
|
+ $form_id = ! empty( $form['id'] ) ? $form['id'] : ''; |
|
394
|
+ $form_title = ! empty( $form['title'] ) ? sanitize_title_with_dashes( $form['title'] ) : ''; |
|
395
|
+ $option_text = sprintf( |
|
396
|
+ /* translators: %1$s: Form title, %2$s: Form ID */ |
|
397
|
+ esc_html__( '%1$s - #%2$s', 'userswp' ), |
|
398
|
+ $form_title, |
|
399
|
+ $form_id |
|
400
|
+ ); |
|
401
|
+ $option_value = esc_url( add_query_arg( 'form', $form_id, $register_tab ) ); |
|
402
|
+ ?> |
|
403
|
+ <option <?php selected( $current_form_id, $form_id ); ?> value="<?php echo esc_attr( $option_value ); ?>"> |
|
404
|
+ <?php echo esc_html( $option_text ); ?> |
|
405
|
+ </option> |
|
406
|
+ <?php endforeach; ?> |
|
407
|
+ </select> |
|
408
|
+ </div> |
|
409
|
+ </div> |
|
410
|
+ <?php |
|
411
|
+ } else { |
|
412
|
+ $alert_content = wp_kses( |
|
413
|
+ sprintf( |
|
414
|
+ /* translators: %1$s: Alert message, %2$s: URL to add user type, %3$s: Add User Type button text */ |
|
415
|
+ '%1$s <a href="%2$s" class="btn btn-primary btn-sm text-decoration-none ms-auto" role="button">%3$s</a>', |
|
416
|
+ esc_html__( 'Add different user types to create custom registration forms with unique roles and redirects.', 'userswp' ), |
|
417
|
+ esc_url( admin_url( 'admin.php?page=uwp_user_types&form=add' ) ), |
|
418
|
+ esc_html__( 'Add User Type', 'userswp' ) |
|
419
|
+ ), |
|
420
|
+ array( |
|
421
|
+ 'a' => array( |
|
422
|
+ 'href' => array(), |
|
423
|
+ 'class' => array(), |
|
424
|
+ 'role' => array(), |
|
425
|
+ ), |
|
426
|
+ ) |
|
427
|
+ ); |
|
374
|
428
|
|
|
375
|
|
- public function uwp_manage_selected_fields($form_type) { |
|
376
|
|
- switch ($form_type) { |
|
377
|
|
- case 'account': |
|
378
|
|
- $this->uwp_custom_selected_fields($form_type); |
|
379
|
|
- break; |
|
380
|
|
- } |
|
381
|
|
- } |
|
429
|
+ aui()->alert( |
|
430
|
+ array( |
|
431
|
+ 'type' => 'dark', |
|
432
|
+ 'class' => 'd-flex align-items-center mb-0', |
|
433
|
+ 'content' => $alert_content, |
|
434
|
+ 'dismissible' => false, |
|
435
|
+ ), |
|
436
|
+ true |
|
437
|
+ ); |
|
438
|
+ } |
|
439
|
+ ?> |
|
440
|
+ </div> |
|
441
|
+ </div> |
|
442
|
+ </div> |
|
443
|
+ </div> |
|
444
|
+ <?php |
|
445
|
+ } |
|
382
|
446
|
|
|
383
|
|
- function uwp_custom_selected_fields($form_type) |
|
384
|
|
- { |
|
447
|
+ public function manage_available_fields_predefined( $form_type ) { |
|
448
|
+ switch ( $form_type ) { |
|
449
|
+ case 'account': |
|
450
|
+ $this->custom_available_fields( 'predefined', $form_type ); |
|
451
|
+ break; |
|
452
|
+ } |
|
453
|
+ } |
|
385
|
454
|
|
|
386
|
|
- global $wpdb; |
|
387
|
|
- $table_name = uwp_get_table_prefix() . 'uwp_form_fields'; |
|
388
|
|
- ?> |
|
389
|
|
- <input type="hidden" name="form_type" id="form_type" value="<?php echo $form_type; ?>"/> |
|
455
|
+ public function custom_available_fields( $type, $form_type ) { |
|
456
|
+ ?> |
|
457
|
+ <input type="hidden" name="form_type" id="form_type" value="<?php echo esc_attr( $form_type ); ?>"/> |
|
390
|
458
|
<input type="hidden" name="manage_field_type" class="manage_field_type" value="custom_fields"> |
|
391
|
|
- <ul class="core"> |
|
392
|
|
- <?php |
|
393
|
|
- $fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . $table_name . " WHERE form_type = %s ORDER BY sort_order ASC", array($form_type))); |
|
459
|
+ <?php |
|
460
|
+ if ( $type == 'predefined' ) { |
|
461
|
+ $fields = $this->form_fields_predefined( $form_type ); |
|
462
|
+ } elseif ( $type == 'custom' ) { |
|
463
|
+ $fields = $this->form_fields_custom( $form_type ); |
|
464
|
+ } else { |
|
465
|
+ $fields = $this->form_fields( $form_type ); |
|
466
|
+ ?> |
|
467
|
+ <ul class="row row-cols-1 px-2 mb-0"> |
|
468
|
+ <li class="uwp-tooltip-wrapx col px-1"> |
|
469
|
+ <a id="uwp-fieldset" |
|
470
|
+ class="uwp-draggable-form-itemsx uwp-fieldset btn btn-sm d-block m-0 btn-outline-gray text-dark text-start" |
|
471
|
+ href="javascript:void(0);" |
|
472
|
+ data-field-custom-type="" |
|
473
|
+ data-field-type="fieldset" |
|
474
|
+ data-field-type-key="fieldset"> |
|
475
|
+ <i class="fas fa-long-arrow-alt-left " aria-hidden="true"></i> |
|
476
|
+ <i class="fas fa-long-arrow-alt-right " aria-hidden="true"></i> |
|
477
|
+ <?php |
|
478
|
+ esc_html_e( 'Fieldset (section separator)', 'userswp' ); |
|
479
|
+ echo uwp_help_tip( __( 'This adds a section separator with a title.', 'userswp' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
480
|
+ ?> |
|
481
|
+ </a> |
|
482
|
+ </li> |
|
483
|
+ </ul> |
|
394
|
484
|
|
|
395
|
|
- if (!empty($fields)) { |
|
396
|
|
- foreach ($fields as $field) { |
|
397
|
|
- //$result_str = $field->id; |
|
398
|
|
- $result_str = $field; |
|
399
|
|
- $field_type = $field->field_type; |
|
400
|
|
- $field_type_key = $field->field_type_key; |
|
401
|
|
- $field_ins_upd = 'display'; |
|
485
|
+ <?php |
|
486
|
+ } |
|
402
|
487
|
|
|
403
|
|
- $this->uwp_form_field_adminhtml($field_type, $result_str, $field_ins_upd, $field_type_key); |
|
404
|
|
- } |
|
405
|
|
- } |
|
406
|
|
- ?></ul> |
|
407
|
|
- <?php |
|
488
|
+ if ( ! empty( $fields ) ) { |
|
489
|
+ ?> |
|
490
|
+ <ul class="row row-cols-2 px-2 mb-0"> |
|
491
|
+ <?php |
|
492
|
+ foreach ( $fields as $id => $field ) { |
|
493
|
+ ?> |
|
494
|
+ <li class="uwp-tooltip-wrapx col px-1"> |
|
495
|
+ <a id="uwp-<?php echo esc_attr( $id ); ?>" |
|
496
|
+ data-field-custom-type="<?php echo esc_attr( $type ); ?>" |
|
497
|
+ data-field-type-key="<?php echo esc_attr( $id ); ?>" |
|
498
|
+ data-field-type="<?php echo esc_attr( $field['field_type'] ); ?>" |
|
499
|
+ class="uwp-draggable-form-itemsx btn btn-sm d-block m-0 btn-outline-gray text-dark text-start" |
|
500
|
+ href="javascript:void(0);"> |
|
408
|
501
|
|
|
409
|
|
- } |
|
502
|
+ <?php |
|
503
|
+ if ( isset( $field['field_icon'] ) && strpos( $field['field_icon'], ' fa-' ) !== false ) { |
|
504
|
+ echo '<i class="' . esc_attr( $field['field_icon'] ) . '" aria-hidden="true"></i>'; |
|
505
|
+ } elseif ( isset( $field['field_icon'] ) && $field['field_icon'] ) { |
|
506
|
+ echo '<b style="background-image: url("' . esc_url( $field['field_icon'] ) . '")"></b>'; |
|
507
|
+ } else { |
|
508
|
+ echo '<i class="fas fa-cog" aria-hidden="true"></i>'; |
|
509
|
+ } |
|
410
|
510
|
|
|
411
|
|
- /** |
|
412
|
|
- * @param $field_info |
|
413
|
|
- * @param $field_type |
|
414
|
|
- * @param string $field_type_key |
|
415
|
|
- * @param string $field_ins_upd |
|
416
|
|
- * @param $result_str |
|
417
|
|
- * @param bool $form_type |
|
418
|
|
- */ |
|
419
|
|
- public function uwp_admin_form_field_html($field_info, $field_type, $field_type_key, $field_ins_upd, $result_str, $form_type = false) { |
|
511
|
+ echo ' ' . esc_attr( $field['site_title'] ); |
|
420
|
512
|
|
|
421
|
|
- if (!$form_type) { |
|
422
|
|
- if (!isset($field_info->form_type)) { |
|
423
|
|
- $form_type = sanitize_text_field($_REQUEST['tab']); |
|
424
|
|
- } else { |
|
425
|
|
- $form_type = $field_info->form_type; |
|
426
|
|
- } |
|
427
|
|
- } |
|
513
|
+ if ( isset( $field['help_text'] ) && $field['help_text'] ) { |
|
514
|
+ echo uwp_help_tip( $field['help_text'] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
515
|
+ } |
|
516
|
+ ?> |
|
517
|
+ </a> |
|
518
|
+ </li> |
|
519
|
+ <?php |
|
520
|
+ } |
|
521
|
+ } else { |
|
522
|
+ esc_html_e( 'There are no custom fields here yet.', 'userswp' ); |
|
523
|
+ } |
|
524
|
+ ?> |
|
525
|
+ </ul> |
|
428
|
526
|
|
|
429
|
|
- $cf_arr1 = $this->uwp_form_fields($form_type); |
|
430
|
|
- $cf_arr2 = $this->uwp_form_fields_predefined($form_type); |
|
431
|
|
- $cf_arr3 = $this->uwp_form_fields_custom($form_type); |
|
527
|
+ <?php |
|
528
|
+ } |
|
432
|
529
|
|
|
433
|
|
- $cf_arr = $cf_arr1 + $cf_arr2 + $cf_arr3; // this way defaults can't be overwritten |
|
530
|
+ public function form_fields_predefined( $type = '' ) { |
|
531
|
+ $custom_fields = array(); |
|
434
|
532
|
|
|
435
|
|
- $cf = (isset($cf_arr[$field_type_key])) ? $cf_arr[$field_type_key] : ''; |
|
533
|
+ // Country |
|
534
|
+ $custom_fields['uwp_country'] = array( |
|
535
|
+ 'field_type' => 'select', |
|
536
|
+ 'class' => 'uwp-country', |
|
537
|
+ 'field_icon' => 'fas fa-map-marker-alt', |
|
538
|
+ 'site_title' => __( 'Country', 'userswp' ), |
|
539
|
+ 'help_text' => __( 'Adds a input for Country field.', 'userswp' ), |
|
540
|
+ 'defaults' => array( |
|
541
|
+ 'admin_title' => 'Country', |
|
542
|
+ 'site_title' => 'Country', |
|
543
|
+ 'htmlvar_name' => 'uwp_country', |
|
544
|
+ 'is_active' => 1, |
|
545
|
+ 'default_value' => '', |
|
546
|
+ 'is_required' => 0, |
|
547
|
+ 'option_values' => '', |
|
548
|
+ 'required_msg' => '', |
|
549
|
+ 'field_icon' => 'fas fa-map-marker-alt', |
|
550
|
+ 'css_class' => '', |
|
551
|
+ ), |
|
552
|
+ ); |
|
436
|
553
|
|
|
437
|
|
- $field_info = stripslashes_deep($field_info); // strip slashes from labels |
|
554
|
+ // Gender |
|
555
|
+ $custom_fields['gender'] = array( |
|
556
|
+ 'field_type' => 'select', |
|
557
|
+ 'class' => 'uwp-gender', |
|
558
|
+ 'field_icon' => 'fas fa-user', |
|
559
|
+ 'site_title' => __( 'Gender', 'userswp' ), |
|
560
|
+ 'help_text' => __( 'Adds a input for Gender field.', 'userswp' ), |
|
561
|
+ 'defaults' => array( |
|
562
|
+ 'admin_title' => 'Gender', |
|
563
|
+ 'site_title' => 'Gender', |
|
564
|
+ 'htmlvar_name' => 'gender', |
|
565
|
+ 'is_active' => 1, |
|
566
|
+ 'default_value' => '', |
|
567
|
+ 'is_required' => 0, |
|
568
|
+ 'option_values' => __( 'Male,Female,Other', 'userswp' ), |
|
569
|
+ 'required_msg' => '', |
|
570
|
+ 'field_icon' => 'fas fa-user', |
|
571
|
+ 'css_class' => '', |
|
572
|
+ ), |
|
573
|
+ ); |
|
438
|
574
|
|
|
439
|
|
- $field_site_title = ''; |
|
440
|
|
- if (isset($field_info->site_title)) |
|
441
|
|
- $field_site_title = $field_info->site_title; |
|
575
|
+ $custom_fields['dob'] = array( |
|
576
|
+ 'field_type' => 'datepicker', |
|
577
|
+ 'class' => 'uwp-dob', |
|
578
|
+ 'field_icon' => 'fas fa-birthday-cake', |
|
579
|
+ 'site_title' => __( 'Date of birth', 'userswp' ), |
|
580
|
+ 'help_text' => __( 'Adds a date input for users to enter their date of birth.', 'userswp' ), |
|
581
|
+ 'defaults' => array( |
|
582
|
+ 'data_type' => 'DATE', |
|
583
|
+ 'admin_title' => __( 'Date of birth', 'userswp' ), |
|
584
|
+ 'site_title' => __( 'Date of birth', 'userswp' ), |
|
585
|
+ 'form_label' => __( 'Enter your date of birth.', 'userswp' ), |
|
586
|
+ 'htmlvar_name' => 'dob', |
|
587
|
+ 'is_active' => true, |
|
588
|
+ 'for_admin_use' => false, |
|
589
|
+ 'default_value' => '', |
|
590
|
+ 'is_required' => false, |
|
591
|
+ 'validation_pattern' => '', |
|
592
|
+ 'validation_msg' => '', |
|
593
|
+ 'required_msg' => '', |
|
594
|
+ 'field_icon' => 'fas fa-birthday-cake', |
|
595
|
+ 'css_class' => '', |
|
596
|
+ 'extra_fields' => array( |
|
597
|
+ 'date_range' => 'c-100:c+0', |
|
598
|
+ ), |
|
599
|
+ ), |
|
600
|
+ ); |
|
442
|
601
|
|
|
443
|
|
- $default = isset($field_info->is_default) ? $field_info->is_default : ''; |
|
602
|
+ // Mobile |
|
603
|
+ $custom_fields['mobile'] = array( |
|
604
|
+ 'field_type' => 'phone', |
|
605
|
+ 'class' => 'uwp-mobile', |
|
606
|
+ 'field_icon' => 'fas fa-mobile-alt', |
|
607
|
+ 'site_title' => __( 'Mobile', 'userswp' ), |
|
608
|
+ 'help_text' => __( 'Adds a input for Mobile field.', 'userswp' ), |
|
609
|
+ 'defaults' => array( |
|
610
|
+ 'admin_title' => 'Mobile', |
|
611
|
+ 'site_title' => 'Mobile', |
|
612
|
+ 'htmlvar_name' => 'mobile', |
|
613
|
+ 'is_active' => 1, |
|
614
|
+ 'default_value' => '', |
|
615
|
+ 'is_required' => 0, |
|
616
|
+ 'required_msg' => '', |
|
617
|
+ 'field_icon' => 'fas fa-mobile-alt', |
|
618
|
+ 'css_class' => '', |
|
619
|
+ ), |
|
620
|
+ ); |
|
444
|
621
|
|
|
445
|
|
- $field_display = $field_type == 'address' && $field_info->htmlvar_name == 'post' ? 'style="display:none"' : ''; |
|
622
|
+ $custom_fields['register_gdpr'] = array( |
|
623
|
+ 'field_type' => 'checkbox', |
|
624
|
+ 'class' => 'uwp-register-gdpr', |
|
625
|
+ 'field_icon' => 'fas fa-file', |
|
626
|
+ 'site_title' => __( 'GDPR Policy Page', 'userswp' ), |
|
627
|
+ 'help_text' => __( 'Adds Register GDPR page.', 'userswp' ), |
|
628
|
+ 'defaults' => array( |
|
629
|
+ 'admin_title' => 'GDPR Policy', |
|
630
|
+ 'site_title' => 'GDPR Policy', |
|
631
|
+ 'form_label' => __( 'GDPR Policy', 'userswp' ), |
|
632
|
+ 'htmlvar_name' => 'register_gdpr', |
|
633
|
+ 'is_active' => 1, |
|
634
|
+ 'default_value' => '', |
|
635
|
+ 'is_required' => 1, |
|
636
|
+ 'required_msg' => '', |
|
637
|
+ 'field_icon' => 'fas fa-file', |
|
638
|
+ 'css_class' => 'btn-register-gdpr', |
|
639
|
+ ), |
|
640
|
+ ); |
|
446
|
641
|
|
|
447
|
|
- $radio_id = (isset($field_info->htmlvar_name)) ? $field_info->htmlvar_name : rand(5, 500); |
|
642
|
+ $custom_fields['register_tos'] = array( |
|
643
|
+ 'field_type' => 'checkbox', |
|
644
|
+ 'class' => 'uwp-register-tos', |
|
645
|
+ 'field_icon' => 'fas fa-file', |
|
646
|
+ 'site_title' => __( 'Terms & Conditions', 'userswp' ), |
|
647
|
+ 'help_text' => __( 'Adds Register TOS page.', 'userswp' ), |
|
648
|
+ 'help_text_tip' => __( 'This will show next to the checkbox, to add a link to the TOS page, use format: %%link_start%% View TOS %%link_end%%', 'userswp' ), |
|
649
|
+ 'defaults' => array( |
|
650
|
+ 'admin_title' => 'Terms & Conditions', |
|
651
|
+ 'site_title' => 'Terms & Conditions', |
|
652
|
+ 'form_label' => __( 'Terms & Conditions', 'userswp' ), |
|
653
|
+ 'htmlvar_name' => 'register_tos', |
|
654
|
+ 'is_active' => 1, |
|
655
|
+ 'default_value' => '', |
|
656
|
+ 'is_required' => 1, |
|
657
|
+ 'required_msg' => '', |
|
658
|
+ 'field_icon' => 'fas fa-file', |
|
659
|
+ 'css_class' => 'btn-register-tos', |
|
660
|
+ ), |
|
661
|
+ ); |
|
448
|
662
|
|
|
663
|
+ // Website |
|
664
|
+ $custom_fields['user_url'] = array( |
|
665
|
+ 'field_type' => 'url', |
|
666
|
+ 'class' => 'uwp-website', |
|
667
|
+ 'field_icon' => 'fas fa-link', |
|
668
|
+ 'site_title' => __( 'Website', 'userswp' ), |
|
669
|
+ 'help_text' => __( 'Let users enter their website url.', 'userswp' ), |
|
670
|
+ 'defaults' => array( |
|
671
|
+ 'admin_title' => 'Website', |
|
672
|
+ 'site_title' => 'Website', |
|
673
|
+ 'form_label' => __( 'Website', 'userswp' ), |
|
674
|
+ 'htmlvar_name' => 'user_url', |
|
675
|
+ 'is_active' => 1, |
|
676
|
+ 'default_value' => '', |
|
677
|
+ 'is_required' => 0, |
|
678
|
+ 'required_msg' => '', |
|
679
|
+ 'field_icon' => 'fas fa-link', |
|
680
|
+ 'css_class' => 'btn-website', |
|
681
|
+ ), |
|
682
|
+ ); |
|
449
|
683
|
|
|
450
|
|
- if (isset($cf['icon']) && strpos($cf['icon'], ' fa-') !== false) { |
|
451
|
|
- $field_icon = '<i class="' . $cf['icon'] . '" aria-hidden="true"></i>'; |
|
452
|
|
- }elseif (isset($cf['icon']) && $cf['icon']) { |
|
453
|
|
- $field_icon = '<b style="background-image: url("' . $cf['icon'] . '")"></b>'; |
|
454
|
|
- } else { |
|
455
|
|
- $field_icon = '<i class="fas fa-cog" aria-hidden="true"></i>'; |
|
456
|
|
- } |
|
684
|
+ // Facebook |
|
685
|
+ $custom_fields['facebook'] = array( |
|
686
|
+ 'field_type' => 'url', |
|
687
|
+ 'class' => 'uwp-facebook', |
|
688
|
+ 'field_icon' => 'fab fa-facebook-square', |
|
689
|
+ 'site_title' => __( 'Facebook', 'userswp' ), |
|
690
|
+ 'help_text' => __( 'Let users enter their facebook url.', 'userswp' ), |
|
691
|
+ 'defaults' => array( |
|
692
|
+ 'admin_title' => 'Facebook', |
|
693
|
+ 'site_title' => 'Facebook', |
|
694
|
+ 'form_label' => __( 'Facebook url', 'userswp' ), |
|
695
|
+ 'htmlvar_name' => 'facebook', |
|
696
|
+ 'is_active' => 1, |
|
697
|
+ 'default_value' => '', |
|
698
|
+ 'is_required' => 0, |
|
699
|
+ 'required_msg' => '', |
|
700
|
+ 'field_icon' => 'fab fa-facebook-f', |
|
701
|
+ 'css_class' => 'btn-facebook', |
|
702
|
+ ), |
|
703
|
+ ); |
|
457
|
704
|
|
|
458
|
|
- if (isset($cf['name']) && $cf['name']) { |
|
459
|
|
- $field_type_name = $cf['name']; |
|
460
|
|
- } else { |
|
461
|
|
- $field_type_name = $field_type; |
|
462
|
|
- } |
|
705
|
+ // Twitter |
|
706
|
+ $custom_fields['twitter'] = array( |
|
707
|
+ 'field_type' => 'url', |
|
708
|
+ 'class' => 'uwp-twitter', |
|
709
|
+ 'field_icon' => 'fab fa-twitter-square', |
|
710
|
+ 'site_title' => __( 'Twitter', 'userswp' ), |
|
711
|
+ 'help_text' => __( 'Let users enter their twitter url.', 'userswp' ), |
|
712
|
+ 'defaults' => array( |
|
713
|
+ 'admin_title' => 'Twitter', |
|
714
|
+ 'site_title' => 'Twitter', |
|
715
|
+ 'form_label' => __( 'Twitter url', 'userswp' ), |
|
716
|
+ 'htmlvar_name' => 'twitter', |
|
717
|
+ 'is_active' => 1, |
|
718
|
+ 'default_value' => '', |
|
719
|
+ 'is_required' => 0, |
|
720
|
+ 'required_msg' => '', |
|
721
|
+ 'field_icon' => 'fab fa-twitter', |
|
722
|
+ 'css_class' => 'btn-twitter', |
|
723
|
+ ), |
|
724
|
+ ); |
|
463
|
725
|
|
|
464
|
|
- ?> |
|
465
|
|
- <li class="text" id="licontainer_<?php echo $result_str; ?>"> |
|
466
|
|
- <div class="title title<?php echo $result_str; ?> uwp-fieldset" |
|
467
|
|
- title="<?php _e('Double Click to toggle and drag-drop to sort', 'userswp'); ?>" |
|
468
|
|
- ondblclick="uwp_show_hide('field_frm<?php echo $result_str; ?>')"> |
|
469
|
|
- <?php |
|
726
|
+ // Instagram |
|
727
|
+ $custom_fields['instagram'] = array( |
|
728
|
+ 'field_type' => 'url', |
|
729
|
+ 'class' => 'uwp-instagram', |
|
730
|
+ 'field_icon' => 'fab fa-instagram', |
|
731
|
+ 'site_title' => __( 'Instagram', 'userswp' ), |
|
732
|
+ 'help_text' => __( 'Let users enter their instagram url.', 'userswp' ), |
|
733
|
+ 'defaults' => array( |
|
734
|
+ 'admin_title' => 'Instagram', |
|
735
|
+ 'site_title' => 'Instagram', |
|
736
|
+ 'form_label' => __( 'Instagram url', 'userswp' ), |
|
737
|
+ 'htmlvar_name' => 'instagram', |
|
738
|
+ 'is_active' => 1, |
|
739
|
+ 'default_value' => '', |
|
740
|
+ 'is_required' => 0, |
|
741
|
+ 'required_msg' => '', |
|
742
|
+ 'field_icon' => 'fab fa-instagram', |
|
743
|
+ 'css_class' => 'btn-instagram', |
|
744
|
+ ), |
|
745
|
+ ); |
|
470
|
746
|
|
|
471
|
|
- $nonce = wp_create_nonce('custom_fields_' . $result_str); |
|
472
|
|
- ?> |
|
747
|
+ // Linkedin |
|
748
|
+ $custom_fields['linkedin'] = array( |
|
749
|
+ 'field_type' => 'url', |
|
750
|
+ 'class' => 'uwp-linkedin', |
|
751
|
+ 'field_icon' => 'fab fa-linkedin', |
|
752
|
+ 'site_title' => __( 'Linkedin', 'userswp' ), |
|
753
|
+ 'help_text' => __( 'Let users enter their linkedin url.', 'userswp' ), |
|
754
|
+ 'defaults' => array( |
|
755
|
+ 'admin_title' => 'Linkedin', |
|
756
|
+ 'site_title' => 'Linkedin', |
|
757
|
+ 'form_label' => __( 'Linkedin url', 'userswp' ), |
|
758
|
+ 'htmlvar_name' => 'linkedin', |
|
759
|
+ 'is_active' => 1, |
|
760
|
+ 'default_value' => '', |
|
761
|
+ 'is_required' => 0, |
|
762
|
+ 'required_msg' => '', |
|
763
|
+ 'field_icon' => 'fab fa-linkedin-in', |
|
764
|
+ 'css_class' => 'btn-linkedin', |
|
765
|
+ ), |
|
766
|
+ ); |
|
473
|
767
|
|
|
474
|
|
- <?php if ($default): ?> |
|
475
|
|
- <?php else: ?> |
|
476
|
|
- <div title="<?php _e('Click to remove field', 'userswp'); ?>" |
|
477
|
|
- onclick="delete_field('<?php echo $result_str; ?>', '<?php echo $nonce; ?>')" |
|
478
|
|
- class="handlediv close"><i class="fas fa-times" aria-hidden="true"></i></div> |
|
479
|
|
- <?php endif; |
|
480
|
|
- if ($field_type == 'fieldset') { |
|
481
|
|
- ?> |
|
482
|
|
- <i class="fas fa-long-arrow-alt-left " aria-hidden="true"></i> |
|
483
|
|
- <i class="fas fa-long-arrow-alt-right " aria-hidden="true"></i> |
|
484
|
|
- <b style="cursor:pointer;" |
|
485
|
|
- onclick="uwp_show_hide('field_frm<?php echo $result_str; ?>')"><?php echo uwp_ucwords(__('Fieldset:', 'userswp') . ' ' . $field_site_title); ?></b> |
|
486
|
|
- <?php |
|
487
|
|
- } else {echo $field_icon; |
|
488
|
|
- ?> |
|
489
|
|
- <b style="cursor:pointer;" |
|
490
|
|
- onclick="uwp_show_hide('field_frm<?php echo $result_str; ?>')"><?php echo uwp_ucwords(' ' . $field_site_title . ' (' . $field_type_name . ')'); ?></b> |
|
491
|
|
- <?php |
|
492
|
|
- } |
|
493
|
|
- ?> |
|
494
|
|
- </div> |
|
768
|
+ // Flickr |
|
769
|
+ $custom_fields['flickr'] = array( |
|
770
|
+ 'field_type' => 'url', |
|
771
|
+ 'class' => 'uwp-flickr', |
|
772
|
+ 'field_icon' => 'fab fa-flickr', |
|
773
|
+ 'site_title' => __( 'Flickr', 'userswp' ), |
|
774
|
+ 'help_text' => __( 'Let users enter their Flickr url.', 'userswp' ), |
|
775
|
+ 'defaults' => array( |
|
776
|
+ 'admin_title' => 'Flickr', |
|
777
|
+ 'site_title' => 'Flickr', |
|
778
|
+ 'form_label' => __( 'Flickr url', 'userswp' ), |
|
779
|
+ 'htmlvar_name' => 'flickr', |
|
780
|
+ 'is_active' => 1, |
|
781
|
+ 'default_value' => '', |
|
782
|
+ 'is_required' => 0, |
|
783
|
+ 'required_msg' => '', |
|
784
|
+ 'field_icon' => 'fab fa-flickr', |
|
785
|
+ 'css_class' => 'btn-flickr', |
|
786
|
+ ), |
|
787
|
+ ); |
|
495
|
788
|
|
|
496
|
|
- <form><!-- we need to wrap in a fom so we can use radio buttons with same name --> |
|
497
|
|
- <div id="field_frm<?php echo $result_str; ?>" class="field_frm" |
|
498
|
|
- style="display:<?php if ($field_ins_upd == 'submit') { |
|
499
|
|
- echo 'block;'; |
|
500
|
|
- } else { |
|
501
|
|
- echo 'none;'; |
|
502
|
|
- } ?>"> |
|
503
|
|
- <input type="hidden" name="_wpnonce" value="<?php echo esc_attr($nonce); ?>"/> |
|
504
|
|
- <input type="hidden" name="form_type" id="form_type" value="<?php echo $form_type; ?>"/> |
|
505
|
|
- <input type="hidden" name="field_type" id="field_type" value="<?php echo $field_type; ?>"/> |
|
506
|
|
- <input type="hidden" name="field_type_key" id="field_type_key" value="<?php echo $field_type_key; ?>"/> |
|
507
|
|
- <input type="hidden" name="field_id" id="field_id" value="<?php echo esc_attr($result_str); ?>"/> |
|
508
|
|
- <input type="hidden" name="is_active" id="is_active" value="1"/> |
|
789
|
+ // GitHub |
|
790
|
+ $custom_fields['github'] = array( |
|
791
|
+ 'field_type' => 'url', |
|
792
|
+ 'class' => 'uwp-github', |
|
793
|
+ 'field_icon' => 'fab fa-github-square', |
|
794
|
+ 'site_title' => __( 'GitHub', 'userswp' ), |
|
795
|
+ 'help_text' => __( 'Let users enter their GitHub url.', 'userswp' ), |
|
796
|
+ 'defaults' => array( |
|
797
|
+ 'admin_title' => 'GitHub', |
|
798
|
+ 'site_title' => 'GitHub', |
|
799
|
+ 'form_label' => __( 'GitHub url', 'userswp' ), |
|
800
|
+ 'htmlvar_name' => 'github', |
|
801
|
+ 'is_active' => 1, |
|
802
|
+ 'default_value' => '', |
|
803
|
+ 'is_required' => 0, |
|
804
|
+ 'required_msg' => '', |
|
805
|
+ 'field_icon' => 'fab fa-github-alt', |
|
806
|
+ 'css_class' => 'btn-github', |
|
807
|
+ ), |
|
808
|
+ ); |
|
509
|
809
|
|
|
510
|
|
- <input type="hidden" name="is_default" value="<?php echo isset($field_info->is_default) ? $field_info->is_default : ''; ?>" /><?php // show in sidebar value?> |
|
810
|
+ // YouTube |
|
811
|
+ $custom_fields['youtube'] = array( |
|
812
|
+ 'field_type' => 'url', |
|
813
|
+ 'class' => 'uwp-youtube', |
|
814
|
+ 'field_icon' => 'fab fa-youtube-square', |
|
815
|
+ 'site_title' => __( 'YouTube', 'userswp' ), |
|
816
|
+ 'help_text' => __( 'Let users enter their YouTube url.', 'userswp' ), |
|
817
|
+ 'defaults' => array( |
|
818
|
+ 'admin_title' => 'YouTube', |
|
819
|
+ 'site_title' => 'YouTube', |
|
820
|
+ 'form_label' => __( 'YouTube url', 'userswp' ), |
|
821
|
+ 'htmlvar_name' => 'youtube', |
|
822
|
+ 'is_active' => 1, |
|
823
|
+ 'default_value' => '', |
|
824
|
+ 'is_required' => 0, |
|
825
|
+ 'required_msg' => '', |
|
826
|
+ 'field_icon' => 'fab fa-youtube', |
|
827
|
+ 'css_class' => 'btn-youtube', |
|
828
|
+ ), |
|
829
|
+ ); |
|
511
|
830
|
|
|
512
|
|
- <ul class="widefat post fixed" style="width:100%;"> |
|
831
|
+ // WordPress |
|
832
|
+ $custom_fields['wordpress'] = array( |
|
833
|
+ 'field_type' => 'url', |
|
834
|
+ 'class' => 'uwp-wordpress', |
|
835
|
+ 'field_icon' => 'fab fa-wordpress-simple', |
|
836
|
+ 'site_title' => __( 'WordPress', 'userswp' ), |
|
837
|
+ 'help_text' => __( 'Let users enter their WordPress profile url.', 'userswp' ), |
|
838
|
+ 'defaults' => array( |
|
839
|
+ 'admin_title' => 'WordPress', |
|
840
|
+ 'site_title' => 'WordPress', |
|
841
|
+ 'form_label' => __( 'WordPress url', 'userswp' ), |
|
842
|
+ 'htmlvar_name' => 'wordpress', |
|
843
|
+ 'is_active' => 1, |
|
844
|
+ 'default_value' => '', |
|
845
|
+ 'is_required' => 0, |
|
846
|
+ 'required_msg' => '', |
|
847
|
+ 'field_icon' => 'fab fa-wordpress-simple', |
|
848
|
+ 'css_class' => 'btn-wordpress', |
|
849
|
+ ), |
|
850
|
+ ); |
|
513
|
851
|
|
|
514
|
|
- <?php |
|
515
|
|
- // data_type |
|
516
|
|
- if (has_filter("uwp_builder_data_type_{$field_type}")) { |
|
852
|
+ // Language |
|
853
|
+ $custom_fields['uwp_language'] = array( |
|
854
|
+ 'field_type' => 'select', |
|
855
|
+ 'class' => 'uwp-language', |
|
856
|
+ 'field_icon' => 'fas fa-language', |
|
857
|
+ 'site_title' => __( 'Select Language', 'userswp' ), |
|
858
|
+ 'help_text' => __( 'Adds a input for user language selection.', 'userswp' ), |
|
859
|
+ 'defaults' => array( |
|
860
|
+ 'admin_title' => 'Select Language', |
|
861
|
+ 'site_title' => 'Select Language', |
|
862
|
+ 'form_label' => __( 'Site Language', 'userswp' ), |
|
863
|
+ 'htmlvar_name' => 'uwp_language', |
|
864
|
+ 'is_active' => 1, |
|
865
|
+ 'default_value' => 'site-default', |
|
866
|
+ 'is_required' => 0, |
|
867
|
+ 'option_values' => '', |
|
868
|
+ 'required_msg' => '', |
|
869
|
+ 'field_icon' => 'fas fa-language', |
|
870
|
+ 'css_class' => '', |
|
871
|
+ ), |
|
872
|
+ ); |
|
517
|
873
|
|
|
518
|
|
- echo apply_filters("uwp_builder_data_type_{$field_type}", '', $result_str, $cf, $field_info); |
|
874
|
+ return apply_filters( 'uwp_form_fields_predefined', $custom_fields, $type ); |
|
875
|
+ } |
|
519
|
876
|
|
|
520
|
|
- } else { |
|
521
|
|
- $value = ''; |
|
522
|
|
- if (isset($field_info->data_type)) { |
|
523
|
|
- $value = esc_attr($field_info->data_type); |
|
524
|
|
- }elseif (isset($cf['defaults']['data_type']) && $cf['defaults']['data_type']) { |
|
525
|
|
- $value = $cf['defaults']['data_type']; |
|
526
|
|
- } |
|
527
|
|
- ?> |
|
528
|
|
- <input type="hidden" name="data_type" id="data_type" value="<?php echo $value; ?>"/> |
|
529
|
|
- <?php |
|
530
|
|
- } |
|
531
|
|
- |
|
532
|
|
- // site_title |
|
533
|
|
- if (has_filter("uwp_builder_site_title_{$field_type}")) { |
|
877
|
+ public function form_fields_custom( $type = '' ) { |
|
878
|
+ $custom_fields = array(); |
|
534
|
879
|
|
|
535
|
|
- echo apply_filters("uwp_builder_site_title_{$field_type}", '', $result_str, $cf, $field_info); |
|
880
|
+ return apply_filters( 'uwp_form_fields_custom', $custom_fields, $type ); |
|
881
|
+ } |
|
536
|
882
|
|
|
537
|
|
- } else { |
|
538
|
|
- $value = ''; |
|
539
|
|
- if (isset($field_info->site_title)) { |
|
540
|
|
- $value = esc_attr($field_info->site_title); |
|
541
|
|
- }elseif (isset($cf['defaults']['site_title']) && $cf['defaults']['site_title']) { |
|
542
|
|
- $value = $cf['defaults']['site_title']; |
|
543
|
|
- } |
|
544
|
|
- ?> |
|
545
|
|
- <li> |
|
546
|
|
- <label for="site_title" class="uwp-tooltip-wrap"> <i class="fas fa-info-circle" aria-hidden="true"></i> <?php _e('Label:', 'userswp'); ?> |
|
547
|
|
- <div class="uwp-tooltip"> |
|
548
|
|
- <?php _e('This will be the label for the field.', 'userswp'); ?> |
|
549
|
|
- </div> |
|
550
|
|
- </label> |
|
551
|
|
- <div class="uwp-input-wrap"> |
|
552
|
|
- <input type="text" name="site_title" id="site_title" |
|
553
|
|
- value="<?php echo $value; ?>"/> |
|
554
|
|
- </div> |
|
555
|
|
- </li> |
|
556
|
|
- <?php |
|
557
|
|
- } |
|
883
|
+ public function form_fields( $type = '' ) { |
|
558
|
884
|
|
|
559
|
|
- // Input Label |
|
560
|
|
- if (has_filter("uwp_builder_form_label_{$field_type}")) { |
|
885
|
+ $custom_fields = array( |
|
886
|
+ 'text' => array( |
|
887
|
+ 'field_type' => 'text', |
|
888
|
+ 'class' => 'uwp-text', |
|
889
|
+ 'field_icon' => 'fas fa-minus', |
|
890
|
+ 'site_title' => __( 'Text', 'userswp' ), |
|
891
|
+ 'help_text' => __( 'Add any sort of text field, text or numbers', 'userswp' ), |
|
892
|
+ ), |
|
893
|
+ 'datepicker' => array( |
|
894
|
+ 'field_type' => 'datepicker', |
|
895
|
+ 'class' => 'uwp-datepicker', |
|
896
|
+ 'field_icon' => 'fas fa-calendar-alt', |
|
897
|
+ 'site_title' => __( 'Date', 'userswp' ), |
|
898
|
+ 'help_text' => __( 'Adds a date picker.', 'userswp' ), |
|
899
|
+ ), |
|
900
|
+ 'textarea' => array( |
|
901
|
+ 'field_type' => 'textarea', |
|
902
|
+ 'class' => 'uwp-textarea', |
|
903
|
+ 'field_icon' => 'fas fa-bars', |
|
904
|
+ 'site_title' => __( 'Textarea', 'userswp' ), |
|
905
|
+ 'help_text' => __( 'Adds a textarea', 'userswp' ), |
|
906
|
+ ), |
|
907
|
+ 'time' => array( |
|
908
|
+ 'field_type' => 'time', |
|
909
|
+ 'class' => 'uwp-time', |
|
910
|
+ 'field_icon' => 'far fa-clock', |
|
911
|
+ 'site_title' => __( 'Time', 'userswp' ), |
|
912
|
+ 'help_text' => __( 'Adds a time picker', 'userswp' ), |
|
913
|
+ ), |
|
914
|
+ 'checkbox' => array( |
|
915
|
+ 'field_type' => 'checkbox', |
|
916
|
+ 'class' => 'uwp-checkbox', |
|
917
|
+ 'field_icon' => 'far fa-check-square', |
|
918
|
+ 'site_title' => __( 'Checkbox', 'userswp' ), |
|
919
|
+ 'help_text' => __( 'Adds a checkbox', 'userswp' ), |
|
920
|
+ ), |
|
921
|
+ 'phone' => array( |
|
922
|
+ 'field_type' => 'phone', |
|
923
|
+ 'class' => 'uwp-phone', |
|
924
|
+ 'field_icon' => 'fas fa-phone', |
|
925
|
+ 'site_title' => __( 'Phone', 'userswp' ), |
|
926
|
+ 'help_text' => __( 'Adds a phone input', 'userswp' ), |
|
927
|
+ ), |
|
928
|
+ 'radio' => array( |
|
929
|
+ 'field_type' => 'radio', |
|
930
|
+ 'class' => 'uwp-radio', |
|
931
|
+ 'field_icon' => 'far fa-dot-circle', |
|
932
|
+ 'site_title' => __( 'Radio', 'userswp' ), |
|
933
|
+ 'help_text' => __( 'Adds a radio input', 'userswp' ), |
|
934
|
+ ), |
|
935
|
+ 'email' => array( |
|
936
|
+ 'field_type' => 'email', |
|
937
|
+ 'class' => 'uwp-email', |
|
938
|
+ 'field_icon' => 'far fa-envelope', |
|
939
|
+ 'site_title' => __( 'Email', 'userswp' ), |
|
940
|
+ 'help_text' => __( 'Adds a email input', 'userswp' ), |
|
941
|
+ ), |
|
942
|
+ 'select' => array( |
|
943
|
+ 'field_type' => 'select', |
|
944
|
+ 'field_icon' => 'far fa-caret-square-down', |
|
945
|
+ 'site_title' => __( 'Select', 'userswp' ), |
|
946
|
+ 'help_text' => __( 'Adds a select input', 'userswp' ), |
|
947
|
+ ), |
|
948
|
+ 'multiselect' => array( |
|
949
|
+ 'field_type' => 'multiselect', |
|
950
|
+ 'class' => 'uwp-multiselect', |
|
951
|
+ 'field_icon' => 'far fa-caret-square-down', |
|
952
|
+ 'site_title' => __( 'Multi Select', 'userswp' ), |
|
953
|
+ 'help_text' => __( 'Adds a multiselect input', 'userswp' ), |
|
954
|
+ ), |
|
955
|
+ 'url' => array( |
|
956
|
+ 'field_type' => 'url', |
|
957
|
+ 'class' => 'uwp-url', |
|
958
|
+ 'field_icon' => 'fas fa-link', |
|
959
|
+ 'site_title' => __( 'URL', 'userswp' ), |
|
960
|
+ 'help_text' => __( 'Adds a url input', 'userswp' ), |
|
961
|
+ ), |
|
962
|
+ 'editor' => array( |
|
963
|
+ 'field_type' => 'editor', |
|
964
|
+ 'class' => 'uwp-html', |
|
965
|
+ 'field_icon' => 'fas fa-code', |
|
966
|
+ 'site_title' => __( 'HTML', 'userswp' ), |
|
967
|
+ 'help_text' => __( 'Adds a wysiwyg editor input', 'userswp' ), |
|
968
|
+ ), |
|
969
|
+ 'file' => array( |
|
970
|
+ 'field_type' => 'file', |
|
971
|
+ 'class' => 'uwp-file', |
|
972
|
+ 'field_icon' => 'fas fa-file', |
|
973
|
+ 'site_title' => __( 'File Upload', 'userswp' ), |
|
974
|
+ 'help_text' => __( 'Adds a file input', 'userswp' ), |
|
975
|
+ ), |
|
976
|
+ ); |
|
561
|
977
|
|
|
562
|
|
- echo apply_filters("uwp_builder_form_label_{$field_type}", '', $result_str, $cf, $field_info); |
|
978
|
+ return apply_filters( 'uwp_form_fields', $custom_fields, $type ); |
|
979
|
+ } |
|
563
|
980
|
|
|
564
|
|
- } else { |
|
565
|
|
- $value = ''; |
|
566
|
|
- if (isset($field_info->form_label)) { |
|
567
|
|
- $value = esc_attr($field_info->form_label); |
|
568
|
|
- }elseif (isset($cf['defaults']['form_label']) && $cf['defaults']['form_label']) { |
|
569
|
|
- $value = $cf['defaults']['form_label']; |
|
570
|
|
- } |
|
571
|
|
- ?> |
|
572
|
|
- <li> |
|
573
|
|
- <label for="form_label" class="uwp-tooltip-wrap"> <i class="fas fa-info-circle" aria-hidden="true"></i> <?php _e('Form Label: (Optional)', 'userswp'); ?> |
|
574
|
|
- <div class="uwp-tooltip"> |
|
575
|
|
- <?php _e('If your form label is different, then you can fill this field. Ex: You would like to display "What is your age?" in Form Field but would like to display "DOB" in site. In such cases "What is your age?" should be entered here and "DOB" should be entered in previous field. Note: If this field not filled, then the previous field will be used in Form. ', 'userswp'); ?> |
|
576
|
|
- </div> |
|
577
|
|
- </label> |
|
578
|
|
- <div class="uwp-input-wrap"> |
|
579
|
|
- <input type="text" name="form_label" id="form_label" |
|
580
|
|
- value="<?php echo $value; ?>"/> |
|
581
|
|
- </div> |
|
582
|
|
- </li> |
|
583
|
|
- <?php |
|
584
|
|
- } |
|
981
|
+ public function manage_available_fields_custom( $form_type ) { |
|
982
|
+ switch ( $form_type ) { |
|
983
|
+ case 'account': |
|
984
|
+ $this->custom_available_fields( 'custom', $form_type ); |
|
985
|
+ break; |
|
986
|
+ } |
|
987
|
+ } |
|
585
|
988
|
|
|
989
|
+ public function manage_available_fields( $form_type ) { |
|
990
|
+ switch ( $form_type ) { |
|
991
|
+ case 'account': |
|
992
|
+ $this->custom_available_fields( '', $form_type ); |
|
993
|
+ break; |
|
994
|
+ case 'register': |
|
995
|
+ $this->register_available_fields( $form_type ); |
|
996
|
+ break; |
|
997
|
+ } |
|
998
|
+ } |
|
586
|
999
|
|
|
587
|
|
- // htmlvar_name |
|
588
|
|
- if(has_filter("uwp_builder_htmlvar_name_{$field_type}")){ |
|
1000
|
+ public function register_available_fields( $form_type ) { |
|
1001
|
+ global $wpdb; |
|
589
|
1002
|
|
|
590
|
|
- echo apply_filters("uwp_builder_htmlvar_name_{$field_type}",'',$result_str,$cf,$field_info); |
|
1003
|
+ $form_id = self::get_form_id(); |
|
591
|
1004
|
|
|
592
|
|
- }else{ |
|
593
|
|
- $value = ''; |
|
594
|
|
- if (isset($field_info->htmlvar_name)) { |
|
595
|
|
- $value = esc_attr($field_info->htmlvar_name); |
|
596
|
|
- }elseif(isset($cf['defaults']['htmlvar_name']) && $cf['defaults']['htmlvar_name']){ |
|
597
|
|
- $value = $cf['defaults']['htmlvar_name']; |
|
598
|
|
- } |
|
599
|
|
- ?> |
|
600
|
|
- <li> |
|
601
|
|
- <label for="htmlvar_name" class="uwp-tooltip-wrap"><i class="fas fa-info-circle" aria-hidden="true"></i> <?php _e('HTML variable name :', 'userswp');?> |
|
602
|
|
- <div class="uwp-tooltip"> |
|
603
|
|
- <?php _e('This is a unique identifier used in the HTML, it MUST NOT contain spaces or special characters.', 'userswp'); ?> |
|
604
|
|
- </div> |
|
605
|
|
- </label> |
|
606
|
|
- <div class="uwp-input-wrap"> |
|
607
|
|
- <input type="text" name="htmlvar_name" id="htmlvar_name" pattern="[a-zA-Z0-9]+" title="<?php _e('Must not contain spaces or special characters', 'userswp');?>" |
|
608
|
|
- value="<?php if ($value) { |
|
609
|
|
- echo preg_replace('/uwp_'.$form_type.'_/', '', $value, 1); |
|
610
|
|
- }?>" <?php if ($default) { |
|
611
|
|
- echo 'readonly="readonly"'; |
|
612
|
|
- }?> /> |
|
613
|
|
- </div> |
|
614
|
|
- </li> |
|
615
|
|
- <?php |
|
616
|
|
- } |
|
1005
|
+ $extras_table_name = uwp_get_table_prefix() . 'uwp_form_extras'; |
|
617
|
1006
|
|
|
1007
|
+ // Retrieve fields saved with form id 0. |
|
1008
|
+ if ( $form_id === 1 ) { |
|
1009
|
+ $where = 'AND ( form_id = 1 OR form_id = 0 )'; |
|
1010
|
+ } else { |
|
1011
|
+ $where = $wpdb->prepare( 'AND form_id = %d', $form_id ); |
|
1012
|
+ } |
|
618
|
1013
|
|
|
619
|
|
- // is_active |
|
620
|
|
- if (has_filter("uwp_builder_is_active_{$field_type}")) { |
|
1014
|
+ $existing_fields = $wpdb->get_results( $wpdb->prepare( 'SELECT site_htmlvar_name FROM `' . $extras_table_name . "` WHERE form_type = %s {$where}", $form_type ) ); |
|
621
|
1015
|
|
|
622
|
|
- echo apply_filters("uwp_builder_is_active_{$field_type}", '', $result_str, $cf, $field_info); |
|
1016
|
+ $existing_field_ids = array(); |
|
1017
|
+ if ( ! empty( $existing_fields ) ) { |
|
1018
|
+ foreach ( $existing_fields as $existing_field ) { |
|
1019
|
+ $existing_field_ids[] = $existing_field->site_htmlvar_name; |
|
1020
|
+ } |
|
1021
|
+ } |
|
1022
|
+ ?> |
|
1023
|
+ <input type="hidden" name="form_type" id="form_type" value="<?php echo esc_attr( $form_type ); ?>"/> |
|
1024
|
+ <input type="hidden" name="manage_field_type" class="manage_field_type" value="register"> |
|
1025
|
+ <ul class="row row-cols-1 px-2 mb-0"> |
|
1026
|
+ <?php |
|
623
|
1027
|
|
|
624
|
|
- } else { |
|
625
|
|
- $value = ''; |
|
626
|
|
- if (isset($field_info->is_active)) { |
|
627
|
|
- $value = esc_attr($field_info->is_active); |
|
628
|
|
- }elseif (isset($cf['defaults']['is_active']) && $cf['defaults']['is_active']) { |
|
629
|
|
- $value = $cf['defaults']['is_active']; |
|
630
|
|
- } |
|
631
|
|
- ?> |
|
632
|
|
- <li <?php echo $field_display; ?>> |
|
633
|
|
- <label for="is_active" class="uwp-tooltip-wrap"><i class="fas fa-info-circle" aria-hidden="true"></i> <?php _e('Is active :', 'userswp'); ?> |
|
634
|
|
- <div class="uwp-tooltip"> |
|
635
|
|
- <?php _e('If no is selected then the field will not be displayed anywhere.', 'userswp'); ?> |
|
636
|
|
- </div> |
|
637
|
|
- </label> |
|
638
|
|
- <div class="uwp-input-wrap uwp-switch"> |
|
1028
|
+ $fields = $this->register_fields( $form_type, $form_id ); |
|
639
|
1029
|
|
|
640
|
|
- <input type="radio" id="is_active_yes<?php echo $radio_id; ?>" name="is_active" class="uwp-ri-enabled" value="1" |
|
641
|
|
- <?php if ($value == '1') { |
|
642
|
|
- echo 'checked'; |
|
643
|
|
- } ?>/> |
|
644
|
|
- <label for="is_active_yes<?php echo $radio_id; ?>" class="uwp-cb-enable"><span><?php _e('Yes', 'userswp'); ?></span></label> |
|
1030
|
+ if ( ! empty( $fields ) ) { |
|
1031
|
+ foreach ( $fields as $field ) { |
|
1032
|
+ $field = stripslashes_deep( $field ); // strip slashes |
|
645
|
1033
|
|
|
646
|
|
- <input type="radio" id="is_active_no<?php echo $radio_id; ?>" name="is_active" class="uwp-ri-disabled" value="0" |
|
647
|
|
- <?php if ($value == '0' || !$value) { |
|
648
|
|
- echo 'checked'; |
|
649
|
|
- } ?>/> |
|
650
|
|
- <label for="is_active_no<?php echo $radio_id; ?>" class="uwp-cb-disable"><span><?php _e('No', 'userswp'); ?></span></label> |
|
1034
|
+ $fieldset_width = ''; |
|
1035
|
+ if ( $field['field_type'] == 'fieldset' ) { |
|
1036
|
+ $fieldset_width = 'width:100%;'; |
|
1037
|
+ } |
|
651
|
1038
|
|
|
652
|
|
- </div> |
|
653
|
|
- </li> |
|
654
|
|
- <?php |
|
655
|
|
- } |
|
1039
|
+ $display = ''; |
|
1040
|
+ if ( in_array( $field['htmlvar_name'], $existing_field_ids ) ) { |
|
1041
|
+ $display = 'display:none;'; |
|
1042
|
+ } |
|
656
|
1043
|
|
|
657
|
|
- // for_admin_use |
|
658
|
|
- if (isset($field_info->is_default) && $field_info->is_default == '1') { |
|
659
|
|
- // do nothing for default fields |
|
660
|
|
- } else { |
|
661
|
|
- if (has_filter("uwp_builder_for_admin_use_{$field_type}")) { |
|
1044
|
+ $style = 'style="' . $display . $fieldset_width . '"'; |
|
1045
|
+ ?> |
|
1046
|
+ <li <?php echo $style; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> class="col px-1" > |
|
662
|
1047
|
|
|
663
|
|
- echo apply_filters("uwp_builder_for_admin_use_{$field_type}", '', $result_str, $cf, $field_info); |
|
1048
|
+ <a id="uwp-<?php echo esc_attr( $field['htmlvar_name'] ); ?>" |
|
1049
|
+ class="uwp-draggable-form-itemsx uwp-<?php echo esc_attr( $field['field_type'] ); ?> btn btn-sm d-block m-0 btn-outline-gray text-dark text-start" |
|
1050
|
+ href="javascript:void(0);" data-field-type="<?php echo esc_attr( $field['field_type'] ); ?>"> |
|
664
|
1051
|
|
|
665
|
|
- } else { |
|
666
|
|
- $value = ''; |
|
667
|
|
- if (isset($field_info->for_admin_use)) { |
|
668
|
|
- $value = esc_attr($field_info->for_admin_use); |
|
669
|
|
- }elseif (isset($cf['defaults']['for_admin_use']) && $cf['defaults']['for_admin_use']) { |
|
670
|
|
- $value = $cf['defaults']['for_admin_use']; |
|
671
|
|
- } |
|
672
|
|
- ?> |
|
673
|
|
- <li <?php echo $field_display; ?>> |
|
674
|
|
- <label for="for_admin_use" class="uwp-tooltip-wrap"><i class="fas fa-info-circle" aria-hidden="true"></i> <?php _e('For admin use only? :', 'userswp'); ?> |
|
675
|
|
- <div class="uwp-tooltip"> |
|
676
|
|
- <?php _e('If yes is selected then only site admin can see and edit this field.', 'userswp'); ?> |
|
677
|
|
- </div> |
|
678
|
|
- </label> |
|
679
|
|
- <div class="uwp-input-wrap uwp-switch"> |
|
1052
|
+ <?php |
|
1053
|
+ if ( $icon = uwp_get_field_icon( $field['field_icon'] ) ) { |
|
1054
|
+ echo $icon; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
1055
|
+ } else { |
|
1056
|
+ echo '<i class="fas fa-cog" aria-hidden="true"></i>'; |
|
1057
|
+ } |
|
1058
|
+ ?> |
|
680
|
1059
|
|
|
681
|
|
- <input type="radio" id="for_admin_use_yes<?php echo $radio_id; ?>" name="for_admin_use" class="uwp-ri-enabled" value="1" |
|
682
|
|
- <?php if ($value == '1') { |
|
683
|
|
- echo 'checked'; |
|
684
|
|
- } ?>/> |
|
685
|
|
- <label for="for_admin_use_yes<?php echo $radio_id; ?>" onclick="uwp_show_hide_radio(this,'hide','cf-incin-reg-form');uwp_show_hide_radio(this,'hide','cf-inconlyin-reg-form');" class="uwp-cb-enable"><span><?php _e('Yes', 'userswp'); ?></span></label> |
|
1060
|
+ <?php echo esc_attr( $field['site_title'] ); ?> |
|
686
|
1061
|
|
|
687
|
|
- <input type="radio" id="for_admin_use_no<?php echo $radio_id; ?>" name="for_admin_use" class="uwp-ri-disabled" value="0" |
|
688
|
|
- <?php if ($value == '0' || !$value) { |
|
689
|
|
- echo 'checked'; |
|
690
|
|
- } ?>/> |
|
691
|
|
- <label for="for_admin_use_no<?php echo $radio_id; ?>" onclick="uwp_show_hide_radio(this,'show','cf-incin-reg-form');uwp_show_hide_radio(this,'show','cf-inconlyin-reg-form');" class="uwp-cb-disable"><span><?php _e('No', 'userswp'); ?></span></label> |
|
1062
|
+ </a> |
|
1063
|
+ </li> |
|
692
|
1064
|
|
|
693
|
|
- </div> |
|
694
|
|
- </li> |
|
695
|
|
- <?php |
|
696
|
|
- } |
|
697
|
|
- } |
|
698
|
1065
|
|
|
1066
|
+ <?php |
|
1067
|
+ } |
|
1068
|
+ } |
|
1069
|
+ ?> |
|
1070
|
+ </ul> |
|
1071
|
+ <?php |
|
1072
|
+ } |
|
699
|
1073
|
|
|
700
|
|
- // is_public |
|
701
|
|
- if (has_filter("uwp_builder_is_public_{$field_type}")) { |
|
1074
|
+ public function register_fields( $form_type, $form_id = 1 ) { |
|
1075
|
+ global $wpdb; |
|
702
|
1076
|
|
|
703
|
|
- echo apply_filters("uwp_builder_is_public_{$field_type}", '', $result_str, $cf, $field_info); |
|
1077
|
+ $table_name = uwp_get_table_prefix() . 'uwp_form_fields'; |
|
704
|
1078
|
|
|
705
|
|
- } else { |
|
706
|
|
- $value = ''; |
|
707
|
|
- if (isset($field_info->is_public)) { |
|
708
|
|
- $value = esc_attr($field_info->is_public); |
|
709
|
|
- }elseif (isset($cf['defaults']['is_public']) && $cf['defaults']['is_public']) { |
|
710
|
|
- $value = $cf['defaults']['is_public']; |
|
711
|
|
- } |
|
712
|
|
- ?> |
|
713
|
|
- <li <?php echo $field_display; ?>> |
|
714
|
|
- <label for="is_public" class="uwp-tooltip-wrap"><i class="fas fa-info-circle" aria-hidden="true"></i> <?php _e('Is Public :', 'userswp'); ?> |
|
715
|
|
- <div class="uwp-tooltip"> |
|
716
|
|
- <?php _e('If no is selected then the field will not be visible to other users.', 'userswp'); ?> |
|
717
|
|
- </div> |
|
718
|
|
- </label> |
|
719
|
|
- <div class="uwp-input-wrap uwp-switch"> |
|
720
|
|
- <?php |
|
721
|
|
- if (!$value) { |
|
722
|
|
- $value = "0"; |
|
723
|
|
- } |
|
724
|
|
- ?> |
|
1079
|
+ // Retrieve fields saved with form id 0. |
|
1080
|
+ if ( $form_id === 1 ) { |
|
1081
|
+ $where = 'AND ( form_id = 1 OR form_id = 0 )'; |
|
1082
|
+ } else { |
|
1083
|
+ $where = $wpdb->prepare( 'AND form_id = %d', $form_id ); |
|
1084
|
+ } |
|
725
|
1085
|
|
|
726
|
|
- <select name="is_public" id="is_public"> |
|
727
|
|
- <option value="0" <?php selected($value, "0"); ?>><?php echo __("No", "userswp") ?></option> |
|
728
|
|
- <option value="1" <?php selected($value, "1"); ?>><?php echo __("Yes", "userswp") ?></option> |
|
729
|
|
- <option value="2" <?php selected($value, "2"); ?>><?php echo __("Let User Decide", "userswp") ?></option> |
|
730
|
|
- </select> |
|
1086
|
+ $fields = $wpdb->get_results( $wpdb->prepare( 'SELECT field_type, site_title, htmlvar_name, field_icon FROM `' . $table_name . "` WHERE form_type = %s AND is_register_field = %s {$where} ORDER BY sort_order ASC", array( 'account', '1' ) ), ARRAY_A ); |
|
731
|
1087
|
|
|
732
|
|
- </div> |
|
733
|
|
- </li> |
|
734
|
|
- <?php |
|
735
|
|
- } |
|
1088
|
+ return apply_filters( 'uwp_register_fields', $fields, $form_type ); |
|
1089
|
+ } |
|
736
|
1090
|
|
|
1091
|
+ public function manage_selected_fields( $form_type ) { |
|
1092
|
+ switch ( $form_type ) { |
|
1093
|
+ case 'account': |
|
1094
|
+ $this->custom_selected_fields( $form_type ); |
|
1095
|
+ break; |
|
1096
|
+ case 'register': |
|
1097
|
+ $this->register_selected_fields( $form_type ); |
|
1098
|
+ break; |
|
1099
|
+ } |
|
1100
|
+ } |
|
737
|
1101
|
|
|
738
|
|
- // default_value |
|
739
|
|
- if (has_filter("uwp_builder_default_value_{$field_type}")) { |
|
1102
|
+ public function custom_selected_fields( $form_type ) { |
|
740
|
1103
|
|
|
741
|
|
- echo apply_filters("uwp_builder_default_value_{$field_type}", '', $result_str, $cf, $field_info); |
|
1104
|
+ global $wpdb; |
|
1105
|
+ $table_name = uwp_get_table_prefix() . 'uwp_form_fields'; |
|
1106
|
+ $form_id = self::get_form_id(); |
|
1107
|
+ ?> |
|
1108
|
+ <input type="hidden" name="form_type" id="form_type" value="<?php echo esc_attr( $form_type ); ?>"/> |
|
1109
|
+ <input type="hidden" name="manage_field_type" class="manage_field_type" value="custom_fields"> |
|
1110
|
+ <input type="hidden" name="uwp_create_field_nonce" class="uwp_create_field_nonce" value="<?php echo wp_create_nonce( 'uwp_create_field_nonce' ); ?>"/> |
|
1111
|
+ <ul class="core uwp-tabs-selected uwp_form_extras ps-0 list-group"> |
|
1112
|
+ <?php |
|
1113
|
+ // Retrieve fields saved with form id 0. |
|
1114
|
+ if ( $form_id === 1 ) { |
|
1115
|
+ $where = 'AND ( form_id = 1 OR form_id = 0 )'; |
|
1116
|
+ } else { |
|
1117
|
+ $where = $wpdb->prepare( 'AND form_id = %d', $form_id ); |
|
1118
|
+ } |
|
742
|
1119
|
|
|
743
|
|
- } else { |
|
744
|
|
- $value = ''; |
|
745
|
|
- if (isset($field_info->default_value)) { |
|
746
|
|
- $value = esc_attr($field_info->default_value); |
|
747
|
|
- }elseif (isset($cf['defaults']['default_value']) && $cf['defaults']['default_value']) { |
|
748
|
|
- $value = $cf['defaults']['default_value']; |
|
749
|
|
- } |
|
750
|
|
- ?> |
|
751
|
|
- <li> |
|
752
|
|
- <label for="default_value" class="uwp-tooltip-wrap"><i class="fas fa-info-circle" aria-hidden="true"></i> <?php _e('Default value :', 'userswp'); ?> |
|
753
|
|
- <div class="uwp-tooltip"> |
|
754
|
|
- <?php |
|
755
|
|
- if ($field_type == 'checkbox') { |
|
756
|
|
- _e('Should the checkbox be checked by default?', 'userswp'); |
|
757
|
|
- } else if ($field_type == 'email') { |
|
758
|
|
- _e('A default value for the field, usually blank. Ex: info@mysite.com', 'userswp'); |
|
759
|
|
- } else { |
|
760
|
|
- _e('A default value for the field, usually blank. (for "link" this will be used as the link text)', 'userswp'); |
|
761
|
|
- } |
|
762
|
|
- ?> |
|
763
|
|
- </div> |
|
764
|
|
- </label> |
|
765
|
|
- <div class="uwp-input-wrap"> |
|
766
|
|
- <?php if ($field_type == 'checkbox') { ?> |
|
767
|
|
- <select name="default_value" id="default_value"> |
|
768
|
|
- <option value=""><?php _e('Unchecked', 'userswp'); ?></option> |
|
769
|
|
- <option value="1" <?php selected(true, (int) $value === 1); ?>><?php _e('Checked', 'userswp'); ?></option> |
|
770
|
|
- </select> |
|
771
|
|
- <?php } else if ($field_type == 'email') { ?> |
|
772
|
|
- <input type="email" name="default_value" placeholder="<?php _e('info@mysite.com', 'userswp'); ?>" id="default_value" value="<?php echo esc_attr($value); ?>" /><br/> |
|
773
|
|
- <?php } else { ?> |
|
774
|
|
- <input type="text" name="default_value" id="default_value" value="<?php echo esc_attr($value); ?>" /><br/> |
|
775
|
|
- <?php } ?> |
|
776
|
|
- </div> |
|
777
|
|
- </li> |
|
778
|
|
- <?php |
|
779
|
|
- } |
|
1120
|
+ $fields = $wpdb->get_results( $wpdb->prepare( 'SELECT * FROM `' . $table_name . "` WHERE form_type = %s {$where} ORDER BY sort_order ASC", $form_type ) ); |
|
780
|
1121
|
|
|
1122
|
+ if ( ! empty( $fields ) ) { |
|
1123
|
+ foreach ( $fields as $field ) { |
|
1124
|
+ $result_str = $field; |
|
1125
|
+ $field_type = $field->field_type; |
|
1126
|
+ $field_type_key = $field->field_type_key; |
|
1127
|
+ $field_ins_upd = 'display'; |
|
781
|
1128
|
|
|
782
|
|
- // advanced_editor |
|
783
|
|
- if (has_filter("uwp_builder_advanced_editor_{$field_type}")) { |
|
1129
|
+ $this->form_field_adminhtml( $field_type, $result_str, $field_ins_upd, $field_type_key ); |
|
1130
|
+ } |
|
1131
|
+ } |
|
1132
|
+ ?> |
|
1133
|
+ </ul> |
|
1134
|
+ <?php |
|
1135
|
+ } |
|
784
|
1136
|
|
|
785
|
|
- echo apply_filters("uwp_builder_advanced_editor_{$field_type}", '', $result_str, $cf, $field_info); |
|
1137
|
+ public function form_field_adminhtml( $field_type, $result_str, $field_ins_upd = '', $field_type_key = '', $form_type = false ) { |
|
1138
|
+ global $wpdb; |
|
1139
|
+ $table_name = uwp_get_table_prefix() . 'uwp_form_fields'; |
|
1140
|
+ $cf = $result_str; |
|
1141
|
+ $cf_arr = $this->get_form_existing_fields( $form_type ); |
|
786
|
1142
|
|
|
787
|
|
- } |
|
1143
|
+ if ( ! is_object( $cf ) ) { |
|
788
|
1144
|
|
|
1145
|
+ $field_info = $wpdb->get_row( $wpdb->prepare( 'select * from ' . $table_name . ' where id= %d', array( $cf ) ) ); |
|
789
|
1146
|
|
|
790
|
|
- ?> |
|
1147
|
+ } else { |
|
1148
|
+ $field_info = $cf; |
|
1149
|
+ $result_str = $cf->id; |
|
1150
|
+ } |
|
791
|
1151
|
|
|
792
|
|
- <?php // we dont need to show the sort order ?> |
|
793
|
|
- <input type="hidden" readonly="readonly" name="sort_order" id="sort_order" value="<?php if (isset($field_info->sort_order)) { echo esc_attr($field_info->sort_order); } ?>"/> |
|
1152
|
+ if ( ! $field_info ) { |
|
1153
|
+ $field_info = ( isset( $cf_arr[ $field_type_key ] ) ) ? $cf_arr[ $field_type_key ] : null; |
|
1154
|
+ } |
|
794
|
1155
|
|
|
1156
|
+ $this->admin_form_field_html( $field_info, $field_type, $field_type_key, $field_ins_upd, $result_str, $form_type ); |
|
1157
|
+ } |
|
795
|
1158
|
|
|
1159
|
+ /** |
|
1160
|
+ * @param $field_info |
|
1161
|
+ * @param $field_type |
|
1162
|
+ * @param string $field_type_key |
|
1163
|
+ * @param string $field_ins_upd |
|
1164
|
+ * @param $result_str |
|
1165
|
+ * @param bool $form_type |
|
1166
|
+ */ |
|
1167
|
+ public function admin_form_field_html( $field_info, $field_type, $field_type_key, $field_ins_upd, $result_str, $form_type = false ) { |
|
796
|
1168
|
|
|
797
|
|
- <?php |
|
1169
|
+ if ( ! $form_type ) { |
|
1170
|
+ if ( ! isset( $field_info->form_type ) ) { |
|
1171
|
+ $form_type = sanitize_text_field( $_REQUEST['tab'] ); |
|
1172
|
+ } else { |
|
1173
|
+ $form_type = $field_info->form_type; |
|
1174
|
+ } |
|
1175
|
+ } |
|
798
|
1176
|
|
|
799
|
|
- // is_required |
|
800
|
|
- if (has_filter("uwp_builder_is_required_{$field_type}")) { |
|
1177
|
+ $cf_arr1 = $this->form_fields( $form_type ); |
|
1178
|
+ $cf_arr2 = $this->form_fields_predefined( $form_type ); |
|
1179
|
+ $cf_arr3 = $this->form_fields_custom( $form_type ); |
|
801
|
1180
|
|
|
802
|
|
- echo apply_filters("uwp_builder_is_required_{$field_type}", '', $result_str, $cf, $field_info); |
|
1181
|
+ $cf_arr = $cf_arr1 + $cf_arr2 + $cf_arr3; // this way defaults can't be overwritten |
|
803
|
1182
|
|
|
804
|
|
- } else { |
|
805
|
|
- $value = ''; |
|
806
|
|
- if (isset($field_info->is_required)) { |
|
807
|
|
- $value = esc_attr($field_info->is_required); |
|
808
|
|
- }elseif (isset($cf['defaults']['is_required']) && $cf['defaults']['is_required']) { |
|
809
|
|
- $value = $cf['defaults']['is_required']; |
|
810
|
|
- } |
|
811
|
|
- ?> |
|
812
|
|
- <li> |
|
813
|
|
- <label for="is_required" class="uwp-tooltip-wrap"><i class="fas fa-info-circle" aria-hidden="true"></i> <?php _e('Is required :', 'userswp'); ?> |
|
814
|
|
- <div class="uwp-tooltip"> |
|
815
|
|
- <?php _e('Select yes to set field as required', 'userswp'); ?> |
|
816
|
|
- </div> |
|
817
|
|
- </label> |
|
1183
|
+ $cf = ( isset( $cf_arr[ $field_type_key ] ) ) ? $cf_arr[ $field_type_key ] : ''; |
|
818
|
1184
|
|
|
819
|
|
- <div class="uwp-input-wrap uwp-switch"> |
|
1185
|
+ $field_info = stripslashes_deep( $field_info ); // strip slashes from labels |
|
820
|
1186
|
|
|
821
|
|
- <input type="radio" id="is_required_yes<?php echo $radio_id; ?>" name="is_required" class="uwp-ri-enabled" value="1" |
|
822
|
|
- <?php if ($value == '1') { |
|
823
|
|
- echo 'checked'; |
|
824
|
|
- } ?>/> |
|
825
|
|
- <label onclick="uwp_show_hide_radio(this,'show','cf-is-required-msg');" for="is_required_yes<?php echo $radio_id; ?>" class="uwp-cb-enable"><span><?php _e('Yes', 'userswp'); ?></span></label> |
|
1187
|
+ $field_site_title = ''; |
|
1188
|
+ if ( isset( $field_info->site_title ) ) { |
|
1189
|
+ $field_site_title = $field_info->site_title; |
|
1190
|
+ } |
|
826
|
1191
|
|
|
827
|
|
- <input type="radio" id="is_required_no<?php echo $radio_id; ?>" name="is_required" class="uwp-ri-disabled" value="0" |
|
828
|
|
- <?php if ($value == '0' || !$value) { |
|
829
|
|
- echo 'checked'; |
|
830
|
|
- } ?>/> |
|
831
|
|
- <label onclick="uwp_show_hide_radio(this,'hide','cf-is-required-msg');" for="is_required_no<?php echo $radio_id; ?>" class="uwp-cb-disable"><span><?php _e('No', 'userswp'); ?></span></label> |
|
1192
|
+ $field_display = $field_type == 'address' && $field_info->htmlvar_name == 'post' ? 'style="display:none"' : ''; |
|
832
|
1193
|
|
|
833
|
|
- </div> |
|
1194
|
+ if ( isset( $cf['field_icon'] ) && strpos( $cf['field_icon'], ' fa-' ) !== false ) { |
|
1195
|
+ $field_icon = '<i class="' . esc_attr( $cf['field_icon'] ) . '" aria-hidden="true"></i>'; |
|
1196
|
+ } elseif ( isset( $cf['field_icon'] ) && $cf['field_icon'] ) { |
|
1197
|
+ $field_icon = '<b style="background-image: url("' . esc_url( $cf['field_icon'] ) . '")"></b>'; |
|
1198
|
+ } else { |
|
1199
|
+ $field_icon = '<i class="fas fa-cog" aria-hidden="true"></i>'; |
|
1200
|
+ } |
|
834
|
1201
|
|
|
835
|
|
- </li> |
|
1202
|
+ if ( isset( $cf['site_title'] ) && $cf['site_title'] ) { |
|
1203
|
+ $field_type_name = $cf['site_title']; |
|
1204
|
+ } else { |
|
1205
|
+ $field_type_name = $field_type; |
|
1206
|
+ } |
|
836
|
1207
|
|
|
837
|
|
- <?php |
|
838
|
|
- } |
|
1208
|
+ $htmlvar_name = isset( $field_info->htmlvar_name ) ? sanitize_text_field( $field_info->htmlvar_name ) : ''; |
|
1209
|
+ $can_delete = apply_filters( 'uwp_cfa_can_delete_field', true, $field_info, $form_type ); |
|
1210
|
+ $nonce = wp_create_nonce( 'custom_fields_' . $result_str ); |
|
839
|
1211
|
|
|
840
|
|
- // required_msg |
|
841
|
|
- if (has_filter("uwp_builder_required_msg_{$field_type}")) { |
|
1212
|
+ ?> |
|
1213
|
+ <li class="text li-settings" id="licontainer_<?php echo esc_attr( $result_str ); ?>"> |
|
1214
|
+ <div class="title title<?php echo esc_attr( $result_str ); ?> uwp-fieldset hover-shadow dd-form d-flex justify-content-between rounded c-pointer list-group-item border rounded-smx text-start bg-light " onclick="uwp_tabs_item_settings(this);"> |
|
1215
|
+ <div class="flex-fill font-weight-bold fw-bold"> |
|
1216
|
+ <?php if ( $field_type == 'fieldset' ) { ?> |
|
1217
|
+ <i class="fas fa-long-arrow-alt-left " aria-hidden="true"></i> |
|
1218
|
+ <i class="fas fa-long-arrow-alt-right " aria-hidden="true"></i> |
|
1219
|
+ <b><?php echo esc_html( __( 'Fieldset:', 'userswp' ) ); ?></b> |
|
1220
|
+ <span class="field-type float-end text-end small"><?php echo ' (' . esc_html( $field_site_title ) . ')'; ?></span> |
|
1221
|
+ <?php } else { ?> |
|
1222
|
+ <?php echo $field_icon; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> |
|
1223
|
+ <b><?php echo esc_html( ' ' . $field_site_title ); ?></b> |
|
1224
|
+ <span class="field-type float-end text-end small"><?php echo ' (' . esc_html( ucfirst( $field_type_name ) ) . ')'; ?></span> |
|
1225
|
+ <?php } ?> |
|
1226
|
+ </div> |
|
1227
|
+ <div class="dd-handle ui-sortable-handle"> |
|
1228
|
+ <?php if ( $can_delete ) { ?> |
|
1229
|
+ <i class="far fa-trash-alt text-danger ml-2 ms-2" |
|
1230
|
+ id="delete-<?php echo esc_attr( $result_str ); ?>" |
|
1231
|
+ onclick="delete_field('<?php echo esc_attr( $result_str ); ?>', '<?php echo esc_attr( wp_create_nonce( 'custom_fields_delete_' . $result_str ) ); ?>', '<?php echo esc_attr( $htmlvar_name ); ?>');event.stopPropagation();return false;"></i> |
|
1232
|
+ <?php } ?> |
|
1233
|
+ <i class="fas fa-grip-vertical text-muted ml-2 ms-2" style="cursor: move" aria-hidden="true"></i> |
|
1234
|
+ </div> |
|
842
|
1235
|
|
|
843
|
|
- echo apply_filters("uwp_builder_required_msg_{$field_type}", '', $result_str, $cf, $field_info); |
|
1236
|
+ <?php // store the form as a template. This saves a load of memory on page load. ?> |
|
1237
|
+ <script type="text/template" class="dd-setting <?php echo 'dd-type-' . esc_attr( $field_type ); ?>"> |
|
1238
|
+ <input type="hidden" name="_wpnonce" value="<?php echo esc_attr( $nonce ); ?>"/> |
|
1239
|
+ <input type="hidden" name="form_type" id="form_type" value="<?php echo esc_attr( $form_type ); ?>"/> |
|
1240
|
+ <input type="hidden" name="field_type" id="field_type" value="<?php echo esc_attr( $field_type ); ?>"/> |
|
1241
|
+ <input type="hidden" name="field_type_key" id="field_type_key" value="<?php echo esc_attr( $field_type_key ); ?>"/> |
|
1242
|
+ <input type="hidden" name="field_id" id="field_id" value="<?php echo esc_attr( $result_str ); ?>"/> |
|
1243
|
+ <input type="hidden" name="is_default" value="<?php echo isset( $field_info->is_default ) ? esc_attr( $field_info->is_default ) : ''; ?>"/><?php // show in sidebar value ?> |
|
844
|
1244
|
|
|
845
|
|
- } else { |
|
846
|
|
- $value = ''; |
|
847
|
|
- if (isset($field_info->required_msg)) { |
|
848
|
|
- $value = esc_attr($field_info->required_msg); |
|
849
|
|
- }elseif (isset($cf['defaults']['required_msg']) && $cf['defaults']['required_msg']) { |
|
850
|
|
- $value = $cf['defaults']['required_msg']; |
|
851
|
|
- } |
|
852
|
|
- ?> |
|
853
|
|
- <li class="cf-is-required-msg" <?php if ((isset($field_info->is_required) && $field_info->is_required == '0') || !isset($field_info->is_required)) {echo "style='display:none;'"; }?>> |
|
854
|
|
- <label for="required_msg" class="uwp-tooltip-wrap"> |
|
855
|
|
- <i class="fas fa-info-circle" aria-hidden="true"></i> <?php _e('Required message:', 'userswp'); ?> |
|
856
|
|
- <div class="uwp-tooltip"> |
|
857
|
|
- <?php _e('Enter text for the error message if the field is required and has not fulfilled the requirements.', 'userswp'); ?> |
|
858
|
|
- </div> |
|
859
|
|
- </label> |
|
860
|
|
- <div class="uwp-input-wrap"> |
|
861
|
|
- <input type="text" name="required_msg" id="required_msg" |
|
862
|
|
- value="<?php echo esc_attr($value); ?>"/> |
|
863
|
|
- </div> |
|
864
|
|
- </li> |
|
865
|
|
- <?php |
|
1245
|
+ <?php |
|
1246
|
+ // data_type |
|
1247
|
+ if ( has_filter( "uwp_builder_data_type_{$field_type}" ) ) { |
|
1248
|
+ |
|
1249
|
+ echo apply_filters( "uwp_builder_data_type_{$field_type}", '', $result_str, $cf, $field_info ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
1250
|
+ |
|
1251
|
+ } else { |
|
1252
|
+ $value = ''; |
|
1253
|
+ if ( isset( $field_info->data_type ) ) { |
|
1254
|
+ $value = esc_attr( $field_info->data_type ); |
|
1255
|
+ } elseif ( isset( $cf['defaults']['data_type'] ) && $cf['defaults']['data_type'] ) { |
|
1256
|
+ $value = $cf['defaults']['data_type']; |
|
866
|
1257
|
} |
|
1258
|
+ ?> |
|
1259
|
+ <input type="hidden" name="data_type" id="data_type" value="<?php echo esc_attr( $value ); ?>"/> |
|
1260
|
+ <?php |
|
1261
|
+ } |
|
867
|
1262
|
|
|
1263
|
+ // site_title |
|
1264
|
+ if ( has_filter( "uwp_builder_site_title_{$field_type}" ) ) { |
|
868
|
1265
|
|
|
869
|
|
- // required_msg |
|
870
|
|
- if (has_filter("uwp_builder_validation_pattern_{$field_type}")) { |
|
1266
|
+ echo apply_filters( "uwp_builder_site_title_{$field_type}", '', $result_str, $cf, $field_info ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
871
|
1267
|
|
|
872
|
|
- echo apply_filters("uwp_builder_validation_pattern_{$field_type}", '', $result_str, $cf, $field_info); |
|
873
|
|
- |
|
1268
|
+ } else { |
|
1269
|
+ $value = ''; |
|
1270
|
+ if ( isset( $field_info->site_title ) ) { |
|
1271
|
+ $value = esc_attr( $field_info->site_title ); |
|
1272
|
+ } elseif ( isset( $cf['defaults']['site_title'] ) && $cf['defaults']['site_title'] ) { |
|
1273
|
+ $value = $cf['defaults']['site_title']; |
|
874
|
1274
|
} |
|
875
|
1275
|
|
|
1276
|
+ echo aui()->input( |
|
1277
|
+ array( |
|
1278
|
+ 'id' => 'site_title', |
|
1279
|
+ 'name' => 'site_title', |
|
1280
|
+ 'label_type' => 'top', |
|
1281
|
+ 'label' => esc_html__( 'Label', 'userswp' ) . uwp_help_tip( __( 'This will be the label for the field.', 'userswp' ) ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
1282
|
+ 'type' => 'text', |
|
1283
|
+ // 'wrap_class' => geodir_advanced_toggle_class(), |
|
1284
|
+ 'value' => $value, |
|
1285
|
+ ) |
|
1286
|
+ ); |
|
1287
|
+ } |
|
876
|
1288
|
|
|
877
|
|
- // extra_fields |
|
878
|
|
- if (has_filter("uwp_builder_extra_fields_{$field_type}")) { |
|
1289
|
+ // Input Label |
|
1290
|
+ if ( has_filter( "uwp_builder_form_label_{$field_type}" ) ) { |
|
879
|
1291
|
|
|
880
|
|
- echo apply_filters("uwp_builder_extra_fields_{$field_type}", '', $result_str, $cf, $field_info); |
|
1292
|
+ echo apply_filters( "uwp_builder_form_label_{$field_type}", '', $result_str, $cf, $field_info ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
881
|
1293
|
|
|
1294
|
+ } else { |
|
1295
|
+ $value = ''; |
|
1296
|
+ if ( isset( $field_info->form_label ) ) { |
|
1297
|
+ $value = esc_attr( $field_info->form_label ); |
|
1298
|
+ } elseif ( isset( $cf['defaults']['form_label'] ) && $cf['defaults']['form_label'] ) { |
|
1299
|
+ $value = $cf['defaults']['form_label']; |
|
882
|
1300
|
} |
|
883
|
1301
|
|
|
1302
|
+ echo aui()->input( |
|
1303
|
+ array( |
|
1304
|
+ 'id' => 'form_label', |
|
1305
|
+ 'name' => 'form_label', |
|
1306
|
+ 'label_type' => 'top', |
|
1307
|
+ 'label' => esc_html__( 'Form Label: (Optional)', 'userswp' ) . uwp_help_tip( __( 'If your form label is different, then you can fill this field. Ex: You would like to display "What is your age?" in Form Field but would like to display "DOB" in site. In such cases "What is your age?" should be entered here and "DOB" should be entered in previous field. Note: If this field not filled, then the previous field will be used in Form.', 'userswp' ) ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
1308
|
+ 'type' => 'text', |
|
1309
|
+ 'wrap_class' => uwp_advanced_toggle_class(), |
|
1310
|
+ 'value' => $value, |
|
1311
|
+ ) |
|
1312
|
+ ); |
|
1313
|
+ } |
|
884
|
1314
|
|
|
885
|
|
- // field_icon |
|
886
|
|
- if (has_filter("uwp_builder_field_icon_{$field_type}")) { |
|
1315
|
+ // Input Description |
|
1316
|
+ if ( has_filter( "uwp_builder_field_description_{$field_type}" ) ) { |
|
887
|
1317
|
|
|
888
|
|
- echo apply_filters("uwp_builder_field_icon_{$field_type}", '', $result_str, $cf, $field_info); |
|
1318
|
+ echo apply_filters( "uwp_builder_field_description_{$field_type}", '', $result_str, $cf, $field_info ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
889
|
1319
|
|
|
890
|
|
- } else { |
|
891
|
|
- $value = ''; |
|
892
|
|
- if (isset($field_info->field_icon)) { |
|
893
|
|
- $value = esc_attr($field_info->field_icon); |
|
894
|
|
- }elseif (isset($cf['defaults']['field_icon']) && $cf['defaults']['field_icon']) { |
|
895
|
|
- $value = $cf['defaults']['field_icon']; |
|
896
|
|
- } |
|
897
|
|
- ?> |
|
898
|
|
- <li> |
|
899
|
|
- |
|
900
|
|
- <label for="field_icon" class="uwp-tooltip-wrap"> |
|
901
|
|
- <i class="fas fa-info-circle" aria-hidden="true"></i> <?php _e('Upload icon :', 'userswp'); ?> |
|
902
|
|
- <div class="uwp-tooltip"> |
|
903
|
|
- <?php _e('Upload icon using media and enter its url path, or enter <a href="http://fortawesome.github.io/Font-Awesome/icons/" target="_blank" >font awesome </a>class eg:"fas fa-home"', 'userswp'); ?> |
|
904
|
|
- </div> |
|
905
|
|
- </label> |
|
906
|
|
- <div class="uwp-input-wrap"> |
|
907
|
|
- <input type="text" name="field_icon" id="field_icon" |
|
908
|
|
- value="<?php echo $value; ?>"/> |
|
909
|
|
- </div> |
|
910
|
|
- |
|
911
|
|
- </li> |
|
912
|
|
- <?php |
|
1320
|
+ } else { |
|
1321
|
+ $value = ''; |
|
1322
|
+ if ( isset( $field_info->help_text ) ) { |
|
1323
|
+ $value = esc_attr( $field_info->help_text ); |
|
1324
|
+ } elseif ( isset( $cf['defaults']['help_text'] ) && $cf['defaults']['help_text'] ) { |
|
1325
|
+ $value = $cf['defaults']['help_text']; |
|
913
|
1326
|
} |
|
1327
|
+ $tip_text = ! empty( $cf['help_text_tip'] ) ? esc_attr( $cf['help_text_tip'] ) : __( 'This will be displayed below the field in the form.', 'userswp' ); |
|
1328
|
+ echo aui()->input( |
|
1329
|
+ array( |
|
1330
|
+ 'id' => 'help_text', |
|
1331
|
+ 'name' => 'help_text', |
|
1332
|
+ 'label_type' => 'top', |
|
1333
|
+ 'label' => esc_html__( 'Field Description', 'userswp' ) . uwp_help_tip( $tip_text ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
1334
|
+ 'type' => 'text', |
|
1335
|
+ //'wrap_class' => uwp_advanced_toggle_class(), |
|
1336
|
+ 'value' => $value, |
|
1337
|
+ ) |
|
1338
|
+ ); |
|
914
|
1339
|
|
|
1340
|
+ } |
|
915
|
1341
|
|
|
916
|
|
- // css_class |
|
917
|
|
- if (has_filter("uwp_builder_css_class_{$field_type}")) { |
|
1342
|
+ // htmlvar_name |
|
1343
|
+ if ( has_filter( "uwp_builder_htmlvar_name_{$field_type}" ) ) { |
|
918
|
1344
|
|
|
919
|
|
- echo apply_filters("uwp_builder_css_class_{$field_type}", '', $result_str, $cf, $field_info); |
|
1345
|
+ echo apply_filters( "uwp_builder_htmlvar_name_{$field_type}", '', $result_str, $cf, $field_info ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
920
|
1346
|
|
|
921
|
|
- } else { |
|
922
|
|
- ?> |
|
923
|
|
- <li> |
|
924
|
|
- |
|
925
|
|
- <label for="css_class" class="uwp-tooltip-wrap"> |
|
926
|
|
- <i class="fas fa-info-circle" aria-hidden="true"></i> <?php _e('Css class :', 'userswp'); ?> |
|
927
|
|
- <div class="uwp-tooltip"> |
|
928
|
|
- <?php _e('Enter custom css class for field custom style.', 'userswp'); ?> |
|
929
|
|
- <?php if ($field_type == 'multiselect') {_e('(Enter class `uwp-comma-list` to show list as comma separated)', 'userswp'); }?> |
|
930
|
|
- </div> |
|
931
|
|
- </label> |
|
932
|
|
- <div class="uwp-input-wrap"> |
|
933
|
|
- <input type="text" name="css_class" id="css_class" |
|
934
|
|
- value="<?php if (isset($field_info->css_class)) { |
|
935
|
|
- echo esc_attr($field_info->css_class); |
|
936
|
|
- }?>"/> |
|
937
|
|
- </div> |
|
938
|
|
- </li> |
|
939
|
|
- <?php |
|
1347
|
+ } else { |
|
1348
|
+ $value = ''; |
|
1349
|
+ if ( isset( $field_info->htmlvar_name ) ) { |
|
1350
|
+ $value = esc_attr( $field_info->htmlvar_name ); |
|
1351
|
+ } elseif ( isset( $cf['defaults']['htmlvar_name'] ) && $cf['defaults']['htmlvar_name'] ) { |
|
1352
|
+ $value = $cf['defaults']['htmlvar_name']; |
|
940
|
1353
|
} |
|
941
|
1354
|
|
|
942
|
|
- // show_in |
|
943
|
|
- if (has_filter("uwp_builder_show_in_{$field_type}")) { |
|
1355
|
+ $extra_attributes = array(); |
|
1356
|
+ $class = ''; |
|
1357
|
+ if ( isset( $field_info->id ) && substr( $field_info->id, 0, 4 ) === 'new-' && empty( $field_info->single_use ) ) { |
|
1358
|
+} // New non single use predefined fields should have ability to change html_var |
|
1359
|
+ elseif ( ! empty( $value ) && $value != 'uwp_' ) { |
|
1360
|
+$extra_attributes['readonly'] = 'readonly'; $class = 'bg-opacity-50 bg-gray'; } |
|
944
|
1361
|
|
|
945
|
|
- echo apply_filters("uwp_builder_show_in_{$field_type}", '', $result_str, $cf, $field_info); |
|
1362
|
+ $extra_attributes['maxlength'] = 50; |
|
1363
|
+ $extra_attributes['pattern'] = '[a-zA-Z0-9]+'; |
|
946
|
1364
|
|
|
947
|
|
- } else { |
|
948
|
|
- $value = ''; |
|
949
|
|
- if (isset($field_info->show_in)) { |
|
950
|
|
- $value = esc_attr($field_info->show_in); |
|
951
|
|
- }elseif (isset($cf['defaults']['show_in']) && $cf['defaults']['show_in']) { |
|
952
|
|
- $value = esc_attr($cf['defaults']['show_in']); |
|
953
|
|
- } |
|
954
|
|
- ?> |
|
955
|
|
- <li> |
|
956
|
|
- <label for="show_in" class="uwp-tooltip-wrap"><i class="fas fa-info-circle" aria-hidden="true"></i> <?php _e('Show in what locations?:', 'userswp'); ?> |
|
957
|
|
- <div class="uwp-tooltip"> |
|
958
|
|
- <?php _e('Select in what locations you want to display this field.', 'userswp'); ?> |
|
959
|
|
- </div> |
|
960
|
|
- </label> |
|
961
|
|
- <div class="uwp-input-wrap"> |
|
1365
|
+ echo aui()->input( |
|
1366
|
+ array( |
|
1367
|
+ 'id' => 'htmlvar_name', |
|
1368
|
+ 'name' => 'htmlvar_name', |
|
1369
|
+ 'title' => __( 'Must not contain spaces or special characters', 'userswp' ), |
|
1370
|
+ 'label_type' => 'top', |
|
1371
|
+ 'label' => __( 'Key', 'userswp' ) . uwp_help_tip( __( 'This is a unique identifier used in the HTML, it MUST NOT contain spaces or special characters.', 'userswp' ) ), |
|
1372
|
+ 'type' => 'text', |
|
1373
|
+ 'wrap_class' => uwp_advanced_toggle_class(), |
|
1374
|
+ 'value' => $value ? preg_replace( '/uwp_/', '', $value, 1 ) : '', |
|
1375
|
+ 'extra_attributes' => $extra_attributes, |
|
1376
|
+ 'class' => $class, |
|
1377
|
+ ) |
|
1378
|
+ ); |
|
962
|
1379
|
|
|
963
|
|
- <?php |
|
1380
|
+ } |
|
964
|
1381
|
|
|
965
|
|
- $show_in_locations = array( |
|
966
|
|
- "[users]" => __("Users Page", 'userswp'), |
|
967
|
|
- "[more_info]" => __("More info tab", 'userswp'), |
|
968
|
|
- "[own_tab]" => __("Profile page own tab", 'userswp'), |
|
969
|
|
- "[profile_side]" => __("Profile Side", 'userswp'), |
|
970
|
|
- ); |
|
1382
|
+ // Placeholder text |
|
1383
|
+ if ( has_filter( "uwp_builder_placeholder_value_{$field_type}" ) ) { |
|
971
|
1384
|
|
|
972
|
|
- if ($field_type != 'fieldset') { |
|
973
|
|
- $show_in_locations["[fieldset]"] = __("Fieldset", 'userswp'); |
|
974
|
|
- } |
|
975
|
|
- |
|
976
|
|
- $show_in_locations = apply_filters('uwp_show_in_locations', $show_in_locations, $field_info, $field_type); |
|
1385
|
+ echo apply_filters( "uwp_builder_placeholder_value_{$field_type}", '', $result_str, $cf, $field_info ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
977
|
1386
|
|
|
978
|
|
- |
|
979
|
|
- if (in_array($field_type, array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file'))) { |
|
980
|
|
- } else { |
|
981
|
|
- unset($show_in_locations['[own_tab]']); |
|
982
|
|
- } |
|
983
|
|
- |
|
984
|
|
- ?> |
|
1387
|
+ } else { |
|
1388
|
+ $value = ''; |
|
1389
|
+ if ( isset( $field_info->placeholder_value ) ) { |
|
1390
|
+ $value = esc_attr( $field_info->placeholder_value ); |
|
1391
|
+ } elseif ( isset( $cf['defaults']['placeholder_value'] ) && $cf['defaults']['placeholder_value'] ) { |
|
1392
|
+ $value = $cf['defaults']['placeholder_value']; |
|
1393
|
+ } |
|
985
|
1394
|
|
|
986
|
|
- <select multiple="multiple" name="show_in[]" |
|
987
|
|
- id="show_in" |
|
988
|
|
- style="min-width:300px;" |
|
989
|
|
- class="uwp_chosen_select" |
|
990
|
|
- data-placeholder="<?php _e('Select locations', 'userswp'); ?>"> |
|
991
|
|
- <?php |
|
1395
|
+ echo aui()->input( |
|
1396
|
+ array( |
|
1397
|
+ 'id' => 'placeholder_value_' . esc_attr( $result_str ), |
|
1398
|
+ 'name' => 'placeholder_value', |
|
1399
|
+ 'title' => __( 'Enter placeholder text for this field.', 'userswp' ), |
|
1400
|
+ 'label_type' => 'top', |
|
1401
|
+ 'label' => esc_html__( 'Placeholder', 'userswp' ) . uwp_help_tip( __( 'Display placeholder text for this field.', 'userswp' ) ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
1402
|
+ 'type' => 'text', |
|
1403
|
+ 'wrap_class' => uwp_advanced_toggle_class(), |
|
1404
|
+ 'value' => $value, |
|
1405
|
+ ) |
|
1406
|
+ ); |
|
992
|
1407
|
|
|
993
|
|
- $show_in_values = explode(',', $value); |
|
1408
|
+ } |
|
994
|
1409
|
|
|
995
|
|
- foreach ($show_in_locations as $key => $val) { |
|
996
|
|
- $selected = ''; |
|
1410
|
+ // is_active |
|
1411
|
+ if ( has_filter( "uwp_builder_is_active_{$field_type}" ) ) { |
|
997
|
1412
|
|
|
998
|
|
- if (is_array($show_in_values) && in_array($key, $show_in_values)) { |
|
999
|
|
- $selected = 'selected'; |
|
1000
|
|
- } |
|
1413
|
+ echo apply_filters( "uwp_builder_is_active_{$field_type}", '', $result_str, $cf, $field_info ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
1001
|
1414
|
|
|
1002
|
|
- ?> |
|
1003
|
|
- <option value="<?php echo $key; ?>" <?php echo $selected; ?>><?php echo $val; ?></option> |
|
1004
|
|
- <?php |
|
1005
|
|
- } |
|
1006
|
|
- ?> |
|
1007
|
|
- </select> |
|
1008
|
|
- </div> |
|
1009
|
|
- </li> |
|
1010
|
|
- <?php |
|
1415
|
+ } else { |
|
1416
|
+ $value = ''; |
|
1417
|
+ if ( isset( $field_info->is_active ) ) { |
|
1418
|
+ $value = esc_attr( $field_info->is_active ); |
|
1419
|
+ } elseif ( isset( $cf['defaults']['is_active'] ) && $cf['defaults']['is_active'] ) { |
|
1420
|
+ $value = $cf['defaults']['is_active']; |
|
1011
|
1421
|
} |
|
1012
|
1422
|
|
|
1423
|
+ echo aui()->input( |
|
1424
|
+ array( |
|
1425
|
+ 'id' => 'is_active', |
|
1426
|
+ 'name' => 'is_active', |
|
1427
|
+ 'type' => 'checkbox', |
|
1428
|
+ 'label_type' => 'horizontal', |
|
1429
|
+ 'label_col' => '4', |
|
1430
|
+ 'label' => __( 'Is active', 'userswp' ), |
|
1431
|
+ 'checked' => $value, |
|
1432
|
+ 'value' => '1', |
|
1433
|
+ 'with_hidden' => '', |
|
1434
|
+ 'switch' => 'md', |
|
1435
|
+ 'label_force_left' => true, |
|
1436
|
+ 'help_text' => uwp_help_tip( __( 'If no is selected then the field will not be displayed anywhere.', 'userswp' ) ), |
|
1437
|
+ ) |
|
1438
|
+ ); |
|
1013
|
1439
|
|
|
1440
|
+ } |
|
1014
|
1441
|
|
|
1015
|
|
- switch ($field_type): |
|
1016
|
|
- default: |
|
1017
|
|
- do_action('uwp_admin_extra_custom_fields', $field_info, $cf); ?> |
|
1442
|
+ // for_admin_use |
|
1443
|
+ if ( has_filter( "uwp_builder_for_admin_use_{$field_type}" ) ) { |
|
1018
|
1444
|
|
|
1445
|
+ echo apply_filters( "uwp_builder_for_admin_use_{$field_type}", '', $result_str, $cf, $field_info ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
1019
|
1446
|
|
|
1020
|
|
- <?php endswitch; ?> |
|
1447
|
+ } else { |
|
1448
|
+ $value = ''; |
|
1449
|
+ if ( isset( $field_info->for_admin_use ) ) { |
|
1450
|
+ $value = esc_attr( $field_info->for_admin_use ); |
|
1451
|
+ } elseif ( isset( $cf['defaults']['for_admin_use'] ) && $cf['defaults']['for_admin_use'] ) { |
|
1452
|
+ $value = $cf['defaults']['for_admin_use']; |
|
1453
|
+ } |
|
1021
|
1454
|
|
|
1455
|
+ echo aui()->input( |
|
1456
|
+ array( |
|
1457
|
+ 'id' => 'for_admin_use', |
|
1458
|
+ 'name' => 'for_admin_use', |
|
1459
|
+ 'type' => 'checkbox', |
|
1460
|
+ 'label_type' => 'horizontal', |
|
1461
|
+ 'label_col' => '4', |
|
1462
|
+ 'label' => __( 'For admin use only?', 'userswp' ), |
|
1463
|
+ 'checked' => $value, |
|
1464
|
+ 'value' => '1', |
|
1465
|
+ 'switch' => 'md', |
|
1466
|
+ 'label_force_left' => true, |
|
1467
|
+ 'help_text' => uwp_help_tip( __( 'If yes is selected then only site admin can see and edit this field.', 'userswp' ) ), |
|
1468
|
+ // 'wrap_class' => uwp_advanced_toggle_class(), |
|
1469
|
+ ) |
|
1470
|
+ ); |
|
1022
|
1471
|
|
|
1023
|
|
- <li> |
|
1472
|
+ } |
|
1024
|
1473
|
|
|
1025
|
|
- <label for="save" class="uwp-tooltip-wrap"> |
|
1026
|
|
- </label> |
|
1027
|
|
- <div class="uwp-input-wrap"> |
|
1028
|
|
- <input type="button" class="button button-primary" name="save" id="save" value="<?php echo esc_attr(__('Save', 'userswp')); ?>" |
|
1029
|
|
- onclick="save_field('<?php echo esc_attr($result_str); ?>')"/> |
|
1030
|
|
- <?php if (!$default): ?> |
|
1031
|
|
- <a href="javascript:void(0)"><input type="button" name="delete" value="<?php echo esc_attr(__('Delete', 'userswp')); ?>" |
|
1032
|
|
- onclick="delete_field('<?php echo esc_attr($result_str); ?>', '<?php echo $nonce; ?>')" |
|
1033
|
|
- class="button"/></a> |
|
1034
|
|
- <?php endif; ?> |
|
1035
|
|
- </div> |
|
1036
|
|
- </li> |
|
1037
|
|
- </ul> |
|
1038
|
|
- </div> |
|
1039
|
|
- </form> |
|
1040
|
|
- </li> |
|
1041
|
|
- <?php |
|
1042
|
|
- } |
|
1474
|
+ // is_public |
|
1475
|
+ if ( has_filter( "uwp_builder_is_public_{$field_type}" ) ) { |
|
1476
|
+ echo apply_filters( "uwp_builder_is_public_{$field_type}", '', $result_str, $cf, $field_info ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
1477
|
+ } else { |
|
1478
|
+ $value = ''; |
|
1043
|
1479
|
|
|
1044
|
|
- public function uwp_form_field_adminhtml($field_type, $result_str, $field_ins_upd = '', $field_type_key = '', $form_type = false) |
|
1045
|
|
- { |
|
1046
|
|
- global $wpdb; |
|
1047
|
|
- $table_name = uwp_get_table_prefix() . 'uwp_form_fields'; |
|
1048
|
|
- $cf = $result_str; |
|
1049
|
|
- if (!is_object($cf)) { |
|
1480
|
+ if ( isset( $field_info->is_public ) ) { |
|
1481
|
+ $value = (int) $field_info->is_public; |
|
1482
|
+ } elseif ( isset( $cf['defaults']['is_public'] ) && ( $cf['defaults']['is_public'] || $cf['defaults']['is_public'] === '0' || $cf['defaults']['is_public'] === 0 ) ) { |
|
1483
|
+ $value = (int) $cf['defaults']['is_public']; |
|
1484
|
+ } |
|
1050
|
1485
|
|
|
1051
|
|
- $field_info = $wpdb->get_row($wpdb->prepare("select * from " . $table_name . " where id= %d", array($cf))); |
|
1486
|
+ aui()->select( |
|
1487
|
+ array( |
|
1488
|
+ 'id' => 'is_public', |
|
1489
|
+ 'name' => 'is_public', |
|
1490
|
+ 'label_type' => 'top', |
|
1491
|
+ 'multiple' => false, |
|
1492
|
+ 'class' => ' mw-100', |
|
1493
|
+ 'options' => array( |
|
1494
|
+ '1' => __( 'Yes', 'userswp' ), |
|
1495
|
+ '0' => __( 'No', 'userswp' ), |
|
1496
|
+ '2' => __( 'Let User Decide', 'userswp' ) |
|
1497
|
+ ), |
|
1498
|
+ 'label' => __( 'Is Public', 'userswp' ) . uwp_help_tip( __( 'If no is selected then the field will not be visible to other users.', 'userswp' ) ), |
|
1499
|
+ 'value' => $value, |
|
1500
|
+ 'wrap_class' => uwp_advanced_toggle_class() |
|
1501
|
+ ), |
|
1502
|
+ true |
|
1503
|
+ ); |
|
1504
|
+ } |
|
1052
|
1505
|
|
|
1053
|
|
- } else { |
|
1054
|
|
- $field_info = $cf; |
|
1055
|
|
- $result_str = $cf->id; |
|
1056
|
|
- } |
|
1506
|
+ // default_value |
|
1507
|
+ if ( has_filter( "uwp_builder_default_value_{$field_type}" ) ) { |
|
1057
|
1508
|
|
|
1058
|
|
- $this->uwp_admin_form_field_html($field_info, $field_type, $field_type_key, $field_ins_upd, $result_str, $form_type); |
|
1509
|
+ echo apply_filters( "uwp_builder_default_value_{$field_type}", '', $result_str, $cf, $field_info ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
1059
|
1510
|
|
|
1060
|
|
- } |
|
1061
|
|
- |
|
1511
|
+ } else { |
|
1512
|
+ $value = ''; |
|
1513
|
+ if ( isset( $field_info->default_value ) ) { |
|
1514
|
+ $value = esc_attr( $field_info->default_value ); |
|
1515
|
+ } elseif ( isset( $cf['defaults']['default_value'] ) && $cf['defaults']['default_value'] ) { |
|
1516
|
+ $value = $cf['defaults']['default_value']; |
|
1517
|
+ } |
|
1062
|
1518
|
|
|
1063
|
|
- public function uwp_admin_form_field_save($request_field = array()) |
|
1064
|
|
- { |
|
1519
|
+ // tip text |
|
1520
|
+ if ( $field_type == 'checkbox' ) { |
|
1521
|
+ $tip = __( 'Should the checkbox be checked by default?', 'userswp' ); |
|
1522
|
+ } elseif ( $field_type == 'email' ) { |
|
1523
|
+ $tip = __( 'A default value for the field, usually blank. Ex: info@mysite.com', 'userswp' ); |
|
1524
|
+ } else { |
|
1525
|
+ $tip = __( 'A default value for the field, usually blank. (for links this will be used as the link text)', 'userswp' ); |
|
1526
|
+ } |
|
1065
|
1527
|
|
|
1066
|
|
- global $wpdb; |
|
1528
|
+ if ( $field_type == 'checkbox' ) { |
|
1529
|
+ echo aui()->select( |
|
1530
|
+ array( |
|
1531
|
+ 'id' => 'default_value', |
|
1532
|
+ 'name' => 'default_value', |
|
1533
|
+ 'label_type' => 'top', |
|
1534
|
+ 'multiple' => false, |
|
1535
|
+ 'class' => ' mw-100', |
|
1536
|
+ 'options' => array( |
|
1537
|
+ '' => __( 'Unchecked', 'userswp' ), |
|
1538
|
+ '1' => __( 'Checked', 'userswp' ), |
|
1539
|
+ ), |
|
1540
|
+ 'label' => __( 'Default value', 'userswp' ) . uwp_help_tip( $tip ), |
|
1541
|
+ 'value' => $value, |
|
1542
|
+ 'wrap_class' => uwp_advanced_toggle_class(), |
|
1543
|
+ ) |
|
1544
|
+ ); |
|
1545
|
+ } else { |
|
1546
|
+ echo aui()->input( |
|
1547
|
+ array( |
|
1548
|
+ 'id' => 'default_value', |
|
1549
|
+ 'name' => 'default_value', |
|
1550
|
+ 'label_type' => 'top', |
|
1551
|
+ 'label' => __( 'Default value', 'userswp' ) . uwp_help_tip( $tip ), |
|
1552
|
+ 'type' => 'text', |
|
1553
|
+ 'wrap_class' => uwp_advanced_toggle_class(), |
|
1554
|
+ 'value' => $value, |
|
1555
|
+ 'placeholder' => $field_type == 'email' ? __( 'info@mysite.com', 'userswp' ) : '', |
|
1556
|
+ ) |
|
1557
|
+ ); |
|
1558
|
+ } |
|
1559
|
+} |
|
1067
|
1560
|
|
|
1561
|
+ // advanced_editor |
|
1562
|
+ if ( has_filter( "uwp_builder_advanced_editor_{$field_type}" ) ) { |
|
1068
|
1563
|
|
|
1069
|
|
- $table_name = uwp_get_table_prefix() . 'uwp_form_fields'; |
|
1564
|
+ echo apply_filters( "uwp_builder_advanced_editor_{$field_type}", '', $result_str, $cf, $field_info ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
1070
|
1565
|
|
|
1071
|
|
- $meta_table = get_usermeta_table_prefix() . 'uwp_usermeta'; |
|
1566
|
+ } |
|
1567
|
+ ?> |
|
1568
|
+ <input type="hidden" readonly="readonly" name="sort_order" id="sort_order" value="<?php echo isset( $field_info->sort_order ) ? esc_attr( $field_info->sort_order ) : ''; ?>"/> |
|
1569
|
+ <?php |
|
1072
|
1570
|
|
|
1073
|
|
- $old_html_variable = ''; |
|
1571
|
+ // is_required |
|
1572
|
+ if ( has_filter( "uwp_builder_is_required_{$field_type}" ) ) { |
|
1074
|
1573
|
|
|
1574
|
+ echo apply_filters( "uwp_builder_is_required_{$field_type}", '', $result_str, $cf, $field_info ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
1075
|
1575
|
|
|
1076
|
|
- $result_str = isset($request_field['field_id']) ? trim($request_field['field_id']) : ''; |
|
1576
|
+ } else { |
|
1577
|
+ $value = ''; |
|
1578
|
+ if ( isset( $field_info->is_required ) ) { |
|
1579
|
+ $value = esc_attr( $field_info->is_required ); |
|
1580
|
+ } elseif ( isset( $cf['defaults']['is_required'] ) && $cf['defaults']['is_required'] ) { |
|
1581
|
+ $value = $cf['defaults']['is_required']; |
|
1582
|
+ } |
|
1077
|
1583
|
|
|
1078
|
|
- $user_meta_info = null; |
|
1584
|
+ echo aui()->input( |
|
1585
|
+ array( |
|
1586
|
+ 'id' => 'is_required', |
|
1587
|
+ 'name' => 'is_required', |
|
1588
|
+ 'type' => 'checkbox', |
|
1589
|
+ 'label_type' => 'horizontal', |
|
1590
|
+ 'label_col' => '4', |
|
1591
|
+ 'label' => __( 'Is required', 'userswp' ), |
|
1592
|
+ 'checked' => $value, |
|
1593
|
+ 'value' => '1', |
|
1594
|
+ 'switch' => 'md', |
|
1595
|
+ 'label_force_left' => true, |
|
1596
|
+ 'help_text' => uwp_help_tip( __( 'Select yes to set field as required', 'userswp' ) ), |
|
1597
|
+ // 'wrap_class' => uwp_advanced_toggle_class(), |
|
1598
|
+ ) |
|
1599
|
+ ); |
|
1079
|
1600
|
|
|
1080
|
|
- // some servers fail if a POST value is VARCHAR so we change it. |
|
1081
|
|
- if (isset($request_field['data_type']) && $request_field['data_type'] == 'XVARCHAR') { |
|
1082
|
|
- $request_field['data_type'] = 'VARCHAR'; |
|
1083
|
|
- } |
|
1084
|
|
- |
|
1085
|
|
- $cf = trim($result_str, '_'); |
|
1601
|
+ } |
|
1086
|
1602
|
|
|
1603
|
+ // required_msg |
|
1604
|
+ if ( has_filter( "uwp_builder_required_msg_{$field_type}" ) ) { |
|
1087
|
1605
|
|
|
1088
|
|
- $cehhtmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : ''; |
|
1089
|
|
- $form_type = $request_field['form_type']; |
|
1606
|
+ echo apply_filters( "uwp_builder_required_msg_{$field_type}", '', $result_str, $cf, $field_info ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
1090
|
1607
|
|
|
1091
|
|
- if ($request_field['field_type'] != 'fieldset') { |
|
1092
|
|
- $cehhtmlvar_name = 'uwp_' . $form_type . '_' . $cehhtmlvar_name; |
|
1093
|
|
- } |
|
1608
|
+ } else { |
|
1609
|
+ $value = ''; |
|
1610
|
+ if ( isset( $field_info->required_msg ) ) { |
|
1611
|
+ $value = esc_attr( $field_info->required_msg ); |
|
1612
|
+ } elseif ( isset( $cf['defaults']['required_msg'] ) && $cf['defaults']['required_msg'] ) { |
|
1613
|
+ $value = $cf['defaults']['required_msg']; |
|
1614
|
+ } |
|
1094
|
1615
|
|
|
1095
|
|
- $check_html_variable = $wpdb->get_var( |
|
1096
|
|
- $wpdb->prepare( |
|
1097
|
|
- "select htmlvar_name from " . $table_name . " where id <> %d and htmlvar_name = %s and form_type = %s ", |
|
1098
|
|
- array($cf, $cehhtmlvar_name, $form_type) |
|
1099
|
|
- ) |
|
1100
|
|
- ); |
|
1616
|
+ echo aui()->input( |
|
1617
|
+ array( |
|
1618
|
+ 'id' => 'required_msg', |
|
1619
|
+ 'name' => 'required_msg', |
|
1620
|
+ 'label_type' => 'top', |
|
1621
|
+ 'label' => __( 'Required message', 'userswp' ) . uwp_help_tip( __( 'Enter text for the error message if the field is required and has not fulfilled the requirements.', 'userswp' ) ), |
|
1622
|
+ 'type' => 'text', |
|
1623
|
+ 'wrap_class' => uwp_advanced_toggle_class(), |
|
1624
|
+ 'value' => $value, |
|
1625
|
+ 'element_require' => '[%is_required%:checked]', |
|
1626
|
+ ) |
|
1627
|
+ ); |
|
1101
|
1628
|
|
|
1629
|
+ } |
|
1102
|
1630
|
|
|
1103
|
|
- if (!$check_html_variable || $request_field['field_type'] == 'fieldset') { |
|
1631
|
+ // validation pattern |
|
1632
|
+ if ( has_filter( "uwp_builder_validation_pattern_{$field_type}" ) ) { |
|
1104
|
1633
|
|
|
1105
|
|
- if ($cf != '') { |
|
1634
|
+ echo apply_filters( "uwp_builder_validation_pattern_{$field_type}", '', $result_str, $cf, $field_info ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
1106
|
1635
|
|
|
1107
|
|
- $user_meta_info = $wpdb->get_row( |
|
1108
|
|
- $wpdb->prepare( |
|
1109
|
|
- "select * from " . $table_name . " where id = %d", |
|
1110
|
|
- array($cf) |
|
1111
|
|
- ) |
|
1112
|
|
- ); |
|
1636
|
+ } |
|
1113
|
1637
|
|
|
1114
|
|
- } |
|
1638
|
+ // extra_fields |
|
1639
|
+ if ( has_filter( "uwp_builder_extra_fields_{$field_type}" ) ) { |
|
1115
|
1640
|
|
|
1116
|
|
- if (!empty($user_meta_info)) { |
|
1117
|
|
- $old_html_variable = $user_meta_info->htmlvar_name; |
|
1641
|
+ echo apply_filters( "uwp_builder_extra_fields_{$field_type}", '', $result_str, $cf, $field_info ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
1118
|
1642
|
|
|
1119
|
|
- } |
|
1643
|
+ } |
|
1120
|
1644
|
|
|
1645
|
+ // field_icon |
|
1646
|
+ if ( has_filter( "uwp_builder_field_icon_{$field_type}" ) ) { |
|
1121
|
1647
|
|
|
1122
|
|
- $site_title = $request_field['site_title']; |
|
1123
|
|
- $form_label = isset($request_field['form_label']) ? $request_field['form_label'] : ''; |
|
1124
|
|
- $field_type = $request_field['field_type']; |
|
1125
|
|
- $data_type = $request_field['data_type']; |
|
1126
|
|
- $field_type_key = isset($request_field['field_type_key']) ? $request_field['field_type_key'] : $field_type; |
|
1127
|
|
- $htmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : ''; |
|
1128
|
|
- $default_value = isset($request_field['default_value']) ? $request_field['default_value'] : ''; |
|
1129
|
|
- $sort_order = isset($request_field['sort_order']) ? $request_field['sort_order'] : ''; |
|
1130
|
|
- $is_active = isset($request_field['is_active']) ? $request_field['is_active'] : ''; |
|
1131
|
|
- $for_admin_use = isset($request_field['for_admin_use']) ? $request_field['for_admin_use'] : ''; |
|
1132
|
|
- $is_required = isset($request_field['is_required']) ? $request_field['is_required'] : ''; |
|
1133
|
|
- $is_dummy = isset($request_field['is_dummy']) ? $request_field['is_dummy'] : ''; |
|
1134
|
|
- $is_public = isset($request_field['is_public']) ? $request_field['is_public'] : ''; |
|
1135
|
|
- $is_register_field = isset($request_field['is_register_field']) ? $request_field['is_register_field'] : ''; |
|
1136
|
|
- $is_search_field = isset($request_field['is_search_field']) ? $request_field['is_search_field'] : ''; |
|
1137
|
|
- $is_register_only_field = isset($request_field['is_register_only_field']) ? $request_field['is_register_only_field'] : ''; |
|
1138
|
|
- $required_msg = isset($request_field['required_msg']) ? $request_field['required_msg'] : ''; |
|
1139
|
|
- $css_class = isset($request_field['css_class']) ? $request_field['css_class'] : ''; |
|
1140
|
|
- $field_icon = isset($request_field['field_icon']) ? $request_field['field_icon'] : ''; |
|
1141
|
|
- $show_in = isset($request_field['show_in']) ? $request_field['show_in'] : ''; |
|
1142
|
|
- $user_roles = isset($request_field['user_roles']) ? $request_field['user_roles'] : ''; |
|
1143
|
|
- $decimal_point = isset($request_field['decimal_point']) ? trim($request_field['decimal_point']) : ''; // decimal point for DECIMAL data type |
|
1144
|
|
- $decimal_point = $decimal_point > 0 ? ($decimal_point > 10 ? 10 : $decimal_point) : ''; |
|
1145
|
|
- $validation_pattern = isset($request_field['validation_pattern']) ? $request_field['validation_pattern'] : ''; |
|
1146
|
|
- $validation_msg = isset($request_field['validation_msg']) ? $request_field['validation_msg'] : ''; |
|
1648
|
+ echo apply_filters( "uwp_builder_field_icon_{$field_type}", '', $result_str, $cf, $field_info ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
1147
|
1649
|
|
|
1650
|
+ } else { |
|
1651
|
+ $value = ''; |
|
1652
|
+ if ( isset( $field_info->field_icon ) ) { |
|
1653
|
+ $value = esc_attr( $field_info->field_icon ); |
|
1654
|
+ } elseif ( isset( $cf['defaults']['field_icon'] ) && $cf['defaults']['field_icon'] ) { |
|
1655
|
+ $value = $cf['defaults']['field_icon']; |
|
1656
|
+ } |
|
1148
|
1657
|
|
|
1149
|
|
- if (is_array($show_in)) { |
|
1150
|
|
- $show_in = implode(",", $request_field['show_in']); |
|
1151
|
|
- } |
|
1658
|
+ echo aui()->input( |
|
1659
|
+ array( |
|
1660
|
+ 'id' => 'field_icon', |
|
1661
|
+ 'name' => 'field_icon', |
|
1662
|
+ 'label_type' => 'top', |
|
1663
|
+ 'label' => __( 'Icon', 'userswp' ) . uwp_help_tip( sprintf( __( 'Upload icon using media and enter its url path, or enter %1$sfont awesome%2$s class eg:"fas fa-home"', 'userswp' ), '<a href="http://fortawesome.github.io/Font-Awesome/icons/" target="_blank" >', '</a>' ) ), |
|
1664
|
+ 'type' => 'iconpicker', |
|
1665
|
+ 'wrap_class' => uwp_advanced_toggle_class(), |
|
1666
|
+ 'value' => $value, |
|
1667
|
+ 'extra_attributes' => defined( 'FAS_PRO' ) && FAS_PRO ? array( |
|
1668
|
+ 'data-fa-icons' => true, |
|
1669
|
+ 'data-bs-toggle' => 'tooltip', |
|
1670
|
+ 'data-bs-trigger' => 'focus', |
|
1671
|
+ 'title' => __( 'For pro icon variants (light, thin, duotone), paste the class here', 'userswp' ), |
|
1672
|
+ ) : array(), |
|
1673
|
+ ) |
|
1674
|
+ ); |
|
1152
|
1675
|
|
|
1153
|
|
- if (is_array($user_roles)) { |
|
1154
|
|
- $user_roles = implode(",", $request_field['user_roles']); |
|
1155
|
|
- } |
|
1676
|
+ } |
|
1156
|
1677
|
|
|
1157
|
|
- // fieldset need htmlvar_name for register tab |
|
1158
|
|
- $htmlvar_name = 'uwp_' . $form_type . '_' . $htmlvar_name; |
|
1678
|
+ // css_class |
|
1679
|
+ if ( has_filter( "uwp_builder_css_class_{$field_type}" ) ) { |
|
1159
|
1680
|
|
|
1681
|
+ echo apply_filters( "uwp_builder_css_class_{$field_type}", '', $result_str, $cf, $field_info ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
1160
|
1682
|
|
|
1161
|
|
- $option_values = ''; |
|
1162
|
|
- if (isset($request_field['option_values'])) |
|
1163
|
|
- $option_values = $request_field['option_values']; |
|
1683
|
+ } else { |
|
1164
|
1684
|
|
|
1165
|
|
- if (isset($request_field['extra']) && !empty($request_field['extra'])) |
|
1166
|
|
- $extra_fields = $request_field['extra']; |
|
1685
|
+ $value = ''; |
|
1686
|
+ if ( isset( $field_info->css_class ) ) { |
|
1687
|
+ $value = esc_attr( $field_info->css_class ); |
|
1688
|
+ } elseif ( isset( $cf['defaults']['css_class'] ) && $cf['defaults']['css_class'] ) { |
|
1689
|
+ $value = $cf['defaults']['css_class']; |
|
1690
|
+ } |
|
1691
|
+ $tip = __( 'Enter custom css class for field custom style.', 'userswp' ); |
|
1692
|
+ if ( $field_type == 'multiselect' ) { |
|
1693
|
+ $tip .= __( '(Enter class `uwp-comma-list` to show list as comma separated)', 'userswp' ); |
|
1694
|
+ } |
|
1167
|
1695
|
|
|
1168
|
|
- if (isset($request_field['is_default']) && $request_field['is_default'] != '') |
|
1169
|
|
- $is_default = $request_field['is_default']; |
|
1170
|
|
- else |
|
1171
|
|
- $is_default = '0'; |
|
1696
|
+ echo aui()->input( |
|
1697
|
+ array( |
|
1698
|
+ 'id' => 'css_class', |
|
1699
|
+ 'name' => 'css_class', |
|
1700
|
+ 'label_type' => 'top', |
|
1701
|
+ 'label' => __( 'CSS class', 'userswp' ) . uwp_help_tip( $tip ), |
|
1702
|
+ 'type' => 'text', |
|
1703
|
+ 'wrap_class' => uwp_advanced_toggle_class(), |
|
1704
|
+ 'value' => $value, |
|
1705
|
+ ) |
|
1706
|
+ ); |
|
1172
|
1707
|
|
|
1173
|
|
- if ($is_active == '') $is_active = 1; |
|
1174
|
|
- if ($for_admin_use == '') $for_admin_use = 0; |
|
1175
|
|
- if ($is_required == '') $is_required = 0; |
|
1176
|
|
- if ($is_dummy == '') $is_dummy = 0; |
|
1177
|
|
- if ($is_public == '') $is_public = 0; |
|
1178
|
|
- if ($is_register_field == '') $is_register_field = 0; |
|
1179
|
|
- if ($is_search_field == '') $is_search_field = 0; |
|
1180
|
|
- if ($is_register_only_field == '') $is_register_only_field = 0; |
|
1708
|
+ } |
|
1181
|
1709
|
|
|
1710
|
+ // show_in |
|
1711
|
+ if ( has_filter( "uwp_builder_show_in_{$field_type}" ) ) { |
|
1712
|
+ echo apply_filters( "uwp_builder_show_in_$field_type}", '', $result_str, $cf, $field_info ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
1713
|
+ echo apply_filters( "uwp_builder_show_in_$field_type}", '', $result_str, $cf, $field_info ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
1182
|
1714
|
|
|
1183
|
|
- if ($sort_order == '') { |
|
1715
|
+ echo apply_filters( "uwp_builder_show_in_$field_type}", '', $result_str, $cf, $field_info ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
1184
|
1716
|
|
|
1185
|
|
- $last_order = $wpdb->get_var("SELECT MAX(sort_order) as last_order FROM " . $table_name); |
|
1717
|
+ } else { |
|
1718
|
+ $value = ''; |
|
1719
|
+ if ( isset( $field_info->show_in ) ) { |
|
1720
|
+ $value = esc_attr( $field_info->show_in ); |
|
1721
|
+ } elseif ( isset( $cf['defaults']['show_in'] ) && $cf['defaults']['show_in'] ) { |
|
1722
|
+ $value = esc_attr( $cf['defaults']['show_in'] ); |
|
1723
|
+ } |
|
1186
|
1724
|
|
|
1187
|
|
- $sort_order = (int) $last_order + 1; |
|
1188
|
|
- } |
|
1189
|
|
- |
|
1190
|
|
- if (!empty($user_meta_info)) { |
|
1725
|
+ $show_in_locations = uwp_get_show_in_locations(); |
|
1191
|
1726
|
|
|
1192
|
|
- $excluded = uwp_get_excluded_fields(); |
|
1727
|
+ if ( $field_type == 'fieldset' ) { |
|
1728
|
+ unset( $show_in_locations['[fieldset]'] ); |
|
1729
|
+ } |
|
1193
|
1730
|
|
|
1194
|
|
- $starts_with = "uwp_account_"; |
|
1731
|
+ if ( ! in_array( |
|
1732
|
+ $field_type, |
|
1733
|
+ array( |
|
1734
|
+ 'text', |
|
1735
|
+ 'datepicker', |
|
1736
|
+ 'textarea', |
|
1737
|
+ 'time', |
|
1738
|
+ 'phone', |
|
1739
|
+ 'email', |
|
1740
|
+ 'select', |
|
1741
|
+ 'multiselect', |
|
1742
|
+ 'url', |
|
1743
|
+ 'html', |
|
1744
|
+ 'fieldset', |
|
1745
|
+ 'radio', |
|
1746
|
+ 'checkbox', |
|
1747
|
+ 'file', |
|
1748
|
+ ) |
|
1749
|
+ ) ) { |
|
1750
|
+ unset( $show_in_locations['[own_tab]'] ); |
|
1751
|
+ } |
|
1195
|
1752
|
|
|
1196
|
|
- if ((substr($htmlvar_name, 0, strlen($starts_with)) === $starts_with) && !in_array($htmlvar_name, $excluded)) { |
|
1197
|
|
- // Create custom columns |
|
1198
|
|
- switch ($field_type): |
|
1753
|
+ $show_in_values = $value ? explode( ',', $value ) : ''; |
|
1199
|
1754
|
|
|
1200
|
|
- case 'checkbox': |
|
1201
|
|
- case 'multiselect': |
|
1202
|
|
- case 'select': |
|
1755
|
+ echo aui()->select( |
|
1756
|
+ array( |
|
1757
|
+ 'id' => 'show_in', |
|
1758
|
+ 'name' => 'show_in[]', |
|
1759
|
+ 'label_type' => 'top', |
|
1760
|
+ 'multiple' => true, |
|
1761
|
+ 'select2' => true, |
|
1762
|
+ 'class' => ' mw-100', |
|
1763
|
+ 'options' => $show_in_locations, |
|
1764
|
+ 'label' => __( 'Show in what locations?', 'userswp' ) . uwp_help_tip( __( 'Select in what locations you want to display this field.', 'userswp' ) ), |
|
1765
|
+ 'value' => $show_in_values, |
|
1766
|
+ 'placeholder' => __( 'Select locations', 'userswp' ), |
|
1767
|
+ ) |
|
1768
|
+ ); |
|
1203
|
1769
|
|
|
1204
|
|
- $op_size = '500'; |
|
1770
|
+ } |
|
1205
|
1771
|
|
|
1206
|
|
- // only make the field as big as it needs to be. |
|
1207
|
|
- if (isset($option_values) && $option_values && $field_type == 'select') { |
|
1208
|
|
- $option_values_arr = explode(',', $option_values); |
|
1209
|
|
- if (is_array($option_values_arr)) { |
|
1210
|
|
- $op_max = 0; |
|
1211
|
|
- foreach ($option_values_arr as $op_val) { |
|
1212
|
|
- if (strlen($op_val) && strlen($op_val) > $op_max) {$op_max = strlen($op_val); } |
|
1213
|
|
- } |
|
1214
|
|
- if ($op_max) {$op_size = $op_max; } |
|
1215
|
|
- } |
|
1216
|
|
- }elseif (isset($option_values) && $option_values && $field_type == 'multiselect') { |
|
1217
|
|
- if (strlen($option_values)) { |
|
1218
|
|
- $op_size = strlen($option_values); |
|
1219
|
|
- } |
|
1220
|
|
- } |
|
1772
|
+ do_action( 'uwp_admin_extra_custom_fields', $field_info, $cf ); |
|
1773
|
+ ?> |
|
1221
|
1774
|
|
|
1222
|
|
- $meta_field_add = "ALTER TABLE " . $meta_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "`VARCHAR( $op_size ) NULL"; |
|
1223
|
1775
|
|
|
1224
|
|
- if ($default_value != '') { |
|
1225
|
|
- $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
1226
|
|
- } |
|
1776
|
+ <div class="uwp-input-wrap uwp-tab-actions" data-setting="save_button"> |
|
1227
|
1777
|
|
|
1228
|
|
- $alter_result = $wpdb->query($meta_field_add); |
|
1229
|
|
- if ($alter_result === false) { |
|
1230
|
|
- return __('Column change failed, you may have too many columns.', 'userswp'); |
|
1231
|
|
- } |
|
1778
|
+ <span class="text-left text-start float-left float-start"> |
|
1779
|
+ <?php UsersWP_Settings_Page::toggle_advanced_button( 'btn btn-outline-primary text-left text-start uwp-advanced-toggle', false ); ?> |
|
1780
|
+ </span> |
|
1232
|
1781
|
|
|
1233
|
|
- if (isset($request_field['cat_display_type'])) |
|
1234
|
|
- $extra_fields = $request_field['cat_display_type']; |
|
1782
|
+ <a class=" btn btn-link text-muted" href="javascript:void(0);" onclick="uwp_tabs_close_settings(this); return false;"><?php _e( 'Close', 'userswp' ); ?></a> |
|
1783
|
+ <a href='javascript:void(0);' type="button" class="btn btn-primary" id="save" |
|
1784
|
+ onclick="save_field('<?php echo esc_attr( $result_str ); ?>');"><?php echo esc_attr( __( 'Save', 'userswp' ) ); ?></a> |
|
1785
|
+ </div> |
|
1786
|
+ </script> |
|
1787
|
+ </div> |
|
1788
|
+ </li> |
|
1789
|
+ <?php |
|
1790
|
+ } |
|
1235
|
1791
|
|
|
1236
|
|
- if (isset($request_field['multi_display_type'])) |
|
1237
|
|
- $extra_fields = $request_field['multi_display_type']; |
|
1792
|
+ /** |
|
1793
|
+ * Add HTML5 validation pattern fields. |
|
1794
|
+ * |
|
1795
|
+ * @since 1.2.2.17 |
|
1796
|
+ * |
|
1797
|
+ * @param string $output Html output. |
|
1798
|
+ * @param string $result_str Result string. |
|
1799
|
+ * @param array $cf Custom fields values. |
|
1800
|
+ * @param object $field_info Extra fields information. |
|
1801
|
+ * @return string $output. |
|
1802
|
+ */ |
|
1803
|
+ public static function validation_pattern( $output, $result_str, $cf, $field_info ) { |
|
1804
|
+ ob_start(); |
|
1238
|
1805
|
|
|
1806
|
+ $value = ''; |
|
1807
|
+ if ( isset( $field_info->validation_pattern ) ) { |
|
1808
|
+ $value = esc_attr( $field_info->validation_pattern ); |
|
1809
|
+ } elseif ( isset( $cf['defaults']['validation_pattern'] ) && $cf['defaults']['validation_pattern'] ) { |
|
1810
|
+ $value = $cf['defaults']['validation_pattern']; |
|
1811
|
+ } |
|
1239
|
1812
|
|
|
1240
|
|
- break; |
|
1813
|
+ echo aui()->input( |
|
1814
|
+ array( |
|
1815
|
+ 'id' => 'validation_pattern', |
|
1816
|
+ 'name' => 'validation_pattern', |
|
1817
|
+ 'label_type' => 'top', |
|
1818
|
+ 'label' => __( 'Validation Pattern', 'userswp' ) . uwp_help_tip( __( 'Enter regex expression for HTML5 pattern validation.', 'userswp' ) ), |
|
1819
|
+ 'type' => 'text', |
|
1820
|
+ 'wrap_class' => uwp_advanced_toggle_class(), |
|
1821
|
+ 'value' => wp_slash( $value ), // Keep slashes |
|
1822
|
+ ) |
|
1823
|
+ ); |
|
1241
|
1824
|
|
|
1242
|
|
- case 'textarea': |
|
1243
|
|
- case 'html': |
|
1244
|
|
- case 'url': |
|
1245
|
|
- case 'file': |
|
1825
|
+ $value = ''; |
|
1826
|
+ if ( isset( $field_info->validation_msg ) ) { |
|
1827
|
+ $value = esc_attr( $field_info->validation_msg ); |
|
1828
|
+ } elseif ( isset( $cf['defaults']['validation_msg'] ) && $cf['defaults']['validation_msg'] ) { |
|
1829
|
+ $value = $cf['defaults']['validation_msg']; |
|
1830
|
+ } |
|
1246
|
1831
|
|
|
1247
|
|
- $alter_result = $wpdb->query("ALTER TABLE " . $meta_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` TEXT NULL"); |
|
1248
|
|
- if ($alter_result === false) { |
|
1249
|
|
- return __('Column change failed, you may have too many columns.', 'userswp'); |
|
1250
|
|
- } |
|
1251
|
|
- if (isset($request_field['advanced_editor'])) |
|
1252
|
|
- $extra_fields = $request_field['advanced_editor']; |
|
1832
|
+ echo aui()->input( |
|
1833
|
+ array( |
|
1834
|
+ 'id' => 'validation_msg', |
|
1835
|
+ 'name' => 'validation_msg', |
|
1836
|
+ 'label_type' => 'top', |
|
1837
|
+ 'label' => __( 'Validation Message', 'userswp' ) . uwp_help_tip( __( 'Enter a extra validation message to show to the user if validation fails.', 'userswp' ) ), |
|
1838
|
+ 'type' => 'text', |
|
1839
|
+ 'wrap_class' => uwp_advanced_toggle_class(), |
|
1840
|
+ 'value' => $value, |
|
1841
|
+ ) |
|
1842
|
+ ); |
|
1253
|
1843
|
|
|
1254
|
|
- break; |
|
1844
|
+ $output = ob_get_clean(); |
|
1255
|
1845
|
|
|
1256
|
|
- case 'fieldset': |
|
1257
|
|
- // Nothing happened for fieldset |
|
1258
|
|
- break; |
|
1846
|
+ return $output; |
|
1847
|
+ } |
|
1259
|
1848
|
|
|
1260
|
|
- default: |
|
1261
|
|
- if ($data_type != 'VARCHAR' && $data_type != '') { |
|
1262
|
|
- if ($data_type == 'FLOAT' && $decimal_point > 0) { |
|
1263
|
|
- $default_value_add = "ALTER TABLE " . $meta_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` DECIMAL(11, " . (int) $decimal_point . ") NULL"; |
|
1264
|
|
- } else { |
|
1265
|
|
- $default_value_add = "ALTER TABLE " . $meta_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` " . $data_type . " NULL"; |
|
1266
|
|
- } |
|
1849
|
+ public function register_selected_fields( $form_type ) { |
|
1850
|
+ global $wpdb; |
|
1851
|
+ $extras_table_name = uwp_get_table_prefix() . 'uwp_form_extras'; |
|
1852
|
+ $form_id = self::get_form_id() |
|
1853
|
+ ?> |
|
1854
|
+ <input type="hidden" name="manage_field_type" class="manage_field_type" value="register"> |
|
1855
|
+ <input type="hidden" name="uwp_create_field_nonce" class="uwp_create_field_nonce" value="<?php echo wp_create_nonce( 'uwp_create_field_nonce' ); ?>"/> |
|
1856
|
+ <ul class="core uwp_form_extras uwp-tabs-selected ps-0 list-group "> |
|
1857
|
+ <?php |
|
1267
|
1858
|
|
|
1268
|
|
- if (is_numeric($default_value) && $default_value != '') { |
|
1269
|
|
- $default_value_add .= " DEFAULT '" . $default_value . "'"; |
|
1270
|
|
- } |
|
1271
|
|
- } else { |
|
1272
|
|
- $default_value_add = "ALTER TABLE " . $meta_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` VARCHAR( 254 ) NULL"; |
|
1273
|
|
- if ($default_value != '') { |
|
1274
|
|
- $default_value_add .= " DEFAULT '" . $default_value . "'"; |
|
1275
|
|
- } |
|
1276
|
|
- } |
|
1859
|
+ $fields = $wpdb->get_results( |
|
1860
|
+ $wpdb->prepare( |
|
1861
|
+ 'select * from ' . $extras_table_name . ' where form_type = %s AND form_id = %d order by sort_order asc', |
|
1862
|
+ array( $form_type, $form_id ) |
|
1863
|
+ ) |
|
1864
|
+ ); |
|
1277
|
1865
|
|
|
1278
|
|
- $alter_result = $wpdb->query($default_value_add); |
|
1279
|
|
- if ($alter_result === false) { |
|
1280
|
|
- return __('Column change failed, you may have too many columns.', 'userswp'); |
|
1281
|
|
- } |
|
1282
|
|
- break; |
|
1283
|
|
- endswitch; |
|
1866
|
+ if ( ! empty( $fields ) ) { |
|
1867
|
+ foreach ( $fields as $field ) { |
|
1868
|
+ $result_str = $field; |
|
1869
|
+ $field_ins_upd = 'display'; |
|
1870
|
+ $this->register_field_adminhtml( $result_str, $field_ins_upd, false ); |
|
1284
|
1871
|
} |
|
1872
|
+ } |
|
1873
|
+ ?> |
|
1874
|
+ </ul> |
|
1875
|
+ <?php |
|
1876
|
+ } |
|
1285
|
1877
|
|
|
1286
|
|
- $extra_field_query = ''; |
|
1287
|
|
- if (!empty($extra_fields)) { |
|
1288
|
|
- $extra_field_query = serialize($extra_fields); |
|
1289
|
|
- } |
|
1878
|
+ public function register_field_adminhtml( $result_str, $field_ins_upd = '', $default = false, $request = array() ) { |
|
1879
|
+ global $wpdb; |
|
1290
|
1880
|
|
|
1291
|
|
- $wpdb->query( |
|
1881
|
+ $table_name = uwp_get_table_prefix() . 'uwp_form_fields'; |
|
1882
|
+ $extras_table_name = uwp_get_table_prefix() . 'uwp_form_extras'; |
|
1292
|
1883
|
|
|
1293
|
|
- $wpdb->prepare( |
|
1884
|
+ $cf = $result_str; |
|
1885
|
+ if ( ! is_object( $cf ) && ( is_int( $cf ) || ctype_digit( $cf ) ) ) { |
|
1886
|
+ $field_info = $wpdb->get_row( $wpdb->prepare( 'select * from ' . $extras_table_name . ' where id= %d', array( $cf ) ) ); |
|
1887
|
+ } elseif ( is_object( $cf ) ) { |
|
1888
|
+ $result_str = $cf->id; |
|
1889
|
+ $field_info = $wpdb->get_row( $wpdb->prepare( 'select * from ' . $extras_table_name . ' where id= %d', array( (int) $cf->id ) ) ); |
|
1890
|
+ } else { |
|
1891
|
+ $field_info = false; |
|
1892
|
+ } |
|
1294
|
1893
|
|
|
1295
|
|
- "update " . $table_name . " set |
|
1296
|
|
- form_type = %s, |
|
1297
|
|
- site_title = %s, |
|
1298
|
|
- form_label = %s, |
|
1299
|
|
- field_type = %s, |
|
1300
|
|
- data_type = %s, |
|
1301
|
|
- decimal_point = %s, |
|
1302
|
|
- field_type_key = %s, |
|
1303
|
|
- htmlvar_name = %s, |
|
1304
|
|
- default_value = %s, |
|
1305
|
|
- sort_order = %s, |
|
1306
|
|
- is_active = %s, |
|
1307
|
|
- for_admin_use = %s, |
|
1308
|
|
- is_default = %s, |
|
1309
|
|
- is_required = %s, |
|
1310
|
|
- is_dummy = %s, |
|
1311
|
|
- is_public = %s, |
|
1312
|
|
- is_register_field = %s, |
|
1313
|
|
- is_search_field = %s, |
|
1314
|
|
- is_register_only_field = %s, |
|
1315
|
|
- required_msg = %s, |
|
1316
|
|
- css_class = %s, |
|
1317
|
|
- field_icon = %s, |
|
1318
|
|
- field_icon = %s, |
|
1319
|
|
- show_in = %s, |
|
1320
|
|
- user_roles = %s, |
|
1321
|
|
- option_values = %s, |
|
1322
|
|
- extra_fields = %s, |
|
1323
|
|
- validation_pattern = %s, |
|
1324
|
|
- validation_msg = %s |
|
1325
|
|
- where id = %d", |
|
1894
|
+ if ( isset( $request['field_type'] ) && $request['field_type'] != '' ) { |
|
1895
|
+ $field_type = esc_attr( $request['field_type'] ); |
|
1896
|
+ } else { |
|
1897
|
+ $field_type = $field_info->field_type; |
|
1898
|
+ } |
|
1326
|
1899
|
|
|
1327
|
|
- array( |
|
1328
|
|
- $form_type, |
|
1329
|
|
- $site_title, |
|
1330
|
|
- $form_label, |
|
1331
|
|
- $field_type, |
|
1332
|
|
- $data_type, |
|
1333
|
|
- $decimal_point, |
|
1334
|
|
- $field_type_key, |
|
1335
|
|
- $htmlvar_name, |
|
1336
|
|
- $default_value, |
|
1337
|
|
- $sort_order, |
|
1338
|
|
- $is_active, |
|
1339
|
|
- $for_admin_use, |
|
1340
|
|
- $is_default, |
|
1341
|
|
- $is_required, |
|
1342
|
|
- $is_dummy, |
|
1343
|
|
- $is_public, |
|
1344
|
|
- $is_register_field, |
|
1345
|
|
- $is_search_field, |
|
1346
|
|
- $is_register_only_field, |
|
1347
|
|
- $required_msg, |
|
1348
|
|
- $css_class, |
|
1349
|
|
- $field_icon, |
|
1350
|
|
- $field_icon, |
|
1351
|
|
- $show_in, |
|
1352
|
|
- $user_roles, |
|
1353
|
|
- $option_values, |
|
1354
|
|
- $extra_field_query, |
|
1355
|
|
- $validation_pattern, |
|
1356
|
|
- $validation_msg, |
|
1357
|
|
- $cf |
|
1358
|
|
- ) |
|
1359
|
|
- ) |
|
1900
|
+ $field_site_name = ''; |
|
1901
|
+ if ( isset( $request['site_title'] ) ) { |
|
1902
|
+ $field_site_name = $request['site_title']; |
|
1903
|
+ } |
|
1360
|
1904
|
|
|
1361
|
|
- ); |
|
1905
|
+ if ( $field_info ) { |
|
1906
|
+ $account_field_info = uwp_get_custom_field_info( $field_info->site_htmlvar_name ); |
|
1907
|
+ if ( isset( $account_field_info->site_title ) ) { |
|
1908
|
+ if ( $account_field_info->field_type == 'fieldset' ) { |
|
1909
|
+ $field_site_name = __( 'Fieldset:', 'userswp' ) . ' ' . $account_field_info->site_title; |
|
1910
|
+ } else { |
|
1911
|
+ $field_site_name = $account_field_info->site_title; |
|
1912
|
+ } |
|
1913
|
+ } |
|
1914
|
+ $field_info = stripslashes_deep( $field_info ); // strip slashes |
|
1915
|
+ } |
|
1362
|
1916
|
|
|
1363
|
|
- $lastid = trim($cf); |
|
1917
|
+ if ( isset( $request['form_type'] ) ) { |
|
1918
|
+ $form_type = esc_attr( $request['form_type'] ); |
|
1919
|
+ } else { |
|
1920
|
+ $form_type = $field_info->form_type; |
|
1921
|
+ } |
|
1364
|
1922
|
|
|
1923
|
+ if ( isset( $request['htmlvar_name'] ) && $request['htmlvar_name'] != '' ) { |
|
1924
|
+ $htmlvar_name = esc_attr( $request['htmlvar_name'] ); |
|
1925
|
+ } else { |
|
1926
|
+ $htmlvar_name = $field_info->site_htmlvar_name; |
|
1927
|
+ } |
|
1365
|
1928
|
|
|
1366
|
|
- do_action('uwp_after_custom_fields_updated', $lastid); |
|
1929
|
+ if ( isset( $htmlvar_name ) ) { |
|
1930
|
+ if ( ! is_object( $field_info ) ) { |
|
1931
|
+ $field_info = new stdClass(); |
|
1932
|
+ } |
|
1933
|
+ $field_info->field_icon = $wpdb->get_var( |
|
1934
|
+ $wpdb->prepare( 'SELECT field_icon FROM ' . $table_name . ' WHERE htmlvar_name = %s', array( $htmlvar_name ) ) |
|
1935
|
+ ); |
|
1936
|
+ } |
|
1367
|
1937
|
|
|
1368
|
|
- } else { |
|
1938
|
+ $icon = isset( $field_info->field_icon ) ? $field_info->field_icon : ''; |
|
1939
|
+ if ( uwp_is_fa_icon( $icon ) ) { |
|
1940
|
+ $field_icon = '<i class="' . esc_attr( $icon ) . '" aria-hidden="true"></i>'; |
|
1941
|
+ } elseif ( uwp_is_icon_url( $icon ) ) { |
|
1942
|
+ $field_icon = '<b style="background-image: url("' . esc_url( $icon ) . '")"></b>'; |
|
1943
|
+ } elseif ( isset( $field_info->field_type ) && $field_info->field_type == 'fieldset' ) { |
|
1944
|
+ $field_icon = '<i class="fas fa-arrows-alt-h" aria-hidden="true"></i>'; |
|
1945
|
+ } else { |
|
1946
|
+ $field_icon = '<i class="fas fa-cog" aria-hidden="true"></i>'; |
|
1947
|
+ } |
|
1369
|
1948
|
|
|
1370
|
|
- switch ($field_type): |
|
1949
|
+ $no_actions = array( 'email' ); |
|
1950
|
+ $no_actions = apply_filters( 'uwp_register_fields_without_actions', $no_actions ); |
|
1951
|
+ ?> |
|
1952
|
+ <li class="text li-settings" id="licontainer_<?php echo esc_attr( $result_str ); ?>"> |
|
1953
|
+ <form> |
|
1954
|
+ <div class="title title<?php echo esc_attr( $result_str ); ?> uwp-fieldset hover-shadow dd-form d-flex justify-content-between rounded list-group-item border rounded-smx text-start bg-light"> |
|
1955
|
+ <?php |
|
1956
|
+ $nonce = wp_create_nonce( 'uwp_form_extras_nonce' . $result_str ); |
|
1957
|
+ ?> |
|
1958
|
+ <div class=" flex-fill font-weight-bold fw-bold"> |
|
1959
|
+ <?php echo $field_icon; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> |
|
1960
|
+ <b><?php echo ' ' . esc_html( $field_site_name ); ?></b> |
|
1961
|
+ <span class="field-type float-end text-end small"><?php echo ' (' . esc_html( ucfirst( $field_type ) ) . ')'; ?></span> |
|
1962
|
+ </div> |
|
1963
|
+ <div class="dd-handle ui-sortable-handle"> |
|
1964
|
+ <?php if ( isset( $htmlvar_name ) && ! in_array( $htmlvar_name, $no_actions ) ) { ?> |
|
1965
|
+ <i class="far fa-trash-alt text-danger ml-2 ms-2 c-pointer" id="delete-16" |
|
1966
|
+ onclick="delete_field('<?php echo esc_js( $result_str ); ?>', '<?php echo esc_js( $nonce ); ?>','<?php echo esc_js( $htmlvar_name ); ?>', 'register')" |
|
1967
|
+ ></i> |
|
1968
|
+ <?php } ?> |
|
1969
|
+ <i class="fas fa-grip-vertical text-muted ml-2 ms-2" style="cursor: move" aria-hidden="true"></i> |
|
1970
|
+ </div> |
|
1971
|
+ </div> |
|
1371
|
1972
|
|
|
1372
|
|
- case 'checkbox': |
|
1373
|
|
- $data_type = 'TINYINT'; |
|
1973
|
+ <div id="field_frm<?php echo esc_attr( $result_str ); ?>" class="field_frm" style="display:none;"> |
|
1974
|
+ <input type="hidden" name="_wpnonce" value="<?php echo esc_attr( $nonce ); ?>"/> |
|
1975
|
+ <input type="hidden" name="field_id" id="field_id" value="<?php echo esc_attr( $result_str ); ?>"/> |
|
1976
|
+ <input type="hidden" name="form_type" id="form_type" value="<?php echo esc_attr( $form_type ); ?>"/> |
|
1977
|
+ <input type="hidden" name="field_type" id="field_type" value="<?php echo esc_attr( $field_type ); ?>"/> |
|
1978
|
+ <input type="hidden" name="is_active" id="is_active" value="1"/> |
|
1979
|
+ <ul class="widefat post fixed" style="width:100%;"> |
|
1374
|
1980
|
|
|
1375
|
|
- $meta_field_add = $data_type . "( 1 ) NOT NULL "; |
|
1376
|
|
- if ((int) $default_value === 1) { |
|
1377
|
|
- $meta_field_add .= " DEFAULT '1'"; |
|
1378
|
|
- } |
|
1981
|
+ <input type="hidden" name="site_htmlvar_name" value="<?php echo esc_attr( $htmlvar_name ); ?>"/> |
|
1379
|
1982
|
|
|
1380
|
|
- $add_result = uwp_add_column_if_not_exist($meta_table, $htmlvar_name, $meta_field_add); |
|
1381
|
|
- if ($add_result === false) { |
|
1382
|
|
- return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'userswp'); |
|
1383
|
|
- } |
|
1384
|
|
- break; |
|
1385
|
|
- case 'multiselect': |
|
1386
|
|
- case 'select': |
|
1387
|
|
- $data_type = 'VARCHAR'; |
|
1388
|
|
- $op_size = '500'; |
|
1983
|
+ <li> |
|
1984
|
+ <div class="uwp-input-wrap"> |
|
1985
|
+ <p><?php esc_html_e( 'No options available', 'userswp' ); ?></p> |
|
1986
|
+ </div> |
|
1987
|
+ </li> |
|
1389
|
1988
|
|
|
1390
|
|
- // only make the field as big as it needs to be. |
|
1391
|
|
- if (isset($option_values) && $option_values && $field_type == 'select') { |
|
1392
|
|
- $option_values_arr = explode(',', $option_values); |
|
1989
|
+ <li> |
|
1990
|
+ <div class="uwp-input-wrap"> |
|
1991
|
+ <?php if ( isset( $htmlvar_name ) && ! in_array( $htmlvar_name, $no_actions ) ) { ?> |
|
1992
|
+ <input type="button" class="button button-primary" name="save" id="save" |
|
1993
|
+ value="<?php esc_attr_e( 'Save', 'userswp' ); ?>" |
|
1994
|
+ onclick="save_field('<?php echo esc_js( $result_str ); ?>', 'register')" |
|
1995
|
+ style="display: none;"/> |
|
1996
|
+ <input type="button" name="delete" |
|
1997
|
+ value="<?php esc_attr_e( 'Delete', 'userswp' ); ?>" |
|
1998
|
+ onclick="delete_field('<?php echo esc_js( $result_str ); ?>', '<?php echo esc_js( $nonce ); ?>','<?php echo esc_js( $htmlvar_name ); ?>', 'register')" |
|
1999
|
+ class="button"/> |
|
2000
|
+ <?php } ?> |
|
1393
|
2001
|
|
|
1394
|
|
- if (is_array($option_values_arr)) { |
|
1395
|
|
- $op_max = 0; |
|
2002
|
+ </div> |
|
2003
|
+ </li> |
|
2004
|
+ </ul> |
|
1396
|
2005
|
|
|
1397
|
|
- foreach ($option_values_arr as $op_val) { |
|
1398
|
|
- if (strlen($op_val) && strlen($op_val) > $op_max) { |
|
1399
|
|
- $op_max = strlen($op_val); |
|
1400
|
|
- } |
|
1401
|
|
- } |
|
2006
|
+ </div> |
|
2007
|
+ </form> |
|
2008
|
+ </li> |
|
2009
|
+ <?php |
|
2010
|
+ } |
|
1402
|
2011
|
|
|
1403
|
|
- if ($op_max) { |
|
1404
|
|
- $op_size = $op_max; |
|
1405
|
|
- } |
|
1406
|
|
- } |
|
1407
|
|
- } elseif (isset($option_values) && $option_values && $field_type == 'multiselect') { |
|
1408
|
|
- if (strlen($option_values)) { |
|
1409
|
|
- $op_size = strlen($option_values); |
|
1410
|
|
- } |
|
2012
|
+ public function builder_extra_fields_smr( $output, $result_str, $cf, $field_info ) { |
|
1411
|
2013
|
|
|
1412
|
|
- if (isset($request_field['multi_display_type'])) { |
|
1413
|
|
- $extra_fields = $request_field['multi_display_type']; |
|
1414
|
|
- } |
|
1415
|
|
- } |
|
2014
|
+ ob_start(); |
|
1416
|
2015
|
|
|
1417
|
|
- $meta_field_add = $data_type . "( $op_size ) NULL "; |
|
1418
|
|
- if ($default_value != '') { |
|
1419
|
|
- $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
1420
|
|
- } |
|
2016
|
+ $value = ''; |
|
2017
|
+ if ( isset( $field_info->option_values ) ) { |
|
2018
|
+ $value = esc_attr( $field_info->option_values ); |
|
2019
|
+ } elseif ( isset( $cf['defaults']['option_values'] ) && $cf['defaults']['option_values'] ) { |
|
2020
|
+ $value = esc_attr( $cf['defaults']['option_values'] ); |
|
2021
|
+ } |
|
1421
|
2022
|
|
|
1422
|
|
- $add_result = uwp_add_column_if_not_exist($meta_table, $htmlvar_name, $meta_field_add); |
|
1423
|
|
- if ($add_result === false) { |
|
1424
|
|
- return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'userswp'); |
|
1425
|
|
- } |
|
1426
|
|
- break; |
|
1427
|
|
- case 'textarea': |
|
1428
|
|
- case 'html': |
|
1429
|
|
- case 'url': |
|
1430
|
|
- case 'file': |
|
2023
|
+ $field_type = isset( $field_info->field_type ) ? $field_info->field_type : $cf['field_type']; |
|
2024
|
+ $field_type_key = isset( $field_info->field_type_key ) ? $field_info->field_type_key : ''; |
|
2025
|
+ if ( ! $field_type_key ) { |
|
2026
|
+ $field_type_key = isset( $_REQUEST['field_type_key'] ) ? esc_html( $_REQUEST['field_type_key'] ) : ''; |
|
2027
|
+ } |
|
2028
|
+ ?> |
|
2029
|
+ <div class="uwp-setting-name mb-3"> |
|
2030
|
+ <label for="option_values" class=" form-label"> |
|
2031
|
+ <?php |
|
2032
|
+ $tip = __( 'Option Values should be separated by comma.', 'userswp' ); |
|
2033
|
+ if ( $field_type != 'multiselect' ) { |
|
2034
|
+ $tip .= '<br/><small>' . __( 'If using for a tick filter place a / and then either a 1 for true or 0 for false', 'userswp' ); |
|
2035
|
+ $tip .= '<br/>' . __( 'eg: No Dogs Allowed/0,Dogs Allowed/1', 'userswp' ) . '</small>'; |
|
2036
|
+ } |
|
2037
|
+ if ( $field_type == 'multiselect' || $field_type == 'select' ) { |
|
2038
|
+ $tip .= '<br/><small>' . __( 'Like: Apple,Bannana,Pear,Peach', 'userswp' ); |
|
2039
|
+ $tip .= '<br/>' . __( 'Or you can show Selection/Value shown: Pets Allowed/Yes,Pets not Allowed/No', 'userswp' ); |
|
2040
|
+ $tip .= '<br/>' . __( '- If using OPTGROUP tag to grouping options, use {optgroup}OPTGROUP-LABEL|OPTION-1,OPTION-2{/optgroup}', 'userswp' ); |
|
2041
|
+ $tip .= '<br/>' . __( 'eg: {optgroup}Pets Allowed|No Dogs Allowed/0,Dogs Allowed/1{/optgroup},{optgroup}Sports|Cricket/Cricket,Football/Football,Hockey{/optgroup}', 'userswp' ) . '</small>'; |
|
2042
|
+ } |
|
2043
|
+ ?> |
|
2044
|
+ <?php |
|
2045
|
+ echo uwp_help_tip( $tip ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
2046
|
+ esc_html_e( 'Option Values :', 'userswp' ); |
|
2047
|
+ ?> |
|
2048
|
+ </label> |
|
2049
|
+ <div class="uwp-input-wrap"> |
|
1431
|
2050
|
|
|
1432
|
|
- $data_type = 'TEXT'; |
|
2051
|
+ <?php |
|
2052
|
+ if ( isset( $field_type_key ) && $field_type_key == 'uwp_country' ) { |
|
2053
|
+ // @todo here we should show a multiselect to either include or exclude countries |
|
2054
|
+ echo aui()->alert( |
|
2055
|
+ array( |
|
2056
|
+ 'type' => 'info', |
|
2057
|
+ 'content' => esc_html__( 'A full country list will be shown', 'userswp' ), |
|
2058
|
+ ) |
|
2059
|
+ ); |
|
1433
|
2060
|
|
|
1434
|
|
- $meta_field_add = $data_type . " NULL "; |
|
2061
|
+ } elseif ( isset( $field_type_key ) && $field_type_key == 'uwp_language' ) { |
|
2062
|
+ echo aui()->alert( |
|
2063
|
+ array( |
|
2064
|
+ 'type' => 'info', |
|
2065
|
+ 'content' => esc_html__( 'Available translation languages list will be shown', 'userswp' ), |
|
2066
|
+ ) |
|
2067
|
+ ); |
|
2068
|
+ } else { |
|
2069
|
+ ?> |
|
2070
|
+ <input type="text" name="option_values" id="option_values" class="form-control" value="<?php echo esc_attr( $value ); ?>"/> |
|
2071
|
+ <?php } ?> |
|
1435
|
2072
|
|
|
1436
|
|
- $add_result = uwp_add_column_if_not_exist($meta_table, $htmlvar_name, $meta_field_add); |
|
1437
|
|
- if ($add_result === false) { |
|
1438
|
|
- return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'userswp'); |
|
1439
|
|
- } |
|
2073
|
+ <br/> |
|
1440
|
2074
|
|
|
1441
|
|
- break; |
|
2075
|
+ </div> |
|
2076
|
+ </div> |
|
2077
|
+ <?php |
|
1442
|
2078
|
|
|
1443
|
|
- case 'datepicker': |
|
2079
|
+ $html = ob_get_clean(); |
|
1444
|
2080
|
|
|
1445
|
|
- $data_type = 'DATE'; |
|
2081
|
+ return $output . $html; |
|
2082
|
+ } |
|
1446
|
2083
|
|
|
1447
|
|
- $meta_field_add = $data_type . " NULL "; |
|
2084
|
+ public function builder_extra_fields_datepicker( $output, $result_str, $cf, $field_info ) { |
|
2085
|
+ ob_start(); |
|
2086
|
+ $extra = array(); |
|
2087
|
+ if ( isset( $field_info->extra_fields ) && $field_info->extra_fields != '' ) { |
|
2088
|
+ $extra = unserialize( $field_info->extra_fields ); |
|
2089
|
+ } |
|
2090
|
+ ?> |
|
2091
|
+ <div class="uwp-setting-name uwp-advanced-setting mb-3"> |
|
2092
|
+ <label for="date_format" class=" form-label"> |
|
2093
|
+ <?php |
|
2094
|
+ echo uwp_help_tip( __( 'Select the date format.', 'userswp' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
2095
|
+ esc_html_e( 'Date Format :', 'userswp' ); |
|
2096
|
+ ?> |
|
2097
|
+ </label> |
|
2098
|
+ <div class="uwp-input-wrap" style="overflow:inherit;"> |
|
2099
|
+ <?php |
|
2100
|
+ $date_formats = array( |
|
2101
|
+ 'm/d/Y', |
|
2102
|
+ 'd/m/Y', |
|
2103
|
+ 'Y/m/d', |
|
2104
|
+ 'm-d-Y', |
|
2105
|
+ 'd-m-Y', |
|
2106
|
+ 'Y-m-d', |
|
2107
|
+ 'F j, Y', |
|
2108
|
+ ); |
|
1448
|
2109
|
|
|
1449
|
|
- $add_result = uwp_add_column_if_not_exist($meta_table, $htmlvar_name, $meta_field_add); |
|
1450
|
|
- if ($add_result === false) { |
|
1451
|
|
- return __('Column creation failed, you may have too many columns or the default value must have in valid date format.', 'userswp'); |
|
1452
|
|
- } |
|
2110
|
+ $date_formats = apply_filters( 'uwp_date_formats', $date_formats ); |
|
2111
|
+ ?> |
|
2112
|
+ <select name="extra[date_format]" id="date_format" class="aui-selectx2 form-select mw-100" > |
|
2113
|
+ <?php |
|
2114
|
+ foreach ( $date_formats as $format ) { |
|
2115
|
+ $selected = false; |
|
2116
|
+ if ( ! empty( $extra ) && esc_attr( $extra['date_format'] ) == $format ) { |
|
2117
|
+ $selected = true; |
|
2118
|
+ } |
|
2119
|
+ echo '<option ' . selected( $selected, true, false ) . " value='" . esc_attr( $format ) . "'>" . esc_html( $format . ' (' . date_i18n( $format, time() ) . ')' ) . '</option>'; |
|
2120
|
+ } |
|
2121
|
+ ?> |
|
2122
|
+ </select> |
|
1453
|
2123
|
|
|
1454
|
|
- break; |
|
2124
|
+ </div> |
|
2125
|
+ </div> |
|
2126
|
+ <?php |
|
1455
|
2127
|
|
|
1456
|
|
- case 'time': |
|
2128
|
+ $html = ob_get_clean(); |
|
1457
|
2129
|
|
|
1458
|
|
- $data_type = 'TIME'; |
|
2130
|
+ return $output . $html; |
|
2131
|
+ } |
|
1459
|
2132
|
|
|
1460
|
|
- $meta_field_add = $data_type . " NULL "; |
|
2133
|
+ public function builder_extra_fields_password( $output, $result_str, $cf, $field_info ) { |
|
2134
|
+ ob_start(); |
|
1461
|
2135
|
|
|
1462
|
|
- $add_result = uwp_add_column_if_not_exist($meta_table, $htmlvar_name, $meta_field_add); |
|
1463
|
|
- if ($add_result === false) { |
|
1464
|
|
- return __('Column creation failed, you may have too many columns or the default value must have in valid time format.', 'userswp'); |
|
1465
|
|
- } |
|
2136
|
+ //confirm password field |
|
2137
|
+ $extra = array(); |
|
2138
|
+ if ( isset( $field_info->extra_fields ) && $field_info->extra_fields != '' ) { |
|
2139
|
+ $extra = unserialize( $field_info->extra_fields ); |
|
2140
|
+ } |
|
2141
|
+ $value = isset( $extra['confirm_password'] ) ? $extra['confirm_password'] : '1'; |
|
2142
|
+ if ( isset( $field_info->htmlvar_name ) && $field_info->htmlvar_name == 'password' ) { |
|
1466
|
2143
|
|
|
1467
|
|
- break; |
|
2144
|
+ echo '<div class="' . uwp_advanced_toggle_class() . '">'; |
|
2145
|
+ echo aui()->input( |
|
2146
|
+ array( |
|
2147
|
+ 'id' => 'extra_confirm_password', |
|
2148
|
+ 'name' => 'extra[confirm_password]', |
|
2149
|
+ 'type' => 'checkbox', |
|
2150
|
+ 'label_type' => 'horizontal', |
|
2151
|
+ 'label_col' => '4', |
|
2152
|
+ 'label' => __( 'Display confirm password field', 'userswp' ), |
|
2153
|
+ 'checked' => $value, |
|
2154
|
+ 'value' => '1', |
|
2155
|
+ 'switch' => 'md', |
|
2156
|
+ 'label_force_left' => true, |
|
2157
|
+ 'help_text' => uwp_help_tip( __( 'Lets you display confirm password form field.', 'userswp' ) ), |
|
2158
|
+ ) |
|
2159
|
+ ); |
|
2160
|
+ echo '</div>'; |
|
1468
|
2161
|
|
|
1469
|
|
- default: |
|
2162
|
+ } |
|
2163
|
+ $html = ob_get_clean(); |
|
1470
|
2164
|
|
|
1471
|
|
- if ($data_type != 'VARCHAR' && $data_type != '') { |
|
1472
|
|
- $meta_field_add = $data_type . " NULL "; |
|
2165
|
+ return $output . $html; |
|
2166
|
+ } |
|
1473
|
2167
|
|
|
1474
|
|
- if ($data_type == 'FLOAT' && $decimal_point > 0) { |
|
1475
|
|
- $meta_field_add = "DECIMAL(11, " . (int) $decimal_point . ") NULL "; |
|
1476
|
|
- } |
|
2168
|
+ public function builder_extra_fields_email( $output, $result_str, $cf, $field_info ) { |
|
2169
|
+ ob_start(); |
|
2170
|
+ //confirm email field |
|
2171
|
+ $extra = array(); |
|
2172
|
+ if ( isset( $field_info->extra_fields ) && $field_info->extra_fields != '' ) { |
|
2173
|
+ $extra = unserialize( $field_info->extra_fields ); |
|
2174
|
+ } |
|
2175
|
+ $value = isset( $extra['confirm_email'] ) ? $extra['confirm_email'] : '0'; |
|
1477
|
2176
|
|
|
1478
|
|
- if (is_numeric($default_value) && $default_value != '') { |
|
1479
|
|
- $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
1480
|
|
- } |
|
1481
|
|
- } else { |
|
1482
|
|
- $meta_field_add = " VARCHAR( 254 ) NULL "; |
|
2177
|
+ if ( isset( $field_info->htmlvar_name ) && $field_info->htmlvar_name == 'email' ) { |
|
1483
|
2178
|
|
|
1484
|
|
- if ($default_value != '') { |
|
1485
|
|
- $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
1486
|
|
- } |
|
1487
|
|
- } |
|
2179
|
+ echo '<div class="' . uwp_advanced_toggle_class() . '">'; |
|
2180
|
+ echo aui()->input( |
|
2181
|
+ array( |
|
2182
|
+ 'id' => 'extra_confirm_email', |
|
2183
|
+ 'name' => 'extra[confirm_email]', |
|
2184
|
+ 'type' => 'checkbox', |
|
2185
|
+ 'label_type' => 'horizontal', |
|
2186
|
+ 'label_col' => '4', |
|
2187
|
+ 'label' => __( 'Display confirm email field', 'userswp' ), |
|
2188
|
+ 'checked' => $value, |
|
2189
|
+ 'value' => '1', |
|
2190
|
+ 'switch' => 'md', |
|
2191
|
+ 'label_force_left' => true, |
|
2192
|
+ 'help_text' => uwp_help_tip( __( 'Lets you display confirm email form field.', 'userswp' ) ), |
|
2193
|
+ ) |
|
2194
|
+ ); |
|
2195
|
+ echo '</div>'; |
|
1488
|
2196
|
|
|
1489
|
|
- $add_result = uwp_add_column_if_not_exist($meta_table, $htmlvar_name, $meta_field_add); |
|
1490
|
|
- if ($add_result === false) { |
|
1491
|
|
- return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'userswp'); |
|
1492
|
|
- } |
|
1493
|
|
- break; |
|
1494
|
|
- endswitch; |
|
2197
|
+ } |
|
2198
|
+ $html = ob_get_clean(); |
|
1495
|
2199
|
|
|
1496
|
|
- $extra_field_query = ''; |
|
1497
|
|
- if (!empty($extra_fields)) { |
|
1498
|
|
- $extra_field_query = serialize($extra_fields); |
|
1499
|
|
- } |
|
2200
|
+ return $output . $html; |
|
2201
|
+ } |
|
1500
|
2202
|
|
|
1501
|
|
- $wpdb->query( |
|
2203
|
+ public function builder_extra_fields_file( $output, $result_str, $cf, $field_info ) { |
|
2204
|
+ ob_start(); |
|
1502
|
2205
|
|
|
1503
|
|
- $wpdb->prepare( |
|
2206
|
+ $file_obj = new UsersWP_Files(); |
|
2207
|
+ $allowed_file_types = $file_obj->allowed_mime_types(); |
|
1504
|
2208
|
|
|
1505
|
|
- "insert into " . $table_name . " set |
|
1506
|
|
- form_type = %s, |
|
1507
|
|
- site_title = %s, |
|
1508
|
|
- form_label = %s, |
|
1509
|
|
- field_type = %s, |
|
1510
|
|
- data_type = %s, |
|
1511
|
|
- decimal_point = %s, |
|
1512
|
|
- field_type_key = %s, |
|
1513
|
|
- htmlvar_name = %s, |
|
1514
|
|
- default_value = %s, |
|
1515
|
|
- sort_order = %d, |
|
1516
|
|
- is_active = %s, |
|
1517
|
|
- for_admin_use = %s, |
|
1518
|
|
- is_default = %s, |
|
1519
|
|
- is_required = %s, |
|
1520
|
|
- is_dummy = %s, |
|
1521
|
|
- is_public = %s, |
|
1522
|
|
- is_register_field = %s, |
|
1523
|
|
- is_search_field = %s, |
|
1524
|
|
- is_register_only_field = %s, |
|
1525
|
|
- required_msg = %s, |
|
1526
|
|
- css_class = %s, |
|
1527
|
|
- field_icon = %s, |
|
1528
|
|
- show_in = %s, |
|
1529
|
|
- user_roles = %s, |
|
1530
|
|
- option_values = %s, |
|
1531
|
|
- extra_fields = %s, |
|
1532
|
|
- validation_pattern = %s, |
|
1533
|
|
- validation_msg = %s ", |
|
2209
|
+ $extra_fields = isset( $field_info->extra_fields ) && $field_info->extra_fields != '' ? maybe_unserialize( $field_info->extra_fields ) : ''; |
|
2210
|
+ $uwp_file_types = ! empty( $extra_fields ) && ! empty( $extra_fields['uwp_file_types'] ) ? $extra_fields['uwp_file_types'] : array( '*' ); |
|
2211
|
+ ?> |
|
2212
|
+ <div class="uwp-setting-name uwp-advanced-setting mb-3"> |
|
2213
|
+ <label for="uwp_file_types" class="form-label"> |
|
2214
|
+ <?php |
|
2215
|
+ echo uwp_help_tip( __( 'Select file types to allowed for file uploading. (Select multiple file types by holding down "Ctrl" key.)', 'userswp' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
2216
|
+ esc_html_e( 'Allowed file types :', 'userswp' ); |
|
2217
|
+ ?> |
|
2218
|
+ </label> |
|
2219
|
+ <div class="uwp-input-wrap"> |
|
2220
|
+ <select name="extra[uwp_file_types][]" id="uwp_file_types" multiple="multiple" class="aui-select2 form-select mw-100" > |
|
2221
|
+ <option value="*" <?php selected( true, in_array( '*', $uwp_file_types ) ); ?>><?php esc_html_e( 'All types', 'userswp' ); ?></option> |
|
2222
|
+ <?php foreach ( $allowed_file_types as $format => $types ) { ?> |
|
2223
|
+ <optgroup |
|
2224
|
+ label="<?php echo esc_attr( wp_sprintf( __( '%s formats', 'userswp' ), __( $format, 'userswp' ) ) ); ?>"> |
|
2225
|
+ <?php foreach ( $types as $ext => $type ) { ?> |
|
2226
|
+ <option value="<?php echo esc_attr( $ext ); ?>" <?php selected( true, in_array( $ext, $uwp_file_types ) ); ?>><?php echo '.' . esc_html( $ext ); ?></option> |
|
2227
|
+ <?php } ?> |
|
2228
|
+ </optgroup> |
|
2229
|
+ <?php } ?> |
|
2230
|
+ </select> |
|
2231
|
+ </div> |
|
2232
|
+ </div> |
|
2233
|
+ <?php |
|
1534
|
2234
|
|
|
1535
|
|
- array( |
|
1536
|
|
- $form_type, |
|
1537
|
|
- $site_title, |
|
1538
|
|
- $form_label, |
|
1539
|
|
- $field_type, |
|
1540
|
|
- $data_type, |
|
1541
|
|
- $decimal_point, |
|
1542
|
|
- $field_type_key, |
|
1543
|
|
- $htmlvar_name, |
|
1544
|
|
- $default_value, |
|
1545
|
|
- $sort_order, |
|
1546
|
|
- $is_active, |
|
1547
|
|
- $for_admin_use, |
|
1548
|
|
- $is_default, |
|
1549
|
|
- $is_required, |
|
1550
|
|
- $is_dummy, |
|
1551
|
|
- $is_public, |
|
1552
|
|
- $is_register_field, |
|
1553
|
|
- $is_search_field, |
|
1554
|
|
- $is_register_only_field, |
|
1555
|
|
- $required_msg, |
|
1556
|
|
- $css_class, |
|
1557
|
|
- $field_icon, |
|
1558
|
|
- $show_in, |
|
1559
|
|
- $user_roles, |
|
1560
|
|
- $option_values, |
|
1561
|
|
- $extra_field_query, |
|
1562
|
|
- $validation_pattern, |
|
1563
|
|
- $validation_msg |
|
1564
|
|
- ) |
|
2235
|
+ $html = ob_get_clean(); |
|
1565
|
2236
|
|
|
1566
|
|
- ) |
|
2237
|
+ return $output . $html; |
|
2238
|
+ } |
|
1567
|
2239
|
|
|
1568
|
|
- ); |
|
2240
|
+ public function builder_data_type_text( $output, $result_str, $cf, $field_info ) { |
|
2241
|
+ ob_start(); |
|
1569
|
2242
|
|
|
1570
|
|
- $lastid = $wpdb->insert_id; |
|
2243
|
+ $dt_value = ''; |
|
2244
|
+ if ( isset( $field_info->data_type ) ) { |
|
2245
|
+ $dt_value = esc_attr( $field_info->data_type ); |
|
2246
|
+ } elseif ( isset( $cf['defaults']['data_type'] ) && $cf['defaults']['data_type'] ) { |
|
2247
|
+ $dt_value = $cf['defaults']['data_type']; |
|
2248
|
+ } |
|
1571
|
2249
|
|
|
1572
|
|
- $lastid = trim($lastid); |
|
2250
|
+ // fix some values |
|
2251
|
+ if ( $dt_value == 'VARCHAR' ) { |
|
2252
|
+ $dt_value = 'XVARCHAR'; |
|
2253
|
+ } |
|
1573
|
2254
|
|
|
1574
|
|
- } |
|
2255
|
+ echo aui()->select( |
|
2256
|
+ array( |
|
2257
|
+ 'id' => 'data_type', |
|
2258
|
+ 'name' => 'data_type', |
|
2259
|
+ 'label_type' => 'top', |
|
2260
|
+ 'multiple' => false, |
|
2261
|
+ 'wrap_class' => uwp_advanced_toggle_class(), |
|
2262
|
+ 'class' => 'mw-100', |
|
2263
|
+ 'options' => array( |
|
2264
|
+ 'XVARCHAR' => __( 'CHARACTER', 'userswp' ), |
|
2265
|
+ 'INT' => __( 'NUMBER', 'userswp' ), |
|
2266
|
+ 'FLOAT' => __( 'DECIMAL', 'userswp' ), |
|
2267
|
+ ), |
|
2268
|
+ 'label' => __( 'Data Type', 'userswp' ) . uwp_help_tip( __( 'Select Custom Field type', 'userswp' ) ), |
|
2269
|
+ 'value' => $dt_value, |
|
2270
|
+ 'extra_attributes' => array( |
|
2271
|
+ 'onchange' => "javascript:uwp_data_type_changed(this, '$result_str');", |
|
2272
|
+ ), |
|
2273
|
+ ) |
|
2274
|
+ ); |
|
1575
|
2275
|
|
|
1576
|
|
- return (int) $lastid; |
|
2276
|
+ $value = ''; |
|
2277
|
+ if ( isset( $field_info->decimal_point ) ) { |
|
2278
|
+ $value = esc_attr( $field_info->decimal_point ); |
|
2279
|
+ } elseif ( isset( $cf['defaults']['decimal_point'] ) && $cf['defaults']['decimal_point'] ) { |
|
2280
|
+ $value = $cf['defaults']['decimal_point']; |
|
2281
|
+ } |
|
1577
|
2282
|
|
|
2283
|
+ echo aui()->select( |
|
2284
|
+ array( |
|
2285
|
+ 'id' => 'decimal_point', |
|
2286
|
+ 'name' => 'decimal_point', |
|
2287
|
+ 'label_type' => 'top', |
|
2288
|
+ 'multiple' => false, |
|
2289
|
+ 'class' => ' mw-100', |
|
2290
|
+ 'options' => array( |
|
2291
|
+ '' => __( 'Select', 'userswp' ), |
|
2292
|
+ '1' => '1', |
|
2293
|
+ '2' => '2', |
|
2294
|
+ '3' => '3', |
|
2295
|
+ '4' => '4', |
|
2296
|
+ '5' => '5', |
|
2297
|
+ '6' => '6', |
|
2298
|
+ '7' => '7', |
|
2299
|
+ '8' => '8', |
|
2300
|
+ '9' => '9', |
|
2301
|
+ '10' => '10', |
|
2302
|
+ ), |
|
2303
|
+ 'label' => __( 'Decimal points', 'userswp' ) . uwp_help_tip( __( 'Decimals to display after point.', 'userswp' ) ), |
|
2304
|
+ 'value' => $value, |
|
2305
|
+ 'element_require' => '[%data_type%] == "FLOAT"', |
|
2306
|
+ ) |
|
2307
|
+ ); |
|
1578
|
2308
|
|
|
1579
|
|
- } else { |
|
1580
|
|
- return __('HTML Variable Name should be a unique name', 'userswp'); |
|
1581
|
|
- } |
|
2309
|
+ $output = ob_get_clean(); |
|
1582
|
2310
|
|
|
1583
|
|
- } |
|
2311
|
+ return $output; |
|
2312
|
+ } |
|
1584
|
2313
|
|
|
1585
|
|
- public function uwp_set_field_order($field_ids = array()) |
|
1586
|
|
- { |
|
2314
|
+ public function advance_admin_custom_fields( $field_info, $cf ) { |
|
2315
|
+ $hide_register_field = ( isset( $cf['defaults']['is_register_field'] ) && $cf['defaults']['is_register_field'] === false ) ? "style='display:none;'" : ''; |
|
2316
|
+ $hide_register_field = ( isset( $field_info->for_admin_use ) && $field_info->for_admin_use == '1' ) ? "style='display:none;'" : $hide_register_field; |
|
2317
|
+ $hide_user_sort = ( isset( $cf['defaults']['user_sort'] ) && $cf['defaults']['user_sort'] === false ) ? "style='display:none;'" : ''; |
|
1587
|
2318
|
|
|
1588
|
|
- global $wpdb; |
|
2319
|
+ $value = 0; |
|
2320
|
+ if ( isset( $field_info->is_register_field ) ) { |
|
2321
|
+ $value = (int) $field_info->is_register_field; |
|
2322
|
+ } elseif ( isset( $cf['defaults']['is_register_field'] ) && $cf['defaults']['is_register_field'] ) { |
|
2323
|
+ $value = ( $cf['defaults']['is_register_field'] ) ? 1 : 0; |
|
2324
|
+ } |
|
1589
|
2325
|
|
|
1590
|
|
- $table_name = uwp_get_table_prefix() . 'uwp_form_fields'; |
|
2326
|
+ if ( isset( $field_info->htmlvar_name ) ) { |
|
2327
|
+ $htmlvar_name = $field_info->htmlvar_name; |
|
2328
|
+ } elseif ( isset( $cf['defaults']['htmlvar_name'] ) && $cf['defaults']['htmlvar_name'] ) { |
|
2329
|
+ $htmlvar_name = ( $cf['defaults']['htmlvar_name'] ) ? $cf['defaults']['htmlvar_name'] : ''; |
|
2330
|
+ } |
|
1591
|
2331
|
|
|
1592
|
|
- $count = 0; |
|
1593
|
|
- if (!empty($field_ids)): |
|
1594
|
|
- $user_meta_info = false; |
|
1595
|
|
- foreach ($field_ids as $id) { |
|
2332
|
+ //register only field |
|
2333
|
+ $hide_register_only_field = ( isset( $cf['defaults']['is_register_only_field'] ) && $cf['defaults']['is_register_only_field'] === false ) ? "style='display:none;'" : ''; |
|
2334
|
+ $hide_register_only_field = ( isset( $field_info->for_admin_use ) && $field_info->for_admin_use == '1' ) ? "style='display:none;'" : $hide_register_only_field; |
|
2335
|
+ $register_only_value = 0; |
|
2336
|
+ if ( isset( $field_info->is_register_only_field ) ) { |
|
2337
|
+ $register_only_value = (int) $field_info->is_register_only_field; |
|
2338
|
+ } elseif ( isset( $cf['defaults']['is_register_only_field'] ) && $cf['defaults']['is_register_only_field'] ) { |
|
2339
|
+ $register_only_value = ( $cf['defaults']['is_register_only_field'] ) ? 1 : 0; |
|
2340
|
+ } |
|
1596
|
2341
|
|
|
1597
|
|
- $cf = trim($id, '_'); |
|
2342
|
+ $user_sort_value = 0; |
|
2343
|
+ if ( isset( $field_info->user_sort ) ) { |
|
2344
|
+ $user_sort_value = (int) $field_info->user_sort; |
|
2345
|
+ } elseif ( isset( $cf['defaults']['user_sort'] ) && $cf['defaults']['user_sort'] ) { |
|
2346
|
+ $user_sort_value = ( $cf['defaults']['user_sort'] ) ? 1 : 0; |
|
2347
|
+ } |
|
1598
|
2348
|
|
|
1599
|
|
- $user_meta_info = $wpdb->query( |
|
1600
|
|
- $wpdb->prepare( |
|
1601
|
|
- "update " . $table_name . " set |
|
1602
|
|
- sort_order=%d |
|
1603
|
|
- where id= %d", |
|
1604
|
|
- array($count, $cf) |
|
2349
|
+ ?> |
|
2350
|
+ <div <?php echo $hide_register_field; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> class="cf-incin-reg-form uwp-setting-name mb-3"> |
|
2351
|
+ |
|
2352
|
+ <?php |
|
2353
|
+ $reg_only_fields = uwp_get_register_only_fields(); |
|
2354
|
+ if ( isset( $htmlvar_name ) && in_array( $htmlvar_name, $reg_only_fields ) ) { |
|
2355
|
+ ?> |
|
2356
|
+ <label for="is_register_field" class=" form-label"> |
|
2357
|
+ <?php |
|
2358
|
+ echo uwp_help_tip( __( 'Lets you use this field as register form field, set from register tab above.', 'userswp' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
2359
|
+ esc_html_e( 'Include this field in register form:', 'userswp' ); |
|
2360
|
+ ?> |
|
2361
|
+ </label> |
|
2362
|
+ <input type="hidden" name="is_register_field" value="1"/> |
|
2363
|
+ <p><?php esc_html_e( 'This is mandatory register form field.', 'userswp' ); ?></p> |
|
2364
|
+ <?php |
|
2365
|
+ } else { |
|
2366
|
+ echo aui()->input( |
|
2367
|
+ array( |
|
2368
|
+ 'id' => 'is_register_field', |
|
2369
|
+ 'name' => 'is_register_field', |
|
2370
|
+ 'type' => 'checkbox', |
|
2371
|
+ 'label_type' => 'horizontal', |
|
2372
|
+ 'label_col' => '4', |
|
2373
|
+ 'label' => __( 'Include this field in register form', 'userswp' ), |
|
2374
|
+ 'checked' => $value, |
|
2375
|
+ 'value' => '1', |
|
2376
|
+ 'switch' => 'md', |
|
2377
|
+ 'label_force_left' => true, |
|
2378
|
+ 'help_text' => uwp_help_tip( __( 'Lets you use this field as register form field, set from register tab above.', 'userswp' ) ), |
|
1605
|
2379
|
) |
|
1606
|
2380
|
); |
|
1607
|
|
- $count++; |
|
1608
|
2381
|
} |
|
2382
|
+ ?> |
|
2383
|
+ </div> |
|
1609
|
2384
|
|
|
1610
|
|
- return $user_meta_info; |
|
1611
|
|
- else: |
|
1612
|
|
- return false; |
|
1613
|
|
- endif; |
|
1614
|
|
- } |
|
2385
|
+ <div <?php echo $hide_register_only_field; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> class="cf-inconlyin-reg-form uwp-setting-name uwp-advanced-setting"> |
|
1615
|
2386
|
|
|
1616
|
|
- public function uwp_admin_form_field_delete($field_id = '') { |
|
1617
|
|
- global $wpdb; |
|
1618
|
2387
|
|
|
1619
|
|
- $table_name = uwp_get_table_prefix() . 'uwp_form_fields'; |
|
1620
|
|
- $extras_table_name = uwp_get_table_prefix() . 'uwp_form_extras'; |
|
2388
|
+ <?php |
|
2389
|
+ if ( isset( $htmlvar_name ) && in_array( $htmlvar_name, $reg_only_fields ) ) { |
|
2390
|
+ ?> |
|
2391
|
+ <label for="is_register_only_field" class="form-label"> |
|
2392
|
+ <?php |
|
2393
|
+ echo uwp_help_tip( __( 'Lets you use this field as register ONLY form field.', 'userswp' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
2394
|
+ esc_html_e( 'Include this field ONLY in register form:', 'userswp' ); |
|
2395
|
+ ?> |
|
2396
|
+ </label> |
|
2397
|
+ <input type="hidden" name="is_register_only_field" class="form-control" value="1"/> |
|
2398
|
+ <p><?php esc_html_e( 'This field is applicable only for register form.', 'userswp' ); ?></p> |
|
2399
|
+ <?php |
|
2400
|
+ } else { |
|
2401
|
+ echo aui()->input( |
|
2402
|
+ array( |
|
2403
|
+ 'id' => 'is_register_only_field', |
|
2404
|
+ 'name' => 'is_register_only_field', |
|
2405
|
+ 'type' => 'checkbox', |
|
2406
|
+ 'label_type' => 'horizontal', |
|
2407
|
+ 'label_col' => '4', |
|
2408
|
+ 'label' => __( 'Include this field ONLY in register form', 'userswp' ), |
|
2409
|
+ 'checked' => $register_only_value, |
|
2410
|
+ 'value' => '1', |
|
2411
|
+ 'switch' => 'md', |
|
2412
|
+ 'label_force_left' => true, |
|
2413
|
+ 'help_text' => uwp_help_tip( __( 'Lets you use this field as register ONLY form field.', 'userswp' ) ), |
|
1621
|
2414
|
|
|
1622
|
|
- if ($field_id != '') { |
|
1623
|
|
- $cf = trim($field_id, '_'); |
|
2415
|
+ ) |
|
2416
|
+ ); |
|
1624
|
2417
|
|
|
1625
|
|
- if ($field = $wpdb->get_row($wpdb->prepare("select * from " . $table_name . " where id= %d", array($cf)))) { |
|
2418
|
+ } |
|
2419
|
+ ?> |
|
2420
|
+ </div> |
|
1626
|
2421
|
|
|
1627
|
|
- $wpdb->query($wpdb->prepare("delete from " . $table_name . " where id= %d ", array($cf))); |
|
2422
|
+ <div <?php echo $hide_user_sort; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> class="cf-incin-reg-form uwp-setting-name uwp-advanced-setting"> |
|
2423
|
+ <?php |
|
1628
|
2424
|
|
|
1629
|
|
- $form_type = $field->form_type; |
|
2425
|
+ echo aui()->input( |
|
2426
|
+ array( |
|
2427
|
+ 'id' => 'user_sort', |
|
2428
|
+ 'name' => 'user_sort', |
|
2429
|
+ 'type' => 'checkbox', |
|
2430
|
+ 'label_type' => 'horizontal', |
|
2431
|
+ 'label_col' => '4', |
|
2432
|
+ 'label' => __( 'Include this field in sorting options', 'userswp' ), |
|
2433
|
+ 'checked' => $user_sort_value, |
|
2434
|
+ 'value' => '1', |
|
2435
|
+ 'switch' => 'md', |
|
2436
|
+ 'label_force_left' => true, |
|
2437
|
+ 'help_text' => uwp_help_tip( __( 'Lets you use this field as sorting in the users listing page, set from user sorting tab above.', 'userswp' ) ), |
|
1630
|
2438
|
|
|
1631
|
|
- // Also delete register form field |
|
1632
|
|
- $wpdb->query($wpdb->prepare("delete from " . $extras_table_name . " where site_htmlvar_name= %s ", array($field->htmlvar_name))); |
|
2439
|
+ ) |
|
2440
|
+ ); |
|
1633
|
2441
|
|
|
1634
|
|
- do_action('uwp_after_custom_field_deleted', $cf, $field->htmlvar_name, $form_type); |
|
2442
|
+ ?> |
|
1635
|
2443
|
|
|
1636
|
|
- return $field_id; |
|
1637
|
|
- } else |
|
1638
|
|
- return 0; |
|
1639
|
|
- } else |
|
1640
|
|
- return 0; |
|
1641
|
|
- } |
|
2444
|
+ </div> |
|
1642
|
2445
|
|
|
1643
|
|
- public function uwp_builder_extra_fields_smr($output, $result_str, $cf, $field_info) { |
|
2446
|
+ <?php |
|
2447
|
+ } |
|
1644
|
2448
|
|
|
1645
|
|
- ob_start(); |
|
2449
|
+ public function return_empty_string() { |
|
2450
|
+ return ''; |
|
2451
|
+ } |
|
1646
|
2452
|
|
|
1647
|
|
- $value = ''; |
|
1648
|
|
- if (isset($field_info->option_values)) { |
|
1649
|
|
- $value = esc_attr($field_info->option_values); |
|
1650
|
|
- }elseif (isset($cf['defaults']['option_values']) && $cf['defaults']['option_values']) { |
|
1651
|
|
- $value = esc_attr($cf['defaults']['option_values']); |
|
1652
|
|
- } |
|
2453
|
+ public function register_available_fields_head( $heading, $form_type ) { |
|
2454
|
+ switch ( $form_type ) { |
|
2455
|
+ case 'register': |
|
2456
|
+ $heading = __( 'Available register form fields.', 'userswp' ); |
|
2457
|
+ break; |
|
2458
|
+ } |
|
1653
|
2459
|
|
|
1654
|
|
- $field_type = isset($field_info->field_type) ? $field_info->field_type : $cf['field_type']; |
|
1655
|
|
- $field_type_key = isset($field_info->field_type_key) ? $field_info->field_type_key : ''; |
|
1656
|
|
- if(!$field_type_key){ |
|
1657
|
|
- $field_type_key = isset($_REQUEST['field_type_key']) ? esc_html($_REQUEST['field_type_key']) : ''; |
|
1658
|
|
- } |
|
1659
|
|
- ?> |
|
1660
|
|
- <li> |
|
1661
|
|
- <label for="option_values" class="uwp-tooltip-wrap"> |
|
1662
|
|
- <i class="fas fa-info-circle" aria-hidden="true"></i> <?php _e('Option Values :', 'userswp'); ?> |
|
1663
|
|
- <div class="uwp-tooltip"> |
|
1664
|
|
- <span><?php _e('Option Values should be separated by comma.', 'userswp'); ?></span> |
|
1665
|
|
- <br/> |
|
1666
|
|
- <small> |
|
2460
|
+ return $heading; |
|
2461
|
+ } |
|
1667
|
2462
|
|
|
1668
|
|
- <?php if($field_type != 'multiselect'){?> |
|
1669
|
|
- <span><?php _e('If using for a "tick filter" place a / and then either a 1 for true or 0 for false', 'userswp'); ?></span> |
|
1670
|
|
- <br/> |
|
1671
|
|
- <span><?php _e('eg: "No Dogs Allowed/0,Dogs Allowed/1"', 'userswp'); ?></span> |
|
1672
|
|
- <?php }?> |
|
2463
|
+ public function register_available_fields_note( $note, $form_type ) { |
|
2464
|
+ switch ( $form_type ) { |
|
2465
|
+ case 'register': |
|
2466
|
+ $note = __( "Click on any box below to make it appear in register form. To make a field available here, go to account tab and expand any field from selected fields panel and tick the checkbox saying 'Include this field in register form'.", 'userswp' ); |
|
2467
|
+ break; |
|
2468
|
+ } |
|
1673
|
2469
|
|
|
1674
|
|
- <?php if ($field_type == 'multiselect' || $field_type == 'select') { ?> |
|
1675
|
|
- <span><?php _e('Like: Apple,Bannana,Pear,Peach', 'userswp'); ?></span> |
|
1676
|
|
- <br/> |
|
2470
|
+ return $note; |
|
2471
|
+ } |
|
1677
|
2472
|
|
|
1678
|
|
- <span><?php _e('Or you can show Selection/Value shown: Pets Allowed/Yes,Pets not Allowed/No', 'userswp'); ?></span> |
|
2473
|
+ public function register_selected_fields_head( $heading, $form_type ) { |
|
2474
|
+ switch ( $form_type ) { |
|
2475
|
+ case 'register': |
|
2476
|
+ $heading = __( 'List of fields that will appear in the register form.', 'userswp' ); |
|
2477
|
+ break; |
|
1679
|
2478
|
|
|
1680
|
|
- <br/> |
|
1681
|
|
- <span><?php _e('- If using OPTGROUP tag to grouping options, use "{optgroup}OPTGROUP-LABEL|OPTION-1,OPTION-2{/optgroup}"', 'userswp'); ?></span> |
|
1682
|
|
- <br/> |
|
1683
|
|
- <span><?php _e('eg: "{optgroup}Pets Allowed|No Dogs Allowed/0,Dogs Allowed/1{/optgroup},{optgroup}Sports|Cricket/Cricket,Football/Football,Hockey{/optgroup}"', 'userswp'); ?></span> |
|
1684
|
|
- <?php } ?></small> |
|
1685
|
|
- </div> |
|
1686
|
|
- </label> |
|
1687
|
|
- <div class="uwp-input-wrap"> |
|
2479
|
+ } |
|
1688
|
2480
|
|
|
1689
|
|
- <?php if(isset($field_type_key) && $field_type_key == 'country' ){ |
|
2481
|
+ return $heading; |
|
2482
|
+ } |
|
1690
|
2483
|
|
|
1691
|
|
- // @todo here we should show a multiselect to either include or exclude countries |
|
1692
|
|
- _e('A full country list will be shown','userswp'); |
|
1693
|
|
- ?> |
|
2484
|
+ public function register_selected_fields_note( $note, $form_type ) { |
|
2485
|
+ switch ( $form_type ) { |
|
2486
|
+ case 'register': |
|
2487
|
+ $note = __( 'Click to expand and view field related settings. You may drag and drop to arrange fields order in register form.', 'userswp' ); |
|
2488
|
+ break; |
|
1694
|
2489
|
|
|
1695
|
|
- <?php }else{?> |
|
1696
|
|
- <input type="text" name="option_values" id="option_values" value="<?php echo $value; ?>"/> |
|
1697
|
|
- <?php }?> |
|
2490
|
+ } |
|
1698
|
2491
|
|
|
1699
|
|
- <br/> |
|
2492
|
+ return $note; |
|
2493
|
+ } |
|
1700
|
2494
|
|
|
1701
|
|
- </div> |
|
1702
|
|
- </li> |
|
1703
|
|
- <?php |
|
2495
|
+ /** |
|
2496
|
+ * Handles the create custom field ajax request. |
|
2497
|
+ * |
|
2498
|
+ * @since 1.0.0 |
|
2499
|
+ * @package userswp |
|
2500
|
+ * @return void |
|
2501
|
+ */ |
|
2502
|
+ public function create_field() { |
|
1704
|
2503
|
|
|
1705
|
|
- $html = ob_get_clean(); |
|
1706
|
|
- return $output . $html; |
|
1707
|
|
- } |
|
2504
|
+ if ( ! current_user_can( 'manage_options' ) ) { |
|
2505
|
+ wp_die( -1 ); |
|
2506
|
+ } |
|
1708
|
2507
|
|
|
1709
|
|
- public function uwp_builder_extra_fields_datepicker($output, $result_str, $cf, $field_info) { |
|
1710
|
|
- ob_start(); |
|
1711
|
|
- $extra = array(); |
|
1712
|
|
- if (isset($field_info->extra_fields) && $field_info->extra_fields != '') { |
|
1713
|
|
- $extra = unserialize($field_info->extra_fields); |
|
1714
|
|
- } |
|
1715
|
|
- ?> |
|
1716
|
|
- <li> |
|
1717
|
|
- <label for="date_format" class="uwp-tooltip-wrap"> |
|
1718
|
|
- <i class="fas fa-info-circle" aria-hidden="true"></i> <?php _e('Date Format :', 'userswp'); ?> |
|
1719
|
|
- <div class="uwp-tooltip"> |
|
1720
|
|
- <?php _e('Select the date format.', 'userswp'); ?> |
|
1721
|
|
- </div> |
|
1722
|
|
- </label> |
|
1723
|
|
- <div class="uwp-input-wrap" style="overflow:inherit;"> |
|
1724
|
|
- <?php |
|
1725
|
|
- $date_formats = array( |
|
1726
|
|
- 'm/d/Y', |
|
1727
|
|
- 'd/m/Y', |
|
1728
|
|
- 'Y/m/d', |
|
1729
|
|
- 'm-d-Y', |
|
1730
|
|
- 'd-m-Y', |
|
1731
|
|
- 'Y-m-d', |
|
1732
|
|
- 'F j, Y', |
|
1733
|
|
- ); |
|
1734
|
|
- |
|
1735
|
|
- $date_formats = apply_filters('uwp_date_formats', $date_formats); |
|
1736
|
|
- ?> |
|
1737
|
|
- <select name="extra[date_format]" id="date_format"> |
|
1738
|
|
- <?php |
|
1739
|
|
- foreach ($date_formats as $format) { |
|
1740
|
|
- $selected = ''; |
|
1741
|
|
- if (!empty($extra) && esc_attr($extra['date_format']) == $format) { |
|
1742
|
|
- $selected = "selected='selected'"; |
|
1743
|
|
- } |
|
1744
|
|
- echo "<option $selected value='$format'>$format (" . date_i18n($format, time()) . ")</option>"; |
|
1745
|
|
- } |
|
1746
|
|
- ?> |
|
1747
|
|
- </select> |
|
2508
|
+ $form_type = isset( $_REQUEST['form_type'] ) ? sanitize_text_field( $_REQUEST['form_type'] ) : ''; |
|
2509
|
+ $field_type = isset( $_REQUEST['field_type'] ) ? sanitize_text_field( $_REQUEST['field_type'] ) : ''; |
|
2510
|
+ $field_type_key = isset( $_REQUEST['field_type_key'] ) ? sanitize_text_field( $_REQUEST['field_type_key'] ) : ''; |
|
2511
|
+ $field_action = isset( $_REQUEST['field_ins_upd'] ) ? sanitize_text_field( $_REQUEST['field_ins_upd'] ) : ''; |
|
2512
|
+ $field_id = isset( $_REQUEST['field_id'] ) ? sanitize_text_field( $_REQUEST['field_id'] ) : ''; |
|
2513
|
+ $form_id = isset( $_REQUEST['form_id'] ) ? absint( $_REQUEST['form_id'] ) : 1; |
|
1748
|
2514
|
|
|
1749
|
|
- </div> |
|
1750
|
|
- </li> |
|
1751
|
|
- <?php |
|
2515
|
+ $field_id = $field_id != '' ? trim( $field_id, '_' ) : $field_id; |
|
1752
|
2516
|
|
|
1753
|
|
- $html = ob_get_clean(); |
|
1754
|
|
- return $output . $html; |
|
1755
|
|
- } |
|
2517
|
+ $field_ids = array(); |
|
2518
|
+ if ( ! empty( $_REQUEST['licontainer'] ) && is_array( $_REQUEST['licontainer'] ) ) { |
|
2519
|
+ foreach ( $_REQUEST['licontainer'] as $lic_id ) { |
|
2520
|
+ $field_ids[] = sanitize_text_field( $lic_id ); |
|
2521
|
+ } |
|
2522
|
+ } |
|
1756
|
2523
|
|
|
1757
|
|
- public function uwp_builder_extra_fields_password($output, $result_str, $cf, $field_info) { |
|
1758
|
|
- ob_start(); |
|
1759
|
|
- $radio_id = (isset($field_info->htmlvar_name)) ? $field_info->htmlvar_name : rand(5, 500); |
|
1760
|
|
- |
|
1761
|
|
- //confirm password field |
|
1762
|
|
- $extra = array(); |
|
1763
|
|
- if (isset($field_info->extra_fields) && $field_info->extra_fields != '') { |
|
1764
|
|
- $extra = unserialize($field_info->extra_fields); |
|
1765
|
|
- } |
|
1766
|
|
- $value = isset($extra['confirm_password']) ? $extra['confirm_password'] : '1'; |
|
1767
|
|
- if (isset($field_info->htmlvar_name) && $field_info->htmlvar_name == 'uwp_account_password') { |
|
1768
|
|
- ?> |
|
1769
|
|
- <li> |
|
1770
|
|
- <label for="cat_sort" class="uwp-tooltip-wrap"> |
|
1771
|
|
- <i class="fas fa-info-circle" |
|
1772
|
|
- aria-hidden="true"></i> <?php _e('Display confirm password field?:', 'userswp'); ?> |
|
1773
|
|
- <div class="uwp-tooltip"> |
|
1774
|
|
- <?php _e('Lets you display confirm password form field.', 'userswp'); ?> |
|
1775
|
|
- </div> |
|
1776
|
|
- </label> |
|
2524
|
+ /* ------- check nonce field ------- */ |
|
2525
|
+ if ( isset( $_REQUEST['update'] ) && $_REQUEST['update'] == 'update' && isset( $_REQUEST['create_field'] ) && isset( $_REQUEST['manage_field_type'] ) && $_REQUEST['manage_field_type'] == 'custom_fields' ) { |
|
2526
|
+ if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'uwp_create_field_nonce' ) ) { |
|
2527
|
+ return; |
|
2528
|
+ } |
|
2529
|
+ echo $this->set_field_order( $field_ids, $form_id ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
2530
|
+ } |
|
1777
|
2531
|
|
|
1778
|
|
- <div class="uwp-input-wrap uwp-switch"> |
|
1779
|
|
- <input type="radio" id="confirm_password_yes<?php echo $radio_id; ?>" name="extra[confirm_password]" |
|
1780
|
|
- class="uwp-ri-enabled" value="1" <?php checked(1, $value); ?> /> |
|
1781
|
|
- <label for="confirm_password_yes<?php echo $radio_id; ?>" |
|
1782
|
|
- class="uwp-cb-enable"><span><?php _e('Yes', 'userswp'); ?></span></label> |
|
2532
|
+ /* ---- Show field form in admin ---- */ |
|
2533
|
+ if ( $field_type != '' && $field_id != '' && $field_action == 'new' && isset( $_REQUEST['create_field'] ) && isset( $_REQUEST['manage_field_type'] ) && $_REQUEST['manage_field_type'] == 'custom_fields' ) { |
|
2534
|
+ $this->form_field_adminhtml( $field_type, $field_id, $field_action, $field_type_key, $form_type ); |
|
2535
|
+ } |
|
1783
|
2536
|
|
|
1784
|
|
- <input type="radio" id="confirm_password_no<?php echo $radio_id; ?>" name="extra[confirm_password]" |
|
1785
|
|
- class="uwp-ri-disabled" value="0" <?php checked(0, $value); ?> /> |
|
1786
|
|
- <label for="confirm_password_no<?php echo $radio_id; ?>" |
|
1787
|
|
- class="uwp-cb-disable"><span><?php _e('No', 'userswp'); ?></span></label> |
|
1788
|
|
- </div> |
|
1789
|
|
- </li> |
|
1790
|
|
- <?php |
|
1791
|
|
- } |
|
1792
|
|
- $html = ob_get_clean(); |
|
1793
|
|
- return $output . $html; |
|
1794
|
|
- } |
|
2537
|
+ /* ---- Delete field ---- */ |
|
2538
|
+ if ( $field_id != '' && $field_action == 'delete' && isset( $_REQUEST['_wpnonce'] ) && isset( $_REQUEST['create_field'] ) && isset( $_REQUEST['manage_field_type'] ) && $_REQUEST['manage_field_type'] == 'custom_fields' ) { |
|
2539
|
+ if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'custom_fields_delete_' . $field_id ) ) { |
|
2540
|
+ return; |
|
2541
|
+ } |
|
1795
|
2542
|
|
|
1796
|
|
- public function uwp_builder_extra_fields_email($output, $result_str, $cf, $field_info) { |
|
1797
|
|
- ob_start(); |
|
1798
|
|
- $radio_id = (isset($field_info->htmlvar_name)) ? $field_info->htmlvar_name : rand(5, 500); |
|
2543
|
+ echo $this->admin_form_field_delete( $field_id, true, $form_id ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
2544
|
+ } |
|
1799
|
2545
|
|
|
1800
|
|
- //confirm email field |
|
1801
|
|
- $extra = array(); |
|
1802
|
|
- if (isset($field_info->extra_fields) && $field_info->extra_fields != '') { |
|
1803
|
|
- $extra = unserialize($field_info->extra_fields); |
|
1804
|
|
- } |
|
1805
|
|
- $value = isset($extra['confirm_email']) ? $extra['confirm_email'] : '0'; |
|
2546
|
+ /* ---- Save field ---- */ |
|
2547
|
+ if ( $field_id != '' && $field_action == 'submit' && isset( $_REQUEST['_wpnonce'] ) && isset( $_REQUEST['create_field'] ) && isset( $_REQUEST['manage_field_type'] ) && $_REQUEST['manage_field_type'] == 'custom_fields' ) { |
|
2548
|
+ if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'custom_fields_' . $field_id ) ) { |
|
2549
|
+ return; |
|
2550
|
+ } |
|
1806
|
2551
|
|
|
1807
|
|
- if (isset($field_info->htmlvar_name) && $field_info->htmlvar_name == 'uwp_account_email') { |
|
1808
|
|
- ?> |
|
1809
|
|
- <li> |
|
1810
|
|
- <label for="cat_sort" class="uwp-tooltip-wrap"> |
|
1811
|
|
- <i class="fas fa-info-circle" |
|
1812
|
|
- aria-hidden="true"></i> <?php _e('Display confirm email field?:', 'userswp'); ?> |
|
1813
|
|
- <div class="uwp-tooltip"> |
|
1814
|
|
- <?php _e('Lets you display confirm email form field.', 'userswp'); ?> |
|
1815
|
|
- </div> |
|
1816
|
|
- </label> |
|
2552
|
+ foreach ( $_REQUEST as $pkey => $pval ) { |
|
2553
|
+ if ( isset( $_REQUEST[ $pkey ] ) && is_array( $_REQUEST[ $pkey ] ) ) { |
|
2554
|
+ $tags = 'skip_field'; |
|
2555
|
+ } else { |
|
2556
|
+ $tags = ''; |
|
2557
|
+ } |
|
1817
|
2558
|
|
|
1818
|
|
- <div class="uwp-input-wrap uwp-switch"> |
|
1819
|
|
- <input type="radio" id="confirm_email_yes<?php echo $radio_id; ?>" name="extra[confirm_email]" |
|
1820
|
|
- class="uwp-ri-enabled" value="1" <?php checked(1, $value); ?> /> |
|
1821
|
|
- <label for="confirm_email_yes<?php echo $radio_id; ?>" |
|
1822
|
|
- class="uwp-cb-enable"><span><?php _e('Yes', 'userswp'); ?></span></label> |
|
2559
|
+ if ( $tags != 'skip_field' && !empty( $_REQUEST[ $pkey ] ) ) { |
|
2560
|
+ $_REQUEST[ $pkey ] = strip_tags( $_REQUEST[ $pkey ], $tags ); |
|
2561
|
+ } |
|
2562
|
+ } |
|
1823
|
2563
|
|
|
1824
|
|
- <input type="radio" id="confirm_email_no<?php echo $radio_id; ?>" name="extra[confirm_email]" |
|
1825
|
|
- class="uwp-ri-disabled" value="0" <?php checked(0, $value); ?> /> |
|
1826
|
|
- <label for="confirm_email_no<?php echo $radio_id; ?>" |
|
1827
|
|
- class="uwp-cb-disable"><span><?php _e('No', 'userswp'); ?></span></label> |
|
1828
|
|
- </div> |
|
1829
|
|
- </li> |
|
1830
|
|
- <?php |
|
1831
|
|
- } |
|
1832
|
|
- $html = ob_get_clean(); |
|
1833
|
|
- return $output . $html; |
|
1834
|
|
- } |
|
2564
|
+ $return = $this->admin_form_field_save( $_REQUEST ); |
|
1835
|
2565
|
|
|
1836
|
|
- public function uwp_builder_extra_fields_file($output, $result_str, $cf, $field_info) { |
|
1837
|
|
- ob_start(); |
|
2566
|
+ if ( is_int( $return ) ) { |
|
2567
|
+ $lastid = $return; |
|
2568
|
+ $this->form_field_adminhtml( $field_type, $lastid, 'submit', $field_type_key, $form_type ); |
|
2569
|
+ } else { |
|
2570
|
+ echo $return; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
2571
|
+ } |
|
2572
|
+ } |
|
1838
|
2573
|
|
|
1839
|
|
- $file_obj = new UsersWP_Files(); |
|
1840
|
|
- $allowed_file_types = $file_obj->allowed_mime_types(); |
|
2574
|
+ wp_die(); |
|
2575
|
+ } |
|
1841
|
2576
|
|
|
1842
|
|
- $extra_fields = isset($field_info->extra_fields) && $field_info->extra_fields != '' ? maybe_unserialize($field_info->extra_fields) : ''; |
|
1843
|
|
- $uwp_file_types = !empty($extra_fields) && !empty($extra_fields['uwp_file_types']) ? $extra_fields['uwp_file_types'] : array('*'); |
|
1844
|
|
- ?> |
|
1845
|
|
- <li> |
|
1846
|
|
- <label for="uwp_file_types" class="uwp-tooltip-wrap"> |
|
1847
|
|
- <i class="fas fa-info-circle" aria-hidden="true"></i> <?php _e('Allowed file types :', 'userswp'); ?> |
|
1848
|
|
- <div class="uwp-tooltip"> |
|
1849
|
|
- <?php _e('Select file types to allowed for file uploading. (Select multiple file types by holding down "Ctrl" key.)', 'userswp'); ?> |
|
1850
|
|
- </div> |
|
1851
|
|
- </label> |
|
1852
|
|
- <div class="uwp-input-wrap"> |
|
1853
|
|
- <select name="extra[uwp_file_types][]" id="uwp_file_types" multiple="multiple" style="height:100px;width:90%;"> |
|
1854
|
|
- <option value="*" <?php selected(true, in_array('*', $uwp_file_types)); ?>><?php _e('All types', 'userswp'); ?></option> |
|
1855
|
|
- <?php foreach ($allowed_file_types as $format => $types) { ?> |
|
1856
|
|
- <optgroup label="<?php echo esc_attr(wp_sprintf(__('%s formats', 'userswp'), __($format, 'userswp'))); ?>"> |
|
1857
|
|
- <?php foreach ($types as $ext => $type) { ?> |
|
1858
|
|
- <option value="<?php echo esc_attr($ext); ?>" <?php selected(true, in_array($ext, $uwp_file_types)); ?>><?php echo '.' . $ext; ?></option> |
|
1859
|
|
- <?php } ?> |
|
1860
|
|
- </optgroup> |
|
1861
|
|
- <?php } ?> |
|
1862
|
|
- </select> |
|
1863
|
|
- </div> |
|
1864
|
|
- </li> |
|
1865
|
|
- <?php |
|
2577
|
+ public function set_field_order( $field_ids = array(), $form_id = 1 ) { |
|
1866
|
2578
|
|
|
1867
|
|
- $html = ob_get_clean(); |
|
1868
|
|
- return $output . $html; |
|
1869
|
|
- } |
|
1870
|
|
- |
|
1871
|
|
- public function uwp_builder_data_type_text($output, $result_str, $cf, $field_info) { |
|
1872
|
|
- ob_start(); |
|
2579
|
+ global $wpdb; |
|
1873
|
2580
|
|
|
1874
|
|
- $dt_value = ''; |
|
1875
|
|
- if (isset($field_info->data_type)) { |
|
1876
|
|
- $dt_value = esc_attr($field_info->data_type); |
|
1877
|
|
- }elseif (isset($cf['defaults']['data_type']) && $cf['defaults']['data_type']) { |
|
1878
|
|
- $dt_value = $cf['defaults']['data_type']; |
|
1879
|
|
- } |
|
1880
|
|
- ?> |
|
1881
|
|
- <li> |
|
1882
|
|
- <label for="data_type" class="uwp-tooltip-wrap"> |
|
1883
|
|
- <i class="fas fa-info-circle" aria-hidden="true"></i> <?php _e('Field Data Type ? :', 'userswp'); ?> |
|
1884
|
|
- <div class="uwp-tooltip"> |
|
1885
|
|
- <?php _e('Select Custom Field type', 'userswp'); ?> |
|
1886
|
|
- </div> |
|
1887
|
|
- </label> |
|
1888
|
|
- <div class="uwp-input-wrap"> |
|
2581
|
+ $table_name = uwp_get_table_prefix() . 'uwp_form_fields'; |
|
1889
|
2582
|
|
|
1890
|
|
- <select name="data_type" id="data_type" |
|
1891
|
|
- onchange="uwp_data_type_changed(this, '<?php echo $result_str; ?>');"> |
|
1892
|
|
- <option |
|
1893
|
|
- value="XVARCHAR" <?php if ($dt_value == 'VARCHAR') { |
|
1894
|
|
- echo 'selected="selected"'; |
|
1895
|
|
- } ?>><?php _e('Text Field', 'userswp'); ?></option> |
|
1896
|
|
- <option |
|
1897
|
|
- value="INT" <?php if ($dt_value == 'INT') { |
|
1898
|
|
- echo 'selected="selected"'; |
|
1899
|
|
- } ?>><?php _e('Number Field', 'userswp'); ?></option> |
|
1900
|
|
- <option |
|
1901
|
|
- value="FLOAT" <?php if ($dt_value == 'FLOAT') { |
|
1902
|
|
- echo 'selected="selected"'; |
|
1903
|
|
- } ?>><?php _e('Decimal Field', 'userswp'); ?></option> |
|
1904
|
|
- </select> |
|
2583
|
+ $count = 0; |
|
2584
|
+ if ( ! empty( $field_ids ) ) : |
|
2585
|
+ $user_meta_info = false; |
|
2586
|
+ foreach ( $field_ids as $id ) { |
|
1905
|
2587
|
|
|
1906
|
|
- </div> |
|
1907
|
|
- </li> |
|
2588
|
+ $cf = trim( $id, '_' ); |
|
1908
|
2589
|
|
|
1909
|
|
- <?php |
|
1910
|
|
- $value = ''; |
|
1911
|
|
- if (isset($field_info->decimal_point)) { |
|
1912
|
|
- $value = esc_attr($field_info->decimal_point); |
|
1913
|
|
- }elseif (isset($cf['defaults']['decimal_point']) && $cf['defaults']['decimal_point']) { |
|
1914
|
|
- $value = $cf['defaults']['decimal_point']; |
|
1915
|
|
- } |
|
1916
|
|
- ?> |
|
2590
|
+ $user_meta_info = $wpdb->query( |
|
2591
|
+ $wpdb->prepare( |
|
2592
|
+ 'update ' . $table_name . ' set |
|
2593
|
+ sort_order=%d |
|
2594
|
+ where id= %d and form_id = %d', |
|
2595
|
+ array( $count, $cf, $form_id ) |
|
2596
|
+ ) |
|
2597
|
+ ); |
|
2598
|
+ ++$count; |
|
2599
|
+ } |
|
1917
|
2600
|
|
|
1918
|
|
- <li class="decimal-point-wrapper" |
|
1919
|
|
- style="<?php echo ($dt_value == 'FLOAT') ? '' : 'display:none' ?>"> |
|
1920
|
|
- <label for="decimal_point" class="uwp-tooltip-wrap"> |
|
1921
|
|
- <i class="fas fa-info-circle" aria-hidden="true"></i> <?php _e('Select decimal precision:', 'userswp'); ?> |
|
1922
|
|
- <div class="uwp-tooltip"> |
|
1923
|
|
- <?php _e('Decimal places to display after point', 'userswp'); ?> |
|
1924
|
|
- </div> |
|
1925
|
|
- </label> |
|
1926
|
|
- <div class="uwp-input-wrap"> |
|
1927
|
|
- <select name="decimal_point" id="decimal_point"> |
|
1928
|
|
- <option value=""><?php echo __('Select', 'userswp'); ?></option> |
|
1929
|
|
- <?php for ($i = 1; $i <= 10; $i++) { |
|
1930
|
|
- $selected = $i == $value ? 'selected="selected"' : ''; ?> |
|
1931
|
|
- <option value="<?php echo $i; ?>" <?php echo $selected; ?>><?php echo $i; ?></option> |
|
1932
|
|
- <?php } ?> |
|
1933
|
|
- </select> |
|
1934
|
|
- </div> |
|
1935
|
|
- </li> |
|
1936
|
|
- <?php |
|
2601
|
+ return $user_meta_info; |
|
2602
|
+ else : |
|
2603
|
+ return false; |
|
2604
|
+ endif; |
|
2605
|
+ } |
|
1937
|
2606
|
|
|
1938
|
|
- $output = ob_get_clean(); |
|
1939
|
|
- return $output; |
|
1940
|
|
- } |
|
2607
|
+ public function admin_form_field_delete( $field_id = '', $delete_meta = true, $form_id = 1 ) { |
|
1941
|
2608
|
|
|
1942
|
|
- public function uwp_advance_admin_custom_fields($field_info, $cf) { |
|
1943
|
|
- $radio_id = (isset($field_info->htmlvar_name)) ? $field_info->htmlvar_name : rand(5, 500); |
|
1944
|
|
- $hide_register_field = (isset($cf['defaults']['is_register_field']) && $cf['defaults']['is_register_field'] === false) ? "style='display:none;'" : ''; |
|
1945
|
|
- $hide_register_field = (isset($field_info->for_admin_use) && $field_info->for_admin_use == '1') ? "style='display:none;'" : $hide_register_field; |
|
2609
|
+ global $wpdb; |
|
1946
|
2610
|
|
|
1947
|
|
- $value = 0; |
|
1948
|
|
- if (isset($field_info->is_register_field)) { |
|
1949
|
|
- $value = (int) $field_info->is_register_field; |
|
1950
|
|
- } else if (isset($cf['defaults']['is_register_field']) && $cf['defaults']['is_register_field']) { |
|
1951
|
|
- $value = ($cf['defaults']['is_register_field']) ? 1 : 0; |
|
1952
|
|
- } |
|
2611
|
+ $table_name = uwp_get_table_prefix() . 'uwp_form_fields'; |
|
2612
|
+ $extras_table_name = uwp_get_table_prefix() . 'uwp_form_extras'; |
|
2613
|
+ $meta_table = get_usermeta_table_prefix() . 'uwp_usermeta'; |
|
1953
|
2614
|
|
|
1954
|
|
- //register only field |
|
1955
|
|
- $hide_register_only_field = (isset($cf['defaults']['is_register_only_field']) && $cf['defaults']['is_register_only_field'] === false) ? "style='display:none;'" : ''; |
|
1956
|
|
- $hide_register_only_field = (isset($field_info->for_admin_use) && $field_info->for_admin_use == '1') ? "style='display:none;'" : $hide_register_only_field; |
|
1957
|
|
- $register_only_value = 0; |
|
1958
|
|
- if (isset($field_info->is_register_only_field)) { |
|
1959
|
|
- $register_only_value = (int) $field_info->is_register_only_field; |
|
1960
|
|
- } else if (isset($cf['defaults']['is_register_only_field']) && $cf['defaults']['is_register_only_field']) { |
|
1961
|
|
- $register_only_value = ($cf['defaults']['is_register_only_field']) ? 1 : 0; |
|
1962
|
|
- } |
|
1963
|
|
- ?> |
|
1964
|
|
- <li <?php echo $hide_register_field; ?> class="cf-incin-reg-form"> |
|
1965
|
|
- <label for="cat_sort" class="uwp-tooltip-wrap"> |
|
1966
|
|
- <i class="fas fa-info-circle" aria-hidden="true"></i> <?php _e('Include this field in register form:', 'userswp'); ?> |
|
1967
|
|
- <div class="uwp-tooltip"> |
|
1968
|
|
- <?php _e('Lets you use this field as register form field, set from register tab above.', 'userswp'); ?> |
|
1969
|
|
- </div> |
|
1970
|
|
- </label> |
|
2615
|
+ if ( $field_id != '' ) { |
|
2616
|
+ $cf = trim( $field_id, '_' ); |
|
1971
|
2617
|
|
|
1972
|
|
- <?php |
|
1973
|
|
- if (isset($field_info->htmlvar_name) && $field_info->htmlvar_name == 'uwp_account_username') { |
|
1974
|
|
- ?> |
|
1975
|
|
- <div> |
|
1976
|
|
- <input type="hidden" name="is_register_field" value="1" /> |
|
1977
|
|
- <p><?php _e('This is mandatory register form field.', 'userswp'); ?></p> |
|
1978
|
|
- </div> |
|
1979
|
|
- <?php |
|
1980
|
|
- } else { |
|
1981
|
|
- ?> |
|
1982
|
|
- <div class="uwp-input-wrap uwp-switch"> |
|
1983
|
|
- <input type="radio" id="is_register_field_yes<?php echo $radio_id; ?>" name="is_register_field" class="uwp-ri-enabled" value="1" <?php checked(1, $value); ?> /> |
|
1984
|
|
- <label for="is_register_field_yes<?php echo $radio_id; ?>" class="uwp-cb-enable"><span><?php _e('Yes', 'userswp'); ?></span></label> |
|
2618
|
+ if ( $field = $wpdb->get_row( $wpdb->prepare( 'select id, htmlvar_name FROM ' . $table_name . ' WHERE id= %d AND form_id = %d', array( (int) $cf, (int) $form_id ) ) ) ) { |
|
1985
|
2619
|
|
|
1986
|
|
- <input type="radio" id="is_register_field_no<?php echo $radio_id; ?>" name="is_register_field" class="uwp-ri-disabled" value="0" <?php checked(0, $value); ?> /> |
|
1987
|
|
- <label for="is_register_field_no<?php echo $radio_id; ?>" class="uwp-cb-disable"><span><?php _e('No', 'userswp'); ?></span></label> |
|
1988
|
|
- </div> |
|
1989
|
|
- <?php } ?> |
|
1990
|
|
- </li> |
|
2620
|
+ $excluded_delete = array( 'email' ); |
|
2621
|
+ $excluded_delete = apply_filters( 'uwp_register_fields_exculde_delete', $excluded_delete ); |
|
1991
|
2622
|
|
|
1992
|
|
- <li <?php echo $hide_register_only_field; ?> class="cf-inconlyin-reg-form"> |
|
1993
|
|
- <label for="cat_sort" class="uwp-tooltip-wrap"> |
|
1994
|
|
- <i class="fas fa-info-circle" aria-hidden="true"></i> <?php _e('Include this field ONLY in register form:', 'userswp'); ?> |
|
1995
|
|
- <div class="uwp-tooltip"> |
|
1996
|
|
- <?php _e('Lets you use this field as register ONLY form field.', 'userswp'); ?> |
|
1997
|
|
- </div> |
|
1998
|
|
- </label> |
|
2623
|
+ if ( isset( $field->htmlvar_name ) && in_array( $field->htmlvar_name, $excluded_delete ) ) { |
|
2624
|
+ return $field_id; |
|
2625
|
+ } |
|
1999
|
2626
|
|
|
2000
|
|
- <?php |
|
2001
|
|
- if (isset($field_info->htmlvar_name) && $field_info->htmlvar_name == 'uwp_account_username') { |
|
2002
|
|
- ?> |
|
2003
|
|
- <div> |
|
2004
|
|
- <input type="hidden" name="is_register_only_field" value="1" /> |
|
2005
|
|
- <p><?php _e('This field is applicable only for register form.', 'userswp'); ?></p> |
|
2006
|
|
- </div> |
|
2007
|
|
- <?php |
|
2008
|
|
- } else { |
|
2009
|
|
- ?> |
|
2010
|
|
- <div class="uwp-input-wrap uwp-switch"> |
|
2011
|
|
- <input type="radio" id="is_register_only_field_yes<?php echo $radio_id; ?>" name="is_register_only_field" class="uwp-ri-enabled" value="1" <?php checked(1, $register_only_value); ?> /> |
|
2012
|
|
- <label for="is_register_only_field_yes<?php echo $radio_id; ?>" class="uwp-cb-enable"><span><?php _e('Yes', 'userswp'); ?></span></label> |
|
2627
|
+ // delete the meta column |
|
2628
|
+ if ( isset( $field->htmlvar_name ) && $delete_meta ) { |
|
2629
|
+ $register_forms = uwp_get_option( 'multiple_registration_forms' ); |
|
2630
|
+ $custom_fields = array(); |
|
2013
|
2631
|
|
|
2014
|
|
- <input type="radio" id="is_register_only_field_no<?php echo $radio_id; ?>" name="is_register_only_field" class="uwp-ri-disabled" value="0" <?php checked(0, $register_only_value); ?> /> |
|
2015
|
|
- <label for="is_register_only_field_no<?php echo $radio_id; ?>" class="uwp-cb-disable"><span><?php _e('No', 'userswp'); ?></span></label> |
|
2016
|
|
- </div> |
|
2017
|
|
- <?php } ?> |
|
2018
|
|
- </li> |
|
2019
|
|
- <?php |
|
2020
|
|
- } |
|
2632
|
+ if ( ! empty( $register_forms ) && is_array( $register_forms ) ) { |
|
2633
|
+ foreach ( $register_forms as $key => $register_form ) { |
|
2634
|
+ $form_ids[] = (int) $register_form['id']; |
|
2635
|
+ } |
|
2021
|
2636
|
|
|
2022
|
|
- public function uwp_return_empty_string() { |
|
2023
|
|
- return ""; |
|
2024
|
|
- } |
|
2637
|
+ if ( isset( $form_ids ) && count( $form_ids ) > 0 ) { |
|
2638
|
+ $form_ids_placeholder = array_fill( 0, count( $form_ids ), '%d' ); |
|
2639
|
+ $form_ids_placeholder = implode( ', ', $form_ids_placeholder ); |
|
2640
|
+ $query = $wpdb->prepare( 'SELECT id FROM ' . $table_name . " WHERE form_type = 'account' AND htmlvar_name = '" . $field->htmlvar_name . "' AND form_id IN (" . $form_ids_placeholder . ') ORDER BY sort_order ASC', $form_ids ); |
|
2641
|
+ $custom_fields = $wpdb->get_results( $query ); |
|
2642
|
+ } |
|
2643
|
+ } |
|
2025
|
2644
|
|
|
2026
|
|
- public function uwp_register_available_fields_head($heading, $form_type) |
|
2027
|
|
- { |
|
2028
|
|
- switch ($form_type) |
|
2029
|
|
- { |
|
2030
|
|
- case 'register': |
|
2031
|
|
- $heading = __('Available register form fields.', 'userswp'); |
|
2032
|
|
- break; |
|
2033
|
|
- } |
|
2034
|
|
- return $heading; |
|
2035
|
|
- } |
|
2645
|
+ if ( isset( $custom_fields ) && ! empty( $custom_fields ) && count( $custom_fields ) > 1 ) { |
|
2646
|
+ // Do not delete user meta column if field used in more than one form. |
|
2647
|
+ } else { |
|
2648
|
+ $col_name = sanitize_sql_orderby( $field->htmlvar_name ); |
|
2649
|
+ $wpdb->query( "ALTER TABLE `{$meta_table}` DROP COLUMN `{$col_name}`" ); |
|
2650
|
+ } |
|
2651
|
+ } |
|
2036
|
2652
|
|
|
2653
|
+ $wpdb->query( $wpdb->prepare( 'delete from ' . $table_name . ' where id= %d AND form_id = %d', array( $cf, $form_id ) ) ); |
|
2037
|
2654
|
|
|
2038
|
|
- public function uwp_register_available_fields_note($note, $form_type) |
|
2039
|
|
- { |
|
2040
|
|
- switch ($form_type) |
|
2041
|
|
- { |
|
2042
|
|
- case 'register': |
|
2043
|
|
- $note = __("Click on any box below to make it appear in register form. To make a field available here, go to account tab and expand any field from selected fields panel and tick the checkbox saying 'Include this field in register form'.", 'userswp'); |
|
2044
|
|
- break; |
|
2045
|
|
- } |
|
2046
|
|
- return $note; |
|
2047
|
|
- } |
|
2655
|
+ // Also delete register form field |
|
2656
|
+ $wpdb->query( $wpdb->prepare( 'delete from ' . $extras_table_name . ' where site_htmlvar_name= %s AND form_id = %d ', array( $field->htmlvar_name, $form_id ) ) ); |
|
2048
|
2657
|
|
|
2658
|
+ do_action( 'uwp_after_custom_field_deleted', $cf, $field ); |
|
2049
|
2659
|
|
|
2050
|
|
- public function uwp_register_selected_fields_head($heading, $form_type) |
|
2051
|
|
- { |
|
2052
|
|
- switch ($form_type) |
|
2053
|
|
- { |
|
2054
|
|
- case 'register': |
|
2055
|
|
- $heading = __('List of fields those will appear in register form.', 'userswp'); |
|
2056
|
|
- break; |
|
2660
|
+ return $field_id; |
|
2661
|
+ } else { |
|
2662
|
+ return 0; |
|
2663
|
+ } |
|
2664
|
+ } else { |
|
2665
|
+ return 0; |
|
2666
|
+ } |
|
2667
|
+ } |
|
2057
|
2668
|
|
|
2058
|
|
- } |
|
2059
|
|
- return $heading; |
|
2060
|
|
- } |
|
2669
|
+ public function admin_form_field_save( $request_field = array() ) { |
|
2061
|
2670
|
|
|
2671
|
+ global $wpdb;$wpdb->show_errors(); |
|
2062
|
2672
|
|
|
2063
|
|
- public function uwp_register_selected_fields_note($note, $form_type) |
|
2064
|
|
- { |
|
2065
|
|
- switch ($form_type) |
|
2066
|
|
- { |
|
2067
|
|
- case 'register': |
|
2068
|
|
- $note = __('Click to expand and view field related settings. You may drag and drop to arrange fields order in register form.', 'userswp'); |
|
2069
|
|
- break; |
|
2673
|
+ $table_name = uwp_get_table_prefix() . 'uwp_form_fields'; |
|
2070
|
2674
|
|
|
2071
|
|
- } |
|
2072
|
|
- return $note; |
|
2073
|
|
- } |
|
2675
|
+ $meta_table = get_usermeta_table_prefix() . 'uwp_usermeta'; |
|
2074
|
2676
|
|
|
2677
|
+ $old_html_variable = ''; |
|
2075
|
2678
|
|
|
2076
|
|
- public function uwp_manage_register_available_fields($form_type) |
|
2077
|
|
- { |
|
2078
|
|
- switch ($form_type) { |
|
2079
|
|
- case 'register': |
|
2080
|
|
- $this->uwp_register_available_fields($form_type); |
|
2081
|
|
- break; |
|
2082
|
|
- } |
|
2083
|
|
- } |
|
2679
|
+ $result_str = isset( $request_field['field_id'] ) ? trim( $request_field['field_id'] ) : ''; |
|
2680
|
+ $form_id = isset( $request_field['form_id'] ) ? (int) $request_field['form_id'] : 1; |
|
2084
|
2681
|
|
|
2085
|
|
- public function uwp_manage_register_selected_fields($form_type) |
|
2086
|
|
- { |
|
2087
|
|
- switch ($form_type) { |
|
2088
|
|
- case 'register': |
|
2089
|
|
- $this->uwp_register_selected_fields($form_type); |
|
2090
|
|
- break; |
|
2091
|
|
- } |
|
2092
|
|
- } |
|
2682
|
+ $user_meta_info = null; |
|
2093
|
2683
|
|
|
2094
|
|
- public function uwp_register_available_fields($form_type) |
|
2095
|
|
- { |
|
2096
|
|
- global $wpdb; |
|
2684
|
+ // some servers fail if a POST value is VARCHAR so we change it. |
|
2685
|
+ if ( isset( $request_field['data_type'] ) && $request_field['data_type'] == 'XVARCHAR' ) { |
|
2686
|
+ $request_field['data_type'] = 'VARCHAR'; |
|
2687
|
+ } |
|
2097
|
2688
|
|
|
2098
|
|
- $extras_table_name = uwp_get_table_prefix() . 'uwp_form_extras'; |
|
2689
|
+ $cf = trim( $result_str, '_' ); |
|
2099
|
2690
|
|
|
2100
|
|
- $existing_fields = $wpdb->get_results("select site_htmlvar_name from " . $extras_table_name . " where form_type ='" . $form_type . "'"); |
|
2691
|
+ $cehhtmlvar_name = isset( $request_field['htmlvar_name'] ) ? $request_field['htmlvar_name'] : ''; |
|
2692
|
+ $form_type = $request_field['form_type']; |
|
2101
|
2693
|
|
|
2102
|
|
- $existing_field_ids = array(); |
|
2103
|
|
- if (!empty($existing_fields)) { |
|
2104
|
|
- foreach ($existing_fields as $existing_field) { |
|
2105
|
|
- $existing_field_ids[] = $existing_field->site_htmlvar_name; |
|
2106
|
|
- } |
|
2107
|
|
- } |
|
2108
|
|
- ?> |
|
2109
|
|
- <input type="hidden" name="form_type" id="form_type" value="<?php echo $form_type; ?>"/> |
|
2110
|
|
- <input type="hidden" name="manage_field_type" class="manage_field_type" value="register"> |
|
2111
|
|
- <ul> |
|
2112
|
|
- <?php |
|
2694
|
+ $old_html_variable_name = 'uwp_account_' . $cehhtmlvar_name; |
|
2695
|
+ $check_old_html_variable = $wpdb->get_var( |
|
2696
|
+ $wpdb->prepare( |
|
2697
|
+ 'select htmlvar_name from ' . $table_name . ' where id <> %d and htmlvar_name = %s and form_type = %s and form_id = %d', |
|
2698
|
+ array( $cf, $old_html_variable_name, $form_type, $form_id ) |
|
2699
|
+ ) |
|
2700
|
+ ); |
|
2113
|
2701
|
|
|
2114
|
|
- $fields = $this->uwp_register_fields($form_type); |
|
2702
|
+ $check_html_variable = $wpdb->get_var( |
|
2703
|
+ $wpdb->prepare( |
|
2704
|
+ 'select htmlvar_name from ' . $table_name . ' where id <> %d and htmlvar_name = %s and form_type = %s and form_id = %d', |
|
2705
|
+ array( $cf, $cehhtmlvar_name, $form_type, $form_id ) |
|
2706
|
+ ) |
|
2707
|
+ ); |
|
2115
|
2708
|
|
|
2116
|
|
- if (!empty($fields)) { |
|
2117
|
|
- foreach ($fields as $field) { |
|
2118
|
|
- $field = stripslashes_deep($field); // strip slashes |
|
2709
|
+ if ( ( ! $check_old_html_variable && ! $check_html_variable ) || $request_field['field_type'] == 'fieldset' ) { |
|
2119
|
2710
|
|
|
2711
|
+ if ( $cf != '' ) { |
|
2120
|
2712
|
|
|
2121
|
|
- $fieldset_width = ''; |
|
2122
|
|
- if ($field['field_type'] == 'fieldset') { |
|
2123
|
|
- $fieldset_width = 'width:100%;'; |
|
2124
|
|
- } |
|
2713
|
+ $user_meta_info = $wpdb->get_row( |
|
2714
|
+ $wpdb->prepare( |
|
2715
|
+ 'select * from ' . $table_name . ' where id = %d', |
|
2716
|
+ array( $cf ) |
|
2717
|
+ ) |
|
2718
|
+ ); |
|
2125
|
2719
|
|
|
2126
|
|
- $display = ''; |
|
2127
|
|
- if (in_array($field['htmlvar_name'], $existing_field_ids)) |
|
2128
|
|
- $display = 'display:none;'; |
|
2720
|
+ } |
|
2129
|
2721
|
|
|
2130
|
|
- $style = 'style="' . $display . $fieldset_width . '"'; |
|
2131
|
|
- ?> |
|
2132
|
|
- <li <?php echo $style; ?> > |
|
2722
|
+ if ( ! empty( $user_meta_info ) ) { |
|
2723
|
+ $old_html_variable = $user_meta_info->htmlvar_name; |
|
2133
|
2724
|
|
|
2134
|
|
- <a id="uwp-<?php echo $field['htmlvar_name']; ?>" |
|
2135
|
|
- class="uwp-draggable-form-items uwp-<?php echo $field['field_type']; ?>" |
|
2136
|
|
- href="javascript:void(0);" data-type="<?php echo $field['field_type']; ?>"> |
|
2725
|
+ } |
|
2137
|
2726
|
|
|
2138
|
|
- <?php if ($icon = uwp_get_field_icon($field['field_icon'])) { |
|
2139
|
|
- echo $icon; |
|
2140
|
|
- } else { |
|
2141
|
|
- echo '<i class="fas fa-cog" aria-hidden="true"></i>'; |
|
2142
|
|
- }?> |
|
2727
|
+ $site_title = sanitize_text_field( $request_field['site_title'] ); |
|
2728
|
+ $form_label = isset( $request_field['form_label'] ) ? sanitize_text_field( $request_field['form_label'] ) : ''; |
|
2729
|
+ $help_text = isset( $request_field['help_text'] ) ? sanitize_text_field( $request_field['help_text'] ) : ''; |
|
2730
|
+ $field_type = sanitize_text_field( $request_field['field_type'] ); |
|
2731
|
+ $data_type = sanitize_text_field( $request_field['data_type'] ); |
|
2732
|
+ $field_type_key = isset( $request_field['field_type_key'] ) ? sanitize_text_field( $request_field['field_type_key'] ) : $field_type; |
|
2733
|
+ $htmlvar_name = isset( $request_field['htmlvar_name'] ) ? str_replace( |
|
2734
|
+ array( |
|
2735
|
+ '-', |
|
2736
|
+ ' ', |
|
2737
|
+ '"', |
|
2738
|
+ "'", |
|
2739
|
+ ), |
|
2740
|
+ array( '_', '', '', '' ), |
|
2741
|
+ sanitize_title_with_dashes( $request_field['htmlvar_name'] ) |
|
2742
|
+ ) : null; |
|
2743
|
+ $default_value = isset( $request_field['default_value'] ) ? sanitize_text_field( $request_field['default_value'] ) : ''; |
|
2744
|
+ $sort_order = isset( $request_field['sort_order'] ) ? absint( $request_field['sort_order'] ) : ''; |
|
2745
|
+ $is_active = isset( $request_field['is_active'] ) ? absint( $request_field['is_active'] ) : 1; |
|
2746
|
+ $placeholder_value = isset( $request_field['placeholder_value'] ) ? $request_field['placeholder_value'] : ''; |
|
2747
|
+ $for_admin_use = isset( $request_field['for_admin_use'] ) ? absint( $request_field['for_admin_use'] ) : 0; |
|
2748
|
+ $is_required = isset( $request_field['is_required'] ) ? absint( $request_field['is_required'] ) : 0; |
|
2749
|
+ $is_dummy = isset( $request_field['is_dummy'] ) ? absint( $request_field['is_dummy'] ) : 0; |
|
2750
|
+ $is_public = isset( $request_field['is_public'] ) ? absint( $request_field['is_public'] ) : 0; |
|
2751
|
+ $is_default = isset( $request_field['is_default'] ) ? absint( $request_field['is_default'] ) : 0; |
|
2752
|
+ $is_register_field = isset( $request_field['is_register_field'] ) ? absint( $request_field['is_register_field'] ) : 0; |
|
2753
|
+ $is_search_field = isset( $request_field['is_search_field'] ) ? absint( $request_field['is_search_field'] ) : 0; |
|
2754
|
+ $is_register_only_field = isset( $request_field['is_register_only_field'] ) ? absint( $request_field['is_register_only_field'] ) : 0; |
|
2755
|
+ $required_msg = isset( $request_field['required_msg'] ) ? sanitize_text_field( $request_field['required_msg'] ) : ''; |
|
2756
|
+ $css_class = isset( $request_field['css_class'] ) ? sanitize_text_field( $request_field['css_class'] ) : ''; |
|
2757
|
+ $field_icon = isset( $request_field['field_icon'] ) ? sanitize_text_field( $request_field['field_icon'] ) : ''; |
|
2758
|
+ $show_in = isset( $request_field['show_in'] ) ? $request_field['show_in'] : ''; |
|
2759
|
+ $user_roles = isset( $request_field['user_roles'] ) ? $request_field['user_roles'] : ''; |
|
2760
|
+ $decimal_point = isset( $request_field['decimal_point'] ) ? absint( $request_field['decimal_point'] ) : ''; // decimal point for DECIMAL data type |
|
2761
|
+ $decimal_point = $decimal_point > 0 ? ( $decimal_point > 10 ? 10 : $decimal_point ) : ''; |
|
2762
|
+ $validation_pattern = isset( $request_field['validation_pattern'] ) ? sanitize_text_field( $request_field['validation_pattern'] ) : ''; |
|
2763
|
+ $validation_msg = isset( $request_field['validation_msg'] ) ? sanitize_text_field( $request_field['validation_msg'] ) : ''; |
|
2764
|
+ $user_sort = isset( $request_field['user_sort'] ) ? absint( $request_field['user_sort'] ) : 0; |
|
2143
|
2765
|
|
|
2144
|
|
- <?php echo $field['site_title']; ?> |
|
2766
|
+ if ( empty( $htmlvar_name ) ) { |
|
2767
|
+ $htmlvar_name = sanitize_key( |
|
2768
|
+ str_replace( |
|
2769
|
+ array( '-', ' ', '"', "'" ), |
|
2770
|
+ array( |
|
2771
|
+ '_', |
|
2772
|
+ '_', |
|
2773
|
+ '', |
|
2774
|
+ '', |
|
2775
|
+ ), |
|
2776
|
+ $request_field['site_title'] |
|
2777
|
+ ) |
|
2778
|
+ ); |
|
2779
|
+ if ( str_replace( '_', '', $htmlvar_name ) != '' ) { |
|
2780
|
+ $htmlvar_name = substr( $htmlvar_name, 0, 50 ); |
|
2781
|
+ } else { |
|
2782
|
+ $htmlvar_name = time(); |
|
2783
|
+ } |
|
2784
|
+ } |
|
2145
|
2785
|
|
|
2786
|
+ if ( is_array( $show_in ) ) { |
|
2787
|
+ $show_in = implode( ',', $request_field['show_in'] ); |
|
2788
|
+ $show_in = sanitize_text_field( $show_in ); |
|
2789
|
+ } |
|
2146
|
2790
|
|
|
2147
|
|
- </a> |
|
2148
|
|
- </li> |
|
2791
|
+ if ( is_array( $user_roles ) ) { |
|
2792
|
+ $user_roles = implode( ',', $request_field['user_roles'] ); |
|
2793
|
+ $user_roles = sanitize_text_field( $user_roles ); |
|
2794
|
+ } |
|
2149
|
2795
|
|
|
2796
|
+ $option_values = ''; |
|
2797
|
+ if ( isset( $request_field['option_values'] ) ) { |
|
2798
|
+ $option_values = $request_field['option_values']; |
|
2799
|
+ } |
|
2150
|
2800
|
|
|
2151
|
|
- <?php |
|
2152
|
|
- } |
|
2153
|
|
- } |
|
2154
|
|
- ?> |
|
2155
|
|
- </ul> |
|
2156
|
|
- <?php |
|
2157
|
|
- } |
|
2801
|
+ if ( isset( $request_field['extra'] ) && ! empty( $request_field['extra'] ) ) { |
|
2802
|
+ $extra_fields = $request_field['extra']; |
|
2803
|
+ } |
|
2158
|
2804
|
|
|
2159
|
|
- public function uwp_register_fields($form_type) |
|
2160
|
|
- { |
|
2161
|
|
- $fields = array(); |
|
2805
|
+ if ( $sort_order == '' ) { |
|
2162
|
2806
|
|
|
2163
|
|
- return apply_filters('uwp_register_fields', $fields, $form_type); |
|
2164
|
|
- } |
|
2165
|
|
- |
|
2166
|
|
- public function uwp_register_extra_fields($fields, $form_type) |
|
2167
|
|
- { |
|
2168
|
|
- global $wpdb; |
|
2807
|
+ $last_order = $wpdb->get_var( 'SELECT MAX(sort_order) as last_order FROM ' . $table_name ); |
|
2169
|
2808
|
|
|
2170
|
|
- $table_name = uwp_get_table_prefix() . 'uwp_form_fields'; |
|
2171
|
|
- $records = $wpdb->get_results($wpdb->prepare("select * from " . $table_name . " where form_type = %s and is_register_field=%s order by sort_order asc", array('account', '1'))); |
|
2809
|
+ $sort_order = (int) $last_order + 1; |
|
2810
|
+ } |
|
2172
|
2811
|
|
|
2173
|
|
- foreach ($records as $row) { |
|
2174
|
|
- $field_type = $row->field_type; |
|
2175
|
|
- $fields[] = array( |
|
2176
|
|
- 'field_type' => $field_type, |
|
2177
|
|
- 'site_title' => $row->site_title, |
|
2178
|
|
- 'htmlvar_name' => $row->htmlvar_name, |
|
2179
|
|
- 'field_icon' => $row->field_icon |
|
2180
|
|
- ); |
|
2181
|
|
- } |
|
2182
|
|
- return $fields; |
|
2183
|
|
- } |
|
2812
|
+ if ( ! empty( $user_meta_info ) ) { |
|
2184
|
2813
|
|
|
2185
|
|
- public function uwp_register_selected_fields($form_type) |
|
2186
|
|
- { |
|
2187
|
|
- global $wpdb; |
|
2188
|
|
- $extras_table_name = uwp_get_table_prefix() . 'uwp_form_extras'; |
|
2189
|
|
- ?> |
|
2190
|
|
- <input type="hidden" name="manage_field_type" class="manage_field_type" value="register"> |
|
2191
|
|
- <ul class="uwp_form_extras"><?php |
|
2814
|
+ $excluded = uwp_get_excluded_fields(); |
|
2192
|
2815
|
|
|
2193
|
|
- $fields = $wpdb->get_results( |
|
2194
|
|
- $wpdb->prepare( |
|
2195
|
|
- "select * from " . $extras_table_name . " where form_type = %s order by sort_order asc", |
|
2196
|
|
- array($form_type) |
|
2197
|
|
- ) |
|
2198
|
|
- ); |
|
2816
|
+ if ( ! in_array( $htmlvar_name, $excluded ) ) { |
|
2817
|
+ // Create custom columns |
|
2818
|
+ switch ( $field_type ) : |
|
2199
|
2819
|
|
|
2200
|
|
- if (!empty($fields)) { |
|
2201
|
|
- foreach ($fields as $field) { |
|
2202
|
|
- $result_str = $field; |
|
2203
|
|
- $field_ins_upd = 'display'; |
|
2820
|
+ case 'checkbox': |
|
2821
|
+ case 'multiselect': |
|
2822
|
+ case 'select': |
|
2823
|
+ $op_size = '500'; |
|
2204
|
2824
|
|
|
2205
|
|
- $default = false; |
|
2825
|
+ // only make the field as big as it needs to be. |
|
2826
|
+ if ( isset( $option_values ) && $option_values && $field_type == 'select' ) { |
|
2827
|
+ $option_values_arr = explode( ',', $option_values ); |
|
2828
|
+ if ( isset( $option_values_arr ) && is_array( $option_values_arr ) ) { |
|
2829
|
+ $op_max = 0; |
|
2830
|
+ foreach ( $option_values_arr as $op_val ) { |
|
2831
|
+ if ( strlen( $op_val ) && strlen( $op_val ) > $op_max ) { |
|
2832
|
+ $op_max = strlen( $op_val ); |
|
2833
|
+ } |
|
2834
|
+ } |
|
2835
|
+ if ( $op_max ) { |
|
2836
|
+ $op_size = $op_max; |
|
2837
|
+ } |
|
2838
|
+ } |
|
2839
|
+ } elseif ( isset( $option_values ) && $option_values && $field_type == 'multiselect' ) { |
|
2840
|
+ if ( strlen( $option_values ) ) { |
|
2841
|
+ $op_size = strlen( $option_values ); |
|
2842
|
+ } |
|
2843
|
+ } |
|
2206
|
2844
|
|
|
2207
|
|
- $this->uwp_register_field_adminhtml($result_str, $field_ins_upd, $default); |
|
2208
|
|
- } |
|
2209
|
|
- }?> |
|
2210
|
|
- </ul> |
|
2211
|
|
- <?php |
|
2212
|
|
- } |
|
2845
|
+ $meta_field_add = 'ALTER TABLE ' . $meta_table . ' CHANGE `' . $old_html_variable . '` `' . $htmlvar_name . "`VARCHAR( $op_size ) NULL"; |
|
2213
|
2846
|
|
|
2214
|
|
- public function uwp_register_field_adminhtml($result_str, $field_ins_upd = '', $default = false, $request = array()) |
|
2215
|
|
- { |
|
2216
|
|
- global $wpdb; |
|
2847
|
+ if ( $default_value != '' ) { |
|
2848
|
+ $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
2849
|
+ } |
|
2217
|
2850
|
|
|
2218
|
|
- $table_name = uwp_get_table_prefix() . 'uwp_form_fields'; |
|
2219
|
|
- $extras_table_name = uwp_get_table_prefix() . 'uwp_form_extras'; |
|
2851
|
+ $alter_result = $wpdb->query( $meta_field_add ); |
|
2852
|
+ if ( $alter_result === false ) { |
|
2853
|
+ return __( 'Column change failed, you may have too many columns.', 'userswp' ); |
|
2854
|
+ } |
|
2220
|
2855
|
|
|
2221
|
|
- $cf = $result_str; |
|
2222
|
|
- if (!is_object($cf) && (is_int($cf) || ctype_digit($cf))) { |
|
2223
|
|
- $field_info = $wpdb->get_row($wpdb->prepare("select * from " . $extras_table_name . " where id= %d", array($cf))); |
|
2224
|
|
- } elseif (is_object($cf)) { |
|
2225
|
|
- //$field_info = $cf; |
|
2226
|
|
- $result_str = $cf->id; |
|
2227
|
|
- $field_info = $wpdb->get_row($wpdb->prepare("select * from " . $extras_table_name . " where id= %d", array((int) $cf->id))); |
|
2228
|
|
- } else { |
|
2229
|
|
- $field_info = false; |
|
2230
|
|
- } |
|
2856
|
+ if ( isset( $request_field['cat_display_type'] ) ) { |
|
2857
|
+ $extra_fields = $request_field['cat_display_type']; |
|
2858
|
+ } |
|
2231
|
2859
|
|
|
2860
|
+ if ( isset( $request_field['multi_display_type'] ) ) { |
|
2861
|
+ $extra_fields = $request_field['multi_display_type']; |
|
2862
|
+ } |
|
2232
|
2863
|
|
|
2233
|
|
- if (isset($request['field_type']) && $request['field_type'] != '') |
|
2234
|
|
- $field_type = esc_attr($request['field_type']); |
|
2235
|
|
- else |
|
2236
|
|
- $field_type = $field_info->field_type; |
|
2864
|
+ break; |
|
2237
|
2865
|
|
|
2866
|
+ case 'textarea': |
|
2867
|
+ case 'editor': |
|
2868
|
+ case 'url': |
|
2869
|
+ case 'file': |
|
2870
|
+ $alter_result = $wpdb->query( 'ALTER TABLE ' . $meta_table . ' CHANGE `' . $old_html_variable . '` `' . $htmlvar_name . '` TEXT NULL' ); |
|
2871
|
+ if ( $alter_result === false ) { |
|
2872
|
+ return __( 'Column change failed, you may have too many columns.', 'userswp' ); |
|
2873
|
+ } |
|
2874
|
+ if ( isset( $request_field['advanced_editor'] ) ) { |
|
2875
|
+ $extra_fields = $request_field['advanced_editor']; |
|
2876
|
+ } |
|
2238
|
2877
|
|
|
2239
|
|
- $field_site_name = ''; |
|
2240
|
|
- if (isset($request['site_title'])) { |
|
2241
|
|
- $field_site_name = $request['site_title']; |
|
2242
|
|
- } |
|
2878
|
+ break; |
|
2243
|
2879
|
|
|
2244
|
|
- if ($field_info) { |
|
2245
|
|
- $account_field_info = $wpdb->get_row($wpdb->prepare("select * from " . $table_name . " where htmlvar_name= %s", array($field_info->site_htmlvar_name))); |
|
2246
|
|
- if (isset($account_field_info->site_title)) { |
|
2247
|
|
- if ($account_field_info->field_type == 'fieldset') { |
|
2248
|
|
- $field_site_name = __('Fieldset:', 'userswp') . ' ' . $account_field_info->site_title; |
|
2249
|
|
- } else { |
|
2250
|
|
- $field_site_name = $account_field_info->site_title; |
|
2251
|
|
- } |
|
2252
|
|
- } |
|
2253
|
|
- $field_info = stripslashes_deep($field_info); // strip slashes |
|
2254
|
|
- } |
|
2255
|
|
- $field_site_name = sanitize_title($field_site_name); |
|
2880
|
+ case 'fieldset': |
|
2881
|
+ // Nothing happened for fieldset |
|
2882
|
+ break; |
|
2256
|
2883
|
|
|
2257
|
|
- if (isset($request['form_type'])) { |
|
2258
|
|
- $form_type = esc_attr($request['form_type']); |
|
2259
|
|
- } else { |
|
2260
|
|
- $form_type = $field_info->form_type; |
|
2261
|
|
- } |
|
2884
|
+ default: |
|
2885
|
+ if ( $data_type != 'VARCHAR' && $data_type != '' ) { |
|
2886
|
+ if ( $data_type == 'FLOAT' && $decimal_point > 0 ) { |
|
2887
|
+ $default_value_add = 'ALTER TABLE ' . $meta_table . ' CHANGE `' . $old_html_variable . '` `' . $htmlvar_name . '` DECIMAL(11, ' . (int) $decimal_point . ') NULL'; |
|
2888
|
+ } else { |
|
2889
|
+ $default_value_add = 'ALTER TABLE ' . $meta_table . ' CHANGE `' . $old_html_variable . '` `' . $htmlvar_name . '` ' . $data_type . ' NULL'; |
|
2890
|
+ } |
|
2262
|
2891
|
|
|
2263
|
|
- if (isset($request['is_default']) && $request['is_default'] != '') { |
|
2264
|
|
- $default = esc_attr($request['is_default']); |
|
2265
|
|
- } else { |
|
2266
|
|
- $default = $field_info->is_default; |
|
2267
|
|
- } |
|
2892
|
+ if ( is_numeric( $default_value ) && $default_value != '' ) { |
|
2893
|
+ $default_value_add .= " DEFAULT '" . $default_value . "'"; |
|
2894
|
+ } |
|
2895
|
+ } else { |
|
2896
|
+ $default_value_add = 'ALTER TABLE ' . $meta_table . ' CHANGE `' . $old_html_variable . '` `' . $htmlvar_name . '` VARCHAR( 254 ) NULL'; |
|
2897
|
+ if ( $default_value != '' ) { |
|
2898
|
+ $default_value_add .= " DEFAULT '" . $default_value . "'"; |
|
2899
|
+ } |
|
2900
|
+ } |
|
2268
|
2901
|
|
|
2269
|
|
- if (isset($request['htmlvar_name']) && $request['htmlvar_name'] != '') { |
|
2270
|
|
- $htmlvar_name = esc_attr($request['htmlvar_name']); |
|
2271
|
|
- } else { |
|
2272
|
|
- $htmlvar_name = $field_info->site_htmlvar_name; |
|
2273
|
|
- } |
|
2902
|
+ $alter_result = $wpdb->query( $default_value_add ); |
|
2903
|
+ if ( $alter_result === false ) { |
|
2904
|
+ return __( 'Column change failed, you may have too many columns.', 'userswp' ); |
|
2905
|
+ } |
|
2906
|
+ break; |
|
2907
|
+ endswitch; |
|
2908
|
+ } |
|
2274
|
2909
|
|
|
2275
|
|
- if (isset($htmlvar_name)) { |
|
2276
|
|
- if (!is_object($field_info)) {$field_info = new stdClass(); } |
|
2277
|
|
- $field_info->field_icon = $wpdb->get_var( |
|
2278
|
|
- $wpdb->prepare("SELECT field_icon FROM " . $table_name . " WHERE htmlvar_name = %s", array($htmlvar_name)) |
|
2279
|
|
- ); |
|
2280
|
|
- } |
|
2910
|
+ $extra_field_query = ''; |
|
2911
|
+ if ( ! empty( $extra_fields ) ) { |
|
2912
|
+ $extra_field_query = serialize( $extra_fields ); |
|
2913
|
+ } |
|
2281
|
2914
|
|
|
2282
|
|
- if (isset($field_info->field_icon) && strpos($field_info->field_icon, ' fa-') !== false) { |
|
2283
|
|
- $field_icon = '<i class="' . $field_info->field_icon . '" aria-hidden="true"></i>'; |
|
2284
|
|
- }elseif (isset($field_info->field_icon) && $field_info->field_icon) { |
|
2285
|
|
- $field_icon = '<b style="background-image: url("' . $field_info->field_icon . '")"></b>'; |
|
2286
|
|
- } |
|
2287
|
|
- elseif (isset($field_info->field_type) && $field_info->field_type == 'fieldset') { |
|
2288
|
|
- $field_icon = '<i class="fas fa-arrows-alt-h" aria-hidden="true"></i>'; |
|
2289
|
|
- } else { |
|
2290
|
|
- $field_icon = '<i class="fas fa-cog" aria-hidden="true"></i>'; |
|
2291
|
|
- } |
|
2915
|
+ $wpdb->query( |
|
2916
|
+ $wpdb->prepare( |
|
2917
|
+ 'update ' . $table_name . ' set |
|
2918
|
+ form_type = %s, |
|
2919
|
+ site_title = %s, |
|
2920
|
+ form_label = %s, |
|
2921
|
+ help_text = %s, |
|
2922
|
+ field_type = %s, |
|
2923
|
+ data_type = %s, |
|
2924
|
+ decimal_point = %s, |
|
2925
|
+ field_type_key = %s, |
|
2926
|
+ htmlvar_name = %s, |
|
2927
|
+ default_value = %s, |
|
2928
|
+ sort_order = %s, |
|
2929
|
+ is_active = %s, |
|
2930
|
+ placeholder_value = %s, |
|
2931
|
+ for_admin_use = %s, |
|
2932
|
+ is_default = %s, |
|
2933
|
+ is_required = %s, |
|
2934
|
+ is_dummy = %s, |
|
2935
|
+ is_public = %s, |
|
2936
|
+ is_register_field = %s, |
|
2937
|
+ is_search_field = %s, |
|
2938
|
+ is_register_only_field = %s, |
|
2939
|
+ required_msg = %s, |
|
2940
|
+ css_class = %s, |
|
2941
|
+ field_icon = %s, |
|
2942
|
+ show_in = %s, |
|
2943
|
+ user_roles = %s, |
|
2944
|
+ option_values = %s, |
|
2945
|
+ extra_fields = %s, |
|
2946
|
+ validation_pattern = %s, |
|
2947
|
+ validation_msg = %s, |
|
2948
|
+ form_id = %d, |
|
2949
|
+ user_sort = %s |
|
2950
|
+ where id = %d', |
|
2951
|
+ array( |
|
2952
|
+ $form_type, |
|
2953
|
+ $site_title, |
|
2954
|
+ $form_label, |
|
2955
|
+ $help_text, |
|
2956
|
+ $field_type, |
|
2957
|
+ $data_type, |
|
2958
|
+ $decimal_point, |
|
2959
|
+ $field_type_key, |
|
2960
|
+ $htmlvar_name, |
|
2961
|
+ $default_value, |
|
2962
|
+ $sort_order, |
|
2963
|
+ $is_active, |
|
2964
|
+ $placeholder_value, |
|
2965
|
+ $for_admin_use, |
|
2966
|
+ $is_default, |
|
2967
|
+ $is_required, |
|
2968
|
+ $is_dummy, |
|
2969
|
+ $is_public, |
|
2970
|
+ $is_register_field, |
|
2971
|
+ $is_search_field, |
|
2972
|
+ $is_register_only_field, |
|
2973
|
+ $required_msg, |
|
2974
|
+ $css_class, |
|
2975
|
+ $field_icon, |
|
2976
|
+ $show_in, |
|
2977
|
+ $user_roles, |
|
2978
|
+ $option_values, |
|
2979
|
+ $extra_field_query, |
|
2980
|
+ $validation_pattern, |
|
2981
|
+ $validation_msg, |
|
2982
|
+ $form_id, |
|
2983
|
+ $user_sort, |
|
2984
|
+ $cf, |
|
2985
|
+ ) |
|
2986
|
+ ) |
|
2987
|
+ ); |
|
2292
|
2988
|
|
|
2293
|
|
- ?> |
|
2294
|
|
- <li class="text" id="licontainer_<?php echo $result_str; ?>"> |
|
2295
|
|
- <form><!-- we need to wrap in a fom so we can use radio buttons with same name --> |
|
2296
|
|
- <div class="title title<?php echo $result_str; ?> gt-fieldset" |
|
2297
|
|
- title="<?php _e('Double Click to toggle and drag-drop to sort', 'userswp'); ?>" |
|
2298
|
|
- ondblclick="uwp_show_hide_register('field_frm<?php echo $result_str; ?>')"> |
|
2299
|
|
- <?php |
|
2989
|
+ $lastid = trim( $cf ); |
|
2300
|
2990
|
|
|
2301
|
|
- $nonce = wp_create_nonce('uwp_form_extras_nonce' . $result_str); |
|
2302
|
|
- ?> |
|
2991
|
+ do_action( 'uwp_after_custom_fields_updated', $lastid ); |
|
2303
|
2992
|
|
|
2304
|
|
- <?php if ($default == '1'): ?> |
|
2305
|
|
- <?php else: ?> |
|
2306
|
|
- <div title="<?php _e('Click to remove field', 'userswp'); ?>" |
|
2307
|
|
- onclick="delete_register_field('<?php echo $result_str; ?>', '<?php echo $nonce; ?>','<?php echo $htmlvar_name; ?>')" |
|
2308
|
|
- class="handlediv close"><i class="fas fa-times" aria-hidden="true"></i></div> |
|
2309
|
|
- <?php endif; |
|
2310
|
|
- echo $field_icon; |
|
2311
|
|
- ?> |
|
2312
|
|
- <b style="cursor:pointer;" |
|
2313
|
|
- onclick="uwp_show_hide_register('field_frm<?php echo $result_str; ?>')"><?php echo uwp_ucwords(' ' . $field_site_name); ?></b> |
|
2993
|
+ } else { |
|
2314
|
2994
|
|
|
2315
|
|
- </div> |
|
2995
|
+ switch ( $field_type ) : |
|
2316
|
2996
|
|
|
2317
|
|
- <div id="field_frm<?php echo $result_str; ?>" class="field_frm" |
|
2318
|
|
- style="display:<?php if ($field_ins_upd == 'submit') { |
|
2319
|
|
- echo 'block;'; |
|
2320
|
|
- } else { |
|
2321
|
|
- echo 'none;'; |
|
2322
|
|
- } ?>"> |
|
2323
|
|
- <input type="hidden" name="_wpnonce" value="<?php echo $nonce; ?>"/> |
|
2324
|
|
- <input type="hidden" name="field_id" id="field_id" value="<?php echo esc_attr($result_str); ?>"/> |
|
2325
|
|
- <input type="hidden" name="form_type" id="form_type" value="<?php echo $form_type; ?>"/> |
|
2326
|
|
- <input type="hidden" name="field_type" id="field_type" value="<?php echo $field_type; ?>"/> |
|
2327
|
|
- <input type="hidden" name="is_active" id="is_active" value="1"/> |
|
2328
|
|
- <ul class="widefat post fixed" style="width:100%;"> |
|
2997
|
+ case 'checkbox': |
|
2998
|
+ $data_type = 'TINYINT'; |
|
2329
|
2999
|
|
|
2330
|
|
- <input type="hidden" name="site_htmlvar_name" value="<?php echo $htmlvar_name ?>"/> |
|
3000
|
+ $meta_field_add = $data_type . '( 1 ) NOT NULL '; |
|
3001
|
+ if ( (int) $default_value === 1 ) { |
|
3002
|
+ $meta_field_add .= " DEFAULT '1'"; |
|
3003
|
+ } |
|
2331
|
3004
|
|
|
2332
|
|
- <li> |
|
2333
|
|
- <div class="uwp-input-wrap"> |
|
2334
|
|
- <p>No options available</p> |
|
2335
|
|
- </div> |
|
2336
|
|
- </li> |
|
3005
|
+ $add_result = uwp_add_column_if_not_exist( $meta_table, $htmlvar_name, $meta_field_add ); |
|
3006
|
+ if ( $add_result === false ) { |
|
3007
|
+ return __( 'Column creation failed, you may have too many columns or the default value does not match with field data type.', 'userswp' ); |
|
3008
|
+ } |
|
3009
|
+ break; |
|
3010
|
+ case 'multiselect': |
|
3011
|
+ case 'select': |
|
3012
|
+ $data_type = 'VARCHAR'; |
|
3013
|
+ $op_size = '500'; |
|
2337
|
3014
|
|
|
2338
|
|
- <li> |
|
2339
|
|
- <div class="uwp-input-wrap"> |
|
2340
|
|
- <?php if ($default != '1' || $field_info->site_htmlvar_name == 'uwp_account_password') { ?> |
|
2341
|
|
- <input type="button" class="button button-primary" name="save" id="save" |
|
2342
|
|
- value="<?php esc_attr_e('Save', 'userswp'); ?>" |
|
2343
|
|
- onclick="save_register_field('<?php echo $result_str; ?>')"/> |
|
2344
|
|
- <input type="button" name="delete" value="<?php esc_attr_e('Delete', 'userswp'); ?>" |
|
2345
|
|
- onclick="delete_register_field('<?php echo $result_str; ?>', '<?php echo $nonce; ?>','<?php echo $htmlvar_name ?>')" |
|
2346
|
|
- class="button"/> |
|
2347
|
|
- <?php } ?> |
|
3015
|
+ // only make the field as big as it needs to be. |
|
3016
|
+ if ( isset( $option_values ) && $option_values && $field_type == 'select' ) { |
|
3017
|
+ $option_values_arr = explode( ',', $option_values ); |
|
2348
|
3018
|
|
|
2349
|
|
- </div> |
|
2350
|
|
- </li> |
|
2351
|
|
- </ul> |
|
3019
|
+ if ( isset( $option_values_arr ) && is_array( $option_values_arr ) ) { |
|
3020
|
+ $op_max = 0; |
|
2352
|
3021
|
|
|
2353
|
|
- </div> |
|
2354
|
|
- </form> |
|
2355
|
|
- </li> |
|
2356
|
|
- <?php |
|
2357
|
|
- } |
|
3022
|
+ foreach ( $option_values_arr as $op_val ) { |
|
3023
|
+ if ( strlen( $op_val ) && strlen( $op_val ) > $op_max ) { |
|
3024
|
+ $op_max = strlen( $op_val ); |
|
3025
|
+ } |
|
3026
|
+ } |
|
2358
|
3027
|
|
|
2359
|
|
- public function uwp_register_ajax_handler() |
|
2360
|
|
- { |
|
2361
|
|
- if (isset($_REQUEST['create_field'])) { |
|
2362
|
|
- $field_id = isset($_REQUEST['field_id']) ? trim(sanitize_text_field($_REQUEST['field_id']), '_') : ''; |
|
2363
|
|
- $field_action = isset($_REQUEST['field_ins_upd']) ? sanitize_text_field($_REQUEST['field_ins_upd']) : ''; |
|
3028
|
+ if ( $op_max ) { |
|
3029
|
+ $op_size = $op_max; |
|
3030
|
+ } |
|
3031
|
+ } |
|
3032
|
+ } elseif ( isset( $option_values ) && $option_values && $field_type == 'multiselect' ) { |
|
3033
|
+ if ( strlen( $option_values ) ) { |
|
3034
|
+ $op_size = strlen( $option_values ); |
|
3035
|
+ } |
|
2364
|
3036
|
|
|
2365
|
|
- /* ------- check nonce field ------- */ |
|
2366
|
|
- if (isset($_REQUEST['update']) && $_REQUEST['update'] == 'update') { |
|
2367
|
|
- $field_ids = array(); |
|
2368
|
|
- if (!empty($_REQUEST['licontainer']) && is_array($_REQUEST['licontainer'])) { |
|
2369
|
|
- foreach ($_REQUEST['licontainer'] as $lic_id) { |
|
2370
|
|
- $field_ids[] = sanitize_text_field($lic_id); |
|
2371
|
|
- } |
|
2372
|
|
- } |
|
3037
|
+ if ( isset( $request_field['multi_display_type'] ) ) { |
|
3038
|
+ $extra_fields = $request_field['multi_display_type']; |
|
3039
|
+ } |
|
3040
|
+ } |
|
2373
|
3041
|
|
|
2374
|
|
- $return = uwp_form_extras_field_order($field_ids, "register"); |
|
3042
|
+ $meta_field_add = $data_type . "( $op_size ) NULL "; |
|
3043
|
+ if ( $default_value != '' ) { |
|
3044
|
+ $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
3045
|
+ } |
|
2375
|
3046
|
|
|
2376
|
|
- if (is_array($return)) { |
|
2377
|
|
- $return = json_encode($return); |
|
2378
|
|
- } |
|
3047
|
+ $add_result = uwp_add_column_if_not_exist( $meta_table, $htmlvar_name, $meta_field_add ); |
|
3048
|
+ if ( $add_result === false ) { |
|
3049
|
+ return __( 'Column creation failed, you may have too many columns or the default value does not match with field data type.', 'userswp' ); |
|
3050
|
+ } |
|
3051
|
+ break; |
|
3052
|
+ case 'textarea': |
|
3053
|
+ case 'editor': |
|
3054
|
+ case 'url': |
|
3055
|
+ case 'file': |
|
3056
|
+ $data_type = 'TEXT'; |
|
2379
|
3057
|
|
|
2380
|
|
- echo $return; |
|
2381
|
|
- } |
|
3058
|
+ $meta_field_add = $data_type . ' NULL '; |
|
2382
|
3059
|
|
|
2383
|
|
- /* ---- Show field form in admin ---- */ |
|
2384
|
|
- if ($field_action == 'new') { |
|
2385
|
|
- $form_type = isset($_REQUEST['form_type']) ? sanitize_text_field($_REQUEST['form_type']) : ''; |
|
2386
|
|
- $fields = $this->uwp_register_fields($form_type); |
|
3060
|
+ $add_result = uwp_add_column_if_not_exist( $meta_table, $htmlvar_name, $meta_field_add ); |
|
3061
|
+ if ( $add_result === false ) { |
|
3062
|
+ return __( 'Column creation failed, you may have too many columns or the default value does not match with field data type.', 'userswp' ); |
|
3063
|
+ } |
|
2387
|
3064
|
|
|
3065
|
+ break; |
|
2388
|
3066
|
|
|
2389
|
|
- $_REQUEST['site_field_id'] = isset($_REQUEST['field_id']) ? sanitize_text_field($_REQUEST['field_id']) : ''; |
|
2390
|
|
- $_REQUEST['is_default'] = '0'; |
|
3067
|
+ case 'datepicker': |
|
3068
|
+ $data_type = 'DATE'; |
|
2391
|
3069
|
|
|
2392
|
|
- if (!empty($fields)) { |
|
2393
|
|
- foreach ($fields as $val) { |
|
2394
|
|
- $val = stripslashes_deep($val); |
|
3070
|
+ $meta_field_add = $data_type . ' NULL '; |
|
2395
|
3071
|
|
|
2396
|
|
- if ($val['htmlvar_name'] == $_REQUEST['htmlvar_name']) { |
|
2397
|
|
- $_REQUEST['field_type'] = $val['field_type']; |
|
2398
|
|
- $_REQUEST['site_title'] = $val['site_title']; |
|
2399
|
|
- } |
|
2400
|
|
- } |
|
2401
|
|
- } |
|
3072
|
+ $add_result = uwp_add_column_if_not_exist( $meta_table, $htmlvar_name, $meta_field_add ); |
|
3073
|
+ if ( $add_result === false ) { |
|
3074
|
+ return __( 'Column creation failed, you may have too many columns or the default value must have in valid date format.', 'userswp' ); |
|
3075
|
+ } |
|
2402
|
3076
|
|
|
3077
|
+ break; |
|
2403
|
3078
|
|
|
2404
|
|
- $htmlvar_name = isset($_REQUEST['htmlvar_name']) ? sanitize_text_field($_REQUEST['htmlvar_name']) : ''; |
|
3079
|
+ case 'time': |
|
3080
|
+ $data_type = 'TIME'; |
|
2405
|
3081
|
|
|
2406
|
|
- $this->uwp_register_field_adminhtml($htmlvar_name, $field_action, false, $_REQUEST); |
|
2407
|
|
- } |
|
3082
|
+ $meta_field_add = $data_type . ' NULL '; |
|
2408
|
3083
|
|
|
2409
|
|
- /* ---- Delete field ---- */ |
|
2410
|
|
- if ($field_id != '' && $field_action == 'delete' && isset($_REQUEST['_wpnonce'])) { |
|
2411
|
|
- if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'uwp_form_extras_nonce' . $field_id)) |
|
2412
|
|
- return; |
|
3084
|
+ $add_result = uwp_add_column_if_not_exist( $meta_table, $htmlvar_name, $meta_field_add ); |
|
3085
|
+ if ( $add_result === false ) { |
|
3086
|
+ return __( 'Column creation failed, you may have too many columns or the default value must have in valid time format.', 'userswp' ); |
|
3087
|
+ } |
|
2413
|
3088
|
|
|
2414
|
|
- echo $this->uwp_register_field_delete($field_id); |
|
2415
|
|
- } |
|
3089
|
+ break; |
|
2416
|
3090
|
|
|
2417
|
|
- /* ---- Save field ---- */ |
|
2418
|
|
- if ($field_id != '' && $field_action == 'submit' && isset($_REQUEST['_wpnonce'])) { |
|
2419
|
|
- if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'uwp_form_extras_nonce' . $field_id)) |
|
2420
|
|
- return; |
|
3091
|
+ default: |
|
3092
|
+ if ( $data_type != 'VARCHAR' && $data_type != '' ) { |
|
3093
|
+ $meta_field_add = $data_type . ' NULL '; |
|
2421
|
3094
|
|
|
2422
|
|
- foreach ($_REQUEST as $pkey => $pval) { |
|
2423
|
|
- $tags = is_array($_REQUEST[$pkey]) ? 'skip_field' : ''; |
|
3095
|
+ if ( $data_type == 'FLOAT' && $decimal_point > 0 ) { |
|
3096
|
+ $meta_field_add = 'DECIMAL(11, ' . (int) $decimal_point . ') NULL '; |
|
3097
|
+ } |
|
2424
|
3098
|
|
|
2425
|
|
- if ($tags != 'skip_field') { |
|
2426
|
|
- $_REQUEST[$pkey] = strip_tags(sanitize_text_field($_REQUEST[$pkey]), $tags); |
|
2427
|
|
- } |
|
2428
|
|
- } |
|
3099
|
+ if ( is_numeric( $default_value ) && $default_value != '' ) { |
|
3100
|
+ $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
3101
|
+ } |
|
3102
|
+ } else { |
|
3103
|
+ $meta_field_add = ' VARCHAR( 254 ) NULL '; |
|
2429
|
3104
|
|
|
3105
|
+ if ( $default_value != '' ) { |
|
3106
|
+ $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
3107
|
+ } |
|
3108
|
+ } |
|
2430
|
3109
|
|
|
2431
|
|
- $return = $this->uwp_register_field_save($_REQUEST); |
|
3110
|
+ $add_result = uwp_add_column_if_not_exist( $meta_table, $htmlvar_name, $meta_field_add ); |
|
3111
|
+ if ( $add_result === false ) { |
|
3112
|
+ return __( 'Column creation failed, you may have too many columns or the default value does not match with field data type.', 'userswp' ); |
|
3113
|
+ } |
|
3114
|
+ break; |
|
3115
|
+ endswitch; |
|
2432
|
3116
|
|
|
2433
|
|
- if (is_int($return)) { |
|
2434
|
|
- $lastid = $return; |
|
3117
|
+ $extra_field_query = ''; |
|
3118
|
+ if ( ! empty( $extra_fields ) ) { |
|
3119
|
+ $extra_field_query = serialize( $extra_fields ); |
|
3120
|
+ } |
|
2435
|
3121
|
|
|
2436
|
|
- $this->uwp_register_field_adminhtml($lastid, 'submit'); |
|
2437
|
|
- } else { |
|
2438
|
|
- echo $return; |
|
2439
|
|
- } |
|
2440
|
|
- } |
|
2441
|
|
- } |
|
2442
|
|
- die(); |
|
2443
|
|
- } |
|
3122
|
+ $wpdb->query( |
|
3123
|
+ $wpdb->prepare( |
|
3124
|
+ 'insert into ' . $table_name . ' set |
|
3125
|
+ form_type = %s, |
|
3126
|
+ site_title = %s, |
|
3127
|
+ form_label = %s, |
|
3128
|
+ help_text = %s, |
|
3129
|
+ field_type = %s, |
|
3130
|
+ data_type = %s, |
|
3131
|
+ decimal_point = %s, |
|
3132
|
+ field_type_key = %s, |
|
3133
|
+ htmlvar_name = %s, |
|
3134
|
+ default_value = %s, |
|
3135
|
+ sort_order = %d, |
|
3136
|
+ is_active = %s, |
|
3137
|
+ placeholder_value = %s, |
|
3138
|
+ for_admin_use = %s, |
|
3139
|
+ is_default = %s, |
|
3140
|
+ is_required = %s, |
|
3141
|
+ is_dummy = %s, |
|
3142
|
+ is_public = %s, |
|
3143
|
+ is_register_field = %s, |
|
3144
|
+ is_search_field = %s, |
|
3145
|
+ is_register_only_field = %s, |
|
3146
|
+ required_msg = %s, |
|
3147
|
+ css_class = %s, |
|
3148
|
+ field_icon = %s, |
|
3149
|
+ show_in = %s, |
|
3150
|
+ user_roles = %s, |
|
3151
|
+ option_values = %s, |
|
3152
|
+ extra_fields = %s, |
|
3153
|
+ validation_pattern = %s, |
|
3154
|
+ validation_msg = %s, |
|
3155
|
+ form_id = %d, |
|
3156
|
+ user_sort = %s ', |
|
3157
|
+ array( |
|
3158
|
+ $form_type, |
|
3159
|
+ $site_title, |
|
3160
|
+ $form_label, |
|
3161
|
+ $help_text, |
|
3162
|
+ $field_type, |
|
3163
|
+ $data_type, |
|
3164
|
+ $decimal_point, |
|
3165
|
+ $field_type_key, |
|
3166
|
+ $htmlvar_name, |
|
3167
|
+ $default_value, |
|
3168
|
+ $sort_order, |
|
3169
|
+ $is_active, |
|
3170
|
+ $placeholder_value, |
|
3171
|
+ $for_admin_use, |
|
3172
|
+ $is_default, |
|
3173
|
+ $is_required, |
|
3174
|
+ $is_dummy, |
|
3175
|
+ $is_public, |
|
3176
|
+ $is_register_field, |
|
3177
|
+ $is_search_field, |
|
3178
|
+ $is_register_only_field, |
|
3179
|
+ $required_msg, |
|
3180
|
+ $css_class, |
|
3181
|
+ $field_icon, |
|
3182
|
+ $show_in, |
|
3183
|
+ $user_roles, |
|
3184
|
+ $option_values, |
|
3185
|
+ $extra_field_query, |
|
3186
|
+ $validation_pattern, |
|
3187
|
+ $validation_msg, |
|
3188
|
+ $form_id, |
|
3189
|
+ $user_sort, |
|
3190
|
+ ) |
|
3191
|
+ ) |
|
3192
|
+ ); |
|
2444
|
3193
|
|
|
2445
|
|
- public function uwp_register_field_save($request_field = array()) |
|
2446
|
|
- { |
|
2447
|
|
- global $wpdb; |
|
2448
|
|
- $extras_table_name = uwp_get_table_prefix() . 'uwp_form_extras'; |
|
3194
|
+ $lastid = $wpdb->insert_id; |
|
2449
|
3195
|
|
|
2450
|
|
- $result_str = isset($request_field['field_id']) ? trim($request_field['field_id']) : ''; |
|
3196
|
+ $lastid = trim( $lastid ); |
|
2451
|
3197
|
|
|
2452
|
|
- $cf = trim($result_str, '_'); |
|
3198
|
+ } |
|
2453
|
3199
|
|
|
2454
|
|
- /*-------- check duplicate validation --------*/ |
|
3200
|
+ return (int) $lastid; |
|
2455
|
3201
|
|
|
2456
|
|
- $site_htmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : ''; |
|
2457
|
|
- $form_type = $request_field['form_type']; |
|
2458
|
|
- $field_type = $request_field['field_type']; |
|
3202
|
+ } else { |
|
3203
|
+ return 'invalid_key'; |
|
3204
|
+ } |
|
3205
|
+ } |
|
2459
|
3206
|
|
|
2460
|
|
- $check_html_variable = $wpdb->get_var($wpdb->prepare("select site_htmlvar_name from " . $extras_table_name . " where id <> %d and site_htmlvar_name = %s and form_type = %s ", |
|
2461
|
|
- array($cf, $site_htmlvar_name, $form_type))); |
|
3207
|
+ public function register_ajax_handler() { |
|
3208
|
+ if ( isset( $_REQUEST['create_field'] ) ) { |
|
2462
|
3209
|
|
|
3210
|
+ if ( ! current_user_can( 'manage_options' ) ) { |
|
3211
|
+ wp_die( -1 ); |
|
3212
|
+ } |
|
2463
|
3213
|
|
|
2464
|
|
- if (!$check_html_variable) { |
|
3214
|
+ $form_id = isset( $_REQUEST['form_id'] ) ? sanitize_text_field( $_REQUEST['form_id'] ) : 1; |
|
3215
|
+ $field_id = isset( $_REQUEST['field_id'] ) ? trim( sanitize_text_field( $_REQUEST['field_id'] ), '_' ) : ''; |
|
3216
|
+ $field_action = isset( $_REQUEST['field_ins_upd'] ) ? sanitize_text_field( $_REQUEST['field_ins_upd'] ) : ''; |
|
2465
|
3217
|
|
|
2466
|
|
- if ($cf != '') { |
|
3218
|
+ /* ------- update order of fields ------- */ |
|
3219
|
+ if ( isset( $_REQUEST['update'] ) && $_REQUEST['update'] == 'update' && isset( $_REQUEST['_wpnonce'] )) { |
|
3220
|
+ if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'uwp_create_field_nonce' ) ) { |
|
3221
|
+ return; |
|
3222
|
+ } |
|
2467
|
3223
|
|
|
2468
|
|
- $user_meta_info = $wpdb->get_row( |
|
2469
|
|
- $wpdb->prepare( |
|
2470
|
|
- "select * from " . $extras_table_name . " where id = %d", |
|
2471
|
|
- array($cf) |
|
2472
|
|
- ) |
|
2473
|
|
- ); |
|
3224
|
+ $field_ids = array(); |
|
3225
|
+ if ( ! empty( $_REQUEST['licontainer'] ) && is_array( $_REQUEST['licontainer'] ) ) { |
|
3226
|
+ foreach ( $_REQUEST['licontainer'] as $lic_id ) { |
|
3227
|
+ $field_ids[] = sanitize_text_field( $lic_id ); |
|
3228
|
+ } |
|
3229
|
+ } |
|
2474
|
3230
|
|
|
2475
|
|
- } |
|
3231
|
+ $return = uwp_form_extras_field_order( $field_ids, 'register', $form_id ); |
|
2476
|
3232
|
|
|
2477
|
|
- if ($form_type == '') $form_type = 'register'; |
|
3233
|
+ if ( is_array( $return ) ) { |
|
3234
|
+ $return = json_encode( $return ); |
|
3235
|
+ } |
|
2478
|
3236
|
|
|
3237
|
+ echo $return; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
3238
|
+ } |
|
2479
|
3239
|
|
|
2480
|
|
- $site_htmlvar_name = $request_field['site_htmlvar_name']; |
|
2481
|
|
- $field_id = (isset($request_field['field_id']) && $request_field['field_id']) ? str_replace('new', '', $request_field['field_id']) : ''; |
|
2482
|
|
- |
|
3240
|
+ /* ---- Show field form in admin ---- */ |
|
3241
|
+ if ( $field_action == 'new' ) { |
|
3242
|
+ $form_type = isset( $_REQUEST['form_type'] ) ? sanitize_text_field( $_REQUEST['form_type'] ) : ''; |
|
3243
|
+ $fields = $this->register_fields( $form_type, $form_id ); |
|
2483
|
3244
|
|
|
2484
|
|
- if (!empty($user_meta_info)) { |
|
3245
|
+ $_REQUEST['site_field_id'] = isset( $_REQUEST['field_id'] ) ? sanitize_text_field( $_REQUEST['field_id'] ) : ''; |
|
3246
|
+ $_REQUEST['is_default'] = '0'; |
|
2485
|
3247
|
|
|
2486
|
|
- $wpdb->query( |
|
2487
|
|
- $wpdb->prepare( |
|
2488
|
|
- "update " . $extras_table_name . " set |
|
2489
|
|
- form_type = %s, |
|
2490
|
|
- field_type = %s, |
|
2491
|
|
- site_htmlvar_name = %s, |
|
2492
|
|
- sort_order = %s |
|
2493
|
|
- where id = %d", |
|
2494
|
|
- array( |
|
2495
|
|
- $form_type, |
|
2496
|
|
- $field_type, |
|
2497
|
|
- $site_htmlvar_name, |
|
2498
|
|
- $field_id, |
|
2499
|
|
- $cf |
|
2500
|
|
- ) |
|
3248
|
+ if ( ! empty( $fields ) ) { |
|
3249
|
+ foreach ( $fields as $val ) { |
|
3250
|
+ $val = stripslashes_deep( $val ); |
|
2501
|
3251
|
|
|
2502
|
|
- ) |
|
3252
|
+ if ( $val['htmlvar_name'] == $_REQUEST['htmlvar_name'] ) { |
|
3253
|
+ $_REQUEST['field_type'] = $val['field_type']; |
|
3254
|
+ $_REQUEST['site_title'] = $val['site_title']; |
|
3255
|
+ } |
|
3256
|
+ } |
|
3257
|
+ } |
|
2503
|
3258
|
|
|
2504
|
|
- ); |
|
3259
|
+ $htmlvar_name = isset( $_REQUEST['htmlvar_name'] ) ? sanitize_text_field( $_REQUEST['htmlvar_name'] ) : ''; |
|
2505
|
3260
|
|
|
2506
|
|
- $lastid = trim($cf); |
|
3261
|
+ $this->register_field_adminhtml( $htmlvar_name, $field_action, false, $_REQUEST ); |
|
3262
|
+ } |
|
2507
|
3263
|
|
|
3264
|
+ /* ---- Delete field ---- */ |
|
3265
|
+ if ( $field_id != '' && $field_action == 'delete' && isset( $_REQUEST['_wpnonce'] ) ) { |
|
3266
|
+ if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'uwp_form_extras_nonce' . $field_id ) ) { |
|
3267
|
+ return; |
|
3268
|
+ } |
|
2508
|
3269
|
|
|
2509
|
|
- } else { |
|
3270
|
+ echo $this->register_field_delete( $field_id ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
3271
|
+ } |
|
2510
|
3272
|
|
|
3273
|
+ /* ---- Save field ---- */ |
|
3274
|
+ if ( $field_id != '' && $field_action == 'submit' && isset( $_REQUEST['_wpnonce'] ) ) { |
|
3275
|
+ if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'uwp_form_extras_nonce' . $field_id ) ) { |
|
3276
|
+ return; |
|
3277
|
+ } |
|
2511
|
3278
|
|
|
2512
|
|
- $wpdb->query( |
|
2513
|
|
- $wpdb->prepare( |
|
3279
|
+ foreach ( $_REQUEST as $pkey => $pval ) { |
|
3280
|
+ $tags = is_array( $_REQUEST[ $pkey ] ) ? 'skip_field' : ''; |
|
2514
|
3281
|
|
|
2515
|
|
- "insert into " . $extras_table_name . " set |
|
2516
|
|
- form_type = %s, |
|
2517
|
|
- field_type = %s, |
|
2518
|
|
- site_htmlvar_name = %s, |
|
2519
|
|
- sort_order = %s", |
|
2520
|
|
- array($form_type, |
|
2521
|
|
- $field_type, |
|
2522
|
|
- $site_htmlvar_name, |
|
2523
|
|
- $field_id |
|
2524
|
|
- ) |
|
2525
|
|
- ) |
|
2526
|
|
- ); |
|
2527
|
|
- $lastid = $wpdb->insert_id; |
|
2528
|
|
- $lastid = trim($lastid); |
|
2529
|
|
- } |
|
3282
|
+ if ( $tags != 'skip_field' ) { |
|
3283
|
+ $_REQUEST[ $pkey ] = strip_tags( sanitize_text_field( $_REQUEST[ $pkey ] ), $tags ); |
|
3284
|
+ } |
|
3285
|
+ } |
|
2530
|
3286
|
|
|
2531
|
|
- return (int) $lastid; |
|
3287
|
+ $return = $this->register_field_save( $_REQUEST ); |
|
2532
|
3288
|
|
|
3289
|
+ if ( is_int( $return ) ) { |
|
3290
|
+ $lastid = $return; |
|
2533
|
3291
|
|
|
2534
|
|
- } else { |
|
2535
|
|
- return 'HTML Variable Name should be a unique name'; |
|
2536
|
|
- } |
|
2537
|
|
- } |
|
3292
|
+ $this->register_field_adminhtml( $lastid, 'submit' ); |
|
3293
|
+ } else { |
|
3294
|
+ echo $return; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
3295
|
+ } |
|
3296
|
+ } |
|
3297
|
+ } |
|
3298
|
+ die(); |
|
3299
|
+ } |
|
2538
|
3300
|
|
|
2539
|
|
- public function uwp_register_field_delete($field_id = '') |
|
2540
|
|
- { |
|
3301
|
+ public function register_field_delete( $field_id = '' ) { |
|
2541
|
3302
|
|
|
2542
|
|
- global $wpdb; |
|
2543
|
|
- $extras_table_name = uwp_get_table_prefix() . 'uwp_form_extras'; |
|
3303
|
+ global $wpdb; |
|
3304
|
+ $extras_table_name = uwp_get_table_prefix() . 'uwp_form_extras'; |
|
2544
|
3305
|
|
|
2545
|
|
- if ($field_id != '') { |
|
2546
|
|
- $cf = trim($field_id, '_'); |
|
3306
|
+ if ( $field_id != '' ) { |
|
3307
|
+ $cf = trim( $field_id, '_' ); |
|
2547
|
3308
|
|
|
2548
|
|
- $wpdb->query($wpdb->prepare("delete from " . $extras_table_name . " where id= %d ", array($cf))); |
|
3309
|
+ $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $extras_table_name . ' WHERE id= %d ', array( $cf ) ) ); |
|
2549
|
3310
|
|
|
2550
|
|
- return $field_id; |
|
3311
|
+ return $field_id; |
|
2551
|
3312
|
|
|
2552
|
|
- } else |
|
2553
|
|
- return 0; |
|
3313
|
+ } else { |
|
3314
|
+ return 0; |
|
3315
|
+ } |
|
3316
|
+ } |
|
2554
|
3317
|
|
|
3318
|
+ public function register_field_save( $request_field = array() ) { |
|
2555
|
3319
|
|
|
2556
|
|
- } |
|
2557
|
|
- |
|
2558
|
|
- public function uwp_form_builder_dummy_fields() { |
|
2559
|
|
- global $wpdb; |
|
3320
|
+ if ( ! current_user_can( 'manage_options' ) ) { |
|
3321
|
+ wp_die( -1 ); |
|
3322
|
+ } |
|
2560
|
3323
|
|
|
2561
|
|
- $table_name = uwp_get_table_prefix() . 'uwp_form_fields'; |
|
2562
|
|
- $extras_table_name = uwp_get_table_prefix() . 'uwp_form_extras'; |
|
2563
|
|
- // This function is intended for testing purpose |
|
2564
|
|
- if (isset($_GET['uwp_dummy']) |
|
2565
|
|
- && is_admin() |
|
2566
|
|
- && is_user_logged_in() |
|
2567
|
|
- && current_user_can('manage_options')) { |
|
3324
|
+ global $wpdb; |
|
3325
|
+ $extras_table_name = uwp_get_table_prefix() . 'uwp_form_extras'; |
|
2568
|
3326
|
|
|
2569
|
|
- if ($_GET['uwp_dummy'] == 'create') { |
|
2570
|
|
- // Account |
|
2571
|
|
- $fields = $this->uwp_dummy_custom_fields(); |
|
3327
|
+ $form_id = isset( $request_field['form_id'] ) ? (int) $request_field['form_id'] : ''; |
|
3328
|
+ $result_str = isset( $request_field['field_id'] ) ? trim( $request_field['field_id'] ) : ''; |
|
2572
|
3329
|
|
|
2573
|
|
- foreach ($fields as $field_index => $field) { |
|
2574
|
|
- $this->uwp_admin_form_field_save($field); |
|
2575
|
|
- } |
|
3330
|
+ $cf = trim( $result_str, '_' ); |
|
2576
|
3331
|
|
|
2577
|
|
- // Register |
|
2578
|
|
- foreach ($fields as $field) { |
|
2579
|
|
- $last_order = $wpdb->get_var("SELECT MAX(sort_order) as last_order FROM " . $extras_table_name); |
|
2580
|
|
- $sort_order = (int) $last_order + 1; |
|
2581
|
|
- $wpdb->query( |
|
2582
|
|
- $wpdb->prepare( |
|
3332
|
+ /*-------- check duplicate validation --------*/ |
|
2583
|
3333
|
|
|
2584
|
|
- "insert into " . $extras_table_name . " set |
|
2585
|
|
- form_type = %s, |
|
2586
|
|
- field_type = %s, |
|
2587
|
|
- is_dummy = %s, |
|
2588
|
|
- site_htmlvar_name = %s, |
|
2589
|
|
- sort_order = %s", |
|
2590
|
|
- array( |
|
2591
|
|
- 'register', |
|
2592
|
|
- $field['field_type'], |
|
2593
|
|
- $field['is_dummy'], |
|
2594
|
|
- 'uwp_account_' . $field['htmlvar_name'], |
|
2595
|
|
- $sort_order |
|
2596
|
|
- ) |
|
2597
|
|
- ) |
|
2598
|
|
- ); |
|
2599
|
|
- } |
|
2600
|
|
- |
|
2601
|
|
- wp_redirect(admin_url('admin.php?page=uwp_form_builder')); |
|
2602
|
|
- exit; |
|
2603
|
|
- } |
|
3334
|
+ $site_htmlvar_name = isset( $request_field['site_htmlvar_name'] ) ? sanitize_text_field( $request_field['site_htmlvar_name'] ) : sanitize_text_field( $request_field['htmlvar_name'] ); |
|
3335
|
+ $form_type = $request_field['form_type']; |
|
3336
|
+ $field_type = $request_field['field_type']; |
|
2604
|
3337
|
|
|
2605
|
|
- |
|
2606
|
|
- if ($_GET['uwp_dummy'] == 'delete') { |
|
2607
|
|
- |
|
2608
|
|
- $wpdb->query($wpdb->prepare("delete from " . $table_name . " where is_dummy= %s ", array('1'))); |
|
2609
|
|
- $wpdb->query($wpdb->prepare("delete from " . $extras_table_name . " where is_dummy= %s ", array('1'))); |
|
2610
|
|
- wp_redirect(admin_url('admin.php?page=uwp_form_builder')); |
|
2611
|
|
- exit; |
|
2612
|
|
- } |
|
2613
|
|
- |
|
2614
|
|
- } |
|
2615
|
|
- |
|
2616
|
|
- |
|
2617
|
|
- } |
|
2618
|
|
- |
|
2619
|
|
- public function uwp_dummy_custom_fields() { |
|
2620
|
|
- |
|
2621
|
|
- $fields = array(); |
|
2622
|
|
- |
|
2623
|
|
- //Fieldset |
|
2624
|
|
- $fields[] = array( |
|
2625
|
|
- 'form_type' => 'account', |
|
2626
|
|
- 'field_type' => 'fieldset', |
|
2627
|
|
- 'site_title' => __('Dummy Fieldset', 'userswp'), |
|
2628
|
|
- 'htmlvar_name' => 'dummy_fieldset', |
|
2629
|
|
- 'default_value' => '', |
|
2630
|
|
- 'option_values' => '', |
|
2631
|
|
- 'is_dummy' => '1', |
|
2632
|
|
- 'is_public' => '1', |
|
2633
|
|
- 'is_active' => '1', |
|
2634
|
|
- 'is_register_field' => '1', |
|
2635
|
|
- 'is_search_field' => '1', |
|
3338
|
+ $check_html_variable = $wpdb->get_var( |
|
3339
|
+ $wpdb->prepare( |
|
3340
|
+ 'select site_htmlvar_name from ' . $extras_table_name . ' where id <> %d and site_htmlvar_name = %s and form_type = %s and form_id=%d', |
|
3341
|
+ array( $cf, $site_htmlvar_name, $form_type, $form_id ) |
|
3342
|
+ ) |
|
2636
|
3343
|
); |
|
2637
|
3344
|
|
|
2638
|
|
- //Text |
|
2639
|
|
- $fields[] = array( |
|
2640
|
|
- 'form_type' => 'account', |
|
2641
|
|
- 'field_type' => 'text', |
|
2642
|
|
- 'site_title' => __('Dummy Text', 'userswp'), |
|
2643
|
|
- 'htmlvar_name' => 'dummy_text', |
|
2644
|
|
- 'default_value' => '', |
|
2645
|
|
- 'option_values' => '', |
|
2646
|
|
- 'is_dummy' => '1', |
|
2647
|
|
- 'is_public' => '1', |
|
2648
|
|
- 'is_active' => '1', |
|
2649
|
|
- 'is_register_field' => '1', |
|
2650
|
|
- 'is_search_field' => '1', |
|
2651
|
|
- ); |
|
3345
|
+ if ( ! $check_html_variable ) { |
|
2652
|
3346
|
|
|
2653
|
|
- //Textarea |
|
2654
|
|
- $fields[] = array( |
|
2655
|
|
- 'form_type' => 'account', |
|
2656
|
|
- 'field_type' => 'textarea', |
|
2657
|
|
- 'site_title' => __('Dummy Textarea', 'userswp'), |
|
2658
|
|
- 'htmlvar_name' => 'dummy_textarea', |
|
2659
|
|
- 'default_value' => '', |
|
2660
|
|
- 'option_values' => '', |
|
2661
|
|
- 'is_dummy' => '1', |
|
2662
|
|
- 'is_public' => '1', |
|
2663
|
|
- 'is_active' => '1', |
|
2664
|
|
- 'is_register_field' => '1', |
|
2665
|
|
- 'is_search_field' => '1', |
|
2666
|
|
- ); |
|
3347
|
+ if ( $cf != '' ) { |
|
2667
|
3348
|
|
|
2668
|
|
- //Checkbox |
|
2669
|
|
- $fields[] = array( |
|
2670
|
|
- 'form_type' => 'account', |
|
2671
|
|
- 'field_type' => 'checkbox', |
|
2672
|
|
- 'site_title' => __('Dummy Checkbox', 'userswp'), |
|
2673
|
|
- 'htmlvar_name' => 'dummy_checkbox', |
|
2674
|
|
- 'default_value' => '', |
|
2675
|
|
- 'option_values' => '', |
|
2676
|
|
- 'is_dummy' => '1', |
|
2677
|
|
- 'is_public' => '1', |
|
2678
|
|
- 'is_active' => '1', |
|
2679
|
|
- 'is_register_field' => '1', |
|
2680
|
|
- 'is_search_field' => '1', |
|
2681
|
|
- ); |
|
3349
|
+ $user_meta_info = $wpdb->get_row( |
|
3350
|
+ $wpdb->prepare( |
|
3351
|
+ 'select * from ' . $extras_table_name . ' where id = %d', |
|
3352
|
+ array( $cf ) |
|
3353
|
+ ) |
|
3354
|
+ ); |
|
2682
|
3355
|
|
|
2683
|
|
- //Radio |
|
2684
|
|
- $fields[] = array( |
|
2685
|
|
- 'form_type' => 'account', |
|
2686
|
|
- 'field_type' => 'radio', |
|
2687
|
|
- 'site_title' => __('Dummy Radio', 'userswp'), |
|
2688
|
|
- 'htmlvar_name' => 'dummy_radio', |
|
2689
|
|
- 'default_value' => '', |
|
2690
|
|
- 'option_values' => __('Value1,Value2,Value3', 'userswp'), |
|
2691
|
|
- 'is_dummy' => '1', |
|
2692
|
|
- 'is_public' => '1', |
|
2693
|
|
- 'is_active' => '1', |
|
2694
|
|
- 'is_register_field' => '1', |
|
2695
|
|
- 'is_search_field' => '1', |
|
2696
|
|
- ); |
|
3356
|
+ } |
|
2697
|
3357
|
|
|
2698
|
|
- //Select |
|
2699
|
|
- $fields[] = array( |
|
2700
|
|
- 'form_type' => 'account', |
|
2701
|
|
- 'field_type' => 'select', |
|
2702
|
|
- 'site_title' => __('Dummy Select', 'userswp'), |
|
2703
|
|
- 'htmlvar_name' => 'dummy_select', |
|
2704
|
|
- 'default_value' => '', |
|
2705
|
|
- 'option_values' => __('Select Option/,Value1,Value2,Value3', 'userswp'), |
|
2706
|
|
- 'is_dummy' => '1', |
|
2707
|
|
- 'is_public' => '1', |
|
2708
|
|
- 'is_active' => '1', |
|
2709
|
|
- 'is_register_field' => '1', |
|
2710
|
|
- 'is_search_field' => '1', |
|
2711
|
|
- ); |
|
3358
|
+ if ( $form_type == '' ) { |
|
3359
|
+ $form_type = 'register'; |
|
3360
|
+ } |
|
2712
|
3361
|
|
|
2713
|
|
- //URL |
|
2714
|
|
- $fields[] = array( |
|
2715
|
|
- 'form_type' => 'account', |
|
2716
|
|
- 'field_type' => 'url', |
|
2717
|
|
- 'site_title' => __('Dummy URL', 'userswp'), |
|
2718
|
|
- 'htmlvar_name' => 'dummy_url', |
|
2719
|
|
- 'default_value' => '', |
|
2720
|
|
- 'option_values' => '', |
|
2721
|
|
- 'is_dummy' => '1', |
|
2722
|
|
- 'is_public' => '1', |
|
2723
|
|
- 'is_active' => '1', |
|
2724
|
|
- 'is_register_field' => '1', |
|
2725
|
|
- 'is_search_field' => '1', |
|
2726
|
|
- ); |
|
3362
|
+ $site_htmlvar_name = sanitize_text_field( $request_field['site_htmlvar_name'] ); |
|
3363
|
+ $field_id = ( isset( $request_field['field_id'] ) && $request_field['field_id'] ) ? str_replace( 'new', '', $request_field['field_id'] ) : ''; |
|
2727
|
3364
|
|
|
2728
|
|
- //Date |
|
2729
|
|
- $fields[] = array( |
|
2730
|
|
- 'form_type' => 'account', |
|
2731
|
|
- 'field_type' => 'datepicker', |
|
2732
|
|
- 'site_title' => __('Dummy Date', 'userswp'), |
|
2733
|
|
- 'htmlvar_name' => 'dummy_datepicker', |
|
2734
|
|
- 'default_value' => '', |
|
2735
|
|
- 'option_values' => '', |
|
2736
|
|
- 'is_dummy' => '1', |
|
2737
|
|
- 'is_public' => '1', |
|
2738
|
|
- 'is_active' => '1', |
|
2739
|
|
- 'is_register_field' => '1', |
|
2740
|
|
- 'is_search_field' => '1', |
|
2741
|
|
- 'extra' => array( |
|
2742
|
|
- 'date_format' => 'F j, Y' |
|
2743
|
|
- ) |
|
2744
|
|
- ); |
|
3365
|
+ if ( ! empty( $user_meta_info ) ) { |
|
2745
|
3366
|
|
|
2746
|
|
- //Time |
|
2747
|
|
- $fields[] = array( |
|
2748
|
|
- 'form_type' => 'account', |
|
2749
|
|
- 'field_type' => 'time', |
|
2750
|
|
- 'site_title' => __('Dummy Time', 'userswp'), |
|
2751
|
|
- 'htmlvar_name' => 'dummy_time', |
|
2752
|
|
- 'default_value' => '', |
|
2753
|
|
- 'option_values' => '', |
|
2754
|
|
- 'is_dummy' => '1', |
|
2755
|
|
- 'is_public' => '1', |
|
2756
|
|
- 'is_active' => '1', |
|
2757
|
|
- 'is_register_field' => '1', |
|
2758
|
|
- 'is_search_field' => '1', |
|
2759
|
|
- ); |
|
3367
|
+ $wpdb->query( |
|
3368
|
+ $wpdb->prepare( |
|
3369
|
+ 'update ' . $extras_table_name . ' set |
|
3370
|
+ form_type = %s, |
|
3371
|
+ field_type = %s, |
|
3372
|
+ site_htmlvar_name = %s, |
|
3373
|
+ sort_order = %s, |
|
3374
|
+ form_id = %d |
|
3375
|
+ where id = %d', |
|
3376
|
+ array( |
|
3377
|
+ $form_type, |
|
3378
|
+ $field_type, |
|
3379
|
+ $site_htmlvar_name, |
|
3380
|
+ $field_id, |
|
3381
|
+ $form_id, |
|
3382
|
+ $cf, |
|
3383
|
+ ) |
|
3384
|
+ ) |
|
3385
|
+ ); |
|
2760
|
3386
|
|
|
2761
|
|
- //Phone |
|
2762
|
|
- $fields[] = array( |
|
2763
|
|
- 'form_type' => 'account', |
|
2764
|
|
- 'field_type' => 'phone', |
|
2765
|
|
- 'site_title' => __('Dummy Phone', 'userswp'), |
|
2766
|
|
- 'htmlvar_name' => 'dummy_phone', |
|
2767
|
|
- 'default_value' => '', |
|
2768
|
|
- 'option_values' => '', |
|
2769
|
|
- 'is_dummy' => '1', |
|
2770
|
|
- 'is_public' => '1', |
|
2771
|
|
- 'is_active' => '1', |
|
2772
|
|
- 'is_register_field' => '1', |
|
2773
|
|
- 'is_search_field' => '1', |
|
2774
|
|
- ); |
|
3387
|
+ $lastid = trim( $cf ); |
|
2775
|
3388
|
|
|
2776
|
|
- //Email |
|
2777
|
|
- $fields[] = array( |
|
2778
|
|
- 'form_type' => 'account', |
|
2779
|
|
- 'field_type' => 'email', |
|
2780
|
|
- 'site_title' => __('Dummy Email', 'userswp'), |
|
2781
|
|
- 'htmlvar_name' => 'dummy_email', |
|
2782
|
|
- 'default_value' => '', |
|
2783
|
|
- 'option_values' => '', |
|
2784
|
|
- 'is_dummy' => '1', |
|
2785
|
|
- 'is_public' => '1', |
|
2786
|
|
- 'is_active' => '1', |
|
2787
|
|
- 'is_register_field' => '1', |
|
2788
|
|
- 'is_search_field' => '1', |
|
2789
|
|
- ); |
|
3389
|
+ } else { |
|
2790
|
3390
|
|
|
2791
|
|
- //Multiselect |
|
2792
|
|
- $fields[] = array( |
|
2793
|
|
- 'form_type' => 'account', |
|
2794
|
|
- 'field_type' => 'multiselect', |
|
2795
|
|
- 'site_title' => __('Dummy Multiselect', 'userswp'), |
|
2796
|
|
- 'htmlvar_name' => 'dummy_multiselect', |
|
2797
|
|
- 'default_value' => '', |
|
2798
|
|
- 'option_values' => __('Select Option/,Value1,Value2,Value3', 'userswp'), |
|
2799
|
|
- 'is_dummy' => '1', |
|
2800
|
|
- 'is_public' => '1', |
|
2801
|
|
- 'is_active' => '1', |
|
2802
|
|
- 'is_register_field' => '1', |
|
2803
|
|
- 'is_search_field' => '1', |
|
2804
|
|
- ); |
|
3391
|
+ $wpdb->query( |
|
3392
|
+ $wpdb->prepare( |
|
3393
|
+ 'insert into ' . $extras_table_name . ' set |
|
3394
|
+ form_type = %s, |
|
3395
|
+ field_type = %s, |
|
3396
|
+ site_htmlvar_name = %s, |
|
3397
|
+ sort_order = %s, |
|
3398
|
+ form_id = %s', |
|
3399
|
+ array( |
|
3400
|
+ $form_type, |
|
3401
|
+ $field_type, |
|
3402
|
+ $site_htmlvar_name, |
|
3403
|
+ $field_id, |
|
3404
|
+ $form_id, |
|
3405
|
+ ) |
|
3406
|
+ ) |
|
3407
|
+ ); |
|
3408
|
+ $lastid = $wpdb->insert_id; |
|
3409
|
+ $lastid = trim( $lastid ); |
|
3410
|
+ } |
|
2805
|
3411
|
|
|
2806
|
|
- //File Upload |
|
2807
|
|
- $fields[] = array( |
|
2808
|
|
- 'form_type' => 'account', |
|
2809
|
|
- 'field_type' => 'file', |
|
2810
|
|
- 'site_title' => __('Dummy File', 'userswp'), |
|
2811
|
|
- 'htmlvar_name' => 'dummy_file', |
|
2812
|
|
- 'default_value' => '', |
|
2813
|
|
- 'option_values' => '', |
|
2814
|
|
- 'is_dummy' => '1', |
|
2815
|
|
- 'is_public' => '1', |
|
2816
|
|
- 'is_active' => '1', |
|
2817
|
|
- 'is_register_field' => '1', |
|
2818
|
|
- 'is_search_field' => '1', |
|
2819
|
|
- ); |
|
3412
|
+ return (int) $lastid; |
|
2820
|
3413
|
|
|
2821
|
|
- $fields = apply_filters('uwp_dummy_custom_fields', $fields); |
|
2822
|
|
- |
|
2823
|
|
- return $fields; |
|
2824
|
|
- } |
|
2825
|
|
- |
|
2826
|
|
-} |
|
3414
|
+ } else { |
|
3415
|
+ return 'invalid_key'; |
|
3416
|
+ } |
|
3417
|
+ } |
|
3418
|
+} |