PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.16.1
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.16.1
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/helpers/FrmFieldsHelper.php +220 -857 6.34 → 6.16.1 View file →
@@ -4,23 +4,11 @@
4 4 }
5 5
6 6 class FrmFieldsHelper {
7 7
8 - /**
9 - * The context is memoized for re-use as the context is checked for each field.
10 - *
11 - * @var bool|null
12 - */
13 - private static $context_is_safe_to_load_field_options_from_request_data;
8 + public static function setup_new_vars( $type = '', $form_id = '' ) {
14 9
15 - /**
16 - * @param string $type
17 - * @param int|string $form_id
18 - *
19 - * @return array
20 - */
21 - public static function setup_new_vars( $type = '', $form_id = '' ) {
22 - if ( str_contains( $type, '|' ) ) {
10 + if ( strpos( $type, '|' ) ) {
23 11 list( $type, $setting ) = explode( '|', $type );
24 12 }
25 13
26 14 $values = self::get_default_field( $type );
@@ -47,55 +35,41 @@
47 35 }
48 36 }
49 37
50 38 // Increase the field order of submit field and fields in the same row.
51 - FrmSubmitHelper::update_last_row_fields_order_when_adding_field( $field_count );
39 + $last_row_field_ids = FrmAppHelper::get_post_param( 'last_row_field_ids', array() );
40 + if ( $last_row_field_ids ) {
41 + foreach ( $last_row_field_ids as $index => $last_row_field_id ) {
42 + FrmField::update(
43 + $last_row_field_id,
44 + array( 'field_order' => $field_count + $index + 2 )
45 + );
46 + }
47 + }
52 48
53 49 return $values;
54 50 }
55 51
56 - /**
57 - * @param array $field
58 - * @param string $plus
59 - *
60 - * @return string
61 - */
62 52 public static function get_html_id( $field, $plus = '' ) {
63 53 return apply_filters( 'frm_field_html_id', 'field_' . $field['field_key'] . $plus, $field );
64 54 }
65 55
66 - /**
67 - * @param object $field
68 - * @param bool $doing_ajax
69 - *
70 - * @return array
71 - */
72 56 public static function setup_edit_vars( $field, $doing_ajax = false ) {
73 57 $values = self::field_object_to_array( $field );
58 +
74 59 return apply_filters( 'frm_setup_edit_field_vars', $values, array( 'doing_ajax' => $doing_ajax ) );
75 60 }
76 61
77 - /**
78 - * @param object $field
79 - *
80 - * @return array
81 - */
82 62 public static function field_object_to_array( $field ) {
83 63 $values = (array) $field;
84 64
85 65 self::fill_field_array( $field, $values );
86 66
87 - $values['custom_html'] = $field->field_options['custom_html'] ?? self::get_default_html( $field->type );
67 + $values['custom_html'] = isset( $field->field_options['custom_html'] ) ? $field->field_options['custom_html'] : self::get_default_html( $field->type );
88 68
89 69 return $values;
90 70 }
91 71
92 - /**
93 - * @param object $field
94 - * @param array $field_array
95 - *
96 - * @return void
97 - */
98 72 private static function fill_field_array( $field, array &$field_array ) {
99 73 $field_array['options'] = $field->options;
100 74 $field_array['value'] = $field->default_value;
101 75
@@ -104,17 +78,11 @@
104 78 $field_array = array_merge( (array) $field->field_options, $field_array );
105 79 }
106 80
107 81 /**
108 - * Prepare field while creating a new entry.
82 + * Prepare field while creating a new entry
109 83 *
110 84 * @since 3.0
111 - *
112 - * @param array $field_array Field values array, passed by reference.
113 - * @param stdClass $field Field object.
114 - * @param array $args Additional arguments.
115 - *
116 - * @return void
117 85 */
118 86 public static function prepare_new_front_field( &$field_array, $field, $args = array() ) {
119 87 $args['action'] = 'new';
120 88 self::prepare_front_field( $field_array, $field, $args );
@@ -120,18 +88,11 @@
120 88 self::prepare_front_field( $field_array, $field, $args );
121 89 }
122 90
123 91 /**
124 - * Prepare field while editing an entry.
92 + * Prepare field while editing an entry
125 93 *
126 94 * @since 3.0
127 - *
128 - * @param array $field_array Field values array, passed by reference.
129 - * @param array|stdClass $field Field object or array.
130 - * @param int $entry_id Entry ID.
131 - * @param array $args Additional arguments.
132 - *
133 - * @return void
134 95 */
135 96 public static function prepare_edit_front_field( &$field_array, $field, $entry_id = 0, $args = array() ) {
136 97 $args['entry_id'] = $entry_id;
137 98 $args['action'] = 'edit';
@@ -145,9 +106,8 @@
145 106 *
146 107 * @param array $field_array
147 108 * @param stdClass $field
148 109 * @param array $args
149 - *
150 110 * @return void
151 111 */
152 112 private static function prepare_front_field( &$field_array, $field, $args ) {
153 113 self::fill_default_field_opts( $field, $field_array );
@@ -153,9 +113,9 @@
153 113 self::fill_default_field_opts( $field, $field_array );
154 114 self::fill_cleared_strings( $field, $field_array );
155 115
156 116 // Track the original field's type
157 - $field_array['original_type'] = $field->field_options['original_type'] ?? $field->type;
117 + $field_array['original_type'] = isset( $field->field_options['original_type'] ) ? $field->field_options['original_type'] : $field->type;
158 118
159 119 self::prepare_field_options_for_display( $field_array, $field, $args );
160 120
161 121 if ( $args['action'] === 'edit' ) {
@@ -165,18 +125,16 @@
165 125 * @param int|string $entry_id
166 126 * @param array $args
167 127 */
168 128 $field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $args['entry_id'], $args );
169 -
170 - return;
129 + } else {
130 + /**
131 + * @param array $field_array
132 + * @param stdClass $field
133 + * @param array $args
134 + */
135 + $field_array = apply_filters( 'frm_setup_new_fields_vars', $field_array, $field, $args );
171 136 }
172 -
173 - /**
174 - * @param array $field_array
175 - * @param stdClass $field
176 - * @param array $args
177 - */
178 - $field_array = apply_filters( 'frm_setup_new_fields_vars', $field_array, $field, $args );
179 137 }
180 138
181 139 /**
182 140 * @since 3.0
@@ -186,8 +144,9 @@
186 144 * @return array
187 145 */
188 146 public static function get_default_field_options( $type ) {
189 147 $field_type = FrmFieldFactory::get_field_type( $type );
148 +
190 149 return $field_type->get_default_field_options();
191 150 }
192 151
193 152 /**
@@ -194,15 +153,13 @@
194 153 * @since 3.0
195 154 *
196 155 * @param object $field
197 156 * @param array $values
198 - *
199 - * @return void
200 157 */
201 158 private static function fill_default_field_opts( $field, array &$values ) {
202 - $check_post = self::context_is_safe_to_load_field_options_from_request_data();
203 - $defaults = self::get_default_field_options_from_field( $field, $values );
159 + $check_post = FrmAppHelper::is_admin_page() && $_POST && isset( $_POST['field_options'] ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
204 160
161 + $defaults = self::get_default_field_options_from_field( $field, $values );
205 162 if ( ! $check_post ) {
206 163 $defaults['required_indicator'] = '';
207 164 $defaults['original_type'] = $field->type;
208 165 }
@@ -207,65 +164,16 @@
207 164 $defaults['original_type'] = $field->type;
208 165 }
209 166
210 167 foreach ( $defaults as $opt => $default ) {
211 - $values[ $opt ] = $field->field_options[ $opt ] ?? $default;
168 + $values[ $opt ] = isset( $field->field_options[ $opt ] ) ? $field->field_options[ $opt ] : $default;
212 169
213 170 if ( $check_post ) {
214 171 self::get_posted_field_setting( $opt . '_' . $field->id, $values[ $opt ] );
215 172 }
216 - }
217 - }
218 173
219 - /**
220 - * The fill_default_field_opts method is called when loading a field.
221 - * This is used to preserve the $_POST data after updating settings for a field.
222 - * To prevent this from happening when creating an entry, we need to check the context.
223 - *
224 - * @return bool
225 - */
226 - private static function context_is_safe_to_load_field_options_from_request_data() {
227 - if ( isset( self::$context_is_safe_to_load_field_options_from_request_data ) ) {
228 - return self::$context_is_safe_to_load_field_options_from_request_data;
174 + unset( $opt, $default );
229 175 }
230 -
231 - $function = function () {
232 - if ( ! FrmAppHelper::is_admin_page() ) {
233 - return false;
234 - }
235 -
236 - if ( ! $_POST || ! isset( $_POST['field_options'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
237 - return false;
238 - }
239 -
240 - if ( ! current_user_can( 'frm_edit_forms' ) ) {
241 - return false;
242 - }
243 -
244 - $action = FrmAppHelper::get_post_param( 'action', '', 'sanitize_title' );
245 -
246 - if ( 'frm_forms_preview' === $action ) {
247 - // Never trigger when previewing.
248 - return false;
249 - }
250 -
251 - // Confirm an allowed action is being used, and that the correct nonce is being used.
252 - if ( 'update' === $action ) {
253 - $nonce = FrmAppHelper::get_post_param( 'frm_save_form', '', 'sanitize_text_field' );
254 - return wp_verify_nonce( $nonce, 'frm_save_form_nonce' );
255 - }
256 -
257 - $action = FrmAppHelper::get_post_param( 'frm_action', '', 'sanitize_title' );
258 -
259 - if ( 'update_settings' === $action ) {
260 - $nonce = FrmAppHelper::get_post_param( 'process_form', '', 'sanitize_text_field' );
261 - return wp_verify_nonce( $nonce, 'process_form_nonce' );
262 - }
263 - };
264 -
265 - self::$context_is_safe_to_load_field_options_from_request_data = $function();
266 -
267 - return self::$context_is_safe_to_load_field_options_from_request_data;
268 176 }
269 177
270 178 /**
271 179 * Fill the required message, invalid message,
@@ -274,13 +182,10 @@
274 182 * @since 3.0
275 183 *
276 184 * @param object $field
277 185 * @param array $field_array
278 - *
279 - * @return void
280 186 */
281 187 private static function fill_cleared_strings( $field, array &$field_array ) {
282 - // phpcs:ignore Universal.Operators.StrictComparisons
283 188 if ( '' == $field_array['blank'] && '1' === $field_array['required'] ) {
284 189 $field_array['blank'] = self::default_blank_msg();
285 190 }
286 191
@@ -292,9 +197,8 @@
292 197 $field_array['invalid'] = self::default_invalid_msg();
293 198 }
294 199 }
295 200
296 - // phpcs:ignore Universal.Operators.StrictComparisons
297 201 if ( '' == $field_array['custom_html'] ) {
298 202 $field_array['custom_html'] = self::get_default_html( $field->type );
299 203 }
300 204 }
@@ -316,9 +220,10 @@
316 220 */
317 221 public static function default_unique_msg() {
318 222 $frm_settings = FrmAppHelper::get_settings();
319 223 $unique_message = $frm_settings->unique_msg;
320 - return str_replace( 'This value', '[field_name]', $unique_message );
224 + $unique_message = str_replace( 'This value', '[field_name]', $unique_message );
225 + return $unique_message;
321 226 }
322 227
323 228 /**
324 229 * @since 6.8.3
@@ -327,20 +232,17 @@
327 232 */
328 233 public static function default_blank_msg() {
329 234 $frm_settings = FrmAppHelper::get_settings();
330 235 $blank_message = $frm_settings->blank_msg;
331 - return str_replace( 'This field', '[field_name]', $blank_message );
236 + $blank_message = str_replace( 'This field', '[field_name]', $blank_message );
237 + return $blank_message;
332 238 }
333 239
334 240 /**
335 - * When loading settings for a field, check the $_POST data and possibly use that instead of the DB value.
336 - *
337 241 * @since 3.0
338 242 *
339 243 * @param string $setting
340 244 * @param mixed $value
341 - *
342 - * @return void
343 245 */
344 246 private static function get_posted_field_setting( $setting, &$value ) {
345 247 if ( ! isset( $_POST['field_options'][ $setting ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
346 248 return;
@@ -345,20 +247,16 @@
345 247 if ( ! isset( $_POST['field_options'][ $setting ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
346 248 return;
347 249 }
348 250
349 - if ( str_contains( $setting, 'html' ) ) {
350 - $value = wp_unslash( $_POST['field_options'][ $setting ] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing, SlevomatCodingStandard.Files.LineLength.LineTooLong
351 -
352 - // Conditionally strip script tags if the user sending $_POST data is not allowed to use unfiltered HTML.
353 - if ( ! FrmAppHelper::allow_unfiltered_html() ) {
354 - $value = FrmAppHelper::kses( $value, 'all' );
355 - }
356 - } elseif ( str_starts_with( $setting, 'format_' ) ) {
251 + if ( strpos( $setting, 'html' ) !== false ) {
252 + // Strip slashes from HTML but not regex or script tags.
253 + $value = wp_unslash( $_POST['field_options'][ $setting ] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing
254 + } elseif ( strpos( $setting, 'format_' ) === 0 ) {
357 255 // TODO: Remove stripslashes on output, and use on input only.
358 - $value = sanitize_text_field( $_POST['field_options'][ $setting ] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.NonceVerification.Missing, SlevomatCodingStandard.Files.LineLength.LineTooLong
256 + $value = sanitize_text_field( $_POST['field_options'][ $setting ] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.NonceVerification.Missing
359 257 } else {
360 - $value = wp_unslash( $_POST['field_options'][ $setting ] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing, SlevomatCodingStandard.Files.LineLength.LineTooLong
258 + $value = wp_unslash( $_POST['field_options'][ $setting ] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing
361 259 FrmAppHelper::sanitize_value( 'wp_kses_post', $value );
362 260 }
363 261 }
364 262
@@ -372,11 +270,13 @@
372 270 */
373 271 public static function get_default_field_options_from_field( $field, $values = array() ) {
374 272 $field_type = self::get_original_field( $field );
375 273 $opts = $field_type->get_default_field_options();
376 - $opts = apply_filters( 'frm_default_field_opts', $opts, $values, $field );
377 274
378 - return apply_filters( 'frm_default_' . $field->type . '_field_opts', $opts, $values, $field );
275 + $opts = apply_filters( 'frm_default_field_opts', $opts, $values, $field );
276 + $opts = apply_filters( 'frm_default_' . $field->type . '_field_opts', $opts, $values, $field );
277 +
278 + return $opts;
379 279 }
380 280
381 281 /**
382 282 * @since 3.0
@@ -386,10 +286,9 @@
386 286 * @return FrmFieldType
387 287 */
388 288 private static function get_original_field( $field ) {
389 289 $original_type = FrmField::get_option( $field, 'original_type' );
390 -
391 - if ( $original_type && $field->type !== $original_type ) {
290 + if ( ! empty( $original_type ) && $field->type != $original_type ) {
392 291 $field->type = $original_type;
393 292 }
394 293
395 294 return FrmFieldFactory::get_field_object( $field );
@@ -400,10 +299,8 @@
400 299 *
401 300 * @param array $field_array
402 301 * @param object $field
403 302 * @param array $atts
404 - *
405 - * @return void
406 303 */
407 304 private static function prepare_field_options_for_display( &$field_array, $field, $atts ) {
408 305 $field_obj = FrmFieldFactory::get_field_object( $field );
409 306 $field_array = $field_obj->prepare_front_field( $field_array, $atts );
@@ -417,19 +314,12 @@
417 314 * @return array
418 315 */
419 316 public static function get_default_field( $type ) {
420 317 $field_type = FrmFieldFactory::get_field_type( $type );
318 +
421 319 return $field_type->get_new_field_defaults();
422 320 }
423 321
424 - /**
425 - * @param array $values
426 - * @param object $field
427 - * @param int|string $form_id
428 - * @param string $new_key
429 - *
430 - * @return void
431 - */
432 322 public static function fill_field( &$values, $field, $form_id, $new_key = '' ) {
433 323 global $wpdb;
434 324
435 325 $values['field_key'] = FrmAppHelper::get_unique_key( $new_key, $wpdb->prefix . 'frm_fields', 'field_key' );
@@ -451,10 +341,11 @@
451 341 * @return string
452 342 */
453 343 public static function get_error_msg( $field, $error ) {
454 344 $frm_settings = FrmAppHelper::get_settings();
455 - $conf_msg = __( 'The entered values do not match', 'formidable' );
456 - $defaults = array(
345 +
346 + $conf_msg = __( 'The entered values do not match', 'formidable' );
347 + $defaults = array(
457 348 'unique_msg' => array(
458 349 'full' => self::default_unique_msg(),
459 350 /* translators: %s: Field name */
460 351 'part' => sprintf( __( '%s must be unique', 'formidable' ), '[field_name]' ),
@@ -473,21 +364,15 @@
473 364 'part' => $conf_msg,
474 365 ),
475 366 );
476 367
477 - /**
478 - * @since 6.28
479 - *
480 - * @param array $defaults
481 - * @param array|object $field
482 - */
483 - $defaults = apply_filters( 'frm_default_field_validation_messages', $defaults, $field );
484 -
485 368 $msg = FrmField::get_option( $field, $error );
486 - $msg = $msg ? $msg : $defaults[ $error ]['part'];
369 + $msg = empty( $msg ) ? $defaults[ $error ]['part'] : $msg;
487 370 $msg = do_shortcode( $msg );
488 371
489 - return self::maybe_replace_substrings_with_field_name( $msg, $error, $field );
372 + $msg = self::maybe_replace_substrings_with_field_name( $msg, $error, $field );
373 +
374 + return $msg;
490 375 }
491 376
492 377 /**
493 378 * @since 6.8.3
@@ -494,10 +379,8 @@
494 379 *
495 380 * @param string $msg
496 381 * @param string $error
497 382 * @param array|object $field
498 - *
499 - * @return string
500 383 */
501 384 private static function maybe_replace_substrings_with_field_name( $msg, $error, $field ) {
502 385 $field_name = is_array( $field ) ? $field['name'] : $field->name;
503 386 $field_name = FrmAppHelper::maybe_kses( $field_name );
@@ -504,12 +387,17 @@
504 387 $substrings = self::get_substrings_to_replace_with_field_name( $field_name, compact( 'msg', 'error', 'field' ) );
505 388
506 389 // Use the "This value"/"This field" placeholder strings if field name is empty.
507 390 if ( ! $field_name ) {
508 - $field_name = 'unique_msg' === $error ? __( 'This value', 'formidable' ) : __( 'This field', 'formidable' );
391 + if ( 'unique_msg' === $error ) {
392 + $field_name = __( 'This value', 'formidable' );
393 + } else {
394 + $field_name = __( 'This field', 'formidable' );
395 + }
509 396 }
510 397
511 - return str_replace( $substrings, $field_name, $msg );
398 + $msg = str_replace( $substrings, $field_name, $msg );
399 + return $msg;
512 400 }
513 401
514 402 /**
515 403 * @since 6.8.3
@@ -521,14 +409,12 @@
521 409 * @type string $msg The current error message before the substrings are replaced.
522 410 * @type string $error A key including 'unique_msg', 'invalid', 'blank', or 'conf_msg'.
523 411 * @type array|object $field The field with the error.
524 412 * }
525 - *
526 413 * @return array
527 414 */
528 415 private static function get_substrings_to_replace_with_field_name( $field_name, $filter_args ) {
529 416 $substrings = array( '[field_name]' );
530 -
531 417 if ( $field_name ) {
532 418 array_push( $substrings, 'This value', 'This field' );
533 419 }
534 420
@@ -548,32 +434,19 @@
548 434
549 435 return $substrings;
550 436 }
551 437
552 - /**
553 - * @param int|string $form_id
554 - * @param array $error
555 - *
556 - * @return array
557 - */
558 438 public static function get_form_fields( $form_id, $error = array() ) {
559 439 $fields = FrmField::get_all_for_form( $form_id );
560 440
561 - FrmFieldName::track_first_name_field( $fields );
562 -
563 441 return apply_filters( 'frm_get_paged_fields', $fields, $form_id, $error );
564 442 }
565 443
566 - /**
567 - * @param string $type
568 - *
569 - * @return string
570 - */
571 444 public static function get_default_html( $type = 'text' ) {
572 445 $field = FrmFieldFactory::get_field_type( $type );
573 446 $default_html = $field->default_html();
574 447
575 - // These hooks are here for reverse compatibility since 3.0
448 + // these hooks are here for reverse compatibility since 3.0
576 449 if ( ! apply_filters( 'frm_normal_field_type_html', true, $type ) ) {
577 450 $default_html = apply_filters( 'frm_other_custom_html', '', $type );
578 451 }
579 452
@@ -584,17 +457,11 @@
584 457 * @param array $fields
585 458 * @param array $errors
586 459 * @param object $form
587 460 * @param object $form_action
588 - *
589 - * @return void
590 461 */
591 462 public static function show_fields( $fields, $errors, $form, $form_action ) {
592 463 foreach ( $fields as $field ) {
593 - if ( ! is_array( $field ) ) {
594 - continue;
595 - }
596 -
597 464 $field_obj = FrmFieldFactory::get_field_type( $field['type'], $field );
598 465 $field_obj->show_field( compact( 'errors', 'form', 'form_action' ) );
599 466 }
600 467 }
@@ -603,23 +470,17 @@
603 470 * @since 3.0
604 471 *
605 472 * @param array $atts
606 473 * @param array|string $value
607 - *
608 - * @return void
609 474 */
610 475 public static function run_wpautop( $atts, &$value ) {
611 - $autop = $atts['wpautop'] ?? true;
612 -
613 - if ( ! apply_filters( 'frm_use_wpautop', $autop ) ) {
614 - return;
476 + $autop = isset( $atts['wpautop'] ) ? $atts['wpautop'] : true;
477 + if ( apply_filters( 'frm_use_wpautop', $autop ) ) {
478 + if ( is_array( $value ) ) {
479 + $value = implode( "\n", $value );
480 + }
481 + $value = wpautop( $value );
615 482 }
616 -
617 - if ( is_array( $value ) ) {
618 - $value = implode( "\n", $value );
619 - }
620 -
621 - $value = wpautop( $value );
622 483 }
623 484
624 485 /**
625 486 * Get the class to use for the label position
@@ -624,19 +485,13 @@
624 485 /**
625 486 * Get the class to use for the label position
626 487 *
627 488 * @since 2.05
628 - *
629 - * @param string $position
630 - * @param array $field
631 - * @param bool|object|string $form
632 - *
633 - * @return string
634 489 */
635 - public static function label_position( $position, $field, $form ) {
636 - if ( $position ) {
490 + public static function &label_position( $position, $field, $form ) {
491 + if ( $position && $position != '' ) {
637 492 if ( $position === 'inside' && ! self::is_placeholder_field_type( $field['type'] ) ) {
638 - return 'top';
493 + $position = 'top';
639 494 }
640 495
641 496 return $position;
642 497 }
@@ -641,9 +496,8 @@
641 496 return $position;
642 497 }
643 498
644 499 $position = FrmStylesController::get_style_val( 'position', $form );
645 -
646 500 if ( $position === 'none' ) {
647 501 $position = 'top';
648 502 } elseif ( $position === 'no_label' ) {
649 503 $position = 'none';
@@ -651,9 +505,11 @@
651 505 $position = 'top';
652 506 }
653 507
654 508 $position = apply_filters( 'frm_html_label_position', $position, $field, $form );
655 - return $position ? $position : 'top';
509 + $position = ! empty( $position ) ? $position : 'top';
510 +
511 + return $position;
656 512 }
657 513
658 514 /**
659 515 * Check if this field type allows placeholders
@@ -658,11 +514,9 @@
658 514 /**
659 515 * Check if this field type allows placeholders
660 516 *
661 517 * @since 2.05
662 - *
663 518 * @param string $type
664 - *
665 519 * @return bool
666 520 */
667 521 public static function is_placeholder_field_type( $type ) {
668 522 return ! in_array( $type, array( 'radio', 'checkbox', 'hidden', 'file' ), true );
@@ -667,19 +521,11 @@
667 521 public static function is_placeholder_field_type( $type ) {
668 522 return ! in_array( $type, array( 'radio', 'checkbox', 'hidden', 'file' ), true );
669 523 }
670 524
671 - /**
672 - * @param array $field
673 - * @param int|string $opt_key
674 - * @param string $type
675 - *
676 - * @return string
677 - */
678 525 public static function get_checkbox_id( $field, $opt_key, $type = 'checkbox' ) {
679 526 $id = $field['id'];
680 -
681 - if ( ! empty( $field['in_section'] ) && ! FrmAppHelper::is_admin_page( 'formidable' ) ) {
527 + if ( isset( $field['in_section'] ) && $field['in_section'] && ! FrmAppHelper::is_admin_page( 'formidable' ) ) {
682 528 $id .= '-' . $field['in_section'];
683 529 }
684 530
685 531 return 'frm_' . $type . '_' . $id . '-' . $opt_key;
@@ -684,13 +530,8 @@
684 530
685 531 return 'frm_' . $type . '_' . $id . '-' . $opt_key;
686 532 }
687 533
688 - /**
689 - * @param array $field
690 - *
691 - * @return void
692 - */
693 534 public static function show_single_option( $field ) {
694 535 self::hidden_field_option( $field );
695 536
696 537 if ( ! is_array( $field['options'] ) ) {
@@ -696,20 +537,20 @@
696 537 if ( ! is_array( $field['options'] ) ) {
697 538 return;
698 539 }
699 540
700 - $base_name = 'default_value_' . $field['id'];
701 - $html_id = $field['html_id'] ?? self::get_html_id( $field );
702 - $default_type = self::get_default_value_type( $field );
703 - $options_count = count( $field['options'] );
541 + $base_name = 'default_value_' . $field['id'];
542 + $html_id = isset( $field['html_id'] ) ? $field['html_id'] : self::get_html_id( $field );
704 543
544 + $default_type = self::get_default_value_type( $field );
545 +
705 546 foreach ( $field['options'] as $opt_key => $opt ) {
706 - $field_val = self::get_value_from_array( $opt, $opt_key, $field );
707 - $opt = self::get_label_from_array( $opt, $opt_key, $field );
547 + $field_val = self::get_value_from_array( $opt, $opt_key, $field );
548 + $opt = self::get_label_from_array( $opt, $opt_key, $field );
549 +
708 550 $field_name = $base_name . ( $default_type === 'checkbox' ? '[' . $opt_key . ']' : '' );
709 551
710 - // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict, Universal.Operators.StrictComparisons, SlevomatCodingStandard.Files.LineLength.LineTooLong
711 - $checked = isset( $field['default_value'] ) && ( is_array( $field['default_value'] ) ? in_array( $field_val, $field['default_value'] ) : $field['default_value'] == $field_val );
552 + $checked = ( isset( $field['default_value'] ) && ( ( ! is_array( $field['default_value'] ) && $field['default_value'] == $field_val ) || ( is_array( $field['default_value'] ) && in_array( $field_val, $field['default_value'] ) ) ) );
712 553
713 554 // If this is an "Other" option, get the HTML for it.
714 555 if ( self::is_other_opt( $opt_key ) ) {
715 556 if ( FrmAppHelper::pro_is_installed() ) {
@@ -726,29 +567,26 @@
726 567 /**
727 568 * Include hidden row for javascript to duplicate.
728 569 *
729 570 * @since 4.0
730 - *
731 571 * @param array $field
732 - *
733 - * @return void
734 572 */
735 573 private static function hidden_field_option( $field ) {
736 574 // Don't duplicate during an ajax add option.
737 575 $ajax_action = FrmAppHelper::get_param( 'action', '', 'post', 'sanitize_text_field' );
738 -
739 576 if ( $ajax_action === 'frm_add_field_option' ) {
740 577 return;
741 578 }
742 579
743 - $opt_key = '000';
744 - $field_val = __( 'New Option', 'formidable' );
745 - $opt = __( 'New Option', 'formidable' );
746 - $checked = false;
747 - $field_name = 'default_value_' . $field['id'];
748 - $html_id = $field['html_id'] ?? self::get_html_id( $field );
580 + $opt_key = '000';
581 + $field_val = __( 'New Option', 'formidable' );
582 + $opt = __( 'New Option', 'formidable' );
583 + $checked = false;
584 + $field_name = 'default_value_' . $field['id'];
585 + $html_id = isset( $field['html_id'] ) ? $field['html_id'] : self::get_html_id( $field );
586 +
749 587 $default_type = self::get_default_value_type( $field );
750 - $field_name .= $default_type === 'checkbox' ? '[' . $opt_key . ']' : '';
588 + $field_name .= ( $default_type === 'checkbox' ? '[' . $opt_key . ']' : '' );
751 589
752 590 require FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php';
753 591 }
754 592
@@ -755,39 +593,27 @@
755 593 /**
756 594 * @since 4.0
757 595 *
758 596 * @param array $field
759 - *
760 597 * @return string radio or checkbox
761 598 */
762 599 private static function get_default_value_type( $field ) {
600 + $default_type = $field['type'];
763 601 if ( $field['type'] === 'select' ) {
764 - return FrmField::is_multiple_select( $field ) ? 'checkbox' : 'radio';
602 + $default_type = FrmField::is_multiple_select( $field ) ? 'checkbox' : 'radio';
765 603 }
766 - return $field['type'];
604 + return $default_type;
767 605 }
768 606
769 - /**
770 - * @param array|string $opt
771 - * @param int|string $opt_key
772 - * @param array $field
773 - *
774 - * @return mixed
775 - */
776 607 public static function get_value_from_array( $opt, $opt_key, $field ) {
777 608 $opt = apply_filters( 'frm_field_value_saved', $opt, $opt_key, $field );
609 +
778 610 return FrmFieldsController::check_value( $opt, $opt_key, $field );
779 611 }
780 612
781 - /**
782 - * @param array|string $opt
783 - * @param int|string $opt_key
784 - * @param array $field
785 - *
786 - * @return string
787 - */
788 613 public static function get_label_from_array( $opt, $opt_key, $field ) {
789 614 $opt = apply_filters( 'frm_field_label_seen', $opt, $opt_key, $field );
615 +
790 616 return FrmFieldsController::check_label( $opt );
791 617 }
792 618
793 619 /**
@@ -796,10 +622,8 @@
796 622 * @since 4.0
797 623 * @since 6.4.1 Added `inside_class` in the arguments.
798 624 *
799 625 * @param array $args The arguments.
800 - *
801 - * @return void
802 626 */
803 627 public static function inline_modal( $args ) {
804 628 $defaults = array(
805 629 'id' => '',
@@ -808,9 +632,8 @@
808 632 'callback' => array(),
809 633 'args' => array(),
810 634 'title' => '',
811 635 'inside_class' => 'inside',
812 - 'dismiss-icon' => true,
813 636 );
814 637 $args = array_merge( $defaults, $args );
815 638
816 639 include FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/inline-modal.php';
@@ -817,29 +640,22 @@
817 640 }
818 641
819 642 /**
820 643 * @since 4.0
821 - *
822 - * @return void
823 644 */
824 645 public static function smart_values() {
825 646 $continue = apply_filters( 'frm_smart_values_box', true );
826 -
827 - if ( $continue !== true ) {
828 - return;
647 + if ( $continue === true ) {
648 + $upgrade_link = array(
649 + 'medium' => 'builder',
650 + 'content' => 'smart-tags',
651 + );
652 + include FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/smart-values.php';
829 653 }
830 -
831 - $upgrade_link = array(
832 - 'medium' => 'builder',
833 - 'content' => 'smart-tags',
834 - );
835 - include FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/smart-values.php';
836 654 }
837 655
838 656 /**
839 657 * @since 4.0
840 - *
841 - * @return void
842 658 */
843 659 public static function input_mask() {
844 660 include FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/input-mask-info.php';
845 661 }
@@ -845,10 +661,8 @@
845 661 }
846 662
847 663 /**
848 664 * @since 4.0
849 - *
850 - * @return void
851 665 */
852 666 public static function layout_classes() {
853 667 include FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/layout-classes.php';
854 668 }
@@ -859,30 +673,25 @@
859 673 * @return string
860 674 */
861 675 public static function get_term_link( $tax_id ) {
862 676 $tax = get_taxonomy( $tax_id );
863 -
864 677 if ( ! $tax ) {
865 678 return '';
866 679 }
867 680
868 - return sprintf(
681 + $link = sprintf(
869 682 /* translators: %1$s: Start HTML link, %2$s: Content type label, %3$s: Content type, %4$s: End HTML link */
870 683 esc_html__( 'Options are dynamically created from your %1$s%2$s: %3$s%4$s', 'formidable' ),
871 684 '<a href="' . esc_url( admin_url( 'edit-tags.php?taxonomy=' . $tax->name ) ) . '" target="_blank">',
872 685 esc_html__( 'taxonomy', 'formidable' ),
873 - ! empty( $tax->labels->name ) ? $tax->labels->name : esc_html__( 'Categories', 'formidable' ),
686 + empty( $tax->labels->name ) ? esc_html__( 'Categories', 'formidable' ) : $tax->labels->name,
874 687 '</a>'
875 688 );
689 + unset( $tax );
690 +
691 + return $link;
876 692 }
877 693
878 - /**
879 - * @param array|string $observed_value
880 - * @param string $cond
881 - * @param array|string $hide_opt
882 - *
883 - * @return bool
884 - */
885 694 public static function value_meets_condition( $observed_value, $cond, $hide_opt ) {
886 695 $hide_opt = self::get_value_for_comparison( $hide_opt );
887 696 $observed_value = self::get_value_for_comparison( $observed_value );
888 697
@@ -890,13 +699,12 @@
890 699 return self::array_value_condition( $observed_value, $cond, $hide_opt );
891 700 }
892 701
893 702 $m = false;
894 -
895 703 if ( $cond === '==' ) {
896 - $m = $observed_value == $hide_opt; // phpcs:ignore Universal.Operators.StrictComparisons
704 + $m = $observed_value == $hide_opt;
897 705 } elseif ( $cond === '!=' ) {
898 - $m = $observed_value != $hide_opt; // phpcs:ignore Universal.Operators.StrictComparisons
706 + $m = $observed_value != $hide_opt;
899 707 } elseif ( $cond === '>' ) {
900 708 $m = $observed_value > $hide_opt;
901 709 } elseif ( $cond === '>=' ) {
902 710 $m = $observed_value >= $hide_opt;
@@ -905,16 +713,20 @@
905 713 } elseif ( $cond === '<=' ) {
906 714 $m = $observed_value <= $hide_opt;
907 715 } elseif ( $cond === 'LIKE' || $cond === 'not LIKE' ) {
908 716 $m = stripos( $observed_value, $hide_opt );
909 - $m = $cond === 'not LIKE' ? $m === false : $m !== false;
717 + if ( $cond === 'not LIKE' ) {
718 + $m = $m === false;
719 + } else {
720 + $m = $m !== false;
721 + }
910 722 } elseif ( $cond === '%LIKE' ) {
911 - // Ends with
723 + // ends with
912 724 $length = strlen( $hide_opt );
913 725 $substr = substr( $observed_value, strlen( $observed_value ) - $length );
914 726 $m = 0 === strcasecmp( $substr, $hide_opt );
915 727 } elseif ( 'LIKE%' === $cond ) {
916 - // Starts with
728 + // starts with
917 729 $length = strlen( $hide_opt );
918 730 $substr = substr( $observed_value, 0, $length );
919 731 $m = 0 === strcasecmp( $substr, $hide_opt );
920 732 }//end if
@@ -925,12 +737,8 @@
925 737 /**
926 738 * Trim and sanitize the values
927 739 *
928 740 * @since 2.05
929 - *
930 - * @param array|string $value
931 - *
932 - * @return array|string
933 741 */
934 742 private static function get_value_for_comparison( $value ) {
935 743 // Remove white space from hide_opt
936 744 if ( ! is_array( $value ) ) {
@@ -941,37 +749,28 @@
941 749
942 750 return $value;
943 751 }
944 752
945 - /**
946 - * @param array $observed_value
947 - * @param string $cond
948 - * @param array|string $hide_opt
949 - *
950 - * @return bool
951 - */
952 753 public static function array_value_condition( $observed_value, $cond, $hide_opt ) {
953 754 $m = false;
954 -
955 755 if ( $cond === '==' ) {
956 756 if ( is_array( $hide_opt ) ) {
957 757 $m = array_intersect( $hide_opt, $observed_value );
958 - $m = $m !== array();
758 + $m = ! empty( $m );
959 759 } else {
960 - // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict
961 760 $m = in_array( $hide_opt, $observed_value );
962 761 }
963 762 } elseif ( $cond === '!=' ) {
964 - // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict
965 763 $m = ! in_array( $hide_opt, $observed_value );
966 764 } elseif ( $cond === '>' ) {
967 - $m = min( $observed_value ) > $hide_opt;
765 + $min = min( $observed_value );
766 + $m = $min > $hide_opt;
968 767 } elseif ( $cond === '<' ) {
969 - $m = max( $observed_value ) < $hide_opt;
768 + $max = max( $observed_value );
769 + $m = $max < $hide_opt;
970 770 } elseif ( $cond === 'LIKE' || $cond === 'not LIKE' ) {
971 771 foreach ( $observed_value as $ob ) {
972 772 $m = strpos( $ob, $hide_opt );
973 -
974 773 if ( $m !== false ) {
975 774 $m = true;
976 775 break;
977 776 }
@@ -980,9 +779,9 @@
980 779 if ( $cond === 'not LIKE' ) {
981 780 $m = $m === false;
982 781 }
983 782 } elseif ( $cond === '%LIKE' ) {
984 - // Ends with
783 + // ends with
985 784 foreach ( $observed_value as $ob ) {
986 785 if ( $hide_opt === substr( $ob, strlen( $ob ) - strlen( $hide_opt ) ) ) {
987 786 $m = true;
988 787 break;
@@ -988,11 +787,11 @@
988 787 break;
989 788 }
990 789 }
991 790 } elseif ( $cond === 'LIKE%' ) {
992 - // Starts with
791 + // starts with
993 792 foreach ( $observed_value as $ob ) {
994 - if ( str_starts_with( $ob, $hide_opt ) ) {
793 + if ( $hide_opt === substr( $ob, 0, strlen( $hide_opt ) ) ) {
995 794 $m = true;
996 795 break;
997 796 }
998 797 }
@@ -1004,32 +803,22 @@
1004 803 /**
1005 804 * Replace a few basic shortcodes and field ids
1006 805 *
1007 806 * @since 2.0
1008 - *
1009 - * @param string $value
1010 - * @param object $form
1011 - * @param object $entry
1012 - *
1013 807 * @return string
1014 808 */
1015 809 public static function basic_replace_shortcodes( $value, $form, $entry ) {
1016 - if ( str_contains( $value, '[sitename]' ) ) {
810 + if ( strpos( $value, '[sitename]' ) !== false ) {
1017 811 $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
1018 812 $value = str_replace( '[sitename]', $new_value, $value );
1019 813 }
1020 814
1021 815 $value = apply_filters( 'frm_content', $value, $form, $entry );
816 + $value = do_shortcode( $value );
1022 817
1023 - return do_shortcode( $value );
818 + return $value;
1024 819 }
1025 820
1026 - /**
1027 - * @param string $content
1028 - * @param int|string $form_id
1029 - *
1030 - * @return array
1031 - */
1032 821 public static function get_shortcodes( $content, $form_id ) {
1033 822 if ( FrmAppHelper::pro_is_installed() ) {
1034 823 return FrmProDisplaysHelper::get_shortcodes( $content, $form_id );
1035 824 }
@@ -1047,13 +836,8 @@
1047 836
1048 837 return $matches;
1049 838 }
1050 839
1051 - /**
1052 - * @param array $fields
1053 - *
1054 - * @return string
1055 - */
1056 840 public static function allowed_shortcodes( $fields = array() ) {
1057 841 $tagregexp = array(
1058 842 'editlink',
1059 843 'id',
@@ -1068,9 +852,8 @@
1068 852 'created[-|_]at',
1069 853 'updated[-|_]at',
1070 854 'updated[-|_]by',
1071 855 'parent[-|_]id',
1072 - 'form_name',
1073 856 );
1074 857
1075 858 foreach ( $fields as $field ) {
1076 859 $tagregexp[] = $field->id;
@@ -1076,21 +859,16 @@
1076 859 $tagregexp[] = $field->id;
1077 860 $tagregexp[] = $field->field_key;
1078 861 }
1079 862
1080 - return implode( '|', $tagregexp );
863 + $tagregexp = implode( '|', $tagregexp );
864 +
865 + return $tagregexp;
1081 866 }
1082 867
1083 - /**
1084 - * @param string $content
1085 - * @param false|object $entry
1086 - * @param array $shortcodes
1087 - *
1088 - * @return string
1089 - */
1090 868 public static function replace_content_shortcodes( $content, $entry, $shortcodes ) {
1091 869 foreach ( $shortcodes[0] as $short_key => $tag ) {
1092 - if ( ! $tag ) {
870 + if ( empty( $tag ) ) {
1093 871 continue;
1094 872 }
1095 873
1096 874 $atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[3][ $short_key ] );
@@ -1114,25 +892,21 @@
1114 892
1115 893 /**
1116 894 * @param string $replace_with
1117 895 * @param array $atts
1118 - *
1119 896 * @return string
1120 897 */
1121 898 private static function trigger_shortcode_atts( $replace_with, $atts ) {
1122 899 $supported_atts = array( 'remove_accents', 'sanitize', 'sanitize_url' );
1123 900 $included_atts = array_intersect( $supported_atts, array_keys( $atts ) );
1124 -
1125 901 foreach ( $included_atts as $included_att ) {
1126 902 if ( '0' === $atts[ $included_att ] ) {
1127 903 // Skip any option that uses 0 so sanitize_url=0 does not encode.
1128 904 continue;
1129 905 }
1130 -
1131 906 $function = 'atts_' . $included_att;
1132 - $replace_with = self::$function( $replace_with );
907 + $replace_with = self::$function( $replace_with, $atts );
1133 908 }
1134 -
1135 909 return $replace_with;
1136 910 }
1137 911
1138 912 /**
@@ -1149,9 +923,8 @@
1149 923 }
1150 924
1151 925 /**
1152 926 * @param string $replace_with
1153 - *
1154 927 * @return string
1155 928 */
1156 929 private static function atts_sanitize( $replace_with ) {
1157 930 return sanitize_title_with_dashes( $replace_with );
@@ -1158,9 +931,8 @@
1158 931 }
1159 932
1160 933 /**
1161 934 * @param string $replace_with
1162 - *
1163 935 * @return string
1164 936 */
1165 937 private static function atts_sanitize_url( $replace_with ) {
1166 938 return urlencode( $replace_with );
@@ -1172,9 +944,8 @@
1172 944 * @since 3.01.02
1173 945 *
1174 946 * @param array $atts Includes entry object.
1175 947 * @param string|null $value
1176 - *
1177 948 * @return void
1178 949 */
1179 950 public static function sanitize_embedded_shortcodes( $atts, &$value ) {
1180 951 if ( is_null( $value ) ) {
@@ -1182,9 +953,8 @@
1182 953 }
1183 954
1184 955 $atts['value'] = $value;
1185 956 $should_sanitize = apply_filters( 'frm_sanitize_shortcodes', true, $atts );
1186 -
1187 957 if ( $should_sanitize ) {
1188 958 $value = str_replace( '[', '&#91;', $value );
1189 959 }
1190 960 }
@@ -1252,10 +1022,9 @@
1252 1022 * @return string|null
1253 1023 */
1254 1024 private static function get_field_shortcode_value( $atts ) {
1255 1025 $field = FrmField::getOne( $atts['tag'] );
1256 -
1257 - if ( ! $field ) {
1026 + if ( empty( $field ) ) {
1258 1027 return null;
1259 1028 }
1260 1029
1261 1030 if ( isset( $atts['show'] ) && $atts['show'] === 'field_label' ) {
@@ -1264,16 +1033,14 @@
1264 1033 $replace_with = $field->description;
1265 1034 } else {
1266 1035 $replace_with = FrmEntryMeta::get_meta_value( $atts['entry'], $field->id );
1267 1036 $string_value = $replace_with;
1268 -
1269 1037 if ( is_array( $replace_with ) ) {
1270 - $sep = $atts['sep'] ?? ', ';
1038 + $sep = isset( $atts['sep'] ) ? $atts['sep'] : ', ';
1271 1039 $string_value = FrmAppHelper::safe_implode( $sep, $replace_with );
1272 1040 }
1273 1041
1274 - // phpcs:ignore Universal.Operators.StrictComparisons
1275 - if ( ! $string_value && $string_value != '0' ) {
1042 + if ( empty( $string_value ) && $string_value != '0' ) {
1276 1043 $replace_with = '';
1277 1044 } else {
1278 1045 $atts['entry_id'] = $atts['entry']->id;
1279 1046 $atts['entry_key'] = $atts['entry']->item_key;
@@ -1278,9 +1045,9 @@
1278 1045 $atts['entry_id'] = $atts['entry']->id;
1279 1046 $atts['entry_key'] = $atts['entry']->item_key;
1280 1047 $replace_with = self::get_display_value( $replace_with, $field, $atts );
1281 1048 }
1282 - }//end if
1049 + }
1283 1050
1284 1051 return $replace_with;
1285 1052 }
1286 1053
@@ -1287,13 +1054,8 @@
1287 1054 /**
1288 1055 * Get the value to replace a few standard shortcodes
1289 1056 *
1290 1057 * @since 2.0
1291 - *
1292 - * @param string $tag
1293 - * @param array $atts
1294 - * @param bool $return_array
1295 - *
1296 1058 * @return string
1297 1059 */
1298 1060 public static function dynamic_default_values( $tag, $atts = array(), $return_array = false ) {
1299 1061 $new_value = '';
@@ -1328,12 +1090,8 @@
1328 1090 /**
1329 1091 * Process the [get] shortcode
1330 1092 *
1331 1093 * @since 2.0
1332 - *
1333 - * @param array $atts
1334 - * @param bool $return_array
1335 - *
1336 1094 * @return array|string
1337 1095 */
1338 1096 public static function process_get_shortcode( $atts, $return_array = false ) {
1339 1097 if ( ! isset( $atts['param'] ) ) {
@@ -1339,9 +1097,9 @@
1339 1097 if ( ! isset( $atts['param'] ) ) {
1340 1098 return '';
1341 1099 }
1342 1100
1343 - if ( str_contains( $atts['param'], '&#91;' ) ) {
1101 + if ( strpos( $atts['param'], '&#91;' ) ) {
1344 1102 $atts['param'] = str_replace( '&#91;', '[', $atts['param'] );
1345 1103 $atts['param'] = str_replace( '&#93;', ']', $atts['param'] );
1346 1104 }
1347 1105
@@ -1347,34 +1105,28 @@
1347 1105
1348 1106 $new_value = FrmAppHelper::get_param( $atts['param'], '', 'get', 'sanitize_text_field' );
1349 1107 $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] );
1350 1108
1351 - // phpcs:ignore Universal.Operators.StrictComparisons
1352 1109 if ( $new_value == '' ) {
1353 1110 if ( ! isset( $atts['prev_val'] ) ) {
1354 1111 $atts['prev_val'] = '';
1355 1112 }
1356 1113
1357 - $new_value = $atts['default'] ?? $atts['prev_val'];
1114 + $new_value = isset( $atts['default'] ) ? $atts['default'] : $atts['prev_val'];
1358 1115 }
1359 1116
1360 1117 if ( is_array( $new_value ) && ! $return_array ) {
1361 - return implode( ', ', $new_value );
1118 + $new_value = implode( ', ', $new_value );
1362 1119 }
1363 1120
1364 1121 return $new_value;
1365 1122 }
1366 1123
1367 - /**
1368 - * @param mixed $value
1369 - * @param object $field
1370 - * @param array $atts
1371 - *
1372 - * @return mixed
1373 - */
1374 1124 public static function get_display_value( $value, $field, $atts = array() ) {
1125 +
1375 1126 $value = apply_filters( 'frm_get_' . $field->type . '_display_value', $value, $field, $atts );
1376 1127 $value = apply_filters( 'frm_get_display_value', $value, $field, $atts );
1128 +
1377 1129 $value = self::get_unfiltered_display_value( compact( 'value', 'field', 'atts' ) );
1378 1130
1379 1131 return apply_filters( 'frm_display_value', $value, $field, $atts );
1380 1132 }
@@ -1380,15 +1132,13 @@
1380 1132 }
1381 1133
1382 1134 /**
1383 1135 * @param array $atts Includes value, field, and atts.
1384 - *
1385 - * @return mixed
1386 1136 */
1387 1137 public static function get_unfiltered_display_value( $atts ) {
1388 1138 $value = $atts['value'];
1389 1139 $field = $atts['field'];
1390 - $atts = $atts['atts'] ?? $atts;
1140 + $atts = isset( $atts['atts'] ) ? $atts['atts'] : $atts;
1391 1141
1392 1142 if ( is_array( $field ) ) {
1393 1143 $field = $field['id'];
1394 1144 }
@@ -1402,12 +1152,8 @@
1402 1152 * Get a value from the user profile from the user ID
1403 1153 *
1404 1154 * @since 3.0
1405 1155 *
1406 - * @param int|string $user_id
1407 - * @param string $user_info
1408 - * @param array $args
1409 - *
1410 1156 * @return string
1411 1157 */
1412 1158 public static function get_user_display_name( $user_id, $user_info = 'display_name', $args = array() ) {
1413 1159 $defaults = array(
@@ -1416,8 +1162,9 @@
1416 1162 'size' => 96,
1417 1163 );
1418 1164
1419 1165 $args = wp_parse_args( $args, $defaults );
1166 +
1420 1167 $user = get_userdata( $user_id );
1421 1168 $info = '';
1422 1169
1423 1170 if ( $user ) {
@@ -1425,18 +1172,18 @@
1425 1172 $info = get_avatar( $user_id, $args['size'] );
1426 1173 } elseif ( $user_info === 'author_link' ) {
1427 1174 $info = get_author_posts_url( $user_id );
1428 1175 } else {
1429 - $info = $user->$user_info ?? '';
1176 + $info = isset( $user->$user_info ) ? $user->$user_info : '';
1430 1177 }
1431 1178
1432 - if ( 'display_name' === $user_info && ! $info && ! $args['blank'] ) {
1179 + if ( 'display_name' === $user_info && empty( $info ) && ! $args['blank'] ) {
1433 1180 $info = $user->user_login;
1434 1181 }
1435 1182 }
1436 1183
1437 1184 if ( $args['link'] ) {
1438 - return '<a href="' . esc_url( admin_url( 'user-edit.php?user_id=' . $user_id ) ) . '">' . $info . '</a>';
1185 + $info = '<a href="' . esc_url( admin_url( 'user-edit.php?user_id=' . $user_id ) ) . '">' . $info . '</a>';
1439 1186 }
1440 1187
1441 1188 return $info;
1442 1189 }
@@ -1442,9 +1189,8 @@
1442 1189 }
1443 1190
1444 1191 /**
1445 1192 * @param string $type
1446 - *
1447 1193 * @return array
1448 1194 */
1449 1195 public static function get_field_types( $type ) {
1450 1196 $single_input = self::single_input_fields();
@@ -1459,9 +1205,11 @@
1459 1205 } elseif ( isset( $field_selection[ $type ] ) ) {
1460 1206 $field_types[ $type ] = $field_selection[ $type ];
1461 1207 }
1462 1208
1463 - return apply_filters( 'frm_switch_field_types', $field_types, compact( 'type', 'field_selection' ) );
1209 + $field_types = apply_filters( 'frm_switch_field_types', $field_types, compact( 'type', 'field_selection' ) );
1210 +
1211 + return $field_types;
1464 1212 }
1465 1213
1466 1214 /**
1467 1215 * Get a list of all fields that use a single value input.
@@ -1466,10 +1214,8 @@
1466 1214 /**
1467 1215 * Get a list of all fields that use a single value input.
1468 1216 *
1469 1217 * @since 4.0
1470 - *
1471 - * @return array
1472 1218 */
1473 1219 public static function single_input_fields() {
1474 1220 $fields = array(
1475 1221 'text',
@@ -1483,9 +1229,8 @@
1483 1229 'hidden',
1484 1230 'time',
1485 1231 'tag',
1486 1232 'password',
1487 - 'gdpr',
1488 1233 );
1489 1234 return apply_filters( 'frm_single_input_fields', $fields );
1490 1235 }
1491 1236
@@ -1492,9 +1237,8 @@
1492 1237 /**
1493 1238 * @param string[] $inputs
1494 1239 * @param array $fields
1495 1240 * @param array $field_types
1496 - *
1497 1241 * @return void
1498 1242 */
1499 1243 private static function field_types_for_input( $inputs, $fields, &$field_types ) {
1500 1244 foreach ( $inputs as $input ) {
@@ -1515,9 +1259,9 @@
1515 1259 *
1516 1260 * @return bool Returns true if current field option is an "Other" option
1517 1261 */
1518 1262 public static function is_other_opt( $opt_key ) {
1519 - return $opt_key && str_starts_with( $opt_key, 'other_' );
1263 + return $opt_key && strpos( $opt_key, 'other_' ) === 0;
1520 1264 }
1521 1265
1522 1266 /**
1523 1267 * Get value that belongs in "Other" text box
@@ -1524,19 +1268,18 @@
1524 1268 *
1525 1269 * @since 2.0.6
1526 1270 *
1527 1271 * @param array $args
1528 - *
1529 - * @return string
1530 1272 */
1531 - public static function get_other_val( $args ) { // phpcs:ignore SlevomatCodingStandard.Complexity.Cognitive.ComplexityTooHigh
1532 - $defaults = array(
1273 + public static function get_other_val( $args ) {
1274 + $defaults = array(
1533 1275 'opt_key' => 0,
1534 1276 'field' => array(),
1535 1277 'parent' => false,
1536 1278 'pointer' => false,
1537 1279 );
1538 - $args = wp_parse_args( $args, $defaults );
1280 + $args = wp_parse_args( $args, $defaults );
1281 +
1539 1282 $opt_key = $args['opt_key'];
1540 1283 $field = $args['field'];
1541 1284 $parent = $args['parent'];
1542 1285 $pointer = $args['pointer'];
@@ -1542,9 +1285,9 @@
1542 1285 $pointer = $args['pointer'];
1543 1286 $other_val = '';
1544 1287
1545 1288 // If option is an "other" option and there is a value set for this field,
1546 - // Check if the value belongs in the current "Other" option text field
1289 + // check if the value belongs in the current "Other" option text field
1547 1290 if ( ! self::is_other_opt( $opt_key ) || ! FrmField::is_option_true( $field, 'value' ) ) {
1548 1291 return $other_val;
1549 1292 }
1550 1293
@@ -1551,12 +1294,12 @@
1551 1294 // Check posted vals before checking saved values
1552 1295 // For fields inside repeating sections - note, don't check if $pointer is true because it will often be zero
1553 1296 if ( $parent && isset( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
1554 1297 if ( FrmField::is_field_with_multiple_values( $field ) ) {
1555 - $other_val = isset( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ][ $opt_key ] ) ? sanitize_text_field( wp_unslash( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ][ $opt_key ] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Missing, SlevomatCodingStandard.Files.LineLength.LineTooLong
1298 + // phpcs:ignore WordPress.Security.NonceVerification.Missing
1299 + $other_val = isset( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ][ $opt_key ] ) ? sanitize_text_field( wp_unslash( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ][ $opt_key ] ) ) : '';
1556 1300 } else {
1557 - // phpcs:ignore WordPress.Security.NonceVerification.Missing
1558 - $other_val = sanitize_text_field( wp_unslash( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] ) );
1301 + $other_val = sanitize_text_field( wp_unslash( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
1559 1302 }
1560 1303
1561 1304 return $other_val;
1562 1305 }
@@ -1564,9 +1307,9 @@
1564 1307 if ( isset( $field['id'] ) && isset( $_POST['item_meta']['other'][ $field['id'] ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
1565 1308 // For normal fields
1566 1309
1567 1310 if ( FrmField::is_field_with_multiple_values( $field ) ) {
1568 - // phpcs:ignore WordPress.Security.NonceVerification.Missing, SlevomatCodingStandard.Files.LineLength.LineTooLong
1311 + // phpcs:ignore WordPress.Security.NonceVerification.Missing
1569 1312 $other_val = isset( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) ? sanitize_text_field( wp_unslash( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) ) : '';
1570 1313 } else {
1571 1314 $other_val = sanitize_text_field( wp_unslash( $_POST['item_meta']['other'][ $field['id'] ] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
1572 1315 }
@@ -1577,9 +1320,8 @@
1577 1320 // For checkboxes
1578 1321 if ( $field['type'] === 'checkbox' && is_array( $field['value'] ) ) {
1579 1322 // Check if there is an "other" val in saved value and make sure the
1580 1323 // "other" val is not equal to the Other checkbox option
1581 - // phpcs:ignore Universal.Operators.StrictComparisons
1582 1324 if ( isset( $field['value'][ $opt_key ] ) && $field['options'][ $opt_key ] != $field['value'][ $opt_key ] ) {
1583 1325 $other_val = $field['value'][ $opt_key ];
1584 1326 }
1585 1327 } else {
@@ -1586,30 +1328,26 @@
1586 1328 /**
1587 1329 * For radio buttons and dropdowns
1588 1330 * Check if saved value equals any of the options. If not, set it as the other value.
1589 1331 */
1590 - foreach ( $field['options'] as $opt_val ) {
1332 + foreach ( $field['options'] as $opt_key => $opt_val ) {
1591 1333 $temp_val = is_array( $opt_val ) ? $opt_val['value'] : $opt_val;
1592 -
1593 1334 // Multi-select dropdowns - key is not preserved
1594 1335 if ( is_array( $field['value'] ) ) {
1595 - // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict
1596 1336 $o_key = array_search( $temp_val, $field['value'] );
1597 -
1598 1337 if ( isset( $field['value'][ $o_key ] ) ) {
1599 1338 unset( $field['value'][ $o_key ], $o_key );
1600 1339 }
1601 - } elseif ( $temp_val == $field['value'] ) { // phpcs:ignore Universal.Operators.StrictComparisons
1340 + } elseif ( $temp_val == $field['value'] ) {
1602 1341 // For radio and regular dropdowns
1603 1342 return '';
1604 1343 } else {
1605 1344 $other_val = $field['value'];
1606 1345 }
1607 - unset( $opt_val, $temp_val );
1346 + unset( $opt_key, $opt_val, $temp_val );
1608 1347 }
1609 -
1610 1348 // For multi-select dropdowns only
1611 - if ( is_array( $field['value'] ) && $field['value'] ) {
1349 + if ( is_array( $field['value'] ) && ! empty( $field['value'] ) ) {
1612 1350 $other_val = reset( $field['value'] );
1613 1351 }
1614 1352 }//end if
1615 1353
@@ -1625,9 +1363,9 @@
1625 1363 * @param array $args Should include field, opt_key and field name.
1626 1364 * @param bool $other_opt
1627 1365 * @param string $checked
1628 1366 *
1629 - * @return array Other args.
1367 + * @return array $other_args
1630 1368 */
1631 1369 public static function prepare_other_input( $args, &$other_opt, &$checked ) {
1632 1370 $other_args = array(
1633 1371 'name' => '',
@@ -1662,13 +1400,10 @@
1662 1400 }
1663 1401
1664 1402 /**
1665 1403 * @since 2.0.6
1666 - *
1667 1404 * @param array $args
1668 1405 * @param array $other_args
1669 - *
1670 - * @return void
1671 1406 */
1672 1407 private static function set_other_name( $args, &$other_args ) {
1673 1408 // Set up name for other field
1674 1409 $other_args['name'] = str_replace( '[]', '', $args['field_name'] );
@@ -1685,13 +1420,10 @@
1685 1420 /**
1686 1421 * Find the parent and pointer, and get text for "other" text field
1687 1422 *
1688 1423 * @since 2.0.6
1689 - *
1690 1424 * @param array $args
1691 1425 * @param array $other_args
1692 - *
1693 - * @return void
1694 1426 */
1695 1427 private static function set_other_value( $args, &$other_args ) {
1696 1428 $parent = '';
1697 1429 $pointer = '';
@@ -1719,12 +1451,9 @@
1719 1451 /**
1720 1452 * If this field includes an other option, show it
1721 1453 *
1722 1454 * @since 2.0.6
1723 - *
1724 1455 * @param array $args
1725 - *
1726 - * @return void
1727 1456 */
1728 1457 public static function include_other_input( $args ) {
1729 1458 if ( ! $args['other_opt'] ) {
1730 1459 return;
@@ -1730,15 +1459,13 @@
1730 1459 return;
1731 1460 }
1732 1461
1733 1462 $classes = array( 'frm_other_input' );
1734 -
1735 - if ( ! $args['checked'] || trim( $args['checked'] ) === '' ) {
1736 - // Hide the field if the other option is not selected
1463 + if ( ! $args['checked'] || trim( $args['checked'] ) == '' ) {
1464 + // hide the field if the other option is not selected
1737 1465 $classes[] = 'frm_pos_none';
1738 1466 }
1739 -
1740 - if ( $args['field']['type'] === 'select' && ! empty( $args['field']['multiple'] ) ) {
1467 + if ( $args['field']['type'] === 'select' && $args['field']['multiple'] ) {
1741 1468 $classes[] = 'frm_other_full';
1742 1469 }
1743 1470
1744 1471 // Set up HTML ID for Other field
@@ -1743,11 +1470,10 @@
1743 1470
1744 1471 // Set up HTML ID for Other field
1745 1472 $other_id = self::get_other_field_html_id( $args['field']['type'], $args['html_id'], $args['opt_key'] );
1746 1473
1747 - $label = $args['opt_label'] ?? $args['field']['name'];
1474 + $label = isset( $args['opt_label'] ) ? $args['opt_label'] : $args['field']['name'];
1748 1475
1749 - // phpcs:disable Generic.WhiteSpace.ScopeIndent
1750 1476 echo '<label for="' . esc_attr( $other_id ) . '" class="frm_screen_reader frm_hidden">' .
1751 1477 esc_html( $label ) .
1752 1478 '</label>' .
1753 1479 '<input type="text" id="' . esc_attr( $other_id ) . '" class="' . esc_attr( implode( ' ', $classes ) ) . '" ' .
@@ -1752,9 +1478,8 @@
1752 1478 '</label>' .
1753 1479 '<input type="text" id="' . esc_attr( $other_id ) . '" class="' . esc_attr( implode( ' ', $classes ) ) . '" ' .
1754 1480 ( $args['read_only'] ? ' readonly="readonly" disabled="disabled"' : '' ) .
1755 1481 ' name="' . esc_attr( $args['name'] ) . '" value="' . esc_attr( $args['value'] ) . '" />';
1756 - // phpcs:enable Generic.WhiteSpace.ScopeIndent
1757 1482 }
1758 1483
1759 1484 /**
1760 1485 * Get the HTML id for an "Other" text field
@@ -1765,9 +1490,9 @@
1765 1490 * @param string $type Field type.
1766 1491 * @param string $html_id
1767 1492 * @param bool|string $opt_key
1768 1493 *
1769 - * @return string Other ID.
1494 + * @return string $other_id
1770 1495 */
1771 1496 public static function get_other_field_html_id( $type, $html_id, $opt_key = false ) {
1772 1497 $other_id = $html_id;
1773 1498
@@ -1779,21 +1504,17 @@
1779 1504 if ( $opt_key !== false ) {
1780 1505 $other_id .= '-' . $opt_key;
1781 1506 }
1782 1507
1783 - return $other_id . '-otext';
1508 + $other_id .= '-otext';
1509 +
1510 + return $other_id;
1784 1511 }
1785 1512
1786 - /**
1787 - * @param array|string $val
1788 - *
1789 - * @return array|string
1790 - */
1791 1513 public static function switch_field_ids( $val ) {
1792 1514 global $frm_duplicate_ids;
1793 1515 $replace = array();
1794 1516 $replace_with = array();
1795 -
1796 1517 foreach ( (array) $frm_duplicate_ids as $old => $new ) {
1797 1518 $replace[] = '[if ' . $old . ']';
1798 1519 $replace_with[] = '[if ' . $new . ']';
1799 1520 $replace[] = '[if ' . $old . ' ';
@@ -1815,31 +1536,24 @@
1815 1536 $replace[] = 'field_id="' . $old . '"';
1816 1537 $replace_with[] = 'field_id="' . $new . '"';
1817 1538 $replace[] = 'field_id=\"' . $old . '\"';
1818 1539 $replace_with[] = 'field_id=\"' . $new . '\"';
1819 - // This covers conditional logic.
1820 - $replace[] = '_field":"' . $old . '","';
1821 - $replace_with[] = '_field":"' . $new . '","';
1822 1540 unset( $old, $new );
1823 1541 }//end foreach
1824 -
1825 - if ( ! is_array( $val ) ) {
1826 - return str_replace( $replace, $replace_with, $val );
1827 - }
1828 -
1829 - foreach ( $val as $k => $v ) {
1830 - if ( ! is_string( $v ) ) {
1831 - continue;
1542 + if ( is_array( $val ) ) {
1543 + foreach ( $val as $k => $v ) {
1544 + if ( is_string( $v ) ) {
1545 + if ( 'custom_html' === $k ) {
1546 + $val[ $k ] = self::switch_ids_except_strings( $replace, $replace_with, array( '[if description]', '[description]', '[/if description]' ), $v );
1547 + unset( $k, $v );
1548 + continue;
1549 + }
1550 + $val[ $k ] = str_replace( $replace, $replace_with, $v );
1551 + unset( $k, $v );
1552 + }
1832 1553 }
1833 -
1834 - if ( 'custom_html' === $k ) {
1835 - $val[ $k ] = self::switch_ids_except_strings( $replace, $replace_with, array( '[if description]', '[description]', '[/if description]' ), $v );
1836 - unset( $k, $v );
1837 - continue;
1838 - }
1839 -
1840 - $val[ $k ] = str_replace( $replace, $replace_with, $v );
1841 - unset( $k, $v );
1554 + } else {
1555 + $val = str_replace( $replace, $replace_with, $val );
1842 1556 }
1843 1557
1844 1558 return $val;
1845 1559 }
@@ -1858,9 +1572,8 @@
1858 1572 */
1859 1573 private static function switch_ids_except_strings( $replace, $replace_with, $exceptions, $value ) {
1860 1574 foreach ( $exceptions as $exception ) {
1861 1575 $index = array_search( $exception, $replace, true );
1862 -
1863 1576 if ( false === $index ) {
1864 1577 continue;
1865 1578 }
1866 1579 unset( $replace[ $index ] );
@@ -1865,16 +1578,14 @@
1865 1578 }
1866 1579 unset( $replace[ $index ] );
1867 1580 unset( $replace_with[ $index ] );
1868 1581 }
1869 -
1870 - return str_replace( $replace, $replace_with, $value );
1582 + $value = str_replace( $replace, $replace_with, $value );
1583 + return $value;
1871 1584 }
1872 1585
1873 1586 /**
1874 1587 * @since 4.0
1875 - *
1876 - * @return void
1877 1588 */
1878 1589 public static function bulk_options_overlay() {
1879 1590 $prepop = array();
1880 1591 self::get_bulk_prefilled_opts( $prepop, true );
@@ -1881,11 +1592,8 @@
1881 1592
1882 1593 include FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/bulk-options-overlay.php';
1883 1594 }
1884 1595
1885 - /**
1886 - * @return array
1887 - */
1888 1596 public static function get_us_states() {
1889 1597 $states = array(
1890 1598 'AL' => 'Alabama',
1891 1599 'AK' => 'Alaska',
@@ -1942,11 +1650,8 @@
1942 1650
1943 1651 return apply_filters( 'frm_us_states', $states );
1944 1652 }
1945 1653
1946 - /**
1947 - * @return array
1948 - */
1949 1654 public static function get_countries() {
1950 1655 $countries = array(
1951 1656 __( 'Afghanistan', 'formidable' ),
1952 1657 __( 'Aland Islands', 'formidable' ),
@@ -2211,15 +1916,12 @@
2211 1916 * @since 5.0.04 Add `$include_class` param.
2212 1917 *
2213 1918 * @param array $prepop Bulk options.
2214 1919 * @param array|false $include_class Include the class in the bulk options.
2215 - *
2216 - * @return void
2217 1920 */
2218 1921 public static function get_bulk_prefilled_opts( array &$prepop, $include_class = false ) {
2219 1922 // Countries.
2220 1923 $countries = self::get_countries();
2221 -
2222 1924 if ( $include_class ) {
2223 1925 $countries['class'] = 'frm-countries-opts';
2224 1926 }
2225 1927
@@ -2228,9 +1930,8 @@
2228 1930 // State abv.
2229 1931 $states = self::get_us_states();
2230 1932 $state_abv = array_keys( $states );
2231 1933 sort( $state_abv );
2232 -
2233 1934 if ( $include_class ) {
2234 1935 $state_abv['class'] = 'frm-state-abv-opts';
2235 1936 }
2236 1937
@@ -2238,9 +1939,8 @@
2238 1939
2239 1940 // States.
2240 1941 $states = array_values( $states );
2241 1942 sort( $states );
2242 -
2243 1943 if ( $include_class ) {
2244 1944 $states['class'] = 'frm-states-opts';
2245 1945 }
2246 1946
@@ -2257,9 +1957,8 @@
2257 1957 __( '55-64', 'formidable' ),
2258 1958 __( '65 or Above', 'formidable' ),
2259 1959 __( 'Prefer Not to Answer', 'formidable' ),
2260 1960 );
2261 -
2262 1961 if ( $include_class ) {
2263 1962 $ages['class'] = 'frm-age-opts';
2264 1963 }
2265 1964
@@ -2273,9 +1972,8 @@
2273 1972 __( 'Satisfied', 'formidable' ),
2274 1973 __( 'Very Satisfied', 'formidable' ),
2275 1974 __( 'N/A', 'formidable' ),
2276 1975 );
2277 -
2278 1976 if ( $include_class ) {
2279 1977 $satisfaction['class'] = 'frm-satisfaction-opts';
2280 1978 }
2281 1979
@@ -2289,9 +1987,8 @@
2289 1987 __( 'Important', 'formidable' ),
2290 1988 __( 'Very Important', 'formidable' ),
2291 1989 __( 'N/A', 'formidable' ),
2292 1990 );
2293 -
2294 1991 if ( $include_class ) {
2295 1992 $importance['class'] = 'frm-importance-opts';
2296 1993 }
2297 1994
@@ -2305,9 +2002,8 @@
2305 2002 __( 'Agree', 'formidable' ),
2306 2003 __( 'Strongly Agree', 'formidable' ),
2307 2004 __( 'N/A', 'formidable' ),
2308 2005 );
2309 -
2310 2006 if ( $include_class ) {
2311 2007 $agreement['class'] = 'frm-agreement-opts';
2312 2008 }
2313 2009
@@ -2321,9 +2017,8 @@
2321 2017 __( 'Likely', 'formidable' ),
2322 2018 __( 'Extremely Likely', 'formidable' ),
2323 2019 __( 'N/A', 'formidable' ),
2324 2020 );
2325 -
2326 2021 if ( $include_class ) {
2327 2022 $likely['class'] = 'frm-likely-opts';
2328 2023 }
2329 2024
@@ -2338,10 +2033,8 @@
2338 2033 * @since 2.03.05
2339 2034 *
2340 2035 * @param int $selector_field_id
2341 2036 * @param array $selector_args
2342 - *
2343 - * @return void
2344 2037 */
2345 2038 public static function display_field_value_selector( $selector_field_id, $selector_args ) {
2346 2039 $field_value_selector = FrmFieldFactory::create_field_value_selector( $selector_field_id, $selector_args );
2347 2040 $field_value_selector->display();
@@ -2356,9 +2049,9 @@
2356 2049 *
2357 2050 * @return array
2358 2051 */
2359 2052 public static function convert_field_object_to_flat_array( $field ) {
2360 - $field_options = is_array( $field->field_options ) ? $field->field_options : array();
2053 + $field_options = $field->field_options;
2361 2054 $field_array = get_object_vars( $field );
2362 2055 unset( $field_array['field_options'] );
2363 2056
2364 2057 return $field_array + $field_options;
@@ -2364,43 +2057,11 @@
2364 2057 return $field_array + $field_options;
2365 2058 }
2366 2059
2367 2060 /**
2368 - * Shows add field link.
2369 - *
2370 - * @since 6.30
2371 - *
2372 - * @param array $field_type See file `classes/views/frm-forms/add_field_links.php`.
2373 - *
2374 - * @return void
2375 - */
2376 - public static function show_add_field_link( $field_type ) {
2377 - $field_label = FrmFormsHelper::get_field_link_name( $field_type );
2378 - $classes = 'frmbutton frm6 frm_t' . $field_type['key'];
2379 -
2380 - if ( ! empty( $field_type['hide'] ) ) {
2381 - $classes .= ' frm_hidden';
2382 - }
2383 - ?>
2384 -<li class="<?php echo esc_attr( $classes ); ?>" id="<?php echo esc_attr( $field_type['key'] ); ?>">
2385 - <a href="#" class="frm_add_field" title="<?php echo esc_attr( $field_label ); ?>" role="button" aria-label="<?php echo esc_attr( $field_label ); ?>">
2386 - <?php FrmAppHelper::icon_by_class( FrmFormsHelper::get_field_link_icon( $field_type ) ); ?>
2387 - <span><?php echo esc_html( $field_label ); ?></span>
2388 - <?php
2389 - if ( 'credit_card' === $field_type['key'] && ! FrmTransLiteAppHelper::payments_table_exists() ) {
2390 - FrmAppHelper::show_pill_text();
2391 - }
2392 - ?>
2393 - </a>
2394 -</li>
2395 - <?php
2396 - }
2397 -
2398 - /**
2399 2061 * @since 4.04
2400 2062 *
2401 2063 * @param array $args
2402 - *
2403 2064 * @return void
2404 2065 */
2405 2066 public static function show_add_field_buttons( $args ) {
2406 2067 $field_key = $args['field_key'];
@@ -2415,25 +2076,33 @@
2415 2076 $field_label .= ob_get_clean();
2416 2077 }
2417 2078
2418 2079 // If the individual field isn't allowed, disable it.
2419 - $link = isset( $field_type['link'] ) ? esc_url_raw( $field_type['link'] ) : '';
2080 + $run_filter = true;
2081 + $single_no_allow = ' ';
2082 + $install_data = '';
2083 + $requires = '';
2084 + $link = isset( $field_type['link'] ) ? esc_url_raw( $field_type['link'] ) : '';
2085 + $has_show_upgrade_class = strpos( $field_type['icon'], ' frm_show_upgrade' );
2086 + $show_upgrade = $has_show_upgrade_class || false !== strpos( $args['no_allow_class'], 'frm_show_upgrade' );
2420 2087
2421 - list(
2422 - $run_filter,
2423 - $single_no_allow,
2424 - $install_data,
2425 - $requires,
2426 - $has_show_upgrade_class,
2427 - $has_show_update_class,
2428 - $upgrading,
2429 - $update_addon_name
2430 - ) = self::get_field_upgrade_state( $field_type );
2088 + if ( $has_show_upgrade_class ) {
2089 + $single_no_allow .= 'frm_show_upgrade';
2090 + $field_type['icon'] = str_replace( ' frm_show_upgrade', '', $field_type['icon'] );
2091 + $run_filter = false;
2092 + if ( isset( $field_type['addon'] ) ) {
2093 + $upgrading = FrmAddonsController::install_link( $field_type['addon'] );
2094 + if ( isset( $upgrading['url'] ) ) {
2095 + $install_data = json_encode( $upgrading );
2096 + }
2097 + $requires = FrmFormsHelper::get_plan_required( $upgrading );
2098 + } elseif ( isset( $field_type['require'] ) ) {
2099 + $requires = $field_type['require'];
2100 + }
2101 + }
2431 2102
2432 - $show_upgrade = $has_show_upgrade_class || $has_show_update_class || str_contains( $args['no_allow_class'], 'frm_show_upgrade' );
2433 2103 $upgrade_label = '';
2434 2104 $upgrade_message = '';
2435 -
2436 2105 if ( $show_upgrade ) {
2437 2106 /* translators: %s: Field name */
2438 2107 $upgrade_label = sprintf( esc_html__( '%s fields', 'formidable' ), $field_name );
2439 2108
@@ -2456,41 +2125,15 @@
2456 2125 if ( ! empty( $field_type['hide'] ) ) {
2457 2126 $li_params['class'] .= ' frm_hidden';
2458 2127 }
2459 2128
2460 - if ( ! $show_upgrade && ! empty( $field_type['limit'] ) ) {
2461 - $li_params = self::update_params_with_limit_data( $li_params, $args['id'], $field_key, $field_type['limit'] );
2462 - }
2463 -
2464 2129 if ( ! empty( $field_type['upsell_image'] ) ) {
2465 2130 $li_params['data-upsell-image'] = $field_type['upsell_image'];
2466 2131 }
2467 2132
2468 - if ( ! empty( $field_type['learn-more'] ) ) {
2469 - $li_params['data-learn-more'] = FrmAppHelper::get_doc_url(
2470 - $field_type['learn-more'],
2471 - 'form-builder-add-fields',
2472 - str_contains( $field_type['learn-more'], '/' )
2473 - );
2474 - }
2475 -
2476 - if ( $has_show_update_class ) {
2477 - $li_params['data-message'] = sprintf(
2478 - // translators: %1$s: Add-on name, %2$s: Field type name.
2479 - esc_html__( 'You need a newer version of %1$s for %2$s fields.', 'formidable' ),
2480 - $update_addon_name,
2481 - $field_name
2482 - );
2483 - } elseif ( isset( $upgrading['url'] ) ) {
2484 - $li_params['data-message'] = sprintf(
2485 - // translators: %s: Field name
2486 - esc_html__( 'You already have access to %s fields, you\'ll just need to activate to start using them.', 'formidable' ),
2487 - $field_name
2488 - );
2489 - } elseif ( $upgrade_message ) {
2133 + if ( $upgrade_message ) {
2490 2134 $li_params['data-message'] = $upgrade_message;
2491 2135 }
2492 - // phpcs:disable Generic.WhiteSpace.ScopeIndent
2493 2136 ?>
2494 2137 <li <?php FrmAppHelper::array_to_html_params( $li_params, true ); ?>>
2495 2138 <?php
2496 2139 if ( $run_filter ) {
@@ -2495,130 +2138,26 @@
2495 2138 <?php
2496 2139 if ( $run_filter ) {
2497 2140 $field_label = apply_filters( 'frmpro_field_links', $field_label, $args['id'], $field_key );
2498 2141 }
2499 -
2500 - FrmAppHelper::kses_echo( $field_label, array( 'a', 'i', 'span', 'use', 'svg' ) );
2142 + echo FrmAppHelper::kses( $field_label, array( 'a', 'i', 'span', 'use', 'svg' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2501 2143 ?>
2502 2144 </li>
2503 2145 <?php
2504 - // phpcs:enable Generic.WhiteSpace.ScopeIndent
2505 2146 }
2506 2147
2507 2148 /**
2508 - * Parse the upgrade and update flags from a field type's icon class.
2509 - *
2510 - * @since 6.29
2511 - *
2512 - * @param array $field_type Field type configuration, modified in place to strip icon flag classes.
2513 - *
2514 - * @return array Upgrade and update state values for the field button, in positional order.
2515 - */
2516 - private static function get_field_upgrade_state( &$field_type ) {
2517 - $single_no_allow = ' ';
2518 - $run_filter = true;
2519 - $has_show_upgrade_class = false;
2520 - $has_show_update_class = false;
2521 - $install_data = '';
2522 - $requires = '';
2523 - $upgrading = array();
2524 - $update_addon_name = '';
2525 -
2526 - if ( isset( $field_type['icon'] ) ) {
2527 - $has_show_upgrade_class = str_contains( $field_type['icon'], ' frm_show_upgrade' );
2528 - $has_show_update_class = str_contains( $field_type['icon'], ' frm_show_update' );
2529 - }
2530 -
2531 - if ( $has_show_upgrade_class ) {
2532 - $single_no_allow .= 'frm_show_upgrade';
2533 - $field_type['icon'] = str_replace( ' frm_show_upgrade', '', $field_type['icon'] );
2534 - $run_filter = false;
2535 -
2536 - if ( isset( $field_type['addon'] ) ) {
2537 - $upgrading = FrmAddonsController::install_link( $field_type['addon'] );
2538 -
2539 - if ( isset( $upgrading['url'] ) ) {
2540 - $install_data = json_encode( $upgrading );
2541 - }
2542 -
2543 - $requires = FrmFormsHelper::get_plan_required( $upgrading );
2544 - } elseif ( isset( $field_type['require'] ) ) {
2545 - $requires = $field_type['require'];
2546 - }
2547 - }
2548 -
2549 - if ( $has_show_update_class ) {
2550 - $single_no_allow .= ' frm_show_update';
2551 - $field_type['icon'] = str_replace( ' frm_show_update', '', $field_type['icon'] );
2552 - $run_filter = false;
2553 - $addon_slug = $field_type['addon'] ?? 'pro';
2554 -
2555 - if ( 'pro' === $addon_slug ) {
2556 - $update_addon_name = __( 'Formidable Pro', 'formidable' );
2557 - } else {
2558 - $addon_data = FrmAddonsController::get_addon( $addon_slug );
2559 - $update_addon_name = $addon_data && ! empty( $addon_data['title'] ) ? $addon_data['title'] : ucfirst( $addon_slug );
2560 - }
2561 -
2562 - $install_data = FrmAddonsController::get_update_install_data( $addon_slug );
2563 - }
2564 -
2565 - return array(
2566 - $run_filter,
2567 - $single_no_allow,
2568 - $install_data,
2569 - $requires,
2570 - $has_show_upgrade_class,
2571 - $has_show_update_class,
2572 - $upgrading,
2573 - $update_addon_name,
2574 - );
2575 - }
2576 -
2577 - /**
2578 - * Updates the params with limit data (the data-limit attribute, and possibly the frm_at_limit class).
2579 - * Some field types are limited to a certain number per form, including coupon fields.
2580 - *
2581 - * @since 6.27
2582 - *
2583 - * @param array $li_params The params.
2584 - * @param int $form_id The form ID.
2585 - * @param string $field_type The field type.
2586 - * @param int $limit The limit.
2587 - *
2588 - * @return array The updated params.
2589 - */
2590 - private static function update_params_with_limit_data( $li_params, $form_id, $field_type, $limit ) {
2591 - $fields_in_form = FrmDb::get_count(
2592 - 'frm_fields',
2593 - array(
2594 - 'form_id' => $form_id,
2595 - 'type' => $field_type,
2596 - )
2597 - );
2598 -
2599 - if ( $fields_in_form >= $limit ) {
2600 - $li_params['class'] .= ' frm_at_limit';
2601 - }
2602 -
2603 - $li_params['data-limit'] = $limit;
2604 -
2605 - return $li_params;
2606 - }
2607 -
2608 - /**
2609 2149 * Shows Display format option.
2610 2150 *
2611 2151 * @since 5.0.04
2612 2152 *
2613 2153 * @param array $field Field data.
2614 - *
2615 - * @return void
2616 2154 */
2617 2155 public static function show_radio_display_format( $field ) {
2618 2156 $options = self::get_display_format_options( $field );
2619 - $args = self::get_display_format_args( $field, $options );
2620 2157
2158 + $args = self::get_display_format_args( $field, $options );
2159 +
2621 2160 include FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/radio-display-format.php';
2622 2161 }
2623 2162
2624 2163 /**
@@ -2640,9 +2179,9 @@
2640 2179 'text' => __( 'Images', 'formidable' ),
2641 2180 'svg' => 'frm_image_as_option',
2642 2181 'addon' => 'pro',
2643 2182 'upgrade' => __( 'Image Options', 'formidable' ),
2644 - 'message' => __( 'Show images instead of radio buttons or check boxes. This is ideal for polls, surveys, segmenting questionnaires and more.', 'formidable' ) . '<img src="' . esc_url( FrmAppHelper::plugin_url() ) . '/images/image-options.png" />', // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
2183 + 'message' => __( 'Show images instead of radio buttons or check boxes. This is ideal for polls, surveys, segmenting questionnaires and more.', 'formidable' ) . '<img src="' . esc_url( FrmAppHelper::plugin_url() ) . '/images/image-options.png" />',
2645 2184 'content' => 'image-options',
2646 2185 ),
2647 2186 'buttons' => array(
2648 2187 'text' => __( 'Buttons', 'formidable' ),
@@ -2653,12 +2192,8 @@
2653 2192 'content' => 'button-options',
2654 2193 ),
2655 2194 );
2656 2195
2657 - if ( 'product' === FrmField::get_field_type( $field ) ) {
2658 - unset( $options['buttons'] );
2659 - }
2660 -
2661 2196 /**
2662 2197 * Allows modifying the options of Display format setting of Radio field.
2663 2198 *
2664 2199 * @since 5.0.04
@@ -2665,9 +2200,11 @@
2665 2200 *
2666 2201 * @param array $options Options.
2667 2202 * @param array $field
2668 2203 */
2669 - return apply_filters( 'frm_' . $field['type'] . '_display_format_options', $options, $field );
2204 + $options = apply_filters( 'frm_' . $field['type'] . '_display_format_options', $options, $field );
2205 +
2206 + return $options;
2670 2207 }
2671 2208
2672 2209 /**
2673 2210 * Gets display format arguments to pass to the images_dropdown() method.
@@ -2675,9 +2212,8 @@
2675 2212 * @since 5.0.04
2676 2213 *
2677 2214 * @param array $field Field data.
2678 2215 * @param array $options Options array.
2679 - *
2680 2216 * @return array
2681 2217 */
2682 2218 public static function get_display_format_args( $field, $options ) {
2683 2219 $args = array(
@@ -2703,13 +2239,8 @@
2703 2239 }
2704 2240
2705 2241 /**
2706 2242 * @since 5.0.04
2707 - *
2708 - * @param array $options Options.
2709 - * @param array $args Arguments.
2710 - *
2711 - * @return void
2712 2243 */
2713 2244 private static function fill_image_setting_options( $options, &$args ) {
2714 2245 foreach ( $options as $key => $option ) {
2715 2246 $args['options'][ $key ] = $option;
@@ -2719,9 +2250,8 @@
2719 2250 }
2720 2251
2721 2252 unset( $args['options'][ $key ]['addon'] );
2722 2253 $fill = array( 'upgrade', 'message', 'content' );
2723 -
2724 2254 foreach ( $fill as $f ) {
2725 2255 unset( $args['options'][ $key ][ $f ], $f );
2726 2256 }
2727 2257 }
@@ -2729,10 +2259,8 @@
2729 2259
2730 2260 /**
2731 2261 * @since 5.0.04
2732 2262 *
2733 - * @param array $option Option.
2734 - *
2735 2263 * @return array
2736 2264 */
2737 2265 private static function fill_image_setting_addon_link( $option ) {
2738 2266 $custom_attrs = array(
@@ -2743,9 +2271,8 @@
2743 2271 // translators: Add-on name.
2744 2272 $custom_attrs['data-upgrade'] = sprintf( __( 'Formidable %s', 'formidable' ), ucwords( $option['addon'] ) );
2745 2273
2746 2274 $fill = array( 'upgrade', 'message', 'content' );
2747 -
2748 2275 foreach ( $fill as $f ) {
2749 2276 if ( isset( $option[ $f ] ) ) {
2750 2277 $custom_attrs[ 'data-' . $f ] = $option[ $f ];
2751 2278 }
@@ -2755,10 +2282,15 @@
2755 2282 return $custom_attrs;
2756 2283 }
2757 2284
2758 2285 $upgrading = FrmAddonsController::install_link( $option['addon'] );
2286 + if ( isset( $upgrading['url'] ) ) {
2287 + $install_data = wp_json_encode( $upgrading );
2288 + } else {
2289 + $install_data = '';
2290 + }
2759 2291
2760 - $custom_attrs['data-oneclick'] = isset( $upgrading['url'] ) ? wp_json_encode( $upgrading ) : '';
2292 + $custom_attrs['data-oneclick'] = $install_data;
2761 2293 $custom_attrs['data-requires'] = FrmFormsHelper::get_plan_required( $upgrading );
2762 2294
2763 2295 return $custom_attrs;
2764 2296 }
@@ -2771,9 +2303,8 @@
2771 2303 * @since 6.2
2772 2304 *
2773 2305 * @param mixed $value
2774 2306 * @param string $field_type
2775 - *
2776 2307 * @return void
2777 2308 */
2778 2309 public static function prepare_field_value( &$value, $field_type ) {
2779 2310 $field_object = FrmFieldFactory::get_field_type( $field_type );
@@ -2784,9 +2315,8 @@
2784 2315 * @since 6.8
2785 2316 *
2786 2317 * @param int|string $form_id
2787 2318 * @param array $field_ids If this is not empty, the results will be filtered by field id.
2788 - *
2789 2319 * @return array
2790 2320 */
2791 2321 public static function get_draft_field_results( $form_id, $field_ids = array() ) {
2792 2322 if ( FrmAppHelper::pro_is_installed() ) {
@@ -2823,178 +2353,11 @@
2823 2353 *
2824 2354 * @since 6.8
2825 2355 *
2826 2356 * @param int|string $form_id
2827 - *
2828 2357 * @return array
2829 2358 */
2830 2359 public static function get_all_draft_field_ids( $form_id ) {
2831 2360 $draft_field_rows = self::get_draft_field_results( $form_id );
2832 2361 return wp_list_pluck( $draft_field_rows, 'id' );
2833 - }
2834 -
2835 - /**
2836 - * Render AI generate options button.
2837 - *
2838 - * @since 6.24
2839 - *
2840 - * @param array $args Field arguments.
2841 - * @param bool $should_hide_bulk_edit Whether to hide bulk edit.
2842 - *
2843 - * @return void
2844 - */
2845 - public static function render_ai_generate_options_button( $args, $should_hide_bulk_edit = false ) {
2846 - $attributes = array(
2847 - 'type' => 'button',
2848 - );
2849 -
2850 - $attributes['class'] = ! empty( $args['class'] ) ? $args['class'] : self::get_ai_generate_options_button_class();
2851 -
2852 - if ( $should_hide_bulk_edit ) {
2853 - $attributes['class'] .= ' frm-force-hidden';
2854 - }
2855 -
2856 - $data = FrmAppHelper::get_upgrade_data_params(
2857 - 'ai',
2858 - array(
2859 - 'requires' => 'Business',
2860 - 'upgrade' => $args['upgrade_text'] ?? __( 'Generate options with AI', 'formidable' ),
2861 - 'medium' => 'builder',
2862 - 'content' => 'generate-options-with-ai',
2863 - ),
2864 - true
2865 - );
2866 -
2867 - if ( in_array( FrmAddonsController::license_type(), array( 'elite', 'business' ), true ) && 'active' === $data['plugin-status'] ) {
2868 - // Backwards compatibility "@since 6.24".
2869 - if ( method_exists( 'FrmAIAppController', 'get_ai_generated_options_summary' ) ) {
2870 - $attributes['class'] .= ' frm-ai-generate-options-modal-trigger';
2871 - $attributes['data-fid'] = $args['likert_id'] ?? $args['field']['id'];
2872 - } else {
2873 - $data = array(
2874 - 'modal-title' => __( 'Generate options with AI', 'formidable' ),
2875 - 'modal-content' => __( 'Update the Formidable AI add-on to the last version to use this feature.', 'formidable' ),
2876 - );
2877 - }
2878 - }
2879 -
2880 - if ( empty( $attributes['data-fid'] ) ) {
2881 - unset( $data['plugin-status'] );
2882 -
2883 - foreach ( $data as $key => $value ) {
2884 - $attributes[ 'data-' . $key ] = $value;
2885 - }
2886 - }
2887 -
2888 - include FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/generate-options-with-ai.php';
2889 - }
2890 -
2891 - /**
2892 - * Get AI generate options button class.
2893 - *
2894 - * @since 6.24
2895 - *
2896 - * @return string Button class.
2897 - */
2898 - private static function get_ai_generate_options_button_class() {
2899 - return implode(
2900 - ' ',
2901 - array(
2902 - 'frm_form_field',
2903 - 'frm6',
2904 - 'frm6_followed',
2905 - 'frm-h-stack',
2906 - 'button',
2907 - 'frm-button-secondary',
2908 - 'frm-button-gradient',
2909 - 'frm-rounded-6',
2910 - 'frm-max-w-fit',
2911 - 'frm-font-normal',
2912 - 'frm-py-2xs',
2913 - 'frm-px-xs',
2914 - 'frm-mt-xs',
2915 - 'frm-mb-12',
2916 - )
2917 - );
2918 - }
2919 -
2920 - /**
2921 - * Checks if the field choice should be hidden due to choice limit being reached.
2922 - *
2923 - * @since 6.28
2924 - *
2925 - * @param string $choice_key
2926 - * @param array $field
2927 - *
2928 - * @return bool
2929 - */
2930 - public static function should_hide_field_choice( $choice_key, $field ) {
2931 - /**
2932 - * @since 6.28
2933 - *
2934 - * @param bool $hide_field_choice
2935 - * @param string $choice_key
2936 - * @param array $field
2937 - */
2938 - return (bool) apply_filters( 'frm_hide_field_choice', false, $choice_key, $field );
2939 - }
2940 -
2941 - /**
2942 - * @since 6.28
2943 - *
2944 - * @param array $field
2945 - *
2946 - * @return bool
2947 - */
2948 - public static function should_skip_rendering_choices_for_field( $field ) {
2949 - /**
2950 - * @since 6.28
2951 - *
2952 - * @param bool $skip_rendering_options_for_field
2953 - * @param array $field
2954 - */
2955 - return (bool) apply_filters( 'frm_should_skip_rendering_choices_for_field', false, $field );
2956 - }
2957 -
2958 - /**
2959 - * Determine if 'disabled' attribute should be echoed in a field choice's HTML.
2960 - *
2961 - * @since 6.28
2962 - *
2963 - * @param string $choice_key
2964 - * @param bool $is_selected_choice
2965 - * @param array $field
2966 - *
2967 - * @return bool
2968 - */
2969 - public static function should_disable_choice( $choice_key, $is_selected_choice, $field ) {
2970 - /**
2971 - * @since 6.28
2972 - *
2973 - * @param bool $echo_disabled_attribute
2974 - * @param string $choice_key
2975 - * @param bool $is_selected_choice
2976 - * @param array $field
2977 - */
2978 - return (bool) apply_filters( 'frm_disable_choice', false, $choice_key, $is_selected_choice, $field );
2979 - }
2980 -
2981 - /**
2982 - * @since 6.28
2983 - *
2984 - * @param array $field
2985 - * @param string $choice_key
2986 - *
2987 - * @return void
2988 - */
2989 - public static function after_choice_input( $field, $choice_key ) {
2990 - /**
2991 - * Allows adding content after checkbox, radio button, or dropdown fields.
2992 - *
2993 - * @since 6.28
2994 - *
2995 - * @param array $field The field data.
2996 - * @param string $choice_key The option key.
2997 - */
2998 - do_action( 'frm_after_choice_input', $field, $choice_key );
2999 2362 }
3000 2363 }