PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.16
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.16
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 +223 -865 6.336.16 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 );
@@ -1170,21 +942,14 @@
1170 942 * Prevent shortcodes in fields from being processed
1171 943 *
1172 944 * @since 3.01.02
1173 945 *
1174 - * @param array $atts Includes entry object.
1175 - * @param string|null $value
1176 - *
1177 - * @return void
946 + * @param array $atts Includes entry object.
947 + * @param string $value
1178 948 */
1179 949 public static function sanitize_embedded_shortcodes( $atts, &$value ) {
1180 - if ( is_null( $value ) ) {
1181 - return;
1182 - }
1183 -
1184 950 $atts['value'] = $value;
1185 951 $should_sanitize = apply_filters( 'frm_sanitize_shortcodes', true, $atts );
1186 -
1187 952 if ( $should_sanitize ) {
1188 953 $value = str_replace( '[', '&#91;', $value );
1189 954 }
1190 955 }
@@ -1252,10 +1017,9 @@
1252 1017 * @return string|null
1253 1018 */
1254 1019 private static function get_field_shortcode_value( $atts ) {
1255 1020 $field = FrmField::getOne( $atts['tag'] );
1256 -
1257 - if ( ! $field ) {
1021 + if ( empty( $field ) ) {
1258 1022 return null;
1259 1023 }
1260 1024
1261 1025 if ( isset( $atts['show'] ) && $atts['show'] === 'field_label' ) {
@@ -1264,16 +1028,14 @@
1264 1028 $replace_with = $field->description;
1265 1029 } else {
1266 1030 $replace_with = FrmEntryMeta::get_meta_value( $atts['entry'], $field->id );
1267 1031 $string_value = $replace_with;
1268 -
1269 1032 if ( is_array( $replace_with ) ) {
1270 - $sep = $atts['sep'] ?? ', ';
1271 - $string_value = FrmAppHelper::safe_implode( $sep, $replace_with );
1033 + $sep = isset( $atts['sep'] ) ? $atts['sep'] : ', ';
1034 + $string_value = implode( $sep, $replace_with );
1272 1035 }
1273 1036
1274 - // phpcs:ignore Universal.Operators.StrictComparisons
1275 - if ( ! $string_value && $string_value != '0' ) {
1037 + if ( empty( $string_value ) && $string_value != '0' ) {
1276 1038 $replace_with = '';
1277 1039 } else {
1278 1040 $atts['entry_id'] = $atts['entry']->id;
1279 1041 $atts['entry_key'] = $atts['entry']->item_key;
@@ -1278,9 +1040,9 @@
1278 1040 $atts['entry_id'] = $atts['entry']->id;
1279 1041 $atts['entry_key'] = $atts['entry']->item_key;
1280 1042 $replace_with = self::get_display_value( $replace_with, $field, $atts );
1281 1043 }
1282 - }//end if
1044 + }
1283 1045
1284 1046 return $replace_with;
1285 1047 }
1286 1048
@@ -1287,13 +1049,8 @@
1287 1049 /**
1288 1050 * Get the value to replace a few standard shortcodes
1289 1051 *
1290 1052 * @since 2.0
1291 - *
1292 - * @param string $tag
1293 - * @param array $atts
1294 - * @param bool $return_array
1295 - *
1296 1053 * @return string
1297 1054 */
1298 1055 public static function dynamic_default_values( $tag, $atts = array(), $return_array = false ) {
1299 1056 $new_value = '';
@@ -1328,12 +1085,8 @@
1328 1085 /**
1329 1086 * Process the [get] shortcode
1330 1087 *
1331 1088 * @since 2.0
1332 - *
1333 - * @param array $atts
1334 - * @param bool $return_array
1335 - *
1336 1089 * @return array|string
1337 1090 */
1338 1091 public static function process_get_shortcode( $atts, $return_array = false ) {
1339 1092 if ( ! isset( $atts['param'] ) ) {
@@ -1339,9 +1092,9 @@
1339 1092 if ( ! isset( $atts['param'] ) ) {
1340 1093 return '';
1341 1094 }
1342 1095
1343 - if ( str_contains( $atts['param'], '&#91;' ) ) {
1096 + if ( strpos( $atts['param'], '&#91;' ) ) {
1344 1097 $atts['param'] = str_replace( '&#91;', '[', $atts['param'] );
1345 1098 $atts['param'] = str_replace( '&#93;', ']', $atts['param'] );
1346 1099 }
1347 1100
@@ -1347,34 +1100,28 @@
1347 1100
1348 1101 $new_value = FrmAppHelper::get_param( $atts['param'], '', 'get', 'sanitize_text_field' );
1349 1102 $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] );
1350 1103
1351 - // phpcs:ignore Universal.Operators.StrictComparisons
1352 1104 if ( $new_value == '' ) {
1353 1105 if ( ! isset( $atts['prev_val'] ) ) {
1354 1106 $atts['prev_val'] = '';
1355 1107 }
1356 1108
1357 - $new_value = $atts['default'] ?? $atts['prev_val'];
1109 + $new_value = isset( $atts['default'] ) ? $atts['default'] : $atts['prev_val'];
1358 1110 }
1359 1111
1360 1112 if ( is_array( $new_value ) && ! $return_array ) {
1361 - return implode( ', ', $new_value );
1113 + $new_value = implode( ', ', $new_value );
1362 1114 }
1363 1115
1364 1116 return $new_value;
1365 1117 }
1366 1118
1367 - /**
1368 - * @param mixed $value
1369 - * @param object $field
1370 - * @param array $atts
1371 - *
1372 - * @return mixed
1373 - */
1374 1119 public static function get_display_value( $value, $field, $atts = array() ) {
1120 +
1375 1121 $value = apply_filters( 'frm_get_' . $field->type . '_display_value', $value, $field, $atts );
1376 1122 $value = apply_filters( 'frm_get_display_value', $value, $field, $atts );
1123 +
1377 1124 $value = self::get_unfiltered_display_value( compact( 'value', 'field', 'atts' ) );
1378 1125
1379 1126 return apply_filters( 'frm_display_value', $value, $field, $atts );
1380 1127 }
@@ -1380,15 +1127,13 @@
1380 1127 }
1381 1128
1382 1129 /**
1383 1130 * @param array $atts Includes value, field, and atts.
1384 - *
1385 - * @return mixed
1386 1131 */
1387 1132 public static function get_unfiltered_display_value( $atts ) {
1388 1133 $value = $atts['value'];
1389 1134 $field = $atts['field'];
1390 - $atts = $atts['atts'] ?? $atts;
1135 + $atts = isset( $atts['atts'] ) ? $atts['atts'] : $atts;
1391 1136
1392 1137 if ( is_array( $field ) ) {
1393 1138 $field = $field['id'];
1394 1139 }
@@ -1402,12 +1147,8 @@
1402 1147 * Get a value from the user profile from the user ID
1403 1148 *
1404 1149 * @since 3.0
1405 1150 *
1406 - * @param int|string $user_id
1407 - * @param string $user_info
1408 - * @param array $args
1409 - *
1410 1151 * @return string
1411 1152 */
1412 1153 public static function get_user_display_name( $user_id, $user_info = 'display_name', $args = array() ) {
1413 1154 $defaults = array(
@@ -1416,8 +1157,9 @@
1416 1157 'size' => 96,
1417 1158 );
1418 1159
1419 1160 $args = wp_parse_args( $args, $defaults );
1161 +
1420 1162 $user = get_userdata( $user_id );
1421 1163 $info = '';
1422 1164
1423 1165 if ( $user ) {
@@ -1425,18 +1167,18 @@
1425 1167 $info = get_avatar( $user_id, $args['size'] );
1426 1168 } elseif ( $user_info === 'author_link' ) {
1427 1169 $info = get_author_posts_url( $user_id );
1428 1170 } else {
1429 - $info = $user->$user_info ?? '';
1171 + $info = isset( $user->$user_info ) ? $user->$user_info : '';
1430 1172 }
1431 1173
1432 - if ( 'display_name' === $user_info && ! $info && ! $args['blank'] ) {
1174 + if ( 'display_name' === $user_info && empty( $info ) && ! $args['blank'] ) {
1433 1175 $info = $user->user_login;
1434 1176 }
1435 1177 }
1436 1178
1437 1179 if ( $args['link'] ) {
1438 - return '<a href="' . esc_url( admin_url( 'user-edit.php?user_id=' . $user_id ) ) . '">' . $info . '</a>';
1180 + $info = '<a href="' . esc_url( admin_url( 'user-edit.php?user_id=' . $user_id ) ) . '">' . $info . '</a>';
1439 1181 }
1440 1182
1441 1183 return $info;
1442 1184 }
@@ -1442,9 +1184,8 @@
1442 1184 }
1443 1185
1444 1186 /**
1445 1187 * @param string $type
1446 - *
1447 1188 * @return array
1448 1189 */
1449 1190 public static function get_field_types( $type ) {
1450 1191 $single_input = self::single_input_fields();
@@ -1459,9 +1200,11 @@
1459 1200 } elseif ( isset( $field_selection[ $type ] ) ) {
1460 1201 $field_types[ $type ] = $field_selection[ $type ];
1461 1202 }
1462 1203
1463 - return apply_filters( 'frm_switch_field_types', $field_types, compact( 'type', 'field_selection' ) );
1204 + $field_types = apply_filters( 'frm_switch_field_types', $field_types, compact( 'type', 'field_selection' ) );
1205 +
1206 + return $field_types;
1464 1207 }
1465 1208
1466 1209 /**
1467 1210 * Get a list of all fields that use a single value input.
@@ -1466,10 +1209,8 @@
1466 1209 /**
1467 1210 * Get a list of all fields that use a single value input.
1468 1211 *
1469 1212 * @since 4.0
1470 - *
1471 - * @return array
1472 1213 */
1473 1214 public static function single_input_fields() {
1474 1215 $fields = array(
1475 1216 'text',
@@ -1483,9 +1224,8 @@
1483 1224 'hidden',
1484 1225 'time',
1485 1226 'tag',
1486 1227 'password',
1487 - 'gdpr',
1488 1228 );
1489 1229 return apply_filters( 'frm_single_input_fields', $fields );
1490 1230 }
1491 1231
@@ -1492,9 +1232,8 @@
1492 1232 /**
1493 1233 * @param string[] $inputs
1494 1234 * @param array $fields
1495 1235 * @param array $field_types
1496 - *
1497 1236 * @return void
1498 1237 */
1499 1238 private static function field_types_for_input( $inputs, $fields, &$field_types ) {
1500 1239 foreach ( $inputs as $input ) {
@@ -1515,9 +1254,9 @@
1515 1254 *
1516 1255 * @return bool Returns true if current field option is an "Other" option
1517 1256 */
1518 1257 public static function is_other_opt( $opt_key ) {
1519 - return $opt_key && str_starts_with( $opt_key, 'other_' );
1258 + return $opt_key && strpos( $opt_key, 'other_' ) === 0;
1520 1259 }
1521 1260
1522 1261 /**
1523 1262 * Get value that belongs in "Other" text box
@@ -1524,19 +1263,18 @@
1524 1263 *
1525 1264 * @since 2.0.6
1526 1265 *
1527 1266 * @param array $args
1528 - *
1529 - * @return string
1530 1267 */
1531 - public static function get_other_val( $args ) { // phpcs:ignore SlevomatCodingStandard.Complexity.Cognitive.ComplexityTooHigh
1532 - $defaults = array(
1268 + public static function get_other_val( $args ) {
1269 + $defaults = array(
1533 1270 'opt_key' => 0,
1534 1271 'field' => array(),
1535 1272 'parent' => false,
1536 1273 'pointer' => false,
1537 1274 );
1538 - $args = wp_parse_args( $args, $defaults );
1275 + $args = wp_parse_args( $args, $defaults );
1276 +
1539 1277 $opt_key = $args['opt_key'];
1540 1278 $field = $args['field'];
1541 1279 $parent = $args['parent'];
1542 1280 $pointer = $args['pointer'];
@@ -1542,9 +1280,9 @@
1542 1280 $pointer = $args['pointer'];
1543 1281 $other_val = '';
1544 1282
1545 1283 // 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
1284 + // check if the value belongs in the current "Other" option text field
1547 1285 if ( ! self::is_other_opt( $opt_key ) || ! FrmField::is_option_true( $field, 'value' ) ) {
1548 1286 return $other_val;
1549 1287 }
1550 1288
@@ -1551,12 +1289,12 @@
1551 1289 // Check posted vals before checking saved values
1552 1290 // For fields inside repeating sections - note, don't check if $pointer is true because it will often be zero
1553 1291 if ( $parent && isset( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
1554 1292 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
1293 + // phpcs:ignore WordPress.Security.NonceVerification.Missing
1294 + $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 1295 } else {
1557 - // phpcs:ignore WordPress.Security.NonceVerification.Missing
1558 - $other_val = sanitize_text_field( wp_unslash( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] ) );
1296 + $other_val = sanitize_text_field( wp_unslash( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
1559 1297 }
1560 1298
1561 1299 return $other_val;
1562 1300 }
@@ -1564,9 +1302,9 @@
1564 1302 if ( isset( $field['id'] ) && isset( $_POST['item_meta']['other'][ $field['id'] ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
1565 1303 // For normal fields
1566 1304
1567 1305 if ( FrmField::is_field_with_multiple_values( $field ) ) {
1568 - // phpcs:ignore WordPress.Security.NonceVerification.Missing, SlevomatCodingStandard.Files.LineLength.LineTooLong
1306 + // phpcs:ignore WordPress.Security.NonceVerification.Missing
1569 1307 $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 1308 } else {
1571 1309 $other_val = sanitize_text_field( wp_unslash( $_POST['item_meta']['other'][ $field['id'] ] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
1572 1310 }
@@ -1577,9 +1315,8 @@
1577 1315 // For checkboxes
1578 1316 if ( $field['type'] === 'checkbox' && is_array( $field['value'] ) ) {
1579 1317 // Check if there is an "other" val in saved value and make sure the
1580 1318 // "other" val is not equal to the Other checkbox option
1581 - // phpcs:ignore Universal.Operators.StrictComparisons
1582 1319 if ( isset( $field['value'][ $opt_key ] ) && $field['options'][ $opt_key ] != $field['value'][ $opt_key ] ) {
1583 1320 $other_val = $field['value'][ $opt_key ];
1584 1321 }
1585 1322 } else {
@@ -1586,30 +1323,26 @@
1586 1323 /**
1587 1324 * For radio buttons and dropdowns
1588 1325 * Check if saved value equals any of the options. If not, set it as the other value.
1589 1326 */
1590 - foreach ( $field['options'] as $opt_val ) {
1327 + foreach ( $field['options'] as $opt_key => $opt_val ) {
1591 1328 $temp_val = is_array( $opt_val ) ? $opt_val['value'] : $opt_val;
1592 -
1593 1329 // Multi-select dropdowns - key is not preserved
1594 1330 if ( is_array( $field['value'] ) ) {
1595 - // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict
1596 1331 $o_key = array_search( $temp_val, $field['value'] );
1597 -
1598 1332 if ( isset( $field['value'][ $o_key ] ) ) {
1599 1333 unset( $field['value'][ $o_key ], $o_key );
1600 1334 }
1601 - } elseif ( $temp_val == $field['value'] ) { // phpcs:ignore Universal.Operators.StrictComparisons
1335 + } elseif ( $temp_val == $field['value'] ) {
1602 1336 // For radio and regular dropdowns
1603 1337 return '';
1604 1338 } else {
1605 1339 $other_val = $field['value'];
1606 1340 }
1607 - unset( $opt_val, $temp_val );
1341 + unset( $opt_key, $opt_val, $temp_val );
1608 1342 }
1609 -
1610 1343 // For multi-select dropdowns only
1611 - if ( is_array( $field['value'] ) && $field['value'] ) {
1344 + if ( is_array( $field['value'] ) && ! empty( $field['value'] ) ) {
1612 1345 $other_val = reset( $field['value'] );
1613 1346 }
1614 1347 }//end if
1615 1348
@@ -1625,9 +1358,9 @@
1625 1358 * @param array $args Should include field, opt_key and field name.
1626 1359 * @param bool $other_opt
1627 1360 * @param string $checked
1628 1361 *
1629 - * @return array Other args.
1362 + * @return array $other_args
1630 1363 */
1631 1364 public static function prepare_other_input( $args, &$other_opt, &$checked ) {
1632 1365 $other_args = array(
1633 1366 'name' => '',
@@ -1662,13 +1395,10 @@
1662 1395 }
1663 1396
1664 1397 /**
1665 1398 * @since 2.0.6
1666 - *
1667 1399 * @param array $args
1668 1400 * @param array $other_args
1669 - *
1670 - * @return void
1671 1401 */
1672 1402 private static function set_other_name( $args, &$other_args ) {
1673 1403 // Set up name for other field
1674 1404 $other_args['name'] = str_replace( '[]', '', $args['field_name'] );
@@ -1685,13 +1415,10 @@
1685 1415 /**
1686 1416 * Find the parent and pointer, and get text for "other" text field
1687 1417 *
1688 1418 * @since 2.0.6
1689 - *
1690 1419 * @param array $args
1691 1420 * @param array $other_args
1692 - *
1693 - * @return void
1694 1421 */
1695 1422 private static function set_other_value( $args, &$other_args ) {
1696 1423 $parent = '';
1697 1424 $pointer = '';
@@ -1719,12 +1446,9 @@
1719 1446 /**
1720 1447 * If this field includes an other option, show it
1721 1448 *
1722 1449 * @since 2.0.6
1723 - *
1724 1450 * @param array $args
1725 - *
1726 - * @return void
1727 1451 */
1728 1452 public static function include_other_input( $args ) {
1729 1453 if ( ! $args['other_opt'] ) {
1730 1454 return;
@@ -1730,15 +1454,13 @@
1730 1454 return;
1731 1455 }
1732 1456
1733 1457 $classes = array( 'frm_other_input' );
1734 -
1735 - if ( ! $args['checked'] || trim( $args['checked'] ) === '' ) {
1736 - // Hide the field if the other option is not selected
1458 + if ( ! $args['checked'] || trim( $args['checked'] ) == '' ) {
1459 + // hide the field if the other option is not selected
1737 1460 $classes[] = 'frm_pos_none';
1738 1461 }
1739 -
1740 - if ( $args['field']['type'] === 'select' && ! empty( $args['field']['multiple'] ) ) {
1462 + if ( $args['field']['type'] === 'select' && $args['field']['multiple'] ) {
1741 1463 $classes[] = 'frm_other_full';
1742 1464 }
1743 1465
1744 1466 // Set up HTML ID for Other field
@@ -1743,11 +1465,10 @@
1743 1465
1744 1466 // Set up HTML ID for Other field
1745 1467 $other_id = self::get_other_field_html_id( $args['field']['type'], $args['html_id'], $args['opt_key'] );
1746 1468
1747 - $label = $args['opt_label'] ?? $args['field']['name'];
1469 + $label = isset( $args['opt_label'] ) ? $args['opt_label'] : $args['field']['name'];
1748 1470
1749 - // phpcs:disable Generic.WhiteSpace.ScopeIndent
1750 1471 echo '<label for="' . esc_attr( $other_id ) . '" class="frm_screen_reader frm_hidden">' .
1751 1472 esc_html( $label ) .
1752 1473 '</label>' .
1753 1474 '<input type="text" id="' . esc_attr( $other_id ) . '" class="' . esc_attr( implode( ' ', $classes ) ) . '" ' .
@@ -1752,9 +1473,8 @@
1752 1473 '</label>' .
1753 1474 '<input type="text" id="' . esc_attr( $other_id ) . '" class="' . esc_attr( implode( ' ', $classes ) ) . '" ' .
1754 1475 ( $args['read_only'] ? ' readonly="readonly" disabled="disabled"' : '' ) .
1755 1476 ' name="' . esc_attr( $args['name'] ) . '" value="' . esc_attr( $args['value'] ) . '" />';
1756 - // phpcs:enable Generic.WhiteSpace.ScopeIndent
1757 1477 }
1758 1478
1759 1479 /**
1760 1480 * Get the HTML id for an "Other" text field
@@ -1765,9 +1485,9 @@
1765 1485 * @param string $type Field type.
1766 1486 * @param string $html_id
1767 1487 * @param bool|string $opt_key
1768 1488 *
1769 - * @return string Other ID.
1489 + * @return string $other_id
1770 1490 */
1771 1491 public static function get_other_field_html_id( $type, $html_id, $opt_key = false ) {
1772 1492 $other_id = $html_id;
1773 1493
@@ -1779,21 +1499,17 @@
1779 1499 if ( $opt_key !== false ) {
1780 1500 $other_id .= '-' . $opt_key;
1781 1501 }
1782 1502
1783 - return $other_id . '-otext';
1503 + $other_id .= '-otext';
1504 +
1505 + return $other_id;
1784 1506 }
1785 1507
1786 - /**
1787 - * @param array|string $val
1788 - *
1789 - * @return array|string
1790 - */
1791 1508 public static function switch_field_ids( $val ) {
1792 1509 global $frm_duplicate_ids;
1793 1510 $replace = array();
1794 1511 $replace_with = array();
1795 -
1796 1512 foreach ( (array) $frm_duplicate_ids as $old => $new ) {
1797 1513 $replace[] = '[if ' . $old . ']';
1798 1514 $replace_with[] = '[if ' . $new . ']';
1799 1515 $replace[] = '[if ' . $old . ' ';
@@ -1815,31 +1531,24 @@
1815 1531 $replace[] = 'field_id="' . $old . '"';
1816 1532 $replace_with[] = 'field_id="' . $new . '"';
1817 1533 $replace[] = 'field_id=\"' . $old . '\"';
1818 1534 $replace_with[] = 'field_id=\"' . $new . '\"';
1819 - // This covers conditional logic.
1820 - $replace[] = '_field":"' . $old . '","';
1821 - $replace_with[] = '_field":"' . $new . '","';
1822 1535 unset( $old, $new );
1823 1536 }//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;
1537 + if ( is_array( $val ) ) {
1538 + foreach ( $val as $k => $v ) {
1539 + if ( is_string( $v ) ) {
1540 + if ( 'custom_html' === $k ) {
1541 + $val[ $k ] = self::switch_ids_except_strings( $replace, $replace_with, array( '[if description]', '[description]', '[/if description]' ), $v );
1542 + unset( $k, $v );
1543 + continue;
1544 + }
1545 + $val[ $k ] = str_replace( $replace, $replace_with, $v );
1546 + unset( $k, $v );
1547 + }
1832 1548 }
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 );
1549 + } else {
1550 + $val = str_replace( $replace, $replace_with, $val );
1842 1551 }
1843 1552
1844 1553 return $val;
1845 1554 }
@@ -1858,9 +1567,8 @@
1858 1567 */
1859 1568 private static function switch_ids_except_strings( $replace, $replace_with, $exceptions, $value ) {
1860 1569 foreach ( $exceptions as $exception ) {
1861 1570 $index = array_search( $exception, $replace, true );
1862 -
1863 1571 if ( false === $index ) {
1864 1572 continue;
1865 1573 }
1866 1574 unset( $replace[ $index ] );
@@ -1865,16 +1573,14 @@
1865 1573 }
1866 1574 unset( $replace[ $index ] );
1867 1575 unset( $replace_with[ $index ] );
1868 1576 }
1869 -
1870 - return str_replace( $replace, $replace_with, $value );
1577 + $value = str_replace( $replace, $replace_with, $value );
1578 + return $value;
1871 1579 }
1872 1580
1873 1581 /**
1874 1582 * @since 4.0
1875 - *
1876 - * @return void
1877 1583 */
1878 1584 public static function bulk_options_overlay() {
1879 1585 $prepop = array();
1880 1586 self::get_bulk_prefilled_opts( $prepop, true );
@@ -1881,11 +1587,8 @@
1881 1587
1882 1588 include FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/bulk-options-overlay.php';
1883 1589 }
1884 1590
1885 - /**
1886 - * @return array
1887 - */
1888 1591 public static function get_us_states() {
1889 1592 $states = array(
1890 1593 'AL' => 'Alabama',
1891 1594 'AK' => 'Alaska',
@@ -1942,11 +1645,8 @@
1942 1645
1943 1646 return apply_filters( 'frm_us_states', $states );
1944 1647 }
1945 1648
1946 - /**
1947 - * @return array
1948 - */
1949 1649 public static function get_countries() {
1950 1650 $countries = array(
1951 1651 __( 'Afghanistan', 'formidable' ),
1952 1652 __( 'Aland Islands', 'formidable' ),
@@ -2211,15 +1911,12 @@
2211 1911 * @since 5.0.04 Add `$include_class` param.
2212 1912 *
2213 1913 * @param array $prepop Bulk options.
2214 1914 * @param array|false $include_class Include the class in the bulk options.
2215 - *
2216 - * @return void
2217 1915 */
2218 1916 public static function get_bulk_prefilled_opts( array &$prepop, $include_class = false ) {
2219 1917 // Countries.
2220 1918 $countries = self::get_countries();
2221 -
2222 1919 if ( $include_class ) {
2223 1920 $countries['class'] = 'frm-countries-opts';
2224 1921 }
2225 1922
@@ -2228,9 +1925,8 @@
2228 1925 // State abv.
2229 1926 $states = self::get_us_states();
2230 1927 $state_abv = array_keys( $states );
2231 1928 sort( $state_abv );
2232 -
2233 1929 if ( $include_class ) {
2234 1930 $state_abv['class'] = 'frm-state-abv-opts';
2235 1931 }
2236 1932
@@ -2238,9 +1934,8 @@
2238 1934
2239 1935 // States.
2240 1936 $states = array_values( $states );
2241 1937 sort( $states );
2242 -
2243 1938 if ( $include_class ) {
2244 1939 $states['class'] = 'frm-states-opts';
2245 1940 }
2246 1941
@@ -2257,9 +1952,8 @@
2257 1952 __( '55-64', 'formidable' ),
2258 1953 __( '65 or Above', 'formidable' ),
2259 1954 __( 'Prefer Not to Answer', 'formidable' ),
2260 1955 );
2261 -
2262 1956 if ( $include_class ) {
2263 1957 $ages['class'] = 'frm-age-opts';
2264 1958 }
2265 1959
@@ -2273,9 +1967,8 @@
2273 1967 __( 'Satisfied', 'formidable' ),
2274 1968 __( 'Very Satisfied', 'formidable' ),
2275 1969 __( 'N/A', 'formidable' ),
2276 1970 );
2277 -
2278 1971 if ( $include_class ) {
2279 1972 $satisfaction['class'] = 'frm-satisfaction-opts';
2280 1973 }
2281 1974
@@ -2289,9 +1982,8 @@
2289 1982 __( 'Important', 'formidable' ),
2290 1983 __( 'Very Important', 'formidable' ),
2291 1984 __( 'N/A', 'formidable' ),
2292 1985 );
2293 -
2294 1986 if ( $include_class ) {
2295 1987 $importance['class'] = 'frm-importance-opts';
2296 1988 }
2297 1989
@@ -2305,9 +1997,8 @@
2305 1997 __( 'Agree', 'formidable' ),
2306 1998 __( 'Strongly Agree', 'formidable' ),
2307 1999 __( 'N/A', 'formidable' ),
2308 2000 );
2309 -
2310 2001 if ( $include_class ) {
2311 2002 $agreement['class'] = 'frm-agreement-opts';
2312 2003 }
2313 2004
@@ -2321,9 +2012,8 @@
2321 2012 __( 'Likely', 'formidable' ),
2322 2013 __( 'Extremely Likely', 'formidable' ),
2323 2014 __( 'N/A', 'formidable' ),
2324 2015 );
2325 -
2326 2016 if ( $include_class ) {
2327 2017 $likely['class'] = 'frm-likely-opts';
2328 2018 }
2329 2019
@@ -2338,10 +2028,8 @@
2338 2028 * @since 2.03.05
2339 2029 *
2340 2030 * @param int $selector_field_id
2341 2031 * @param array $selector_args
2342 - *
2343 - * @return void
2344 2032 */
2345 2033 public static function display_field_value_selector( $selector_field_id, $selector_args ) {
2346 2034 $field_value_selector = FrmFieldFactory::create_field_value_selector( $selector_field_id, $selector_args );
2347 2035 $field_value_selector->display();
@@ -2356,9 +2044,9 @@
2356 2044 *
2357 2045 * @return array
2358 2046 */
2359 2047 public static function convert_field_object_to_flat_array( $field ) {
2360 - $field_options = is_array( $field->field_options ) ? $field->field_options : array();
2048 + $field_options = $field->field_options;
2361 2049 $field_array = get_object_vars( $field );
2362 2050 unset( $field_array['field_options'] );
2363 2051
2364 2052 return $field_array + $field_options;
@@ -2364,43 +2052,11 @@
2364 2052 return $field_array + $field_options;
2365 2053 }
2366 2054
2367 2055 /**
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 2056 * @since 4.04
2400 2057 *
2401 2058 * @param array $args
2402 - *
2403 2059 * @return void
2404 2060 */
2405 2061 public static function show_add_field_buttons( $args ) {
2406 2062 $field_key = $args['field_key'];
@@ -2415,25 +2071,33 @@
2415 2071 $field_label .= ob_get_clean();
2416 2072 }
2417 2073
2418 2074 // If the individual field isn't allowed, disable it.
2419 - $link = isset( $field_type['link'] ) ? esc_url_raw( $field_type['link'] ) : '';
2075 + $run_filter = true;
2076 + $single_no_allow = ' ';
2077 + $install_data = '';
2078 + $requires = '';
2079 + $link = isset( $field_type['link'] ) ? esc_url_raw( $field_type['link'] ) : '';
2080 + $has_show_upgrade_class = strpos( $field_type['icon'], ' frm_show_upgrade' );
2081 + $show_upgrade = $has_show_upgrade_class || false !== strpos( $args['no_allow_class'], 'frm_show_upgrade' );
2420 2082
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 );
2083 + if ( $has_show_upgrade_class ) {
2084 + $single_no_allow .= 'frm_show_upgrade';
2085 + $field_type['icon'] = str_replace( ' frm_show_upgrade', '', $field_type['icon'] );
2086 + $run_filter = false;
2087 + if ( isset( $field_type['addon'] ) ) {
2088 + $upgrading = FrmAddonsController::install_link( $field_type['addon'] );
2089 + if ( isset( $upgrading['url'] ) ) {
2090 + $install_data = json_encode( $upgrading );
2091 + }
2092 + $requires = FrmFormsHelper::get_plan_required( $upgrading );
2093 + } elseif ( isset( $field_type['require'] ) ) {
2094 + $requires = $field_type['require'];
2095 + }
2096 + }
2431 2097
2432 - $show_upgrade = $has_show_upgrade_class || $has_show_update_class || str_contains( $args['no_allow_class'], 'frm_show_upgrade' );
2433 2098 $upgrade_label = '';
2434 2099 $upgrade_message = '';
2435 -
2436 2100 if ( $show_upgrade ) {
2437 2101 /* translators: %s: Field name */
2438 2102 $upgrade_label = sprintf( esc_html__( '%s fields', 'formidable' ), $field_name );
2439 2103
@@ -2456,41 +2120,15 @@
2456 2120 if ( ! empty( $field_type['hide'] ) ) {
2457 2121 $li_params['class'] .= ' frm_hidden';
2458 2122 }
2459 2123
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 2124 if ( ! empty( $field_type['upsell_image'] ) ) {
2465 2125 $li_params['data-upsell-image'] = $field_type['upsell_image'];
2466 2126 }
2467 2127
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 ) {
2128 + if ( $upgrade_message ) {
2490 2129 $li_params['data-message'] = $upgrade_message;
2491 2130 }
2492 - // phpcs:disable Generic.WhiteSpace.ScopeIndent
2493 2131 ?>
2494 2132 <li <?php FrmAppHelper::array_to_html_params( $li_params, true ); ?>>
2495 2133 <?php
2496 2134 if ( $run_filter ) {
@@ -2495,130 +2133,26 @@
2495 2133 <?php
2496 2134 if ( $run_filter ) {
2497 2135 $field_label = apply_filters( 'frmpro_field_links', $field_label, $args['id'], $field_key );
2498 2136 }
2499 -
2500 - FrmAppHelper::kses_echo( $field_label, array( 'a', 'i', 'span', 'use', 'svg' ) );
2137 + echo FrmAppHelper::kses( $field_label, array( 'a', 'i', 'span', 'use', 'svg' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2501 2138 ?>
2502 2139 </li>
2503 2140 <?php
2504 - // phpcs:enable Generic.WhiteSpace.ScopeIndent
2505 2141 }
2506 2142
2507 2143 /**
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 2144 * Shows Display format option.
2610 2145 *
2611 2146 * @since 5.0.04
2612 2147 *
2613 2148 * @param array $field Field data.
2614 - *
2615 - * @return void
2616 2149 */
2617 2150 public static function show_radio_display_format( $field ) {
2618 2151 $options = self::get_display_format_options( $field );
2619 - $args = self::get_display_format_args( $field, $options );
2620 2152
2153 + $args = self::get_display_format_args( $field, $options );
2154 +
2621 2155 include FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/radio-display-format.php';
2622 2156 }
2623 2157
2624 2158 /**
@@ -2640,9 +2174,9 @@
2640 2174 'text' => __( 'Images', 'formidable' ),
2641 2175 'svg' => 'frm_image_as_option',
2642 2176 'addon' => 'pro',
2643 2177 '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
2178 + '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 2179 'content' => 'image-options',
2646 2180 ),
2647 2181 'buttons' => array(
2648 2182 'text' => __( 'Buttons', 'formidable' ),
@@ -2653,12 +2187,8 @@
2653 2187 'content' => 'button-options',
2654 2188 ),
2655 2189 );
2656 2190
2657 - if ( 'product' === FrmField::get_field_type( $field ) ) {
2658 - unset( $options['buttons'] );
2659 - }
2660 -
2661 2191 /**
2662 2192 * Allows modifying the options of Display format setting of Radio field.
2663 2193 *
2664 2194 * @since 5.0.04
@@ -2665,9 +2195,11 @@
2665 2195 *
2666 2196 * @param array $options Options.
2667 2197 * @param array $field
2668 2198 */
2669 - return apply_filters( 'frm_' . $field['type'] . '_display_format_options', $options, $field );
2199 + $options = apply_filters( 'frm_' . $field['type'] . '_display_format_options', $options, $field );
2200 +
2201 + return $options;
2670 2202 }
2671 2203
2672 2204 /**
2673 2205 * Gets display format arguments to pass to the images_dropdown() method.
@@ -2675,9 +2207,8 @@
2675 2207 * @since 5.0.04
2676 2208 *
2677 2209 * @param array $field Field data.
2678 2210 * @param array $options Options array.
2679 - *
2680 2211 * @return array
2681 2212 */
2682 2213 public static function get_display_format_args( $field, $options ) {
2683 2214 $args = array(
@@ -2703,13 +2234,8 @@
2703 2234 }
2704 2235
2705 2236 /**
2706 2237 * @since 5.0.04
2707 - *
2708 - * @param array $options Options.
2709 - * @param array $args Arguments.
2710 - *
2711 - * @return void
2712 2238 */
2713 2239 private static function fill_image_setting_options( $options, &$args ) {
2714 2240 foreach ( $options as $key => $option ) {
2715 2241 $args['options'][ $key ] = $option;
@@ -2719,9 +2245,8 @@
2719 2245 }
2720 2246
2721 2247 unset( $args['options'][ $key ]['addon'] );
2722 2248 $fill = array( 'upgrade', 'message', 'content' );
2723 -
2724 2249 foreach ( $fill as $f ) {
2725 2250 unset( $args['options'][ $key ][ $f ], $f );
2726 2251 }
2727 2252 }
@@ -2729,10 +2254,8 @@
2729 2254
2730 2255 /**
2731 2256 * @since 5.0.04
2732 2257 *
2733 - * @param array $option Option.
2734 - *
2735 2258 * @return array
2736 2259 */
2737 2260 private static function fill_image_setting_addon_link( $option ) {
2738 2261 $custom_attrs = array(
@@ -2743,9 +2266,8 @@
2743 2266 // translators: Add-on name.
2744 2267 $custom_attrs['data-upgrade'] = sprintf( __( 'Formidable %s', 'formidable' ), ucwords( $option['addon'] ) );
2745 2268
2746 2269 $fill = array( 'upgrade', 'message', 'content' );
2747 -
2748 2270 foreach ( $fill as $f ) {
2749 2271 if ( isset( $option[ $f ] ) ) {
2750 2272 $custom_attrs[ 'data-' . $f ] = $option[ $f ];
2751 2273 }
@@ -2755,10 +2277,15 @@
2755 2277 return $custom_attrs;
2756 2278 }
2757 2279
2758 2280 $upgrading = FrmAddonsController::install_link( $option['addon'] );
2281 + if ( isset( $upgrading['url'] ) ) {
2282 + $install_data = wp_json_encode( $upgrading );
2283 + } else {
2284 + $install_data = '';
2285 + }
2759 2286
2760 - $custom_attrs['data-oneclick'] = isset( $upgrading['url'] ) ? wp_json_encode( $upgrading ) : '';
2287 + $custom_attrs['data-oneclick'] = $install_data;
2761 2288 $custom_attrs['data-requires'] = FrmFormsHelper::get_plan_required( $upgrading );
2762 2289
2763 2290 return $custom_attrs;
2764 2291 }
@@ -2771,9 +2298,8 @@
2771 2298 * @since 6.2
2772 2299 *
2773 2300 * @param mixed $value
2774 2301 * @param string $field_type
2775 - *
2776 2302 * @return void
2777 2303 */
2778 2304 public static function prepare_field_value( &$value, $field_type ) {
2779 2305 $field_object = FrmFieldFactory::get_field_type( $field_type );
@@ -2784,9 +2310,8 @@
2784 2310 * @since 6.8
2785 2311 *
2786 2312 * @param int|string $form_id
2787 2313 * @param array $field_ids If this is not empty, the results will be filtered by field id.
2788 - *
2789 2314 * @return array
2790 2315 */
2791 2316 public static function get_draft_field_results( $form_id, $field_ids = array() ) {
2792 2317 if ( FrmAppHelper::pro_is_installed() ) {
@@ -2823,178 +2348,11 @@
2823 2348 *
2824 2349 * @since 6.8
2825 2350 *
2826 2351 * @param int|string $form_id
2827 - *
2828 2352 * @return array
2829 2353 */
2830 2354 public static function get_all_draft_field_ids( $form_id ) {
2831 2355 $draft_field_rows = self::get_draft_field_results( $form_id );
2832 2356 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 2357 }
3000 2358 }