PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 4.07.01
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v4.07.01
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
← All changes | classes/controllers/FrmFieldsController.php +285 -496 6.294.07.01 View file →
@@ -4,15 +4,8 @@
4 4 }
5 5
6 6 class FrmFieldsController {
7 7
8 - /**
9 - * This is stored statically so we can re-use this data for every field.
10 - *
11 - * @var FrmFieldSelectionData|null
12 - */
13 - private static $field_selection_data;
14 -
15 8 public static function load_field() {
16 9 FrmAppHelper::permission_check( 'frm_edit_forms' );
17 10 check_ajax_referer( 'frm_ajax', 'nonce' );
18 11
@@ -18,10 +11,9 @@
18 11
19 12 // Javascript may be included in some field settings.
20 13 // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
21 14 $fields = isset( $_POST['field'] ) ? wp_unslash( $_POST['field'] ) : array();
22 -
23 - if ( ! $fields ) {
15 + if ( empty( $fields ) ) {
24 16 wp_die();
25 17 }
26 18
27 19 $_GET['page'] = 'formidable';
@@ -34,11 +26,10 @@
34 26
35 27 foreach ( $fields as $field ) {
36 28 $field = htmlspecialchars_decode( nl2br( $field ) );
37 29 $field = json_decode( $field );
38 -
39 30 if ( ! isset( $field->id ) || ! is_numeric( $field->id ) ) {
40 - // This field may have already been loaded
31 + // this field may have already been loaded
41 32 continue;
42 33 }
43 34
44 35 if ( ! isset( $field->value ) ) {
@@ -49,10 +40,11 @@
49 40 $field->default_value = json_decode( json_encode( $field->default_value ), true );
50 41
51 42 ob_start();
52 43 self::load_single_field( $field, $values );
53 - $field_html[ absint( $field->id ) ] = ob_get_clean();
54 - }//end foreach
44 + $field_html[ absint( $field->id ) ] = ob_get_contents();
45 + ob_end_clean();
46 + }
55 47
56 48 echo json_encode( $field_html );
57 49
58 50 wp_die();
@@ -64,17 +56,16 @@
64 56 public static function create() {
65 57 FrmAppHelper::permission_check( 'frm_edit_forms' );
66 58 check_ajax_referer( 'frm_ajax', 'nonce' );
67 59
68 - $field_type = FrmAppHelper::get_post_param( 'field_type', '', 'sanitize_text_field' );
69 - $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' );
70 - $field_options = FrmAppHelper::get_post_param( 'field_options', array(), 'wp_kses_post' );
60 + $field_type = FrmAppHelper::get_post_param( 'field_type', '', 'sanitize_text_field' );
61 + $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' );
71 62
72 63 do_action( 'frm_before_create_field', $field_type, $form_id );
73 64
74 - $field = self::include_new_field( $field_type, $form_id, $field_options );
65 + $field = self::include_new_field( $field_type, $form_id );
75 66
76 - // This hook will allow for multiple fields to be added at once
67 + // this hook will allow for multiple fields to be added at once
77 68 do_action( 'frm_after_field_created', $field, $form_id );
78 69
79 70 wp_die();
80 71 }
@@ -82,40 +73,29 @@
82 73 /**
83 74 * Set up and create a new field
84 75 *
85 76 * @param string $field_type
86 - * @param int $form_id
87 - * @param array $field_options
77 + * @param integer $form_id
88 78 *
89 - * @return array|false
79 + * @return array|bool
90 80 */
91 - public static function include_new_field( $field_type, $form_id, $field_options = array() ) {
81 + public static function include_new_field( $field_type, $form_id ) {
92 82 $field_values = FrmFieldsHelper::setup_new_vars( $field_type, $form_id );
83 + $field_values = apply_filters( 'frm_before_field_created', $field_values );
93 84
94 - if ( $field_options ) {
95 - $field_values['field_options'] = array_merge( $field_values['field_options'], $field_options );
96 - }
85 + $field_id = FrmField::create( $field_values );
97 86
98 - // When a new field is added to the form, flag it as draft and hide it from the front-end.
99 - $field_values['field_options']['draft'] = 1;
100 -
101 - /**
102 - * @param array $field_values
103 - */
104 - $field_values = apply_filters( 'frm_before_field_created', $field_values );
105 - $field_id = FrmField::create( $field_values );
106 -
107 87 if ( ! $field_id ) {
108 88 return false;
109 89 }
110 90
111 - $field = self::get_field_array_from_id( $field_id );
91 + $field = self::get_field_array_from_id( $field_id );
92 +
112 93 $values = array();
113 -
114 94 if ( FrmAppHelper::pro_is_installed() ) {
115 95 $values['post_type'] = FrmProFormsHelper::post_type( $form_id );
116 - $parent_form_id = FrmDb::get_var( 'frm_forms', array( 'id' => $form_id ), 'parent_form_id' );
117 96
97 + $parent_form_id = FrmDb::get_var( 'frm_forms', array( 'id' => $form_id ), 'parent_form_id' );
118 98 if ( $parent_form_id ) {
119 99 $field['parent_form_id'] = $parent_form_id;
120 100 }
121 101 }
@@ -128,16 +108,30 @@
128 108 public static function duplicate() {
129 109 FrmAppHelper::permission_check( 'frm_edit_forms' );
130 110 check_ajax_referer( 'frm_ajax', 'nonce' );
131 111
132 - $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
133 - $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' );
134 - $new_field = FrmField::duplicate_single_field( $field_id, $form_id );
112 + $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
113 + $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' );
135 114
136 - if ( is_array( $new_field ) && ! empty( $new_field['field_id'] ) ) {
137 - self::load_single_field( $new_field['field_id'], $new_field['values'] );
115 + $copy_field = FrmField::getOne( $field_id );
116 + if ( ! $copy_field ) {
117 + wp_die();
138 118 }
139 119
120 + do_action( 'frm_duplicate_field', $copy_field, $form_id );
121 + do_action( 'frm_duplicate_field_' . $copy_field->type, $copy_field, $form_id );
122 +
123 + $values = array(
124 + 'id' => $copy_field->id,
125 + );
126 + FrmFieldsHelper::fill_field( $values, $copy_field, $copy_field->form_id );
127 + $values = apply_filters( 'frm_prepare_single_field_for_duplication', $values );
128 +
129 + $field_id = FrmField::create( $values );
130 + if ( $field_id ) {
131 + self::load_single_field( $field_id, $values );
132 + }
133 +
140 134 wp_die();
141 135 }
142 136
143 137 /**
@@ -148,8 +142,9 @@
148 142 * @return array
149 143 */
150 144 public static function get_field_array_from_id( $field_id ) {
151 145 $field = FrmField::getOne( $field_id );
146 +
152 147 return FrmFieldsHelper::setup_edit_vars( $field );
153 148 }
154 149
155 150 /**
@@ -154,13 +149,11 @@
154 149
155 150 /**
156 151 * @since 3.0
157 152 *
158 - * @param array|int|object|string $field_object
159 - * @param array $values
160 - * @param int $form_id
161 - *
162 - * @return void
153 + * @param int|array|object $field_object
154 + * @param array $values
155 + * @param int $form_id
163 156 */
164 157 public static function load_single_field( $field_object, $values, $form_id = 0 ) {
165 158 global $frm_vars;
166 159 $frm_vars['is_admin'] = true;
@@ -171,62 +164,47 @@
171 164 $field = $field_object;
172 165 $field_object = FrmField::getOne( $field['id'] );
173 166 }
174 167
175 - $field_obj = FrmFieldFactory::get_field_factory( $field_object );
176 - $display = self::display_field_options( array(), $field_obj );
177 - $ajax_loading = ! empty( $values['ajax_load'] );
178 - $ajax_this_field = isset( $values['count'] ) && $values['count'] > 10 && ! in_array( $field_object->type, array( 'divider', 'end_divider' ), true );
168 + $field_obj = FrmFieldFactory::get_field_factory( $field_object );
169 + $display = self::display_field_options( array(), $field_obj );
179 170
171 + $ajax_loading = isset( $values['ajax_load'] ) && $values['ajax_load'];
172 + $ajax_this_field = isset( $values['count'] ) && $values['count'] > 10 && ! in_array( $field_object->type, array( 'divider', 'end_divider' ) );
173 +
180 174 if ( $ajax_loading && $ajax_this_field ) {
181 175 $li_classes = self::get_classes_for_builder_field( array(), $display, $field_obj );
182 - include FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/ajax-field-placeholder.php';
183 - return;
184 - }
176 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/ajax-field-placeholder.php' );
177 + } else {
178 + if ( ! isset( $field ) && is_object( $field_object ) ) {
179 + $field_object->parent_form_id = isset( $values['id'] ) ? $values['id'] : $field_object->form_id;
185 180
186 - if ( ! isset( $field ) && is_object( $field_object ) ) {
187 - $field_object->parent_form_id = $values['id'] ?? $field_object->form_id;
188 - $field = FrmFieldsHelper::setup_edit_vars( $field_object );
189 - }
181 + $field = FrmFieldsHelper::setup_edit_vars( $field_object );
182 + }
190 183
191 - /**
192 - * Filter for adding extra attributes to the field container.
193 - *
194 - * @since 6.23
195 - *
196 - * @param array $extra_field_attributes
197 - * @param array $field
198 - * @param array $display
199 - */
200 - $extra_field_attributes = apply_filters( 'frm_field_container_extra_attributes', array(), $field, $display );
184 + $li_classes = self::get_classes_for_builder_field( $field, $display, $field_obj );
185 + $li_classes .= ' ui-state-default widgets-holder-wrap';
201 186
202 - $li_classes = self::get_classes_for_builder_field( $field, $display, $field_obj );
203 - $li_classes .= ' ui-state-default widgets-holder-wrap';
204 -
205 - require FrmAppHelper::plugin_path() . '/classes/views/frm-forms/add_field.php';
187 + require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/add_field.php' );
188 + }
206 189 }
207 190
208 191 /**
209 192 * @since 3.0
210 - *
211 - * @param array $field
212 - * @param array $display
213 - * @param FrmFieldType $field_info
214 - *
215 - * @return string
216 193 */
217 194 private static function get_classes_for_builder_field( $field, $display, $field_info ) {
218 - $li_classes = $field_info->form_builder_classes( $display['type'] );
219 - $li_classes .= ' frm_form_field frmstart ';
195 + $li_classes = $field_info->form_builder_classes( $display['type'] );
196 + $classes = isset( $field['classes'] ) ? $field['classes'] : '';
220 197
221 - if ( isset( $field['classes'] ) ) {
222 - $li_classes .= trim( $field['classes'] ) . ' ';
198 + // Exclude alignright for now since we aren't using widths.
199 + $classes = str_replace( ' frm_alignright ', ' ', $classes );
200 + if ( trim( $classes ) === 'frm_alignright' ) {
201 + $classes = '';
223 202 }
224 203
225 - $li_classes .= 'frmend';
226 -
227 - if ( $field ) {
228 - return apply_filters( 'frm_build_field_class', $li_classes, $field );
204 + $li_classes .= ' frm_form_field frmstart ' . $classes . ' frmend';
205 + if ( ! empty( $field ) ) {
206 + $li_classes = apply_filters( 'frm_build_field_class', $li_classes, $field );
229 207 }
230 208
231 209 return $li_classes;
232 210 }
@@ -239,11 +217,10 @@
239 217 FrmField::destroy( $field_id );
240 218 wp_die();
241 219 }
242 220
243 - /**
244 - * Field Options.
245 - */
221 + /* Field Options */
222 +
246 223 public static function import_options() {
247 224 FrmAppHelper::permission_check( 'frm_edit_forms' );
248 225 check_ajax_referer( 'frm_ajax', 'nonce' );
249 226
@@ -250,40 +227,27 @@
250 227 if ( ! is_admin() || ! current_user_can( 'frm_edit_forms' ) ) {
251 228 return;
252 229 }
253 230
254 - $field_id = FrmAppHelper::get_param( 'field_id', '', 'post', 'absint' );
255 - $field = FrmField::getOne( $field_id );
256 - $bulk_edit_types = array( 'radio', 'checkbox', 'select' );
231 + $field_id = FrmAppHelper::get_param( 'field_id', '', 'post', 'absint' );
232 + $field = FrmField::getOne( $field_id );
257 233
258 - /**
259 - * Filter to add new fields that will support import_options/Bulk Edit Options.
260 - *
261 - * @since 6.8.4
262 - *
263 - * @param array $bulk_edit_types
264 - *
265 - * @return array
266 - */
267 - $bulk_edit_types = apply_filters( 'frm_bulk_edit_field_types', $bulk_edit_types );
268 -
269 - if ( ! in_array( $field->type, $bulk_edit_types, true ) ) {
234 + if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'select' ) ) ) {
270 235 return;
271 236 }
272 237
273 238 $field = FrmFieldsHelper::setup_edit_vars( $field );
239 + $opts = FrmAppHelper::get_param( 'opts', '', 'post', 'wp_kses_post' );
240 + $opts = explode( "\n", rtrim( $opts, "\n" ) );
241 + $opts = array_map( 'trim', $opts );
274 242
275 - $opts = FrmAppHelper::get_param( 'opts', '', 'post', 'wp_kses_post' );
276 - $opts = explode( "\n", rtrim( $opts, "\n" ) );
277 - $opts = array_map( 'trim', $opts );
243 + $separate = FrmAppHelper::get_param( 'separate', '', 'post', 'sanitize_text_field' );
244 + $field['separate_value'] = ( $separate === 'true' );
278 245
279 - $separate = FrmAppHelper::get_param( 'separate', '', 'post', 'sanitize_text_field' );
280 - $field['separate_value'] = $separate === 'true';
281 -
282 246 if ( $field['separate_value'] ) {
283 247 foreach ( $opts as $opt_key => $opt ) {
284 - if ( str_contains( $opt, '|' ) ) {
285 - $vals = explode( '|', $opt );
248 + if ( strpos( $opt, '|' ) !== false ) {
249 + $vals = explode( '|', $opt );
286 250 $opts[ $opt_key ] = array(
287 251 'label' => trim( $vals[0] ),
288 252 'value' => trim( $vals[1] ),
289 253 );
@@ -293,11 +257,10 @@
293 257 }
294 258 }
295 259
296 260 // Keep other options after bulk update.
297 - if ( ! empty( $field['field_options']['other'] ) ) {
261 + if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) {
298 262 $other_array = array();
299 -
300 263 foreach ( $field['options'] as $opt_key => $opt ) {
301 264 if ( FrmFieldsHelper::is_other_opt( $opt_key ) ) {
302 265 $other_array[ $opt_key ] = $opt;
303 266 }
@@ -302,10 +265,9 @@
302 265 $other_array[ $opt_key ] = $opt;
303 266 }
304 267 unset( $opt_key, $opt );
305 268 }
306 -
307 - if ( $other_array ) {
269 + if ( ! empty( $other_array ) ) {
308 270 $opts = array_merge( $opts, $other_array );
309 271 }
310 272 }
311 273
@@ -319,10 +281,8 @@
319 281 /**
320 282 * @since 4.0
321 283 *
322 284 * @param array $atts - Includes field array, field_obj, display array, values array.
323 - *
324 - * @return void
325 285 */
326 286 public static function load_single_field_settings( $atts ) {
327 287 $field = $atts['field'];
328 288 $field_obj = $atts['field_obj'];
@@ -337,19 +297,19 @@
337 297 if ( ! isset( $field['read_only'] ) ) {
338 298 $field['read_only'] = false;
339 299 }
340 300
341 - $field_selection_data = self::maybe_define_field_selection_data();
342 - $all_field_types = $field_selection_data->all_field_types;
343 - $disabled_fields = $field_selection_data->disabled_fields;
344 - $frm_settings = FrmAppHelper::get_settings();
345 - $field_types = FrmFieldTypeOptionData::get_field_types( $field['type'] );
301 + $field_types = FrmFieldsHelper::get_field_types( $field['type'] );
302 + $pro_field_selection = FrmField::pro_field_selection();
303 + $all_field_types = array_merge( $pro_field_selection, FrmField::field_selection() );
304 + $disabled_fields = FrmAppHelper::pro_is_installed() ? array() : $pro_field_selection;
305 + $frm_settings = FrmAppHelper::get_settings();
346 306
347 307 if ( ! isset( $all_field_types[ $field['type'] ] ) ) {
348 308 // Add fallback for an add-on field type that has been deactivated.
349 309 $all_field_types[ $field['type'] ] = array(
350 310 'name' => ucfirst( $field['type'] ),
351 - 'icon' => 'frmfont frm_pencil_icon',
311 + 'icon' => 'frm_icon_font frm_pencil_icon',
352 312 );
353 313 } elseif ( ! is_array( $all_field_types[ $field['type'] ] ) ) {
354 314 // Fallback for fields added in a more basic way.
355 315 FrmFormsHelper::prepare_field_type( $all_field_types[ $field['type'] ] );
@@ -355,9 +315,8 @@
355 315 FrmFormsHelper::prepare_field_type( $all_field_types[ $field['type'] ] );
356 316 }
357 317
358 318 $type_name = $all_field_types[ $field['type'] ]['name'];
359 -
360 319 if ( $field['type'] === 'divider' && FrmField::is_option_true( $field, 'repeat' ) ) {
361 320 $type_name = $all_field_types['divider|repeat']['name'];
362 321 }
363 322
@@ -367,77 +326,61 @@
367 326
368 327 if ( $display['clear_on_focus'] && is_array( $field['placeholder'] ) ) {
369 328 $field['placeholder'] = implode( ', ', $field['placeholder'] );
370 329 }
371 -
372 - include FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/settings.php';
330 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/settings.php' );
373 331 }
374 332
375 333 /**
376 - * @since 6.9.1
377 - *
378 - * @return FrmFieldSelectionData
379 - */
380 - private static function maybe_define_field_selection_data() {
381 - if ( ! isset( self::$field_selection_data ) ) {
382 - self::$field_selection_data = new FrmFieldSelectionData();
383 - }
384 - return self::$field_selection_data;
385 - }
386 -
387 - /**
388 334 * Get the list of default value types that can be toggled in the builder.
389 335 *
390 336 * @since 4.0
391 - *
392 - * @param array $field
393 - * @param array $atts
394 - *
395 337 * @return array
396 338 */
397 339 private static function default_value_types( $field, $atts ) {
398 340 $types = array(
399 - 'default_value' => array(
341 + 'default_value' => array(
400 342 'class' => '',
401 - 'icon' => 'frmfont frm_text2_icon',
402 - 'title' => __( 'Default Value', 'formidable' ),
343 + 'icon' => 'frm_icon_font frm_text2_icon',
344 + 'title' => __( 'Default Value (Text)', 'formidable' ),
403 345 'data' => array(
404 346 'frmshow' => '#default-value-for-',
405 347 ),
406 348 ),
407 - 'calc' => array(
408 - 'class' => 'frm_show_upgrade frm_noallow',
409 - 'title' => __( 'Calculate Value', 'formidable' ),
410 - 'icon' => 'frmfont frm_calculator_icon',
411 - 'data' => array(
349 + 'calc' => array(
350 + 'class' => 'frm_show_upgrade frm_noallow',
351 + 'title' => __( 'Default Value (Calculation)', 'formidable' ),
352 + 'icon' => 'frm_icon_font frm_calculator_icon',
353 + 'data' => array(
412 354 'medium' => 'calculations',
413 355 'upgrade' => __( 'Calculator forms', 'formidable' ),
414 356 ),
415 - 'tooltip' => __( 'Automatically calculate the value of this field based on values from other fields.', 'formidable' ),
416 357 ),
417 358 'get_values_field' => array(
418 - 'class' => 'frm_show_upgrade frm_noallow',
419 - 'title' => __( 'Lookup', 'formidable' ),
420 - 'icon' => 'frmfont frm_search_icon',
421 - 'data' => array(
359 + 'class' => 'frm_show_upgrade frm_noallow',
360 + 'title' => __( 'Default Value (Lookup)', 'formidable' ),
361 + 'icon' => 'frm_icon_font frm_search_icon',
362 + 'data' => array(
422 363 'medium' => 'lookup',
423 364 'upgrade' => __( 'Lookup fields', 'formidable' ),
424 365 ),
425 - 'tooltip' => __( 'Dynamically retrieve the value of this field from a lookup field.', 'formidable' ),
426 366 ),
427 367 );
428 368
429 369 $types = apply_filters( 'frm_default_value_types', $types, $atts );
430 370
371 + if ( FrmAppHelper::pro_is_installed() && ! FrmAppHelper::meets_min_pro_version( '4.0' ) ) {
372 + // Prevent settings from showing in 2 spots.
373 + unset( $types['calc'], $types['get_values_field'] );
374 + }
375 +
431 376 // Set active class.
432 377 $settings = array_keys( $types );
433 378 $active = 'default_value';
434 379
435 - if ( FrmAppHelper::pro_is_connected() ) {
436 - foreach ( $settings as $type ) {
437 - if ( ! empty( $field[ $type ] ) ) {
438 - $active = $type;
439 - }
380 + foreach ( $settings as $type ) {
381 + if ( ! empty( $field[ $type ] ) ) {
382 + $active = $type;
440 383 }
441 384 }
442 385
443 386 $types[ $active ]['class'] .= ' current';
@@ -445,13 +388,8 @@
445 388
446 389 return $types;
447 390 }
448 391
449 - /**
450 - * @param string $type
451 - *
452 - * @return string
453 - */
454 392 public static function change_type( $type ) {
455 393 $type_switch = array(
456 394 'scale' => 'radio',
457 395 'star' => 'radio',
@@ -459,32 +397,30 @@
459 397 'rte' => 'textarea',
460 398 'website' => 'url',
461 399 'image' => 'url',
462 400 );
463 -
464 401 if ( isset( $type_switch[ $type ] ) ) {
465 402 $type = $type_switch[ $type ];
466 403 }
467 404
468 405 $pro_fields = FrmField::pro_field_selection();
469 - // We want to keep credit_card types as credit card types for Stripe Lite.
470 - // The credit_card key is set for backward compatibility.
471 - unset( $pro_fields['credit_card'] );
406 + $types = array_keys( $pro_fields );
407 + if ( in_array( $type, $types ) ) {
408 + $type = 'text';
409 + }
472 410
473 - return array_key_exists( $type, $pro_fields ) ? 'text' : $type;
411 + return $type;
474 412 }
475 413
476 414 /**
477 - * @param array $settings
478 - * @param FrmFieldType|null $field_info
415 + * @param array $settings
416 + * @param object $field_info
479 417 *
480 418 * @return array
481 419 */
482 420 public static function display_field_options( $settings, $field_info = null ) {
483 421 if ( $field_info ) {
484 - $settings = $field_info->display_field_settings();
485 -
486 - // Field appears to be protected but there is a __get function in FrmFieldType that makes this public.
422 + $settings = $field_info->display_field_settings();
487 423 $settings['field_data'] = $field_info->field;
488 424 }
489 425
490 426 return apply_filters( 'frm_display_field_options', $settings );
@@ -494,32 +430,14 @@
494 430 * Display the format option
495 431 *
496 432 * @since 3.0
497 433 *
498 - * @param array $field Field data.
499 - * @param bool $is_hidden Whether the format option should be hidden.
500 - *
501 - * @return void
434 + * @param array $field
502 435 */
503 - public static function show_format_option( $field, $is_hidden = false ) {
504 - $attributes = array(
505 - 'class' => 'frm-has-modal',
506 - 'id' => 'frm-field-format-custom-' . $field['id'],
507 - );
508 -
509 - if ( $is_hidden ) {
510 - $attributes['class'] .= ' frm_hidden';
511 - }
512 -
513 - include FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/value-format.php';
436 + public static function show_format_option( $field ) {
437 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/value-format.php' );
514 438 }
515 439
516 - /**
517 - * @param array $field
518 - * @param bool $echo
519 - *
520 - * @return string
521 - */
522 440 public static function input_html( $field, $echo = true ) {
523 441 $class = array();
524 442 self::add_input_classes( $field, $class );
525 443
@@ -539,26 +457,20 @@
539 457 $add_html = apply_filters( 'frm_field_extra_html', $add_html, $field );
540 458 $add_html = ' ' . implode( ' ', $add_html ) . ' ';
541 459
542 460 if ( $echo ) {
543 - echo $add_html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
461 + echo $add_html; // WPCS: XSS ok.
544 462 }
545 463
546 464 return $add_html;
547 465 }
548 466
549 - /**
550 - * @param array $field
551 - * @param array $class
552 - *
553 - * @return void
554 - */
555 467 private static function add_input_classes( $field, array &$class ) {
556 - if ( ! empty( $field['input_class'] ) ) {
468 + if ( isset( $field['input_class'] ) && ! empty( $field['input_class'] ) ) {
557 469 $class[] = $field['input_class'];
558 470 }
559 471
560 - if ( $field['type'] === 'hidden' || $field['type'] === 'user_id' ) {
472 + if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) {
561 473 return;
562 474 }
563 475
564 476 if ( isset( $field['size'] ) && $field['size'] > 0 ) {
@@ -565,14 +477,8 @@
565 477 $class[] = 'auto_width';
566 478 }
567 479 }
568 480
569 - /**
570 - * @param array $field
571 - * @param array $add_html
572 - *
573 - * @return void
574 - */
575 481 private static function add_html_size( $field, array &$add_html ) {
576 482 $size_fields = array(
577 483 'select',
578 484 'data',
@@ -581,9 +487,9 @@
581 487 'file',
582 488 'lookup',
583 489 );
584 490
585 - if ( ! isset( $field['size'] ) || $field['size'] <= 0 || in_array( $field['type'], $size_fields, true ) ) {
491 + if ( ! isset( $field['size'] ) || $field['size'] <= 0 || in_array( $field['type'], $size_fields ) ) {
586 492 return;
587 493 }
588 494
589 495 if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
@@ -600,16 +506,10 @@
600 506
601 507 self::add_html_cols( $field, $add_html );
602 508 }
603 509
604 - /**
605 - * @param array $field
606 - * @param array $add_html
607 - *
608 - * @return void
609 - */
610 510 private static function add_html_cols( $field, array &$add_html ) {
611 - if ( ! in_array( $field['type'], array( 'textarea', 'rte' ), true ) ) {
511 + if ( ! in_array( $field['type'], array( 'textarea', 'rte' ) ) ) {
612 512 return;
613 513 }
614 514
615 515 // Convert to cols for textareas.
@@ -619,9 +519,9 @@
619 519 'rem' => 0.444,
620 520 'em' => 0.544,
621 521 );
622 522
623 - // Include "col" for valid html
523 + // include "col" for valid html
624 524 $unit = trim( preg_replace( '/[0-9]+/', '', $field['size'] ) );
625 525
626 526 if ( ! isset( $calc[ $unit ] ) ) {
627 527 return;
@@ -626,18 +526,13 @@
626 526 if ( ! isset( $calc[ $unit ] ) ) {
627 527 return;
628 528 }
629 529
630 - $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ];
530 + $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ];
531 +
631 532 $add_html['cols'] = 'cols="' . absint( $size ) . '"';
632 533 }
633 534
634 - /**
635 - * @param array $field
636 - * @param array $add_html
637 - *
638 - * @return void
639 - */
640 535 private static function add_html_length( $field, array &$add_html ) {
641 536 // Check for max setting and if this field accepts maxlength.
642 537 $fields = array(
643 538 'textarea',
@@ -645,9 +540,9 @@
645 540 'hidden',
646 541 'file',
647 542 );
648 543
649 - if ( FrmField::is_option_empty( $field, 'max' ) || in_array( $field['type'], $fields, true ) ) {
544 + if ( FrmField::is_option_empty( $field, 'max' ) || in_array( $field['type'], $fields ) ) {
650 545 return;
651 546 }
652 547
653 548 if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
@@ -657,17 +552,9 @@
657 552
658 553 $add_html['maxlength'] = 'maxlength="' . esc_attr( $field['max'] ) . '"';
659 554 }
660 555
661 - /**
662 - * @param array $field
663 - * @param array $add_html
664 - * @param array $class
665 - *
666 - * @return void
667 - */
668 556 private static function add_html_placeholder( $field, array &$add_html, array &$class ) {
669 - // phpcs:ignore Universal.Operators.StrictComparisons
670 557 if ( $field['default_value'] != '' ) {
671 558 if ( is_array( $field['default_value'] ) ) {
672 559 $add_html['data-frmval'] = 'data-frmval="' . esc_attr( json_encode( $field['default_value'] ) ) . '"';
673 560 } else {
@@ -675,29 +562,38 @@
675 562 }
676 563 }
677 564
678 565 $field['placeholder'] = self::prepare_placeholder( $field );
679 -
680 - // phpcs:ignore Universal.Operators.StrictComparisons
681 566 if ( $field['placeholder'] == '' || is_array( $field['placeholder'] ) ) {
682 - // Don't include a json placeholder
567 + // don't include a json placeholder
683 568 return;
684 569 }
685 570
686 - self::add_placeholder_to_input( $field, $add_html );
571 + $frm_settings = FrmAppHelper::get_settings();
572 +
573 + if ( $frm_settings->use_html ) {
574 + self::add_placeholder_to_input( $field, $add_html );
575 + } else {
576 + self::add_frmval_to_input( $field, $add_html );
577 +
578 + $class[] = 'frm_toggle_default';
579 +
580 + if ( $field['value'] == $field['placeholder'] ) {
581 + $class[] = 'frm_default';
582 + }
583 + }
687 584 }
688 585
689 - /**
690 - * Prepares field placeholder.
691 - *
692 - * @since 5.4 This doesn't call `FrmFieldsController::get_default_value_from_name()` anymore.
693 - *
694 - * @param array $field Field array.
695 - *
696 - * @return string
697 - */
698 586 private static function prepare_placeholder( $field ) {
699 - return $field['placeholder'] ?? '';
587 + $is_placeholder_field = FrmFieldsHelper::is_placeholder_field_type( $field['type'] );
588 + $is_combo_field = in_array( $field['type'], array( 'address', 'credit_card' ) );
589 +
590 + $placeholder = isset( $field['placeholder'] ) ? $field['placeholder'] : '';
591 + if ( empty( $placeholder ) && $is_placeholder_field && ! $is_combo_field ) {
592 + $placeholder = self::get_default_value_from_name( $field );
593 + }
594 +
595 + return $placeholder;
700 596 }
701 597
702 598 /**
703 599 * If the label position is "inside",
@@ -703,9 +599,8 @@
703 599 * If the label position is "inside",
704 600 * get the label to use as the placeholder
705 601 *
706 602 * @since 2.05
707 - * @since 5.4 Remove the logic code for "inside" label position.
708 603 *
709 604 * @param array $field
710 605 *
711 606 * @return string
@@ -710,9 +605,19 @@
710 605 *
711 606 * @return string
712 607 */
713 608 public static function get_default_value_from_name( $field ) {
714 - return '';
609 + $position = FrmField::get_option( $field, 'label' );
610 + if ( $position == 'inside' ) {
611 + $default_value = $field['name'];
612 + if ( FrmField::is_required( $field ) ) {
613 + $default_value .= ' ' . $field['required_indicator'];
614 + }
615 + } else {
616 + $default_value = '';
617 + }
618 +
619 + return $default_value;
715 620 }
716 621
717 622 /**
718 623 * Maybe add a blank placeholder option before any options
@@ -718,39 +623,22 @@
718 623 * Maybe add a blank placeholder option before any options
719 624 * in a dropdown.
720 625 *
721 626 * @since 4.04
722 - *
723 - * @param array|object $field
724 - *
725 627 * @return bool True if placeholder was added.
726 628 */
727 629 public static function add_placeholder_to_select( $field ) {
728 630 $placeholder = FrmField::get_option( $field, 'placeholder' );
729 -
730 - if ( ! $placeholder ) {
631 + if ( empty( $placeholder ) ) {
731 632 $placeholder = self::get_default_value_from_name( $field );
732 633 }
733 634
734 - $use_placeholder = $placeholder;
735 - $autocomplete = FrmField::get_option( $field, 'autocom' );
736 -
737 - if ( $autocomplete ) {
738 - $use_chosen = ! is_callable( 'FrmProAppHelper::use_chosen_js' ) || FrmProAppHelper::use_chosen_js();
739 -
740 - if ( $use_chosen ) {
741 - $use_placeholder = '';
742 - }
743 - }
744 -
745 635 if ( $placeholder !== '' ) {
746 - $placeholder_attributes = array(
747 - 'class' => 'frm-select-placeholder',
748 - 'value' => '',
749 - 'data-placeholder' => 'true',
750 - );
751 -
752 - FrmHtmlHelper::echo_dropdown_option( $use_placeholder, false, $placeholder_attributes );
636 + ?>
637 + <option value="">
638 + <?php echo esc_html( FrmField::get_option( $field, 'autocom' ) ? '' : $placeholder ); ?>
639 + </option>
640 + <?php
753 641 return true;
754 642 }
755 643
756 644 return false;
@@ -756,14 +644,12 @@
756 644 return false;
757 645 }
758 646
759 647 /**
760 - * Use HTML5 placeholder with js fallback.
648 + * Use HMTL5 placeholder with js fallback
761 649 *
762 650 * @param array $field
763 651 * @param array $add_html
764 - *
765 - * @return void
766 652 */
767 653 private static function add_placeholder_to_input( $field, &$add_html ) {
768 654 if ( FrmFieldsHelper::is_placeholder_field_type( $field['type'] ) ) {
769 655 $add_html['placeholder'] = 'placeholder="' . esc_attr( $field['placeholder'] ) . '"';
@@ -769,16 +655,9 @@
769 655 $add_html['placeholder'] = 'placeholder="' . esc_attr( $field['placeholder'] ) . '"';
770 656 }
771 657 }
772 658
773 - /**
774 - * @param array $field
775 - * @param array $add_html
776 - *
777 - * @return void
778 - */
779 659 private static function add_frmval_to_input( $field, &$add_html ) {
780 - // phpcs:ignore Universal.Operators.StrictComparisons
781 660 if ( $field['placeholder'] != '' ) {
782 661 $add_html['data-frmval'] = 'data-frmval="' . esc_attr( $field['placeholder'] ) . '"';
783 662
784 663 if ( 'select' === $field['type'] ) {
@@ -785,295 +664,205 @@
785 664 $add_html['data-frmplaceholder'] = 'data-frmplaceholder="' . esc_attr( $field['placeholder'] ) . '"';
786 665 }
787 666 }
788 667
789 - // phpcs:ignore Universal.Operators.StrictComparisons
790 668 if ( $field['default_value'] != '' ) {
791 669 $add_html['data-frmval'] = 'data-frmval="' . esc_attr( $field['default_value'] ) . '"';
792 670 }
793 671 }
794 672
795 - /**
796 - * @param array $field
797 - * @param array $add_html
798 - *
799 - * @return void
800 - */
801 673 private static function add_validation_messages( $field, array &$add_html ) {
802 - $field_validation_messages_status = self::get_validation_data_attribute_visibility_info( $field );
803 -
804 - if ( FrmField::is_required( $field ) && ! empty( $field_validation_messages_status['data-reqmsg'] ) ) {
674 + if ( FrmField::is_required( $field ) ) {
805 675 $required_message = FrmFieldsHelper::get_error_msg( $field, 'blank' );
806 676 $add_html['data-reqmsg'] = 'data-reqmsg="' . esc_attr( $required_message ) . '"';
807 677 self::maybe_add_html_required( $field, $add_html );
808 678 }
809 679
810 - if ( ! FrmField::is_option_empty( $field, 'invalid' ) && ! empty( $field_validation_messages_status['data-invmsg'] ) ) {
680 + if ( ! FrmField::is_option_empty( $field, 'invalid' ) ) {
811 681 $invalid_message = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
812 682 $add_html['data-invmsg'] = 'data-invmsg="' . esc_attr( $invalid_message ) . '"';
813 683 }
814 -
815 - if ( ! empty( $add_html['data-reqmsg'] ) || ! empty( $add_html['data-invmsg'] ) ) {
816 - self::maybe_add_error_html_for_js_validation( $field, $add_html );
817 - }
818 684 }
819 685
820 686 /**
821 - * Returns an array that contains field validation messages status.
687 + * If 'required' is added to a conditionall hidden field, the form won't
688 + * submit in many browsers. Check to make sure the javascript to conditionally
689 + * remove it is present if needed.
822 690 *
823 - * @since 6.9
824 - *
825 - * @param array|object $field
826 - *
827 - * @return array
691 + * @since 3.06.01
692 + * @param array $field
693 + * @param array $add_html
828 694 */
829 - private static function get_validation_data_attribute_visibility_info( $field ) {
830 - if ( FrmField::get_field_type( $field ) === 'hidden' ) {
831 - $field_validation_data_attributes = array(
832 - 'data-invmsg' => false,
833 - 'data-reqmsg' => false,
834 - );
835 - } else {
836 - $field_validation_data_attributes = array(
837 - 'data-invmsg' => true,
838 - 'data-reqmsg' => true,
839 - );
695 + private static function maybe_add_html_required( $field, array &$add_html ) {
696 + if ( in_array( $field['type'], array( 'radio', 'checkbox', 'file', 'data', 'lookup' ) ) ) {
697 + return;
840 698 }
841 699
842 - /**
843 - * Allows controlling which field validation messages would be included in the field html.
844 - *
845 - * @since 6.9
846 - *
847 - * @param array $field_validation_messages_status
848 - * @param array|object $field
849 - */
850 - return apply_filters( 'frm_field_validation_include_data_attributes', $field_validation_data_attributes, $field );
700 + $include_html = FrmAppHelper::meets_min_pro_version( '3.06.01' );
701 + if ( $include_html ) {
702 + $add_html['aria-required'] = 'aria-required="true"';
703 + }
851 704 }
852 705
853 - /**
854 - * @since 5.0.03
855 - *
856 - * @param array $field
857 - * @param array $add_html
858 - *
859 - * @return void
860 - */
861 - private static function maybe_add_error_html_for_js_validation( $field, array &$add_html ) {
862 - $form = self::get_form_for_js_validation( $field );
863 -
864 - if ( false === $form ) {
706 + private static function add_shortcodes_to_html( $field, array &$add_html ) {
707 + if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) {
865 708 return;
866 709 }
867 710
868 - $error_body = self::pull_custom_error_body_from_custom_html( $form, $field );
711 + foreach ( $field['shortcodes'] as $k => $v ) {
712 + if ( 'opt' === $k ) {
713 + continue;
714 + }
869 715
870 - if ( false === $error_body ) {
871 - return;
716 + if ( is_numeric( $k ) && strpos( $v, '=' ) ) {
717 + $add_html[] = $v;
718 + } elseif ( ! empty( $k ) && isset( $add_html[ $k ] ) ) {
719 + $add_html[ $k ] = str_replace( $k . '="', $k . '="' . $v, $add_html[ $k ] );
720 + } else {
721 + $add_html[ $k ] = $k . '="' . esc_attr( $v ) . '"';
722 + }
723 +
724 + unset( $k, $v );
872 725 }
873 -
874 - $error_body = urlencode( $error_body );
875 - $add_html['data-error-html'] = 'data-error-html="' . esc_attr( $error_body ) . '"';
876 726 }
877 727
878 728 /**
879 - * @since 5.0.03
729 + * Add pattern attribute
880 730 *
731 + * @since 3.0
732 + *
881 733 * @param array $field
882 - *
883 - * @return false|stdClass false if there is no form object found with JS validation active.
734 + * @param array $add_html
884 735 */
885 - private static function get_form_for_js_validation( $field ) {
886 - global $frm_vars;
736 + private static function add_pattern_attribute( $field, array &$add_html ) {
737 + $has_format = FrmField::is_option_true_in_array( $field, 'format' );
738 + $format_field = FrmField::is_field_type( $field, 'text' );
887 739
888 - if ( ! empty( $frm_vars['js_validate_forms'] ) ) {
889 - if ( isset( $frm_vars['js_validate_forms'][ $field['form_id'] ] ) ) {
890 - return $frm_vars['js_validate_forms'][ $field['form_id'] ];
740 + if ( $field['type'] == 'phone' || ( $has_format && $format_field ) ) {
741 + $frm_settings = FrmAppHelper::get_settings();
742 +
743 + if ( $frm_settings->use_html ) {
744 + $format = FrmEntryValidate::phone_format( $field );
745 + $format = substr( $format, 2, - 1 );
746 +
747 + $add_html['pattern'] = 'pattern="' . esc_attr( $format ) . '"';
891 748 }
749 + }
750 + }
892 751
893 - if ( ! empty( $field['parent_form_id'] ) && isset( $frm_vars['js_validate_forms'][ $field['parent_form_id'] ] ) ) {
894 - return $frm_vars['js_validate_forms'][ $field['parent_form_id'] ];
752 + public static function check_value( $opt, $opt_key, $field ) {
753 + if ( is_array( $opt ) ) {
754 + if ( FrmField::is_option_true( $field, 'separate_value' ) ) {
755 + $opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) );
756 + } else {
757 + $opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt );
895 758 }
896 759 }
897 760
898 - return false;
761 + return $opt;
899 762 }
900 763
764 + public static function check_label( $opt ) {
765 + if ( is_array( $opt ) ) {
766 + $opt = ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) );
767 + }
768 +
769 + return $opt;
770 + }
771 +
901 772 /**
902 - * @param stdClass $form
903 - * @param array $field
904 - * @param array $errors
905 - *
906 - * @return false|string
773 + * @deprecated 4.0
907 774 */
908 - public static function pull_custom_error_body_from_custom_html( $form, $field, $errors = array() ) {
909 - if ( empty( $field['custom_html'] ) ) {
910 - return false;
775 + public static function update_ajax_option() {
776 + _deprecated_function( __METHOD__, '4.0' );
777 + FrmAppHelper::permission_check( 'frm_edit_forms' );
778 + check_ajax_referer( 'frm_ajax', 'nonce' );
779 +
780 + $field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' );
781 + if ( ! $field_id ) {
782 + wp_die();
911 783 }
912 784
913 - $custom_html = $field['custom_html'];
914 - $custom_html = apply_filters( 'frm_before_replace_shortcodes', $custom_html, $field, $errors, $form );
915 - $start = strpos( $custom_html, '[if error]' );
785 + $field = FrmField::getOne( $field_id );
916 786
917 - if ( false === $start ) {
918 - return false;
919 - }
787 + if ( isset( $_POST['separate_value'] ) ) {
788 + $new_val = FrmField::is_option_true( $field, 'separate_value' ) ? 0 : 1;
920 789
921 - $end = strpos( $custom_html, '[/if error]' );
922 -
923 - if ( false === $end || $end < $start ) {
924 - return false;
790 + $field->field_options['separate_value'] = $new_val;
791 + unset( $new_val );
925 792 }
926 793
927 - $error_body = substr( $custom_html, $start + 10, $end - $start - 10 );
928 - $default_html = array(
929 - '<div class="frm_error" id="frm_error_field_[key]">[error]</div>',
930 - '<div class="frm_error" role="alert" id="frm_error_field_[key]">[error]</div>',
931 - '<div class="frm_error">[error]</div>',
932 - '<div class="frm_error" role="alert">[error]</div>',
794 + FrmField::update(
795 + $field_id,
796 + array(
797 + 'field_options' => $field->field_options,
798 + 'form_id' => $field->form_id,
799 + )
933 800 );
801 + wp_die();
802 + }
934 803
935 - return in_array( $error_body, $default_html, true ) ? false : $error_body;
804 + /**
805 + * @deprecated 4.0
806 + */
807 + public static function import_choices() {
808 + _deprecated_function( __METHOD__, '4.0' );
809 + wp_die();
936 810 }
937 811
938 812 /**
939 - * If 'required' is added to a conditionally hidden field, the form won't
940 - * submit in many browsers. Check to make sure the javascript to conditionally
941 - * remove it is present if needed.
813 + * Add Single Option or Other Option.
942 814 *
943 - * @since 3.06.01
944 - *
945 - * @param array $field
946 - * @param array $add_html
947 - *
948 - * @return void
815 + * @deprecated 4.0 Moved to Pro for Other option only.
949 816 */
950 - private static function maybe_add_html_required( $field, array &$add_html ) {
951 - // phpcs:disable Generic.WhiteSpace.ScopeIndent
952 - $excluded_field_types =
953 - FrmField::is_radio( $field ) ||
954 - FrmField::is_checkbox( $field ) ||
955 - FrmField::is_field_type( $field, 'file' ) ||
956 - FrmField::is_field_type( $field, 'nps' ) ||
957 - FrmField::is_field_type( $field, 'scale' );
958 - // phpcs:enable Generic.WhiteSpace.ScopeIndent
959 -
960 - if ( $excluded_field_types ) {
961 - return;
817 + public static function add_option() {
818 + _deprecated_function( __METHOD__, '4.0', 'FrmProFormsController::add_other_option' );
819 + if ( is_callable( 'FrmProFormsController::add_other_option' ) ) {
820 + FrmProFormsController::add_other_option();
962 821 }
963 -
964 - $add_html['aria-required'] = 'aria-required="true"';
965 822 }
966 823
967 824 /**
968 - * @param array $field
969 - * @param array $add_html
970 - *
971 - * @return void
825 + * @deprecated 4.0
972 826 */
973 - private static function add_shortcodes_to_html( $field, array &$add_html ) {
974 - if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) {
975 - return;
976 - }
977 -
978 - if ( ! empty( $field['autocomplete'] ) ) {
979 - unset( $field['shortcodes']['autocomplete'] );
980 - }
981 -
982 - foreach ( $field['shortcodes'] as $k => $v ) {
983 - if ( isset( $field['subfield_name'] ) && str_starts_with( $k, 'aria-invalid' ) ) {
984 - $subfield_name = $field['subfield_name'];
985 -
986 - if ( ! isset( $field['shortcodes'][ 'aria-invalid-' . $subfield_name ] ) ) {
987 - continue;
988 - }
989 - // Change the key to the correct aria-invalid value so that $add_html is set correctly for the current subfield of a combo field.
990 - $k = 'aria-invalid';
991 - $v = $field['shortcodes'][ 'aria-invalid-' . $subfield_name ];
992 - unset( $field['shortcodes'][ 'aria-invalid-' . $subfield_name ] );
993 - }
994 -
995 - if ( 'opt' === $k || ! self::should_allow_input_attribute( $k ) ) {
996 - continue;
997 - }
998 -
999 - if ( is_numeric( $k ) && str_contains( $v, '=' ) ) {
1000 - $add_html[] = $v;
1001 - } elseif ( ! empty( $k ) && isset( $add_html[ $k ] ) ) {
1002 - $add_html[ $k ] = str_replace( $k . '="', $k . '="' . $v, $add_html[ $k ] );
1003 - } else {
1004 - $add_html[ $k ] = $k . '="' . esc_attr( $v ) . '"';
1005 - }
1006 -
1007 - unset( $k, $v );
1008 - }//end foreach
827 + public static function update_order() {
828 + FrmDeprecated::update_order();
1009 829 }
1010 830
1011 831 /**
1012 - * Disallow possibly unsafe attributees (that trigger JavaScript) when unasfe HTML is not allowed.
1013 - *
1014 - * @since 6.11.2
1015 - *
1016 - * @param string $key The option key.
1017 - *
1018 - * @return bool
832 + * @deprecated 3.0
833 + * @codeCoverageIgnore
1019 834 */
1020 - private static function should_allow_input_attribute( $key ) {
1021 - if ( ! FrmAppHelper::should_never_allow_unfiltered_html() ) {
1022 - return true;
1023 - }
1024 - return FrmAppHelper::input_key_is_safe( $key );
835 + public static function edit_name( $field = 'name', $id = '' ) {
836 + FrmDeprecated::edit_name( $field, $id );
1025 837 }
1026 838
1027 839 /**
1028 - * Add pattern attribute.
840 + * @deprecated 3.0
841 + * @codeCoverageIgnore
1029 842 *
1030 - * @since 3.0
843 + * @param int $field_id
844 + * @param array $values
845 + * @param int $form_id
1031 846 *
1032 - * @param array $field
1033 - * @param array $add_html
1034 - *
1035 - * @return void
847 + * @return array
1036 848 */
1037 - private static function add_pattern_attribute( $field, array &$add_html ) {
1038 - $format_value = FrmField::get_option( $field, 'format' );
1039 - $has_format = $format_value && ! FrmCurrencyHelper::is_currency_format( $format_value );
1040 - $format_field = FrmField::is_field_type( $field, 'text' );
1041 -
1042 - if ( $field['type'] !== 'phone' && ( ! $has_format || ! $format_field ) ) {
1043 - return;
1044 - }
1045 -
1046 - $format = FrmEntryValidate::phone_format( $field );
1047 - $format = substr( $format, 2, - 1 );
1048 -
1049 - $add_html['pattern'] = 'pattern="' . esc_attr( $format ) . '"';
849 + public static function include_single_field( $field_id, $values, $form_id = 0 ) {
850 + return FrmDeprecated::include_single_field( $field_id, $values, $form_id );
1050 851 }
1051 852
1052 853 /**
1053 - * @param mixed $opt
1054 - * @param mixed $opt_key
1055 - * @param array|object $field
1056 - *
1057 - * @return mixed
854 + * @deprecated 2.3
855 + * @codeCoverageIgnore
1058 856 */
1059 - public static function check_value( $opt, $opt_key, $field ) {
1060 - if ( is_array( $opt ) ) {
1061 - if ( FrmField::is_option_true( $field, 'separate_value' ) ) {
1062 - $opt = $opt['value'] ?? $opt['label'] ?? reset( $opt );
1063 - } else {
1064 - $opt = $opt['label'] ?? reset( $opt );
1065 - }
1066 - }
1067 -
1068 - return $opt;
857 + public static function edit_option() {
858 + FrmDeprecated::deprecated( __METHOD__, '2.3' );
1069 859 }
1070 860
1071 861 /**
1072 - * @param mixed $opt
1073 - *
1074 - * @return mixed
862 + * @deprecated 2.3
863 + * @codeCoverageIgnore
1075 864 */
1076 - public static function check_label( $opt ) {
1077 - return is_array( $opt ) ? ( $opt['label'] ?? reset( $opt ) ) : $opt;
865 + public static function delete_option() {
866 + FrmDeprecated::deprecated( __METHOD__, '2.3' );
1078 867 }
1079 868 }