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