PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 3.06.06
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v3.06.06
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 +344 -1170 6.5.33.06.06 View file →
@@ -13,23 +13,17 @@
13 13
14 14 $values = self::get_default_field( $type );
15 15
16 16 global $wpdb;
17 - $field_count = FrmDb::get_var(
18 - 'frm_fields',
19 - array( 'form_id' => $form_id ),
20 - 'field_order',
21 - array( 'order_by' => 'field_order DESC' )
22 - );
17 + $field_count = FrmDb::get_var( 'frm_fields', array( 'form_id' => $form_id ), 'field_order', array( 'order_by' => 'field_order DESC' ) );
23 18
24 - $values['field_key'] = FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_fields', 'field_key' );
25 - $values['form_id'] = $form_id;
19 + $values['field_key'] = FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_fields', 'field_key' );
20 + $values['form_id'] = $form_id;
26 21 $values['field_order'] = $field_count + 1;
27 -
28 22 $values['field_options']['custom_html'] = self::get_default_html( $type );
29 23
30 - if ( ! empty( $setting ) ) {
31 - if ( in_array( $type, array( 'data', 'lookup' ), true ) ) {
24 + if ( isset( $setting ) && ! empty( $setting ) ) {
25 + if ( in_array( $type, array( 'data', 'lookup' ) ) ) {
32 26 $values['field_options']['data_type'] = $setting;
33 27 } else {
34 28 $values['field_options'][ $setting ] = 1;
35 29 }
@@ -34,20 +28,19 @@
34 28 $values['field_options'][ $setting ] = 1;
35 29 }
36 30 }
37 31
38 - return $values;
39 - }
32 + return $values;
33 + }
40 34
41 35 public static function get_html_id( $field, $plus = '' ) {
42 36 return apply_filters( 'frm_field_html_id', 'field_' . $field['field_key'] . $plus, $field );
43 - }
37 + }
44 38
45 - public static function setup_edit_vars( $field, $doing_ajax = false ) {
39 + public static function setup_edit_vars( $field, $doing_ajax = false ) {
46 40 $values = self::field_object_to_array( $field );
47 -
48 41 return apply_filters( 'frm_setup_edit_field_vars', $values, array( 'doing_ajax' => $doing_ajax ) );
49 - }
42 + }
50 43
51 44 public static function field_object_to_array( $field ) {
52 45 $values = (array) $field;
53 46
@@ -59,13 +52,13 @@
59 52 }
60 53
61 54 private static function fill_field_array( $field, array &$field_array ) {
62 55 $field_array['options'] = $field->options;
63 - $field_array['value'] = $field->default_value;
56 + $field_array['value'] = $field->default_value;
64 57
65 58 self::prepare_edit_front_field( $field_array, $field );
66 59
67 - $field_array = array_merge( (array) $field->field_options, $field_array );
60 + $field_array = array_merge( $field->field_options, $field_array );
68 61 }
69 62
70 63 /**
71 64 * Prepare field while creating a new entry
@@ -117,9 +110,8 @@
117 110 * @return array
118 111 */
119 112 public static function get_default_field_options( $type ) {
120 113 $field_type = FrmFieldFactory::get_field_type( $type );
121 -
122 114 return $field_type->get_default_field_options();
123 115 }
124 116
125 117 /**
@@ -128,9 +120,9 @@
128 120 * @param object $field
129 121 * @param array $values
130 122 */
131 123 private static function fill_default_field_opts( $field, array &$values ) {
132 - $check_post = FrmAppHelper::is_admin_page() && $_POST && isset( $_POST['field_options'] ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
124 + $check_post = FrmAppHelper::is_admin() && $_POST && isset( $_POST['field_options'] );
133 125
134 126 $defaults = self::get_default_field_options_from_field( $field, $values );
135 127 if ( ! $check_post ) {
136 128 $defaults['required_indicator'] = '';
@@ -163,13 +155,12 @@
163 155 if ( '' == $field_array['blank'] && '1' === $field_array['required'] ) {
164 156 $field_array['blank'] = $frm_settings->blank_msg;
165 157 }
166 158
167 - if ( '' === $field_array['invalid'] ) {
159 + if ( '' == $field_array['invalid'] ) {
168 160 if ( 'captcha' === $field->type ) {
169 161 $field_array['invalid'] = $frm_settings->re_msg;
170 162 } else {
171 - /* translators: %s: Field name */
172 163 $field_array['invalid'] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] );
173 164 }
174 165 }
175 166
@@ -184,22 +175,15 @@
184 175 * @param string $setting
185 176 * @param mixed $value
186 177 */
187 178 private static function get_posted_field_setting( $setting, &$value ) {
188 - if ( ! isset( $_POST['field_options'][ $setting ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
189 - return;
179 + if ( isset( $_POST['field_options'][ $setting ] ) ) {
180 + $value = maybe_unserialize( $_POST['field_options'][ $setting ] );
181 + if ( strpos( $setting, 'html' ) !== false ) {
182 + // strip slashes from HTML but not regex
183 + $value = stripslashes_deep( $value );
184 + }
190 185 }
191 -
192 - if ( strpos( $setting, 'html' ) !== false ) {
193 - // Strip slashes from HTML but not regex or script tags.
194 - $value = wp_unslash( $_POST['field_options'][ $setting ] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing
195 - } elseif ( strpos( $setting, 'format_' ) === 0 ) {
196 - // TODO: Remove stripslashes on output, and use on input only.
197 - $value = sanitize_text_field( $_POST['field_options'][ $setting ] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.NonceVerification.Missing
198 - } else {
199 - $value = wp_unslash( $_POST['field_options'][ $setting ] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing
200 - FrmAppHelper::sanitize_value( 'wp_kses_post', $value );
201 - }
202 186 }
203 187
204 188 /**
205 189 * @since 3.0
@@ -210,9 +194,9 @@
210 194 * @return array
211 195 */
212 196 public static function get_default_field_options_from_field( $field, $values = array() ) {
213 197 $field_type = self::get_original_field( $field );
214 - $opts = $field_type->get_default_field_options();
198 + $opts = $field_type->get_default_field_options();
215 199
216 200 $opts = apply_filters( 'frm_default_field_opts', $opts, $values, $field );
217 201 $opts = apply_filters( 'frm_default_' . $field->type . '_field_opts', $opts, $values, $field );
218 202
@@ -230,9 +214,8 @@
230 214 $original_type = FrmField::get_option( $field, 'original_type' );
231 215 if ( ! empty( $original_type ) && $field->type != $original_type ) {
232 216 $field->type = $original_type;
233 217 }
234 -
235 218 return FrmFieldFactory::get_field_object( $field );
236 219 }
237 220
238 221 /**
@@ -242,9 +225,9 @@
242 225 * @param object $field
243 226 * @param array $atts
244 227 */
245 228 private static function prepare_field_options_for_display( &$field_array, $field, $atts ) {
246 - $field_obj = FrmFieldFactory::get_field_object( $field );
229 + $field_obj = FrmFieldFactory::get_field_object( $field );
247 230 $field_array = $field_obj->prepare_front_field( $field_array, $atts );
248 231 }
249 232
250 233 /**
@@ -255,24 +238,23 @@
255 238 * @return array
256 239 */
257 240 public static function get_default_field( $type ) {
258 241 $field_type = FrmFieldFactory::get_field_type( $type );
259 -
260 242 return $field_type->get_new_field_defaults();
261 243 }
262 244
263 - public static function fill_field( &$values, $field, $form_id, $new_key = '' ) {
264 - global $wpdb;
245 + public static function fill_field( &$values, $field, $form_id, $new_key = '' ) {
246 + global $wpdb;
265 247
266 - $values['field_key'] = FrmAppHelper::get_unique_key( $new_key, $wpdb->prefix . 'frm_fields', 'field_key' );
267 - $values['form_id'] = $form_id;
268 - $values['options'] = maybe_serialize( $field->options );
269 - $values['default_value'] = FrmAppHelper::maybe_json_encode( $field->default_value );
248 + $values['field_key'] = FrmAppHelper::get_unique_key( $new_key, $wpdb->prefix . 'frm_fields', 'field_key' );
249 + $values['form_id'] = $form_id;
250 + $values['options'] = maybe_serialize( $field->options );
251 + $values['default_value'] = maybe_serialize( $field->default_value );
270 252
271 - foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) {
272 - $values[ $col ] = $field->{$col};
273 - }
274 - }
253 + foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) {
254 + $values[ $col ] = $field->{$col};
255 + }
256 + }
275 257
276 258 /**
277 259 * @since 2.0
278 260 *
@@ -281,29 +263,27 @@
281 263 *
282 264 * @return string
283 265 */
284 266 public static function get_error_msg( $field, $error ) {
285 - $frm_settings = FrmAppHelper::get_settings();
267 + $frm_settings = FrmAppHelper::get_settings();
286 268 $default_settings = $frm_settings->default_options();
287 - $field_name = is_array( $field ) ? $field['name'] : $field->name;
269 + $field_name = is_array( $field ) ? $field['name'] : $field->name;
288 270
289 271 $conf_msg = __( 'The entered values do not match', 'formidable' );
290 272 $defaults = array(
291 273 'unique_msg' => array(
292 274 'full' => $default_settings['unique_msg'],
293 - /* translators: %s: Field name */
294 275 'part' => sprintf( __( '%s must be unique', 'formidable' ), $field_name ),
295 276 ),
296 - 'invalid' => array(
277 + 'invalid' => array(
297 278 'full' => __( 'This field is invalid', 'formidable' ),
298 - /* translators: %s: Field name */
299 279 'part' => sprintf( __( '%s is invalid', 'formidable' ), $field_name ),
300 280 ),
301 - 'blank' => array(
281 + 'blank' => array(
302 282 'full' => $frm_settings->blank_msg,
303 283 'part' => $frm_settings->blank_msg,
304 284 ),
305 - 'conf_msg' => array(
285 + 'conf_msg' => array(
306 286 'full' => $conf_msg,
307 287 'part' => $conf_msg,
308 288 ),
309 289 );
@@ -310,20 +290,18 @@
310 290
311 291 $msg = FrmField::get_option( $field, $error );
312 292 $msg = empty( $msg ) ? $defaults[ $error ]['part'] : $msg;
313 293 $msg = do_shortcode( $msg );
314 -
315 294 return $msg;
316 295 }
317 296
318 297 public static function get_form_fields( $form_id, $error = array() ) {
319 298 $fields = FrmField::get_all_for_form( $form_id );
320 -
321 299 return apply_filters( 'frm_get_paged_fields', $fields, $form_id, $error );
322 300 }
323 301
324 302 public static function get_default_html( $type = 'text' ) {
325 - $field = FrmFieldFactory::get_field_type( $type );
303 + $field = FrmFieldFactory::get_field_type( $type );
326 304 $default_html = $field->default_html();
327 305
328 306 // these hooks are here for reverse compatibility since 3.0
329 307 if ( ! apply_filters( 'frm_normal_field_type_html', true, $type ) ) {
@@ -371,9 +349,8 @@
371 349 if ( $position && $position != '' ) {
372 350 if ( $position == 'inside' && ! self::is_placeholder_field_type( $field['type'] ) ) {
373 351 $position = 'top';
374 352 }
375 -
376 353 return $position;
377 354 }
378 355
379 356 $position = FrmStylesController::get_style_val( 'position', $form );
@@ -394,161 +371,62 @@
394 371 /**
395 372 * Check if this field type allows placeholders
396 373 *
397 374 * @since 2.05
398 - * @param string $type
399 - * @return bool
400 375 */
401 376 public static function is_placeholder_field_type( $type ) {
402 - return ! in_array( $type, array( 'radio', 'checkbox', 'hidden', 'file' ), true );
377 + return ! in_array( $type, array( 'select', 'radio', 'checkbox', 'hidden', 'file' ) );
403 378 }
404 379
405 - public static function get_checkbox_id( $field, $opt_key, $type = 'checkbox' ) {
380 + public static function get_checkbox_id( $field, $opt_key ) {
406 381 $id = $field['id'];
407 - if ( isset( $field['in_section'] ) && $field['in_section'] && ! FrmAppHelper::is_admin_page( 'formidable' ) ) {
382 + if ( isset( $field['in_section'] ) && $field['in_section'] ) {
408 383 $id .= '-' . $field['in_section'];
409 384 }
410 -
411 - return 'frm_' . $type . '_' . $id . '-' . $opt_key;
385 + return 'frm_checkbox_' . $id . '-' . $opt_key;
412 386 }
413 387
414 388 public static function show_single_option( $field ) {
415 - self::hidden_field_option( $field );
416 -
417 389 if ( ! is_array( $field['options'] ) ) {
418 390 return;
419 391 }
420 392
421 - $base_name = 'default_value_' . $field['id'];
422 - $html_id = isset( $field['html_id'] ) ? $field['html_id'] : self::get_html_id( $field );
393 + $field_name = isset( $field['html_name'] ) ? $field['html_name'] : $field['name'];
394 + $html_id = isset( $field['html_id'] ) ? $field['html_id'] : self::get_html_id( $field );
423 395
424 - $default_type = self::get_default_value_type( $field );
425 -
426 396 foreach ( $field['options'] as $opt_key => $opt ) {
427 - $field_val = self::get_value_from_array( $opt, $opt_key, $field );
428 - $opt = self::get_label_from_array( $opt, $opt_key, $field );
397 + $field_val = self::get_value_from_array( $opt, $opt_key, $field );
398 + $opt = self::get_label_from_array( $opt, $opt_key, $field );
429 399
430 - $field_name = $base_name . ( $default_type === 'checkbox' ? '[' . $opt_key . ']' : '' );
400 + // Get string for Other text field, if needed
401 + $other_val = self::get_other_val( compact( 'opt_key', 'field' ) );
431 402
432 - $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'] ) ) ) );
403 + $checked = ( $other_val || isset( $field['value'] ) && ( ( ! is_array( $field['value'] ) && $field['value'] == $field_val ) || ( is_array( $field['value'] ) && in_array( $field_val, $field['value'] ) ) ) ) ? ' checked="checked"' : '';
433 404
434 - // If this is an "Other" option, get the HTML for it.
405 + // If this is an "Other" option, get the HTML for it
435 406 if ( self::is_other_opt( $opt_key ) ) {
436 407 if ( FrmAppHelper::pro_is_installed() ) {
437 408 require( FrmProAppHelper::plugin_path() . '/classes/views/frmpro-fields/other-option.php' );
438 409 }
439 - } else {
410 + } else {
440 411 require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php' );
441 - }
412 + }
442 413
443 - unset( $checked );
414 + unset( $checked, $other_val );
444 415 }
445 - }
416 + }
446 417
447 - /**
448 - * Include hidden row for javascript to duplicate.
449 - *
450 - * @since 4.0
451 - * @param array $field
452 - */
453 - private static function hidden_field_option( $field ) {
454 - // Don't duplicate during an ajax add option.
455 - $ajax_action = FrmAppHelper::get_param( 'action', '', 'post', 'sanitize_text_field' );
456 - if ( $ajax_action === 'frm_add_field_option' ) {
457 - return;
458 - }
459 -
460 - $opt_key = '000';
461 - $field_val = __( 'New Option', 'formidable' );
462 - $opt = __( 'New Option', 'formidable' );
463 - $checked = false;
464 - $field_name = 'default_value_' . $field['id'];
465 - $html_id = isset( $field['html_id'] ) ? $field['html_id'] : self::get_html_id( $field );
466 -
467 - $default_type = self::get_default_value_type( $field );
468 - $field_name .= ( $default_type === 'checkbox' ? '[' . $opt_key . ']' : '' );
469 -
470 - require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php' );
471 - }
472 -
473 - /**
474 - * @since 4.0
475 - *
476 - * @param array $field
477 - * @return string radio or checkbox
478 - */
479 - private static function get_default_value_type( $field ) {
480 - $default_type = $field['type'];
481 - if ( $field['type'] === 'select' ) {
482 - $default_type = FrmField::is_multiple_select( $field ) ? 'checkbox' : 'radio';
483 - }
484 - return $default_type;
485 - }
486 -
487 418 public static function get_value_from_array( $opt, $opt_key, $field ) {
488 419 $opt = apply_filters( 'frm_field_value_saved', $opt, $opt_key, $field );
489 -
490 420 return FrmFieldsController::check_value( $opt, $opt_key, $field );
491 421 }
492 422
493 423 public static function get_label_from_array( $opt, $opt_key, $field ) {
494 424 $opt = apply_filters( 'frm_field_label_seen', $opt, $opt_key, $field );
495 -
496 425 return FrmFieldsController::check_label( $opt );
497 426 }
498 427
499 428 /**
500 - * Shows the inline modal.
501 - *
502 - * @since 4.0
503 - * @since 6.4.1 Added `inside_class` in the arguments.
504 - *
505 - * @param array $args The arguments.
506 - */
507 - public static function inline_modal( $args ) {
508 - $defaults = array(
509 - 'id' => '',
510 - 'class' => '',
511 - 'show' => 0,
512 - 'callback' => array(),
513 - 'args' => array(),
514 - 'title' => '',
515 - 'inside_class' => 'inside',
516 - );
517 - $args = array_merge( $defaults, $args );
518 -
519 - include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/inline-modal.php' );
520 - }
521 -
522 - /**
523 - * @since 4.0
524 - */
525 - public static function smart_values() {
526 - $continue = apply_filters( 'frm_smart_values_box', true );
527 - if ( $continue === true ) {
528 - $upgrade_link = array(
529 - 'medium' => 'builder',
530 - 'content' => 'smart-tags',
531 - );
532 - include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/smart-values.php' );
533 - }
534 - }
535 -
536 - /**
537 - * @since 4.0
538 - */
539 - public static function input_mask() {
540 - include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/input-mask-info.php' );
541 - }
542 -
543 - /**
544 - * @since 4.0
545 - */
546 - public static function layout_classes() {
547 - include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/layout-classes.php' );
548 - }
549 -
550 - /**
551 429 * @param int $tax_id
552 430 *
553 431 * @return string
554 432 */
@@ -553,68 +431,53 @@
553 431 * @return string
554 432 */
555 433 public static function get_term_link( $tax_id ) {
556 434 $tax = get_taxonomy( $tax_id );
557 - if ( ! $tax ) {
558 - return '';
559 - }
435 + if ( ! $tax ) {
436 + return '';
437 + }
560 438
561 439 $link = sprintf(
562 - /* translators: %1$s: Start HTML link, %2$s: Content type label, %3$s: Content type, %4$s: End HTML link */
563 - esc_html__( 'Options are dynamically created from your %1$s%2$s: %3$s%4$s', 'formidable' ),
564 - '<a href="' . esc_url( admin_url( 'edit-tags.php?taxonomy=' . $tax->name ) ) . '" target="_blank">',
565 - esc_html__( 'taxonomy', 'formidable' ),
566 - empty( $tax->labels->name ) ? esc_html__( 'Categories', 'formidable' ) : $tax->labels->name,
567 - '</a>'
440 + esc_html__( 'Please add options from the WordPress "%1$s" page', 'formidable' ),
441 + '<a href="' . esc_url( admin_url( 'edit-tags.php?taxonomy=' . $tax->name ) ) . '" target="_blank">' . ( empty( $tax->labels->name ) ? esc_html__( 'Categories', 'formidable' ) : $tax->labels->name ) . '</a>'
568 442 );
569 443 unset( $tax );
570 444
571 - return $link;
572 - }
445 + return $link;
446 + }
573 447
574 448 public static function value_meets_condition( $observed_value, $cond, $hide_opt ) {
575 - $hide_opt = self::get_value_for_comparision( $hide_opt );
449 + $hide_opt = self::get_value_for_comparision( $hide_opt );
576 450 $observed_value = self::get_value_for_comparision( $observed_value );
577 451
578 452 if ( is_array( $observed_value ) ) {
579 453 return self::array_value_condition( $observed_value, $cond, $hide_opt );
580 - }
454 + }
581 455
582 - $m = false;
583 - if ( $cond === '==' ) {
456 + $m = false;
457 + if ( $cond == '==' ) {
584 458 $m = $observed_value == $hide_opt;
585 - } elseif ( $cond === '!=' ) {
459 + } elseif ( $cond == '!=' ) {
586 460 $m = $observed_value != $hide_opt;
587 - } elseif ( $cond === '>' ) {
461 + } elseif ( $cond == '>' ) {
588 462 $m = $observed_value > $hide_opt;
589 - } elseif ( $cond === '>=' ) {
463 + } elseif ( $cond == '>=' ) {
590 464 $m = $observed_value >= $hide_opt;
591 - } elseif ( $cond === '<' ) {
465 + } elseif ( $cond == '<' ) {
592 466 $m = $observed_value < $hide_opt;
593 - } elseif ( $cond === '<=' ) {
467 + } elseif ( $cond == '<=' ) {
594 468 $m = $observed_value <= $hide_opt;
595 - } elseif ( $cond === 'LIKE' || $cond === 'not LIKE' ) {
469 + } elseif ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
596 470 $m = stripos( $observed_value, $hide_opt );
597 - if ( $cond === 'not LIKE' ) {
471 + if ( $cond == 'not LIKE' ) {
598 472 $m = ( $m === false ) ? true : false;
599 473 } else {
600 474 $m = ( $m === false ) ? false : true;
601 475 }
602 - } elseif ( $cond === '%LIKE' ) {
603 - // ends with
604 - $length = strlen( $hide_opt );
605 - $substr = substr( $observed_value, strlen( $observed_value ) - $length );
606 - $m = 0 === strcasecmp( $substr, $hide_opt );
607 - } elseif ( 'LIKE%' === $cond ) {
608 - // starts with
609 - $length = strlen( $hide_opt );
610 - $substr = substr( $observed_value, 0, $length );
611 - $m = 0 === strcasecmp( $substr, $hide_opt );
612 476 }
477 + return $m;
478 + }
613 479
614 - return $m;
615 - }
616 -
617 480 /**
618 481 * Trim and sanitize the values
619 482 *
620 483 * @since 2.05
@@ -624,16 +487,14 @@
624 487 if ( ! is_array( $value ) ) {
625 488 $value = trim( $value );
626 489 }
627 490
628 - FrmAppHelper::sanitize_value( 'wp_kses_post', $value );
629 -
630 - return $value;
491 + return wp_kses_post( $value );
631 492 }
632 493
633 494 public static function array_value_condition( $observed_value, $cond, $hide_opt ) {
634 - $m = false;
635 - if ( $cond === '==' ) {
495 + $m = false;
496 + if ( $cond == '==' ) {
636 497 if ( is_array( $hide_opt ) ) {
637 498 $m = array_intersect( $hide_opt, $observed_value );
638 499 $m = empty( $m ) ? false : true;
639 500 } else {
@@ -638,17 +499,17 @@
638 499 $m = empty( $m ) ? false : true;
639 500 } else {
640 501 $m = in_array( $hide_opt, $observed_value );
641 502 }
642 - } elseif ( $cond === '!=' ) {
503 + } elseif ( $cond == '!=' ) {
643 504 $m = ! in_array( $hide_opt, $observed_value );
644 - } elseif ( $cond === '>' ) {
505 + } elseif ( $cond == '>' ) {
645 506 $min = min( $observed_value );
646 - $m = $min > $hide_opt;
647 - } elseif ( $cond === '<' ) {
507 + $m = $min > $hide_opt;
508 + } elseif ( $cond == '<' ) {
648 509 $max = max( $observed_value );
649 - $m = $max < $hide_opt;
650 - } elseif ( $cond === 'LIKE' || $cond === 'not LIKE' ) {
510 + $m = $max < $hide_opt;
511 + } elseif ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
651 512 foreach ( $observed_value as $ob ) {
652 513 $m = strpos( $ob, $hide_opt );
653 514 if ( $m !== false ) {
654 515 $m = true;
@@ -655,54 +516,38 @@
655 516 break;
656 517 }
657 518 }
658 519
659 - if ( $cond === 'not LIKE' ) {
660 - $m = ( $m === false ) ? true : false;
661 - }
662 - } elseif ( $cond === '%LIKE' ) {
663 - // ends with
664 - foreach ( $observed_value as $ob ) {
665 - if ( $hide_opt === substr( $ob, strlen( $ob ) - strlen( $hide_opt ) ) ) {
666 - $m = true;
667 - break;
668 - }
669 - }
670 - } elseif ( $cond === 'LIKE%' ) {
671 - // starts with
672 - foreach ( $observed_value as $ob ) {
673 - if ( $hide_opt === substr( $ob, 0, strlen( $hide_opt ) ) ) {
674 - $m = true;
675 - break;
676 - }
677 - }
678 - }
520 + if ( $cond == 'not LIKE' ) {
521 + $m = ( $m === false ) ? true : false;
522 + }
523 + }
679 524
680 - return $m;
681 - }
525 + return $m;
526 + }
682 527
683 - /**
684 - * Replace a few basic shortcodes and field ids
528 + /**
529 + * Replace a few basic shortcodes and field ids
685 530 *
686 - * @since 2.0
687 - * @return string
688 - */
531 + * @since 2.0
532 + * @return string
533 + */
689 534 public static function basic_replace_shortcodes( $value, $form, $entry ) {
690 535 if ( strpos( $value, '[sitename]' ) !== false ) {
691 - $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
692 - $value = str_replace( '[sitename]', $new_value, $value );
693 - }
536 + $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
537 + $value = str_replace( '[sitename]', $new_value, $value );
538 + }
694 539
695 540 $value = apply_filters( 'frm_content', $value, $form, $entry );
696 541 $value = do_shortcode( $value );
697 542
698 - return $value;
699 - }
543 + return $value;
544 + }
700 545
701 546 public static function get_shortcodes( $content, $form_id ) {
702 - if ( FrmAppHelper::pro_is_installed() ) {
547 + if ( FrmAppHelper::pro_is_installed() ) {
703 548 return FrmProDisplaysHelper::get_shortcodes( $content, $form_id );
704 - }
549 + }
705 550
706 551 $fields = FrmField::getAll(
707 552 array(
708 553 'fi.form_id' => (int) $form_id,
@@ -713,39 +558,25 @@
713 558 $tagregexp = self::allowed_shortcodes( $fields );
714 559
715 560 preg_match_all( "/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER );
716 561
717 - return $matches;
718 - }
562 + return $matches;
563 + }
719 564
720 565 public static function allowed_shortcodes( $fields = array() ) {
721 - $tagregexp = array(
722 - 'editlink',
723 - 'id',
724 - 'key',
725 - 'ip',
726 - 'siteurl',
727 - 'sitename',
728 - 'admin_email',
729 - 'post[-|_]id',
730 - 'created[-|_]at',
731 - 'updated[-|_]at',
732 - 'updated[-|_]by',
733 - 'parent[-|_]id',
734 - );
566 + $tagregexp = array( 'editlink', 'id', 'key', 'ip', 'siteurl', 'sitename', 'admin_email', 'post[-|_]id', 'created[-|_]at', 'updated[-|_]at', 'updated[-|_]by', 'parent[-|_]id' );
735 567
736 - foreach ( $fields as $field ) {
737 - $tagregexp[] = $field->id;
738 - $tagregexp[] = $field->field_key;
739 - }
568 + foreach ( $fields as $field ) {
569 + $tagregexp[] = $field->id;
570 + $tagregexp[] = $field->field_key;
571 + }
740 572
741 573 $tagregexp = implode( '|', $tagregexp );
574 + return $tagregexp;
575 + }
742 576
743 - return $tagregexp;
744 - }
745 -
746 577 public static function replace_content_shortcodes( $content, $entry, $shortcodes ) {
747 - foreach ( $shortcodes[0] as $short_key => $tag ) {
578 + foreach ( $shortcodes[0] as $short_key => $tag ) {
748 579 if ( empty( $tag ) ) {
749 580 continue;
750 581 }
751 582
@@ -752,13 +583,12 @@
752 583 $atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[3][ $short_key ] );
753 584 $tag = FrmShortcodeHelper::get_shortcode_tag( $shortcodes, $short_key );
754 585
755 586 $atts['entry'] = $entry;
756 - $atts['tag'] = $tag;
757 - $replace_with = self::get_value_for_shortcode( $atts );
587 + $atts['tag'] = $tag;
588 + $replace_with = self::get_value_for_shortcode( $atts );
758 589
759 590 if ( $replace_with !== null ) {
760 - $replace_with = self::trigger_shortcode_atts( $replace_with, $atts );
761 591 self::sanitize_embedded_shortcodes( compact( 'entry' ), $replace_with );
762 592 $content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content );
763 593 }
764 594
@@ -765,59 +595,11 @@
765 595 unset( $atts, $replace_with );
766 596 }
767 597
768 598 return $content;
769 - }
599 + }
770 600
771 601 /**
772 - * @param string $replace_with
773 - * @param array $atts
774 - * @return string
775 - */
776 - private static function trigger_shortcode_atts( $replace_with, $atts ) {
777 - $supported_atts = array( 'remove_accents', 'sanitize', 'sanitize_url' );
778 - $included_atts = array_intersect( $supported_atts, array_keys( $atts ) );
779 - foreach ( $included_atts as $included_att ) {
780 - if ( '0' === $atts[ $included_att ] ) {
781 - // Skip any option that uses 0 so sanitize_url=0 does not encode.
782 - continue;
783 - }
784 - $function = 'atts_' . $included_att;
785 - $replace_with = self::$function( $replace_with, $atts );
786 - }
787 - return $replace_with;
788 - }
789 -
790 - /**
791 - * Converts all accent characters to ASCII characters.
792 - *
793 - * @since 6.3.1
794 - *
795 - * @param string $replace_with The text to remove accents from.
796 - *
797 - * @return string
798 - */
799 - public static function atts_remove_accents( $replace_with ) {
800 - return remove_accents( $replace_with );
801 - }
802 -
803 - /**
804 - * @param string $replace_with
805 - * @return string
806 - */
807 - private static function atts_sanitize( $replace_with ) {
808 - return sanitize_title_with_dashes( $replace_with );
809 - }
810 -
811 - /**
812 - * @param string $replace_with
813 - * @return string
814 - */
815 - private static function atts_sanitize_url( $replace_with ) {
816 - return urlencode( $replace_with );
817 - }
818 -
819 - /**
820 602 * Prevent shortcodes in fields from being processed
821 603 *
822 604 * @since 3.01.02
823 605 *
@@ -824,9 +606,9 @@
824 606 * @param array $atts - includes entry object
825 607 * @param string $value
826 608 */
827 609 public static function sanitize_embedded_shortcodes( $atts, &$value ) {
828 - $atts['value'] = $value;
610 + $atts['value'] = $value;
829 611 $should_sanitize = apply_filters( 'frm_sanitize_shortcodes', true, $atts );
830 612 if ( $should_sanitize ) {
831 613 $value = str_replace( '[', '&#91;', $value );
832 614 }
@@ -842,11 +624,11 @@
842 624 private static function get_value_for_shortcode( $atts ) {
843 625 $clean_tag = str_replace( '-', '_', $atts['tag'] );
844 626
845 627 $shortcode_values = array(
846 - 'id' => $atts['entry']->id,
847 - 'key' => $atts['entry']->item_key,
848 - 'ip' => $atts['entry']->ip,
628 + 'id' => $atts['entry']->id,
629 + 'key' => $atts['entry']->item_key,
630 + 'ip' => $atts['entry']->ip,
849 631 );
850 632
851 633 $dynamic_default = array( 'admin_email', 'siteurl', 'frmurl', 'sitename', 'get' );
852 634
@@ -853,15 +635,15 @@
853 635 if ( isset( $shortcode_values[ $atts['tag'] ] ) ) {
854 636 $replace_with = $shortcode_values[ $atts['tag'] ];
855 637 } elseif ( in_array( $atts['tag'], $dynamic_default ) ) {
856 638 $replace_with = self::dynamic_default_values( $atts['tag'], $atts );
857 - } elseif ( $clean_tag === 'user_agent' ) {
858 - $description = $atts['entry']->description;
639 + } elseif ( $clean_tag == 'user_agent' ) {
640 + $description = maybe_unserialize( $atts['entry']->description );
859 641 $replace_with = FrmEntriesHelper::get_browser( $description['browser'] );
860 - } elseif ( $clean_tag === 'created_at' || $clean_tag === 'updated_at' ) {
861 - $atts['tag'] = $clean_tag;
642 + } elseif ( $clean_tag == 'created_at' || $clean_tag == 'updated_at' ) {
643 + $atts['tag'] = $clean_tag;
862 644 $replace_with = self::get_entry_timestamp( $atts );
863 - } elseif ( $clean_tag === 'created_by' || $clean_tag === 'updated_by' ) {
645 + } elseif ( $clean_tag == 'created_by' || $clean_tag == 'updated_by' ) {
864 646 $replace_with = self::get_display_value( $atts['entry']->{$clean_tag}, (object) array( 'type' => 'user_id' ), $atts );
865 647 } else {
866 648 $replace_with = self::get_field_shortcode_value( $atts );
867 649 }
@@ -880,9 +662,9 @@
880 662 if ( isset( $atts['format'] ) ) {
881 663 $time_format = ' ';
882 664 } else {
883 665 $atts['format'] = get_option( 'date_format' );
884 - $time_format = '';
666 + $time_format = '';
885 667 }
886 668
887 669 return FrmAppHelper::get_formatted_time( $atts['entry']->{$atts['tag']}, $atts['format'], $time_format );
888 670 }
@@ -899,17 +681,17 @@
899 681 if ( empty( $field ) ) {
900 682 return null;
901 683 }
902 684
903 - if ( isset( $atts['show'] ) && $atts['show'] === 'field_label' ) {
685 + if ( isset( $atts['show'] ) && $atts['show'] == 'field_label' ) {
904 686 $replace_with = $field->name;
905 - } elseif ( isset( $atts['show'] ) && $atts['show'] === 'description' ) {
687 + } elseif ( isset( $atts['show'] ) && $atts['show'] == 'description' ) {
906 688 $replace_with = $field->description;
907 689 } else {
908 690 $replace_with = FrmEntryMeta::get_meta_value( $atts['entry'], $field->id );
909 691 $string_value = $replace_with;
910 692 if ( is_array( $replace_with ) ) {
911 - $sep = isset( $atts['sep'] ) ? $atts['sep'] : ', ';
693 + $sep = isset( $atts['sep'] ) ? $atts['sep'] : ', ';
912 694 $string_value = implode( $sep, $replace_with );
913 695 }
914 696
915 697 if ( empty( $string_value ) && $string_value != '0' ) {
@@ -916,9 +698,9 @@
916 698 $replace_with = '';
917 699 } else {
918 700 $atts['entry_id'] = $atts['entry']->id;
919 701 $atts['entry_key'] = $atts['entry']->item_key;
920 - $replace_with = self::get_display_value( $replace_with, $field, $atts );
702 + $replace_with = self::get_display_value( $replace_with, $field, $atts );
921 703 }
922 704 }
923 705
924 706 return $replace_with;
@@ -923,46 +705,46 @@
923 705
924 706 return $replace_with;
925 707 }
926 708
927 - /**
928 - * Get the value to replace a few standard shortcodes
929 - *
930 - * @since 2.0
931 - * @return string
932 - */
933 - public static function dynamic_default_values( $tag, $atts = array(), $return_array = false ) {
934 - $new_value = '';
935 - switch ( $tag ) {
936 - case 'admin_email':
709 + /**
710 + * Get the value to replace a few standard shortcodes
711 + *
712 + * @since 2.0
713 + * @return string
714 + */
715 + public static function dynamic_default_values( $tag, $atts = array(), $return_array = false ) {
716 + $new_value = '';
717 + switch ( $tag ) {
718 + case 'admin_email':
937 719 $new_value = get_option( 'admin_email' );
938 - break;
939 - case 'siteurl':
940 - $new_value = FrmAppHelper::site_url();
941 - break;
942 - case 'frmurl':
943 - $new_value = FrmAppHelper::plugin_url();
944 - break;
945 - case 'sitename':
946 - $new_value = FrmAppHelper::site_name();
947 - break;
948 - case 'get':
949 - $new_value = self::process_get_shortcode( $atts, $return_array );
950 - }
720 + break;
721 + case 'siteurl':
722 + $new_value = FrmAppHelper::site_url();
723 + break;
724 + case 'frmurl':
725 + $new_value = FrmAppHelper::plugin_url();
726 + break;
727 + case 'sitename':
728 + $new_value = FrmAppHelper::site_name();
729 + break;
730 + case 'get':
731 + $new_value = self::process_get_shortcode( $atts, $return_array );
732 + }
951 733
952 - return $new_value;
953 - }
734 + return $new_value;
735 + }
954 736
955 - /**
956 - * Process the [get] shortcode
957 - *
958 - * @since 2.0
959 - * @return string|array
960 - */
961 - public static function process_get_shortcode( $atts, $return_array = false ) {
737 + /**
738 + * Process the [get] shortcode
739 + *
740 + * @since 2.0
741 + * @return string|array
742 + */
743 + public static function process_get_shortcode( $atts, $return_array = false ) {
962 744 if ( ! isset( $atts['param'] ) ) {
963 - return '';
964 - }
745 + return '';
746 + }
965 747
966 748 if ( strpos( $atts['param'], '&#91;' ) ) {
967 749 $atts['param'] = str_replace( '&#91;', '[', $atts['param'] );
968 750 $atts['param'] = str_replace( '&#93;', ']', $atts['param'] );
@@ -968,24 +750,24 @@
968 750 $atts['param'] = str_replace( '&#93;', ']', $atts['param'] );
969 751 }
970 752
971 753 $new_value = FrmAppHelper::get_param( $atts['param'], '', 'get', 'sanitize_text_field' );
972 - $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] );
754 + $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] );
973 755
974 - if ( $new_value == '' ) {
756 + if ( $new_value == '' ) {
975 757 if ( ! isset( $atts['prev_val'] ) ) {
976 - $atts['prev_val'] = '';
977 - }
758 + $atts['prev_val'] = '';
759 + }
978 760
979 761 $new_value = isset( $atts['default'] ) ? $atts['default'] : $atts['prev_val'];
980 - }
762 + }
981 763
982 764 if ( is_array( $new_value ) && ! $return_array ) {
983 765 $new_value = implode( ', ', $new_value );
984 766 }
985 767
986 - return $new_value;
987 - }
768 + return $new_value;
769 + }
988 770
989 771 public static function get_display_value( $value, $field, $atts = array() ) {
990 772
991 773 $value = apply_filters( 'frm_get_' . $field->type . '_display_value', $value, $field, $atts );
@@ -990,11 +772,9 @@
990 772
991 773 $value = apply_filters( 'frm_get_' . $field->type . '_display_value', $value, $field, $atts );
992 774 $value = apply_filters( 'frm_get_display_value', $value, $field, $atts );
993 775
994 - $value = self::get_unfiltered_display_value( compact( 'value', 'field', 'atts' ) );
995 -
996 - return apply_filters( 'frm_display_value', $value, $field, $atts );
776 + return self::get_unfiltered_display_value( compact( 'value', 'field', 'atts' ) );
997 777 }
998 778
999 779 /**
1000 780 * @param $atts array Includes value, field, and atts
@@ -1001,9 +781,9 @@
1001 781 */
1002 782 public static function get_unfiltered_display_value( $atts ) {
1003 783 $value = $atts['value'];
1004 784 $field = $atts['field'];
1005 - $atts = isset( $atts['atts'] ) ? $atts['atts'] : $atts;
785 + $atts = isset( $atts['atts'] ) ? $atts['atts'] : $atts;
1006 786
1007 787 if ( is_array( $field ) ) {
1008 788 $field = $field['id'];
1009 789 }
@@ -1008,9 +788,8 @@
1008 788 $field = $field['id'];
1009 789 }
1010 790
1011 791 $field_obj = FrmFieldFactory::get_field_object( $field );
1012 -
1013 792 return $field_obj->get_display_value( $value, $atts );
1014 793 }
1015 794
1016 795 /**
@@ -1051,56 +830,35 @@
1051 830 return $info;
1052 831 }
1053 832
1054 833 public static function get_field_types( $type ) {
1055 - $single_input = self::single_input_fields();
834 + $single_input = array( 'text', 'textarea', 'rte', 'number', 'email', 'url', 'file', 'date', 'phone', 'hidden', 'time', 'user_id', 'tag', 'password' );
1056 835 $multiple_input = array( 'radio', 'checkbox', 'select', 'scale', 'star', 'lookup' );
836 + $other_type = array( 'html', 'break' );
1057 837
1058 - $field_selection = FrmField::all_field_selection();
838 + $field_selection = array_merge( FrmField::pro_field_selection(), FrmField::field_selection() );
1059 839
1060 - $field_types = array();
840 + $field_types = array();
1061 841 if ( in_array( $type, $single_input ) ) {
1062 - self::field_types_for_input( $single_input, $field_selection, $field_types );
842 + self::field_types_for_input( $single_input, $field_selection, $field_types );
1063 843 } elseif ( in_array( $type, $multiple_input ) ) {
1064 - self::field_types_for_input( $multiple_input, $field_selection, $field_types );
844 + self::field_types_for_input( $multiple_input, $field_selection, $field_types );
845 + } elseif ( in_array( $type, $other_type ) ) {
846 + self::field_types_for_input( $other_type, $field_selection, $field_types );
1065 847 } elseif ( isset( $field_selection[ $type ] ) ) {
1066 - $field_types[ $type ] = $field_selection[ $type ];
1067 - }
848 + $field_types[ $type ] = $field_selection[ $type ];
849 + }
1068 850
1069 - $field_types = apply_filters( 'frm_switch_field_types', $field_types, compact( 'type', 'field_selection' ) );
851 + $field_types = apply_filters( 'frm_switch_field_types', $field_types, compact( 'type' ) );
852 + return $field_types;
853 + }
1070 854
1071 - return $field_types;
1072 - }
1073 -
1074 - /**
1075 - * Get a list of all fields that use a single value input.
1076 - *
1077 - * @since 4.0
1078 - */
1079 - public static function single_input_fields() {
1080 - $fields = array(
1081 - 'text',
1082 - 'textarea',
1083 - 'rte',
1084 - 'number',
1085 - 'email',
1086 - 'url',
1087 - 'date',
1088 - 'phone',
1089 - 'hidden',
1090 - 'time',
1091 - 'tag',
1092 - 'password',
1093 - );
1094 - return apply_filters( 'frm_single_input_fields', $fields );
1095 - }
1096 -
1097 - private static function field_types_for_input( $inputs, $fields, &$field_types ) {
1098 - foreach ( $inputs as $input ) {
1099 - $field_types[ $input ] = $fields[ $input ];
855 + private static function field_types_for_input( $inputs, $fields, &$field_types ) {
856 + foreach ( $inputs as $input ) {
857 + $field_types[ $input ] = $fields[ $input ];
1100 858 unset( $input );
1101 - }
1102 - }
859 + }
860 + }
1103 861
1104 862 /**
1105 863 * Check if current field option is an "other" option
1106 864 *
@@ -1106,9 +864,8 @@
1106 864 *
1107 865 * @since 2.0.6
1108 866 *
1109 867 * @param string $opt_key
1110 - *
1111 868 * @return boolean Returns true if current field option is an "Other" option
1112 869 */
1113 870 public static function is_other_opt( $opt_key ) {
1114 871 return $opt_key && strpos( $opt_key, 'other_' ) === 0;
@@ -1113,16 +870,16 @@
1113 870 public static function is_other_opt( $opt_key ) {
1114 871 return $opt_key && strpos( $opt_key, 'other_' ) === 0;
1115 872 }
1116 873
1117 - /**
1118 - * Get value that belongs in "Other" text box
1119 - *
1120 - * @since 2.0.6
1121 - *
1122 - * @param array $args
1123 - */
1124 - public static function get_other_val( $args ) {
874 + /**
875 + * Get value that belongs in "Other" text box
876 + *
877 + * @since 2.0.6
878 + *
879 + * @param array $args
880 + */
881 + public static function get_other_val( $args ) {
1125 882 $defaults = array(
1126 883 'opt_key' => 0,
1127 884 'field' => array(),
1128 885 'parent' => false,
@@ -1127,14 +884,14 @@
1127 884 'field' => array(),
1128 885 'parent' => false,
1129 886 'pointer' => false,
1130 887 );
1131 - $args = wp_parse_args( $args, $defaults );
888 + $args = wp_parse_args( $args, $defaults );
1132 889
1133 - $opt_key = $args['opt_key'];
1134 - $field = $args['field'];
1135 - $parent = $args['parent'];
1136 - $pointer = $args['pointer'];
890 + $opt_key = $args['opt_key'];
891 + $field = $args['field'];
892 + $parent = $args['parent'];
893 + $pointer = $args['pointer'];
1137 894 $other_val = '';
1138 895
1139 896 // If option is an "other" option and there is a value set for this field,
1140 897 // check if the value belongs in the current "Other" option text field
@@ -1142,34 +899,31 @@
1142 899 return $other_val;
1143 900 }
1144 901
1145 902 // Check posted vals before checking saved values
903 +
1146 904 // For fields inside repeating sections - note, don't check if $pointer is true because it will often be zero
1147 - if ( $parent && isset( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
905 + if ( $parent && isset( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] ) ) {
1148 906 if ( FrmField::is_field_with_multiple_values( $field ) ) {
1149 - // phpcs:ignore WordPress.Security.NonceVerification.Missing
1150 - $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 ] ) ) : '';
907 + $other_val = isset( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ][ $opt_key ] ) ? sanitize_text_field( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ][ $opt_key ] ) : '';
1151 908 } else {
1152 - $other_val = sanitize_text_field( wp_unslash( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
909 + $other_val = sanitize_text_field( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] );
1153 910 }
1154 -
1155 911 return $other_val;
1156 912
1157 - } elseif ( isset( $field['id'] ) && isset( $_POST['item_meta']['other'][ $field['id'] ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
913 + } else if ( isset( $field['id'] ) && isset( $_POST['item_meta']['other'][ $field['id'] ] ) ) {
1158 914 // For normal fields
1159 915
1160 916 if ( FrmField::is_field_with_multiple_values( $field ) ) {
1161 - // phpcs:ignore WordPress.Security.NonceVerification.Missing
1162 - $other_val = isset( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) ? sanitize_text_field( wp_unslash( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) ) : '';
917 + $other_val = isset( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) ? sanitize_text_field( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) : '';
1163 918 } else {
1164 - $other_val = sanitize_text_field( wp_unslash( $_POST['item_meta']['other'][ $field['id'] ] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
919 + $other_val = sanitize_text_field( $_POST['item_meta']['other'][ $field['id'] ] );
1165 920 }
1166 -
1167 921 return $other_val;
1168 922 }
1169 923
1170 924 // For checkboxes
1171 - if ( $field['type'] === 'checkbox' && is_array( $field['value'] ) ) {
925 + if ( $field['type'] == 'checkbox' && is_array( $field['value'] ) ) {
1172 926 // Check if there is an "other" val in saved value and make sure the
1173 927 // "other" val is not equal to the Other checkbox option
1174 928 if ( isset( $field['value'][ $opt_key ] ) && $field['options'][ $opt_key ] != $field['value'][ $opt_key ] ) {
1175 929 $other_val = $field['value'][ $opt_key ];
@@ -1186,9 +940,9 @@
1186 940 $o_key = array_search( $temp_val, $field['value'] );
1187 941 if ( isset( $field['value'][ $o_key ] ) ) {
1188 942 unset( $field['value'][ $o_key ], $o_key );
1189 943 }
1190 - } elseif ( $temp_val == $field['value'] ) {
944 + } else if ( $temp_val == $field['value'] ) {
1191 945 // For radio and regular dropdowns
1192 946 return '';
1193 947 } else {
1194 948 $other_val = $field['value'];
@@ -1201,49 +955,43 @@
1201 955 }
1202 956 }
1203 957
1204 958 return $other_val;
1205 - }
959 + }
1206 960
1207 - /**
1208 - * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val.
1209 - * Intended for front-end use
1210 - *
1211 - * @since 2.0.6
1212 - *
1213 - * @param array $args should include field, opt_key and field name
1214 - * @param boolean $other_opt
1215 - * @param string $checked
1216 - *
1217 - * @return array $other_args
1218 - */
1219 - public static function prepare_other_input( $args, &$other_opt, &$checked ) {
1220 - $other_args = array(
1221 - 'name' => '',
1222 - 'value' => '',
1223 - );
1224 -
961 + /**
962 + * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val.
963 + * Intended for front-end use
964 + *
965 + * @since 2.0.6
966 + *
967 + * @param array $args should include field, opt_key and field name
968 + * @param boolean $other_opt
969 + * @param string $checked
970 + * @return array $other_args
971 + */
972 + public static function prepare_other_input( $args, &$other_opt, &$checked ) {
1225 973 //Check if this is an "Other" option
1226 974 if ( ! self::is_other_opt( $args['opt_key'] ) ) {
1227 - return $other_args;
975 + return;
1228 976 }
1229 977
1230 - $other_opt = true;
978 + $other_opt = true;
979 + $other_args = array();
1231 980
1232 981 self::set_other_name( $args, $other_args );
1233 982 self::set_other_value( $args, $other_args );
1234 983
1235 - if ( '' !== $other_args['value'] ) {
984 + if ( $other_args['value'] ) {
1236 985 $checked = 'checked="checked" ';
1237 986 }
1238 987
1239 - return $other_args;
1240 - }
988 + return $other_args;
989 + }
1241 990
1242 991 /**
1243 992 * @param array $args
1244 993 * @param array $other_args
1245 - *
1246 994 * @since 2.0.6
1247 995 */
1248 996 private static function set_other_name( $args, &$other_args ) {
1249 997 //Set up name for other field
@@ -1266,9 +1014,9 @@
1266 1014 *
1267 1015 * @since 2.0.6
1268 1016 */
1269 1017 private static function set_other_value( $args, &$other_args ) {
1270 - $parent = '';
1018 + $parent = '';
1271 1019 $pointer = '';
1272 1020
1273 1021 // Check for parent ID and pointer
1274 1022 $temp_array = explode( '[', $args['field_name'] );
@@ -1274,9 +1022,9 @@
1274 1022 $temp_array = explode( '[', $args['field_name'] );
1275 1023
1276 1024 // Count should only be greater than 3 if inside of a repeating section
1277 1025 if ( count( $temp_array ) > 3 ) {
1278 - $parent = str_replace( ']', '', $temp_array[1] );
1026 + $parent = str_replace( ']', '', $temp_array[1] );
1279 1027 $pointer = str_replace( ']', '', $temp_array[2] );
1280 1028 }
1281 1029
1282 1030 // Get text for "other" text field
@@ -1293,14 +1041,13 @@
1293 1041 /**
1294 1042 * If this field includes an other option, show it
1295 1043 *
1296 1044 * @param $args array
1297 - *
1298 1045 * @since 2.0.6
1299 1046 */
1300 1047 public static function include_other_input( $args ) {
1301 - if ( ! $args['other_opt'] ) {
1302 - return;
1048 + if ( ! $args['other_opt'] ) {
1049 + return;
1303 1050 }
1304 1051
1305 1052 $classes = array( 'frm_other_input' );
1306 1053 if ( ! $args['checked'] || trim( $args['checked'] ) == '' ) {
@@ -1315,28 +1062,25 @@
1315 1062 $other_id = self::get_other_field_html_id( $args['field']['type'], $args['html_id'], $args['opt_key'] );
1316 1063
1317 1064 $label = isset( $args['opt_label'] ) ? $args['opt_label'] : $args['field']['name'];
1318 1065
1319 - echo '<label for="' . esc_attr( $other_id ) . '" class="frm_screen_reader frm_hidden">' .
1320 - esc_html( $label ) .
1321 - '</label>' .
1322 - '<input type="text" id="' . esc_attr( $other_id ) . '" class="' . esc_attr( implode( ' ', $classes ) ) . '" ' .
1323 - ( $args['read_only'] ? ' readonly="readonly" disabled="disabled"' : '' ) .
1324 - ' name="' . esc_attr( $args['name'] ) . '" value="' . esc_attr( $args['value'] ) . '" />';
1066 + ?><label for="<?php echo esc_attr( $other_id ) ?>" class="frm_screen_reader frm_hidden"><?php
1067 + echo esc_html( $label );
1068 + ?></label><input type="text" id="<?php echo esc_attr( $other_id ) ?>" class="<?php echo esc_attr( implode( ' ', $classes ) ) ?>" <?php
1069 + echo ( $args['read_only'] ? ' readonly="readonly" disabled="disabled"' : '' );
1070 + ?> name="<?php echo esc_attr( $args['name'] ) ?>" value="<?php echo esc_attr( $args['value'] ); ?>" /><?php
1325 1071 }
1326 1072
1327 1073 /**
1328 - * Get the HTML id for an "Other" text field
1329 - * Note: This does not affect fields in repeating sections
1330 - *
1331 - * @since 2.0.08
1332 - *
1333 - * @param string $type - field type
1334 - * @param string $html_id
1335 - * @param string|boolean $opt_key
1336 - *
1337 - * @return string $other_id
1338 - */
1074 + * Get the HTML id for an "Other" text field
1075 + * Note: This does not affect fields in repeating sections
1076 + *
1077 + * @since 2.0.08
1078 + * @param string $type - field type
1079 + * @param string $html_id
1080 + * @param string|boolean $opt_key
1081 + * @return string $other_id
1082 + */
1339 1083 public static function get_other_field_html_id( $type, $html_id, $opt_key = false ) {
1340 1084 $other_id = $html_id;
1341 1085
1342 1086 // If hidden radio field, add an opt key of 0
@@ -1352,61 +1096,86 @@
1352 1096
1353 1097 return $other_id;
1354 1098 }
1355 1099
1100 + public static function clear_on_focus_html( $field, $display, $id = '' ) {
1101 + if ( $display['clear_on_focus'] ) {
1102 + $has_default_value = ! empty( $field['default_value'] );
1103 + echo '<span id="frm_clear_on_focus_' . esc_attr( $field['id'] . $id ) . '" class="frm-show-click">';
1104 +
1105 + if ( $display['default_blank'] ) {
1106 + self::show_default_blank_js( $field['default_blank'], $has_default_value );
1107 + echo '<input type="hidden" name="field_options[default_blank_' . esc_attr( $field['id'] ) . ']" value="' . esc_attr( $field['default_blank'] ) . '" />';
1108 + }
1109 +
1110 + self::show_onfocus_js( $field['clear_on_focus'], $has_default_value );
1111 + echo '<input type="hidden" name="field_options[clear_on_focus_' . esc_attr( $field['id'] ) . ']" value="' . esc_attr( $field['clear_on_focus'] ) . '" />';
1112 +
1113 + echo '</span>';
1114 + }
1115 + }
1116 +
1117 + public static function show_onfocus_js( $is_selected, $has_default_value = true ) {
1118 + $atts = array(
1119 + 'icon' => 'frm_reload_icon',
1120 + 'message' => $is_selected ? __( 'Clear default value when typing', 'formidable' ) : __( 'Do not clear default value when typing', 'formidable' ),
1121 + 'is_selected' => $is_selected,
1122 + 'has_default' => $has_default_value,
1123 + );
1124 + self::show_icon_link_js( $atts );
1125 + }
1126 +
1127 + public static function show_default_blank_js( $is_selected, $has_default_value = true ) {
1128 + $atts = array(
1129 + 'icon' => 'frm_error_icon',
1130 + 'message' => $is_selected ? __( 'Default value will NOT pass form validation', 'formidable' ) : __( 'Default value will pass form validation', 'formidable' ),
1131 + 'is_selected' => $is_selected,
1132 + 'has_default' => $has_default_value,
1133 + );
1134 + self::show_icon_link_js( $atts );
1135 + }
1136 +
1137 + public static function show_icon_link_js( $atts ) {
1138 + $atts['icon'] .= $atts['is_selected'] ? ' ' : ' frm_inactive_icon ';
1139 + if ( isset( $atts['has_default'] ) && ! $atts['has_default'] ) {
1140 + $atts['icon'] .= 'frm_hidden ';
1141 + }
1142 + echo '<a href="javascript:void(0)" class="frm_bstooltip ' . esc_attr( $atts['icon'] ) . 'frm_default_val_icons frm_action_icon frm_icon_font" title="' . esc_attr( $atts['message'] ) . '"></a>';
1143 + }
1144 +
1356 1145 public static function switch_field_ids( $val ) {
1357 - global $frm_duplicate_ids;
1358 - $replace = array();
1359 - $replace_with = array();
1360 - foreach ( (array) $frm_duplicate_ids as $old => $new ) {
1361 - $replace[] = '[if ' . $old . ']';
1146 + global $frm_duplicate_ids;
1147 + $replace = array();
1148 + $replace_with = array();
1149 + foreach ( (array) $frm_duplicate_ids as $old => $new ) {
1150 + $replace[] = '[if ' . $old . ']';
1362 1151 $replace_with[] = '[if ' . $new . ']';
1363 - $replace[] = '[if ' . $old . ' ';
1152 + $replace[] = '[if ' . $old . ' ';
1364 1153 $replace_with[] = '[if ' . $new . ' ';
1365 - $replace[] = '[/if ' . $old . ']';
1154 + $replace[] = '[/if ' . $old . ']';
1366 1155 $replace_with[] = '[/if ' . $new . ']';
1367 - $replace[] = '[\/if ' . $old . ']';
1368 - $replace_with[] = '[\/if ' . $new . ']';
1369 - $replace[] = '[foreach ' . $old . ']';
1156 + $replace[] = '[foreach ' . $old . ']';
1370 1157 $replace_with[] = '[foreach ' . $new . ']';
1371 - $replace[] = '[/foreach ' . $old . ']';
1158 + $replace[] = '[/foreach ' . $old . ']';
1372 1159 $replace_with[] = '[/foreach ' . $new . ']';
1373 - $replace[] = '[\/foreach ' . $old . ']';
1374 - $replace_with[] = '[\/foreach ' . $new . ']';
1375 - $replace[] = '[' . $old . ']';
1160 + $replace[] = '[' . $old . ']';
1376 1161 $replace_with[] = '[' . $new . ']';
1377 - $replace[] = '[' . $old . ' ';
1162 + $replace[] = '[' . $old . ' ';
1378 1163 $replace_with[] = '[' . $new . ' ';
1379 - $replace[] = 'field_id="' . $old . '"';
1380 - $replace_with[] = 'field_id="' . $new . '"';
1381 - $replace[] = 'field_id=\"' . $old . '\"';
1382 - $replace_with[] = 'field_id=\"' . $new . '\"';
1383 1164 unset( $old, $new );
1384 - }
1165 + }
1385 1166 if ( is_array( $val ) ) {
1386 1167 foreach ( $val as $k => $v ) {
1387 - if ( is_string( $v ) ) {
1388 - $val[ $k ] = str_replace( $replace, $replace_with, $v );
1389 - unset( $k, $v );
1390 - }
1391 - }
1392 - } else {
1168 + $val[ $k ] = str_replace( $replace, $replace_with, $v );
1169 + unset( $k, $v );
1170 + }
1171 + } else {
1393 1172 $val = str_replace( $replace, $replace_with, $val );
1394 - }
1173 + }
1395 1174
1396 - return $val;
1397 - }
1175 + return $val;
1176 + }
1398 1177
1399 - /**
1400 - * @since 4.0
1401 - */
1402 - public static function bulk_options_overlay() {
1403 - $prepop = array();
1404 - self::get_bulk_prefilled_opts( $prepop, true );
1405 -
1406 - include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/bulk-options-overlay.php' );
1407 - }
1408 -
1409 1178 public static function get_us_states() {
1410 1179 $states = array(
1411 1180 'AL' => 'Alabama',
1412 1181 'AK' => 'Alaska',
@@ -1459,310 +1228,29 @@
1459 1228 'WV' => 'West Virginia',
1460 1229 'WI' => 'Wisconsin',
1461 1230 'WY' => 'Wyoming',
1462 1231 );
1463 -
1464 1232 return apply_filters( 'frm_us_states', $states );
1465 1233 }
1466 1234
1467 1235 public static function get_countries() {
1468 - $countries = array(
1469 - __( 'Afghanistan', 'formidable' ),
1470 - __( 'Aland Islands', 'formidable' ),
1471 - __( 'Albania', 'formidable' ),
1472 - __( 'Algeria', 'formidable' ),
1473 - __( 'American Samoa', 'formidable' ),
1474 - __( 'Andorra', 'formidable' ),
1475 - __( 'Angola', 'formidable' ),
1476 - __( 'Anguilla', 'formidable' ),
1477 - __( 'Antarctica', 'formidable' ),
1478 - __( 'Antigua and Barbuda', 'formidable' ),
1479 - __( 'Argentina', 'formidable' ),
1480 - __( 'Armenia', 'formidable' ),
1481 - __( 'Aruba', 'formidable' ),
1482 - __( 'Australia', 'formidable' ),
1483 - __( 'Austria', 'formidable' ),
1484 - __( 'Azerbaijan', 'formidable' ),
1485 - __( 'Bahamas', 'formidable' ),
1486 - __( 'Bahrain', 'formidable' ),
1487 - __( 'Bangladesh', 'formidable' ),
1488 - __( 'Barbados', 'formidable' ),
1489 - __( 'Belarus', 'formidable' ),
1490 - __( 'Belgium', 'formidable' ),
1491 - __( 'Belize', 'formidable' ),
1492 - __( 'Benin', 'formidable' ),
1493 - __( 'Bermuda', 'formidable' ),
1494 - __( 'Bhutan', 'formidable' ),
1495 - __( 'Bolivia', 'formidable' ),
1496 - __( 'Bonaire, Sint Eustatius and Saba', 'formidable' ),
1497 - __( 'Bosnia and Herzegovina', 'formidable' ),
1498 - __( 'Botswana', 'formidable' ),
1499 - __( 'Bouvet Island', 'formidable' ),
1500 - __( 'Brazil', 'formidable' ),
1501 - __( 'British Indian Ocean Territory', 'formidable' ),
1502 - __( 'Brunei', 'formidable' ),
1503 - __( 'Bulgaria', 'formidable' ),
1504 - __( 'Burkina Faso', 'formidable' ),
1505 - __( 'Burundi', 'formidable' ),
1506 - __( 'Cambodia', 'formidable' ),
1507 - __( 'Cameroon', 'formidable' ),
1508 - __( 'Canada', 'formidable' ),
1509 - __( 'Cape Verde', 'formidable' ),
1510 - __( 'Cayman Islands', 'formidable' ),
1511 - __( 'Central African Republic', 'formidable' ),
1512 - __( 'Chad', 'formidable' ),
1513 - __( 'Chile', 'formidable' ),
1514 - __( 'China', 'formidable' ),
1515 - __( 'Christmas Island', 'formidable' ),
1516 - __( 'Cocos (Keeling) Islands', 'formidable' ),
1517 - __( 'Colombia', 'formidable' ),
1518 - __( 'Comoros', 'formidable' ),
1519 - __( 'Congo', 'formidable' ),
1520 - __( 'Cook Islands', 'formidable' ),
1521 - __( 'Costa Rica', 'formidable' ),
1522 - __( 'C&ocirc;te d\'Ivoire', 'formidable' ),
1523 - __( 'Croatia', 'formidable' ),
1524 - __( 'Cuba', 'formidable' ),
1525 - __( 'Curacao', 'formidable' ),
1526 - __( 'Cyprus', 'formidable' ),
1527 - __( 'Czech Republic', 'formidable' ),
1528 - __( 'Denmark', 'formidable' ),
1529 - __( 'Djibouti', 'formidable' ),
1530 - __( 'Dominica', 'formidable' ),
1531 - __( 'Dominican Republic', 'formidable' ),
1532 - __( 'East Timor', 'formidable' ),
1533 - __( 'Ecuador', 'formidable' ),
1534 - __( 'Egypt', 'formidable' ),
1535 - __( 'El Salvador', 'formidable' ),
1536 - __( 'Equatorial Guinea', 'formidable' ),
1537 - __( 'Eritrea', 'formidable' ),
1538 - __( 'Estonia', 'formidable' ),
1539 - __( 'Ethiopia', 'formidable' ),
1540 - __( 'Falkland Islands (Malvinas)', 'formidable' ),
1541 - __( 'Faroe Islands', 'formidable' ),
1542 - __( 'Fiji', 'formidable' ),
1543 - __( 'Finland', 'formidable' ),
1544 - __( 'France', 'formidable' ),
1545 - __( 'French Guiana', 'formidable' ),
1546 - __( 'French Polynesia', 'formidable' ),
1547 - __( 'French Southern Territories', 'formidable' ),
1548 - __( 'Gabon', 'formidable' ),
1549 - __( 'Gambia', 'formidable' ),
1550 - __( 'Georgia', 'formidable' ),
1551 - __( 'Germany', 'formidable' ),
1552 - __( 'Ghana', 'formidable' ),
1553 - __( 'Gibraltar', 'formidable' ),
1554 - __( 'Greece', 'formidable' ),
1555 - __( 'Greenland', 'formidable' ),
1556 - __( 'Grenada', 'formidable' ),
1557 - __( 'Guadeloupe', 'formidable' ),
1558 - __( 'Guam', 'formidable' ),
1559 - __( 'Guatemala', 'formidable' ),
1560 - __( 'Guernsey', 'formidable' ),
1561 - __( 'Guinea', 'formidable' ),
1562 - __( 'Guinea-Bissau', 'formidable' ),
1563 - __( 'Guyana', 'formidable' ),
1564 - __( 'Haiti', 'formidable' ),
1565 - __( 'Heard Island and McDonald Islands', 'formidable' ),
1566 - __( 'Holy See', 'formidable' ),
1567 - __( 'Honduras', 'formidable' ),
1568 - __( 'Hong Kong', 'formidable' ),
1569 - __( 'Hungary', 'formidable' ),
1570 - __( 'Iceland', 'formidable' ),
1571 - __( 'India', 'formidable' ),
1572 - __( 'Indonesia', 'formidable' ),
1573 - __( 'Iran', 'formidable' ),
1574 - __( 'Iraq', 'formidable' ),
1575 - __( 'Ireland', 'formidable' ),
1576 - __( 'Israel', 'formidable' ),
1577 - __( 'Isle of Man', 'formidable' ),
1578 - __( 'Italy', 'formidable' ),
1579 - __( 'Jamaica', 'formidable' ),
1580 - __( 'Japan', 'formidable' ),
1581 - __( 'Jersey', 'formidable' ),
1582 - __( 'Jordan', 'formidable' ),
1583 - __( 'Kazakhstan', 'formidable' ),
1584 - __( 'Kenya', 'formidable' ),
1585 - __( 'Kiribati', 'formidable' ),
1586 - __( 'North Korea', 'formidable' ),
1587 - __( 'South Korea', 'formidable' ),
1588 - __( 'Kosovo', 'formidable' ),
1589 - __( 'Kuwait', 'formidable' ),
1590 - __( 'Kyrgyzstan', 'formidable' ),
1591 - __( 'Laos', 'formidable' ),
1592 - __( 'Latvia', 'formidable' ),
1593 - __( 'Lebanon', 'formidable' ),
1594 - __( 'Lesotho', 'formidable' ),
1595 - __( 'Liberia', 'formidable' ),
1596 - __( 'Libya', 'formidable' ),
1597 - __( 'Liechtenstein', 'formidable' ),
1598 - __( 'Lithuania', 'formidable' ),
1599 - __( 'Luxembourg', 'formidable' ),
1600 - __( 'Macao', 'formidable' ),
1601 - __( 'Macedonia', 'formidable' ),
1602 - __( 'Madagascar', 'formidable' ),
1603 - __( 'Malawi', 'formidable' ),
1604 - __( 'Malaysia', 'formidable' ),
1605 - __( 'Maldives', 'formidable' ),
1606 - __( 'Mali', 'formidable' ),
1607 - __( 'Malta', 'formidable' ),
1608 - __( 'Marshall Islands', 'formidable' ),
1609 - __( 'Martinique', 'formidable' ),
1610 - __( 'Mauritania', 'formidable' ),
1611 - __( 'Mauritius', 'formidable' ),
1612 - __( 'Mayotte', 'formidable' ),
1613 - __( 'Mexico', 'formidable' ),
1614 - __( 'Micronesia', 'formidable' ),
1615 - __( 'Moldova', 'formidable' ),
1616 - __( 'Monaco', 'formidable' ),
1617 - __( 'Mongolia', 'formidable' ),
1618 - __( 'Montenegro', 'formidable' ),
1619 - __( 'Montserrat', 'formidable' ),
1620 - __( 'Morocco', 'formidable' ),
1621 - __( 'Mozambique', 'formidable' ),
1622 - __( 'Myanmar', 'formidable' ),
1623 - __( 'Namibia', 'formidable' ),
1624 - __( 'Nauru', 'formidable' ),
1625 - __( 'Nepal', 'formidable' ),
1626 - __( 'Netherlands', 'formidable' ),
1627 - __( 'New Caledonia', 'formidable' ),
1628 - __( 'New Zealand', 'formidable' ),
1629 - __( 'Nicaragua', 'formidable' ),
1630 - __( 'Niger', 'formidable' ),
1631 - __( 'Nigeria', 'formidable' ),
1632 - __( 'Niue', 'formidable' ),
1633 - __( 'Norfolk Island', 'formidable' ),
1634 - __( 'Northern Mariana Islands', 'formidable' ),
1635 - __( 'Norway', 'formidable' ),
1636 - __( 'Oman', 'formidable' ),
1637 - __( 'Pakistan', 'formidable' ),
1638 - __( 'Palau', 'formidable' ),
1639 - __( 'Palestine', 'formidable' ),
1640 - __( 'Panama', 'formidable' ),
1641 - __( 'Papua New Guinea', 'formidable' ),
1642 - __( 'Paraguay', 'formidable' ),
1643 - __( 'Peru', 'formidable' ),
1644 - __( 'Philippines', 'formidable' ),
1645 - __( 'Pitcairn', 'formidable' ),
1646 - __( 'Poland', 'formidable' ),
1647 - __( 'Portugal', 'formidable' ),
1648 - __( 'Puerto Rico', 'formidable' ),
1649 - __( 'Qatar', 'formidable' ),
1650 - __( 'Reunion', 'formidable' ),
1651 - __( 'Romania', 'formidable' ),
1652 - __( 'Russia', 'formidable' ),
1653 - __( 'Rwanda', 'formidable' ),
1654 - __( 'Saint Barthelemy', 'formidable' ),
1655 - __( 'Saint Helena, Ascension and Tristan da Cunha', 'formidable' ),
1656 - __( 'Saint Kitts and Nevis', 'formidable' ),
1657 - __( 'Saint Lucia', 'formidable' ),
1658 - __( 'Saint Martin (French part)', 'formidable' ),
1659 - __( 'Saint Pierre and Miquelon', 'formidable' ),
1660 - __( 'Saint Vincent and the Grenadines', 'formidable' ),
1661 - __( 'Samoa', 'formidable' ),
1662 - __( 'San Marino', 'formidable' ),
1663 - __( 'Sao Tome and Principe', 'formidable' ),
1664 - __( 'Saudi Arabia', 'formidable' ),
1665 - __( 'Senegal', 'formidable' ),
1666 - __( 'Serbia', 'formidable' ),
1667 - __( 'Seychelles', 'formidable' ),
1668 - __( 'Sierra Leone', 'formidable' ),
1669 - __( 'Singapore', 'formidable' ),
1670 - __( 'Sint Maarten (Dutch part)', 'formidable' ),
1671 - __( 'Slovakia', 'formidable' ),
1672 - __( 'Slovenia', 'formidable' ),
1673 - __( 'Solomon Islands', 'formidable' ),
1674 - __( 'Somalia', 'formidable' ),
1675 - __( 'South Africa', 'formidable' ),
1676 - __( 'South Georgia and the South Sandwich Islands', 'formidable' ),
1677 - __( 'South Sudan', 'formidable' ),
1678 - __( 'Spain', 'formidable' ),
1679 - __( 'Sri Lanka', 'formidable' ),
1680 - __( 'Sudan', 'formidable' ),
1681 - __( 'Suriname', 'formidable' ),
1682 - __( 'Svalbard and Jan Mayen', 'formidable' ),
1683 - __( 'Swaziland', 'formidable' ),
1684 - __( 'Sweden', 'formidable' ),
1685 - __( 'Switzerland', 'formidable' ),
1686 - __( 'Syria', 'formidable' ),
1687 - __( 'Taiwan', 'formidable' ),
1688 - __( 'Tajikistan', 'formidable' ),
1689 - __( 'Tanzania', 'formidable' ),
1690 - __( 'Thailand', 'formidable' ),
1691 - __( 'Timor-Leste', 'formidable' ),
1692 - __( 'Togo', 'formidable' ),
1693 - __( 'Tokelau', 'formidable' ),
1694 - __( 'Tonga', 'formidable' ),
1695 - __( 'Trinidad and Tobago', 'formidable' ),
1696 - __( 'Tunisia', 'formidable' ),
1697 - __( 'Turkey', 'formidable' ),
1698 - __( 'Turkmenistan', 'formidable' ),
1699 - __( 'Turks and Caicos Islands', 'formidable' ),
1700 - __( 'Tuvalu', 'formidable' ),
1701 - __( 'Uganda', 'formidable' ),
1702 - __( 'Ukraine', 'formidable' ),
1703 - __( 'United Arab Emirates', 'formidable' ),
1704 - __( 'United Kingdom', 'formidable' ),
1705 - __( 'United States', 'formidable' ),
1706 - __( 'United States Minor Outlying Islands', 'formidable' ),
1707 - __( 'Uruguay', 'formidable' ),
1708 - __( 'Uzbekistan', 'formidable' ),
1709 - __( 'Vanuatu', 'formidable' ),
1710 - __( 'Vatican City', 'formidable' ),
1711 - __( 'Venezuela', 'formidable' ),
1712 - __( 'Vietnam', 'formidable' ),
1713 - __( 'Virgin Islands, British', 'formidable' ),
1714 - __( 'Virgin Islands, U.S.', 'formidable' ),
1715 - __( 'Wallis and Futuna', 'formidable' ),
1716 - __( 'Western Sahara', 'formidable' ),
1717 - __( 'Yemen', 'formidable' ),
1718 - __( 'Zambia', 'formidable' ),
1719 - __( 'Zimbabwe', 'formidable' ),
1720 - );
1721 -
1722 - sort( $countries, SORT_LOCALE_STRING );
1723 - return apply_filters( 'frm_countries', $countries );
1236 + return apply_filters( 'frm_countries', array( __( 'Afghanistan', 'formidable' ), __( 'Albania', 'formidable' ), __( 'Algeria', 'formidable' ), __( 'American Samoa', 'formidable' ), __( 'Andorra', 'formidable' ), __( 'Angola', 'formidable' ), __( 'Anguilla', 'formidable' ), __( 'Antarctica', 'formidable' ), __( 'Antigua and Barbuda', 'formidable' ), __( 'Argentina', 'formidable' ), __( 'Armenia', 'formidable' ), __( 'Aruba', 'formidable' ), __( 'Australia', 'formidable' ), __( 'Austria', 'formidable' ), __( 'Azerbaijan', 'formidable' ), __( 'Bahamas', 'formidable' ), __( 'Bahrain', 'formidable' ), __( 'Bangladesh', 'formidable' ), __( 'Barbados', 'formidable' ), __( 'Belarus', 'formidable' ), __( 'Belgium', 'formidable' ), __( 'Belize', 'formidable' ), __( 'Benin', 'formidable' ), __( 'Bermuda', 'formidable' ), __( 'Bhutan', 'formidable' ), __( 'Bolivia', 'formidable' ), __( 'Bosnia and Herzegovina', 'formidable' ), __( 'Botswana', 'formidable' ), __( 'Brazil', 'formidable' ), __( 'Brunei', 'formidable' ), __( 'Bulgaria', 'formidable' ), __( 'Burkina Faso', 'formidable' ), __( 'Burundi', 'formidable' ), __( 'Cambodia', 'formidable' ), __( 'Cameroon', 'formidable' ), __( 'Canada', 'formidable' ), __( 'Cape Verde', 'formidable' ), __( 'Cayman Islands', 'formidable' ), __( 'Central African Republic', 'formidable' ), __( 'Chad', 'formidable' ), __( 'Chile', 'formidable' ), __( 'China', 'formidable' ), __( 'Colombia', 'formidable' ), __( 'Comoros', 'formidable' ), __( 'Congo', 'formidable' ), __( 'Costa Rica', 'formidable' ), __( 'C&ocirc;te d\'Ivoire', 'formidable' ), __( 'Croatia', 'formidable' ), __( 'Cuba', 'formidable' ), __( 'Cyprus', 'formidable' ), __( 'Czech Republic', 'formidable' ), __( 'Denmark', 'formidable' ), __( 'Djibouti', 'formidable' ), __( 'Dominica', 'formidable' ), __( 'Dominican Republic', 'formidable' ), __( 'East Timor', 'formidable' ), __( 'Ecuador', 'formidable' ), __( 'Egypt', 'formidable' ), __( 'El Salvador', 'formidable' ), __( 'Equatorial Guinea', 'formidable' ), __( 'Eritrea', 'formidable' ), __( 'Estonia', 'formidable' ), __( 'Ethiopia', 'formidable' ), __( 'Fiji', 'formidable' ), __( 'Finland', 'formidable' ), __( 'France', 'formidable' ), __( 'French Guiana', 'formidable' ), __( 'French Polynesia', 'formidable' ), __( 'Gabon', 'formidable' ), __( 'Gambia', 'formidable' ), __( 'Georgia', 'formidable' ), __( 'Germany', 'formidable' ), __( 'Ghana', 'formidable' ), __( 'Gibraltar', 'formidable' ), __( 'Greece', 'formidable' ), __( 'Greenland', 'formidable' ), __( 'Grenada', 'formidable' ), __( 'Guam', 'formidable' ), __( 'Guatemala', 'formidable' ), __( 'Guinea', 'formidable' ), __( 'Guinea-Bissau', 'formidable' ), __( 'Guyana', 'formidable' ), __( 'Haiti', 'formidable' ), __( 'Honduras', 'formidable' ), __( 'Hong Kong', 'formidable' ), __( 'Hungary', 'formidable' ), __( 'Iceland', 'formidable' ), __( 'India', 'formidable' ), __( 'Indonesia', 'formidable' ), __( 'Iran', 'formidable' ), __( 'Iraq', 'formidable' ), __( 'Ireland', 'formidable' ), __( 'Israel', 'formidable' ), __( 'Italy', 'formidable' ), __( 'Jamaica', 'formidable' ), __( 'Japan', 'formidable' ), __( 'Jordan', 'formidable' ), __( 'Kazakhstan', 'formidable' ), __( 'Kenya', 'formidable' ), __( 'Kiribati', 'formidable' ), __( 'North Korea', 'formidable' ), __( 'South Korea', 'formidable' ), __( 'Kuwait', 'formidable' ), __( 'Kyrgyzstan', 'formidable' ), __( 'Laos', 'formidable' ), __( 'Latvia', 'formidable' ), __( 'Lebanon', 'formidable' ), __( 'Lesotho', 'formidable' ), __( 'Liberia', 'formidable' ), __( 'Libya', 'formidable' ), __( 'Liechtenstein', 'formidable' ), __( 'Lithuania', 'formidable' ), __( 'Luxembourg', 'formidable' ), __( 'Macedonia', 'formidable' ), __( 'Madagascar', 'formidable' ), __( 'Malawi', 'formidable' ), __( 'Malaysia', 'formidable' ), __( 'Maldives', 'formidable' ), __( 'Mali', 'formidable' ), __( 'Malta', 'formidable' ), __( 'Marshall Islands', 'formidable' ), __( 'Mauritania', 'formidable' ), __( 'Mauritius', 'formidable' ), __( 'Mexico', 'formidable' ), __( 'Micronesia', 'formidable' ), __( 'Moldova', 'formidable' ), __( 'Monaco', 'formidable' ), __( 'Mongolia', 'formidable' ), __( 'Montenegro', 'formidable' ), __( 'Montserrat', 'formidable' ), __( 'Morocco', 'formidable' ), __( 'Mozambique', 'formidable' ), __( 'Myanmar', 'formidable' ), __( 'Namibia', 'formidable' ), __( 'Nauru', 'formidable' ), __( 'Nepal', 'formidable' ), __( 'Netherlands', 'formidable' ), __( 'New Zealand', 'formidable' ), __( 'Nicaragua', 'formidable' ), __( 'Niger', 'formidable' ), __( 'Nigeria', 'formidable' ), __( 'Norway', 'formidable' ), __( 'Northern Mariana Islands', 'formidable' ), __( 'Oman', 'formidable' ), __( 'Pakistan', 'formidable' ), __( 'Palau', 'formidable' ), __( 'Palestine', 'formidable' ), __( 'Panama', 'formidable' ), __( 'Papua New Guinea', 'formidable' ), __( 'Paraguay', 'formidable' ), __( 'Peru', 'formidable' ), __( 'Philippines', 'formidable' ), __( 'Poland', 'formidable' ), __( 'Portugal', 'formidable' ), __( 'Puerto Rico', 'formidable' ), __( 'Qatar', 'formidable' ), __( 'Romania', 'formidable' ), __( 'Russia', 'formidable' ), __( 'Rwanda', 'formidable' ), __( 'Saint Kitts and Nevis', 'formidable' ), __( 'Saint Lucia', 'formidable' ), __( 'Saint Vincent and the Grenadines', 'formidable' ), __( 'Samoa', 'formidable' ), __( 'San Marino', 'formidable' ), __( 'Sao Tome and Principe', 'formidable' ), __( 'Saudi Arabia', 'formidable' ), __( 'Senegal', 'formidable' ), __( 'Serbia and Montenegro', 'formidable' ), __( 'Seychelles', 'formidable' ), __( 'Sierra Leone', 'formidable' ), __( 'Singapore', 'formidable' ), __( 'Slovakia', 'formidable' ), __( 'Slovenia', 'formidable' ), __( 'Solomon Islands', 'formidable' ), __( 'Somalia', 'formidable' ), __( 'South Africa', 'formidable' ), __( 'South Sudan', 'formidable' ), __( 'Spain', 'formidable' ), __( 'Sri Lanka', 'formidable' ), __( 'Sudan', 'formidable' ), __( 'Suriname', 'formidable' ), __( 'Swaziland', 'formidable' ), __( 'Sweden', 'formidable' ), __( 'Switzerland', 'formidable' ), __( 'Syria', 'formidable' ), __( 'Taiwan', 'formidable' ), __( 'Tajikistan', 'formidable' ), __( 'Tanzania', 'formidable' ), __( 'Thailand', 'formidable' ), __( 'Togo', 'formidable' ), __( 'Tonga', 'formidable' ), __( 'Trinidad and Tobago', 'formidable' ), __( 'Tunisia', 'formidable' ), __( 'Turkey', 'formidable' ), __( 'Turkmenistan', 'formidable' ), __( 'Tuvalu', 'formidable' ), __( 'Uganda', 'formidable' ), __( 'Ukraine', 'formidable' ), __( 'United Arab Emirates', 'formidable' ), __( 'United Kingdom', 'formidable' ), __( 'United States', 'formidable' ), __( 'Uruguay', 'formidable' ), __( 'Uzbekistan', 'formidable' ), __( 'Vanuatu', 'formidable' ), __( 'Vatican City', 'formidable' ), __( 'Venezuela', 'formidable' ), __( 'Vietnam', 'formidable' ), __( 'Virgin Islands, British', 'formidable' ), __( 'Virgin Islands, U.S.', 'formidable' ), __( 'Yemen', 'formidable' ), __( 'Zambia', 'formidable' ), __( 'Zimbabwe', 'formidable' ) ) );
1724 1237 }
1725 1238
1726 - /**
1727 - * Gets bulk prefilled options.
1728 - *
1729 - * @since 5.0.04 Add `$include_class` param.
1730 - *
1731 - * @param array $prepop Bulk options.
1732 - * @param array|false $include_class Include the class in the bulk options.
1733 - */
1734 - public static function get_bulk_prefilled_opts( array &$prepop, $include_class = false ) {
1735 - // Countries.
1736 - $countries = self::get_countries();
1737 - if ( $include_class ) {
1738 - $countries['class'] = 'frm-countries-opts';
1739 - }
1239 + public static function get_bulk_prefilled_opts( array &$prepop ) {
1240 + $prepop[ __( 'Countries', 'formidable' ) ] = self::get_countries();
1740 1241
1741 - $prepop[ __( 'Countries', 'formidable' ) ] = $countries;
1742 -
1743 - // State abv.
1744 - $states = self::get_us_states();
1242 + $states = self::get_us_states();
1745 1243 $state_abv = array_keys( $states );
1746 1244 sort( $state_abv );
1747 - if ( $include_class ) {
1748 - $state_abv['class'] = 'frm-state-abv-opts';
1749 - }
1750 -
1751 1245 $prepop[ __( 'U.S. State Abbreviations', 'formidable' ) ] = $state_abv;
1752 1246
1753 - // States.
1754 1247 $states = array_values( $states );
1755 1248 sort( $states );
1756 - if ( $include_class ) {
1757 - $states['class'] = 'frm-states-opts';
1758 - }
1759 -
1760 1249 $prepop[ __( 'U.S. States', 'formidable' ) ] = $states;
1761 1250 unset( $state_abv, $states );
1762 1251
1763 - // Age.
1764 - $ages = array(
1252 + $prepop[ __( 'Age', 'formidable' ) ] = array(
1765 1253 __( 'Under 18', 'formidable' ),
1766 1254 __( '18-24', 'formidable' ),
1767 1255 __( '25-34', 'formidable' ),
1768 1256 __( '35-44', 'formidable' ),
@@ -1770,76 +1258,38 @@
1770 1258 __( '55-64', 'formidable' ),
1771 1259 __( '65 or Above', 'formidable' ),
1772 1260 __( 'Prefer Not to Answer', 'formidable' ),
1773 1261 );
1774 - if ( $include_class ) {
1775 - $ages['class'] = 'frm-age-opts';
1776 - }
1777 1262
1778 - $prepop[ __( 'Age', 'formidable' ) ] = $ages;
1779 -
1780 - // Satisfaction.
1781 - $satisfaction = array(
1263 + $prepop[ __( 'Satisfaction', 'formidable' ) ] = array(
1264 + __( 'Very Satisfied', 'formidable' ),
1265 + __( 'Satisfied', 'formidable' ),
1266 + __( 'Neutral', 'formidable' ),
1267 + __( 'Unsatisfied', 'formidable' ),
1782 1268 __( 'Very Unsatisfied', 'formidable' ),
1783 - __( 'Unsatisfied', 'formidable' ),
1784 - __( 'Neutral', 'formidable' ),
1785 - __( 'Satisfied', 'formidable' ),
1786 - __( 'Very Satisfied', 'formidable' ),
1787 1269 __( 'N/A', 'formidable' ),
1788 1270 );
1789 - if ( $include_class ) {
1790 - $satisfaction['class'] = 'frm-satisfaction-opts';
1791 - }
1792 1271
1793 - $prepop[ __( 'Satisfaction', 'formidable' ) ] = $satisfaction;
1794 -
1795 - // Importance.
1796 - $importance = array(
1272 + $prepop[ __( 'Importance', 'formidable' ) ] = array(
1273 + __( 'Very Important', 'formidable' ),
1274 + __( 'Important', 'formidable' ),
1275 + __( 'Neutral', 'formidable' ),
1276 + __( 'Somewhat Important', 'formidable' ),
1797 1277 __( 'Not at all Important', 'formidable' ),
1798 - __( 'Somewhat Important', 'formidable' ),
1799 - __( 'Neutral', 'formidable' ),
1800 - __( 'Important', 'formidable' ),
1801 - __( 'Very Important', 'formidable' ),
1802 1278 __( 'N/A', 'formidable' ),
1803 1279 );
1804 - if ( $include_class ) {
1805 - $importance['class'] = 'frm-importance-opts';
1806 - }
1807 1280
1808 - $prepop[ __( 'Importance', 'formidable' ) ] = $importance;
1809 -
1810 - // Agreement.
1811 - $agreement = array(
1812 - __( 'Strongly Disagree', 'formidable' ),
1813 - __( 'Disagree', 'formidable' ),
1814 - __( 'Neutral', 'formidable' ),
1281 + $prepop[ __( 'Agreement', 'formidable' ) ] = array(
1282 + __( 'Strongly Agree', 'formidable' ),
1815 1283 __( 'Agree', 'formidable' ),
1816 - __( 'Strongly Agree', 'formidable' ),
1817 - __( 'N/A', 'formidable' ),
1818 - );
1819 - if ( $include_class ) {
1820 - $agreement['class'] = 'frm-agreement-opts';
1821 - }
1822 -
1823 - $prepop[ __( 'Agreement', 'formidable' ) ] = $agreement;
1824 -
1825 - // Likely.
1826 - $likely = array(
1827 - __( 'Extremely Unlikely', 'formidable' ),
1828 - __( 'Unlikely', 'formidable' ),
1829 1284 __( 'Neutral', 'formidable' ),
1830 - __( 'Likely', 'formidable' ),
1831 - __( 'Extremely Likely', 'formidable' ),
1285 + __( 'Disagree', 'formidable' ),
1286 + __( 'Strongly Disagree', 'formidable' ),
1832 1287 __( 'N/A', 'formidable' ),
1833 1288 );
1834 - if ( $include_class ) {
1835 - $likely['class'] = 'frm-likely-opts';
1836 - }
1837 1289
1838 - $prepop[ __( 'Likely', 'formidable' ) ] = $likely;
1839 -
1840 1290 $prepop = apply_filters( 'frm_bulk_field_choices', $prepop );
1841 - }
1291 + }
1842 1292
1843 1293 /**
1844 1294 * Display a field value selector
1845 1295 *
@@ -1847,12 +1297,12 @@
1847 1297 *
1848 1298 * @param int $selector_field_id
1849 1299 * @param array $selector_args
1850 1300 */
1851 - public static function display_field_value_selector( $selector_field_id, $selector_args ) {
1852 - $field_value_selector = FrmFieldFactory::create_field_value_selector( $selector_field_id, $selector_args );
1853 - $field_value_selector->display();
1854 - }
1301 + public static function display_field_value_selector( $selector_field_id, $selector_args ) {
1302 + $field_value_selector = FrmFieldFactory::create_field_value_selector( $selector_field_id, $selector_args );
1303 + $field_value_selector->display();
1304 + }
1855 1305
1856 1306 /**
1857 1307 * Convert a field object to a flat array
1858 1308 *
@@ -1863,287 +1313,14 @@
1863 1313 * @return array
1864 1314 */
1865 1315 public static function convert_field_object_to_flat_array( $field ) {
1866 1316 $field_options = $field->field_options;
1867 - $field_array = get_object_vars( $field );
1317 + $field_array = get_object_vars( $field );
1868 1318 unset( $field_array['field_options'] );
1869 -
1870 1319 return $field_array + $field_options;
1871 1320 }
1872 1321
1873 1322 /**
1874 - * @since 4.04
1875 - *
1876 - * @param array $args
1877 - * @return void
1878 - */
1879 - public static function show_add_field_buttons( $args ) {
1880 - $field_key = $args['field_key'];
1881 - $field_type = $args['field_type'];
1882 - $field_label = FrmAppHelper::icon_by_class( FrmFormsHelper::get_field_link_icon( $field_type ), array( 'echo' => false ) );
1883 - $field_name = FrmFormsHelper::get_field_link_name( $field_type );
1884 - $field_label .= ' <span>' . $field_name . '</span>';
1885 -
1886 - // If the individual field isn't allowed, disable it.
1887 - $run_filter = true;
1888 - $single_no_allow = ' ';
1889 - $install_data = '';
1890 - $requires = '';
1891 - $link = isset( $field_type['link'] ) ? esc_url_raw( $field_type['link'] ) : '';
1892 - $has_show_upgrade_class = strpos( $field_type['icon'], ' frm_show_upgrade' );
1893 - $show_upgrade = $has_show_upgrade_class || false !== strpos( $args['no_allow_class'], 'frm_show_upgrade' );
1894 -
1895 - if ( $has_show_upgrade_class ) {
1896 - $single_no_allow .= 'frm_show_upgrade';
1897 - $field_type['icon'] = str_replace( ' frm_show_upgrade', '', $field_type['icon'] );
1898 - $run_filter = false;
1899 - if ( isset( $field_type['addon'] ) ) {
1900 - $upgrading = FrmAddonsController::install_link( $field_type['addon'] );
1901 - if ( isset( $upgrading['url'] ) ) {
1902 - $install_data = json_encode( $upgrading );
1903 - }
1904 - $requires = FrmFormsHelper::get_plan_required( $upgrading );
1905 - } elseif ( isset( $field_type['require'] ) ) {
1906 - $requires = $field_type['require'];
1907 - }
1908 - }
1909 -
1910 - $upgrade_label = '';
1911 - $upgrade_message = '';
1912 - if ( $show_upgrade ) {
1913 - /* translators: %s: Field name */
1914 - $upgrade_label = sprintf( esc_html__( '%s fields', 'formidable' ), $field_name );
1915 -
1916 - if ( isset( $field_type['message'] ) ) {
1917 - $upgrade_message = FrmAppHelper::kses( $field_type['message'], array( 'a', 'img' ) );
1918 - }
1919 - }
1920 -
1921 - $li_params = array(
1922 - 'class' => 'frmbutton frm6 ' . $args['no_allow_class'] . $single_no_allow . ' frm_t' . str_replace( '|', '-', $field_key ),
1923 - 'id' => $field_key,
1924 - 'data-upgrade' => $upgrade_label,
1925 - 'data-link' => $link,
1926 - 'data-medium' => 'builder',
1927 - 'data-oneclick' => $install_data,
1928 - 'data-content' => $field_key,
1929 - 'data-requires' => $requires,
1930 - );
1931 -
1932 - if ( $upgrade_message ) {
1933 - $li_params['data-message'] = $upgrade_message;
1934 - }
1935 - ?>
1936 - <li <?php FrmAppHelper::array_to_html_params( $li_params, true ); ?>>
1937 - <?php
1938 - if ( $run_filter ) {
1939 - $field_label = apply_filters( 'frmpro_field_links', $field_label, $args['id'], $field_key );
1940 - }
1941 - echo FrmAppHelper::kses( $field_label, array( 'a', 'i', 'span', 'use', 'svg' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1942 - ?>
1943 - </li>
1944 - <?php
1945 - }
1946 -
1947 - /**
1948 - * Shows Display format option.
1949 - *
1950 - * @since 5.0.04
1951 - *
1952 - * @param array $field Field data.
1953 - */
1954 - public static function show_radio_display_format( $field ) {
1955 - $options = self::get_display_format_options( $field );
1956 -
1957 - $args = self::get_display_format_args( $field, $options );
1958 -
1959 - include FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/radio-display-format.php';
1960 - }
1961 -
1962 - /**
1963 - * Creates an array that contains variables used for display format options setting.
1964 - *
1965 - * @since 6.3.2
1966 - *
1967 - * @param array $field The field.
1968 - *
1969 - * @return array
1970 - */
1971 - public static function get_display_format_options( $field ) {
1972 - $options = array(
1973 - '0' => array(
1974 - 'text' => __( 'Simple', 'formidable' ),
1975 - 'svg' => 'frm_simple_radio',
1976 - ),
1977 - '1' => array(
1978 - 'text' => __( 'Images', 'formidable' ),
1979 - 'svg' => 'frm_image_as_option',
1980 - 'addon' => 'pro',
1981 - 'upgrade' => __( 'Image Options', 'formidable' ),
1982 - '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" />',
1983 - 'content' => 'image-options',
1984 - ),
1985 - 'buttons' => array(
1986 - 'text' => __( 'Buttons', 'formidable' ),
1987 - 'svg' => 'frm_button_as_option',
1988 - 'addon' => 'surveys',
1989 - 'upgrade' => __( 'Button Options', 'formidable' ),
1990 - 'message' => __( 'Show buttons for radio buttons or check boxes. This is ideal for polls, surveys, segmenting questionnaires and more.', 'formidable' ),
1991 - 'content' => 'button-options',
1992 - ),
1993 - );
1994 -
1995 - /**
1996 - * Allows modifying the options of Display format setting of Radio field.
1997 - *
1998 - * @since 5.0.04
1999 - *
2000 - * @param array $options Options.
2001 - * @param array $field
2002 - */
2003 - $options = apply_filters( 'frm_' . $field['type'] . '_display_format_options', $options, $field );
2004 -
2005 - return $options;
2006 - }
2007 -
2008 - /**
2009 - * Gets display format arguments to pass to the images_dropdown() method.
2010 - *
2011 - * @since 5.0.04
2012 - *
2013 - * @param array $field Field data.
2014 - * @param array $options Options array.
2015 - * @return array
2016 - */
2017 - public static function get_display_format_args( $field, $options ) {
2018 - $args = array(
2019 - 'selected' => '0',
2020 - 'options' => array(),
2021 - 'name' => 'field_options[image_options_' . $field['id'] . ']',
2022 - 'input_attrs' => array(
2023 - 'class' => 'frm_toggle_image_options',
2024 - ),
2025 - );
2026 -
2027 - self::fill_image_setting_options( $options, $args );
2028 -
2029 - /**
2030 - * Allows modifying the arguments of Display format setting of Radio field.
2031 - *
2032 - * @since 5.0.04
2033 - *
2034 - * @param array $args Arguments.
2035 - * @param array $method_args The arguments from the method. Contains `field`, `options`.
2036 - */
2037 - return apply_filters( 'frm_' . $field['type'] . '_display_format_args', $args, compact( 'field', 'options' ) );
2038 - }
2039 -
2040 - /**
2041 - * @since 5.0.04
2042 - */
2043 - private static function fill_image_setting_options( $options, &$args ) {
2044 - foreach ( $options as $key => $option ) {
2045 - $args['options'][ $key ] = $option;
2046 -
2047 - if ( ! empty( $option['addon'] ) ) {
2048 - $args['options'][ $key ]['custom_attrs'] = self::fill_image_setting_addon_link( $option );
2049 - }
2050 -
2051 - unset( $args['options'][ $key ]['addon'] );
2052 - $fill = array( 'upgrade', 'message', 'content' );
2053 - foreach ( $fill as $f ) {
2054 - unset( $args['options'][ $key ][ $f ], $f );
2055 - }
2056 - }
2057 - }
2058 -
2059 - /**
2060 - * @since 5.0.04
2061 - *
2062 - * @return array
2063 - */
2064 - private static function fill_image_setting_addon_link( $option ) {
2065 - $custom_attrs = array(
2066 - 'class' => 'frm_noallow frm_show_upgrade',
2067 - 'data-medium' => 'builder',
2068 - );
2069 -
2070 - // translators: Add-on name.
2071 - $custom_attrs['data-upgrade'] = sprintf( __( 'Formidable %s', 'formidable' ), ucwords( $option['addon'] ) );
2072 -
2073 - $fill = array( 'upgrade', 'message', 'content' );
2074 - foreach ( $fill as $f ) {
2075 - if ( isset( $option[ $f ] ) ) {
2076 - $custom_attrs[ 'data-' . $f ] = $option[ $f ];
2077 - }
2078 - }
2079 -
2080 - if ( 'pro' === $option['addon'] ) {
2081 - return $custom_attrs;
2082 - }
2083 -
2084 - $upgrading = FrmAddonsController::install_link( $option['addon'] );
2085 - if ( isset( $upgrading['url'] ) ) {
2086 - $install_data = wp_json_encode( $upgrading );
2087 - } else {
2088 - $install_data = '';
2089 - }
2090 -
2091 - $custom_attrs['data-oneclick'] = $install_data;
2092 - $custom_attrs['data-requires'] = FrmFormsHelper::get_plan_required( $upgrading );
2093 -
2094 - return $custom_attrs;
2095 - }
2096 -
2097 - /**
2098 - * Maybe adjust a field value based on type.
2099 - * Some types require unserializing an array (@see self::field_type_requires_unserialize).
2100 - *
2101 - * @since 6.2
2102 - *
2103 - * @param mixed $value
2104 - * @param string $field_type
2105 - * @return void
2106 - */
2107 - public static function prepare_field_value( &$value, $field_type ) {
2108 - $field_object = FrmFieldFactory::get_field_type( $field_type );
2109 - $value = $field_object->maybe_decode_value( $value );
2110 - }
2111 -
2112 - /**
2113 - * @deprecated 4.0
2114 - */
2115 - public static function show_icon_link_js( $atts ) {
2116 - _deprecated_function( __METHOD__, '4.0' );
2117 - $atts['icon'] .= $atts['is_selected'] ? ' ' : ' frm_inactive_icon ';
2118 - if ( isset( $atts['has_default'] ) && ! $atts['has_default'] ) {
2119 - $atts['icon'] .= 'frm_hidden ';
2120 - }
2121 - echo '<a href="javascript:void(0)" class="frm_bstooltip ' . esc_attr( $atts['icon'] ) . 'frm_default_val_icons frm_action_icon frm_icon_font" title="' . esc_attr( $atts['message'] ) . '"></a>';
2122 - }
2123 -
2124 - /**
2125 - * @deprecated 4.0
2126 - */
2127 - public static function show_default_blank_js( $is_selected, $has_default_value = true ) {
2128 - _deprecated_function( __METHOD__, '4.0' );
2129 - }
2130 -
2131 - /**
2132 - * @deprecated 4.0
2133 - */
2134 - public static function clear_on_focus_html( $field, $display, $id = '' ) {
2135 - _deprecated_function( __METHOD__, '4.0' );
2136 - }
2137 -
2138 - /**
2139 - * @deprecated 4.0
2140 - */
2141 - public static function show_onfocus_js( $is_selected, $has_default_value = true ) {
2142 - _deprecated_function( __METHOD__, '4.0' );
2143 - }
2144 -
2145 - /**
2146 1323 * @deprecated 3.0
2147 1324 * @codeCoverageIgnore
2148 1325 */
2149 1326 public static function display_recaptcha() {
@@ -2163,19 +1340,19 @@
2163 1340 * @codeCoverageIgnore
2164 1341 */
2165 1342 public static function get_shortcode_tag( $shortcodes, $short_key, $args ) {
2166 1343 return FrmDeprecated::get_shortcode_tag( $shortcodes, $short_key, $args );
2167 - }
1344 + }
2168 1345
2169 1346 /**
2170 1347 * @deprecated 3.0
2171 1348 * @codeCoverageIgnore
2172 1349 *
2173 - * @param string $html
2174 - * @param array $field
2175 - * @param array $errors
2176 - * @param object|false $form
2177 - * @param array $args
1350 + * @param string $html
1351 + * @param array $field
1352 + * @param array $errors
1353 + * @param object $form
1354 + * @param array $args
2178 1355 *
2179 1356 * @return string
2180 1357 */
2181 1358 public static function replace_shortcodes( $html, $field, $errors = array(), $form = false, $args = array() ) {
@@ -2190,13 +1367,10 @@
2190 1367 return FrmDeprecated::get_default_field_opts( $type, $field, $limit );
2191 1368 }
2192 1369
2193 1370 /**
2194 - * @deprecated 2.02.07 This is still referenced in the Highrise add on as of v1.06.
1371 + * @deprecated 2.02.07
2195 1372 * @codeCoverageIgnore
2196 - *
2197 - * @param array $args
2198 - * @return string
2199 1373 */
2200 1374 public static function dropdown_categories( $args ) {
2201 1375 return FrmDeprecated::dropdown_categories( $args );
2202 1376 }