PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / trunk
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More vtrunk
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/views/frm-fields/back-end/settings.php +68 -20 6.25 → trunk View file →
@@ -1,5 +1,27 @@
1 1 <?php
2 +/**
3 + * Field settings panel in the form builder.
4 + *
5 + * @package Formidable
6 + *
7 + * @var array $field Field data.
8 + * @var array $display Display options for each setting section.
9 + * @var array $values Form values associated with the field.
10 + * @var FrmFieldType $field_obj Field type handler.
11 + * @var string $type_name Human-readable field type name.
12 + * @var array $field_types Available field types this field can switch to.
13 + * @var array $disabled_fields Field types that are disabled in the type dropdown.
14 + * @var array $default_value_types Default value types available for this field.
15 + * @var array $unique_values_label_atts Label attributes for the Unique checkbox.
16 + * @var array $read_only_label_atts Label attributes for the Read Only checkbox.
17 + * @var bool|null $show_upsell_for_unique_value Whether to show upsell for Unique.
18 + * @var bool|null $show_upsell_for_read_only Whether to show upsell for Read Only.
19 + * @var bool|null $show_upsell_for_before_after_contents Whether to show upsell for before/after contents.
20 + * @var bool|null $show_upsell_for_autocomplete Whether to show upsell for autocomplete.
21 + * @var bool|null $show_upsell_for_visibility Whether to show upsell for visibility.
22 + */
23 +
2 24 if ( ! defined( 'ABSPATH' ) ) {
3 25 die( 'You are not allowed to call this page directly.' );
4 26 }
5 27 ?>
@@ -22,9 +44,9 @@
22 44 <?php
23 45 if ( $field['type'] === 'captcha' && ! FrmFieldCaptcha::should_show_captcha() ) {
24 46 ?>
25 47 <div class="frm_warning_style frm-with-icon">
26 - <?php FrmAppHelper::icon_by_class( 'frm_icon_font frm_alert_icon', array( 'style' => 'width:24px' ) ); ?>
48 + <?php FrmAppHelper::icon_by_class( 'frmfont frm_alert_icon', array( 'style' => 'width:24px' ) ); ?>
27 49 <span>
28 50 <?php
29 51 /* translators: %1$s: Link HTML, %2$s: End link */
30 52 printf( esc_html__( 'Captchas will not be used until the Site and Secret Keys are %1$sset up%2$s.', 'formidable' ), '<a href="?page=formidable-settings&t=captcha_settings" target="_blank">', '</a>' );
@@ -32,19 +54,20 @@
32 54 </span>
33 55 </div>
34 56 <?php
35 57 }
58 +
36 59 if ( $field['type'] === 'credit_card' && ! FrmAppHelper::pro_is_installed() ) {
37 - if ( ! FrmStrpLiteConnectHelper::at_least_one_mode_is_setup() && ! FrmSquareLiteConnectHelper::at_least_one_mode_is_setup() ) {
60 + if ( ! FrmStrpLiteConnectHelper::at_least_one_mode_is_setup() && ! FrmSquareLiteConnectHelper::at_least_one_mode_is_setup() && ! FrmPayPalLiteConnectHelper::at_least_one_mode_is_setup() ) {
38 61 FrmStrpLiteAppHelper::not_connected_warning();
39 62 } elseif ( ! FrmTransLiteActionsController::get_actions_for_form( $field['form_id'] ) ) {
40 63 ?>
41 64 <div class="frm_warning_style frm-with-icon">
42 - <?php FrmAppHelper::icon_by_class( 'frm_icon_font frm_alert_icon', array( 'style' => 'width:24px' ) ); ?>
65 + <?php FrmAppHelper::icon_by_class( 'frmfont frm_alert_icon', array( 'style' => 'width:24px' ) ); ?>
43 66 <span>
44 67 <?php
45 68 /* translators: %1$s: Link HTML, %2$s: End link */
46 - printf( esc_html__( 'Credit Cards will not work without %1$sadding a Collect Payment action%2$s.', 'formidable' ), '<a href="?page=formidable&frm_action=settings&id=' . absint( $field['form_id'] ) . '&t=email_settings" target="_blank">', '</a>' );
69 + printf( esc_html__( 'Credit Cards will not work without %1$sadding a Stripe, Square, or PayPal action%2$s.', 'formidable' ), '<a href="?page=formidable&frm_action=settings&id=' . absint( $field['form_id'] ) . '&t=email_settings" target="_blank">', '</a>' );
47 70 ?>
48 71 </span>
49 72 </div>
50 73 <?php
@@ -55,9 +78,9 @@
55 78 <?php
56 79 if ( $field['type'] === FrmFieldGdprHelper::FIELD_TYPE && FrmFieldGdprHelper::hide_gdpr_field() ) {
57 80 ?>
58 81 <div class="frm_note_style">
59 - <?php FrmAppHelper::icon_by_class( 'frm_icon_font frm_alert_icon', array( 'style' => 'width:24px' ) ); ?>
82 + <?php FrmAppHelper::icon_by_class( 'frmfont frm_alert_icon', array( 'style' => 'width:24px' ) ); ?>
60 83 <span>
61 84 <?php
62 85 /* translators: %1$s: Link HTML, %2$s: End link */
63 86 printf( esc_html__( 'GDPR field is disabled. Please enable it in the Formidable %1$sSettings%2$s.', 'formidable' ), '<a href="?page=formidable-settings" target="_blank">', '</a>' );
@@ -82,9 +105,12 @@
82 105 ?>
83 106 <?php if ( $display['label'] ) { ?>
84 107 <p class="frm-mt-xs">
85 108 <label for="frm_name_<?php echo esc_attr( $field['id'] ); ?>">
86 - <?php echo esc_html( apply_filters( 'frm_builder_field_label', __( 'Field Label', 'formidable' ), $field ) ); ?>
109 + <?php
110 + // skipcq: PHP-W1020
111 + echo esc_html( apply_filters( 'frm_builder_field_label', __( 'Field Label', 'formidable' ), $field ) );
112 + ?>
87 113 </label>
88 114 <input type="text" name="field_options[name_<?php echo esc_attr( $field['id'] ); ?>]" value="<?php echo esc_attr( $field['name'] ); ?>" id="frm_name_<?php echo esc_attr( $field['id'] ); ?>" data-changeme="field_label_<?php echo esc_attr( $field['id'] ); ?>" />
89 115 </p>
90 116 <?php } else { ?>
@@ -101,13 +127,13 @@
101 127 </div>
102 128 <?php
103 129 }
104 130
105 - if ( $display['unique'] ) {
131 + if ( $display['unique'] || ! empty( $show_upsell_for_unique_value ) ) {
106 132 ?>
107 133 <div class="frm_form_field">
108 - <label for="frm_uniq_field_<?php echo esc_attr( $field['id'] ); ?>" class="frm_help frm-mb-0" title="<?php esc_attr_e( 'Unique: Do not allow the same response multiple times. For example, if one user enters \'Joe\', then no one else will be allowed to enter the same name.', 'formidable' ); ?>" data-trigger="hover">
109 - <input type="checkbox" name="field_options[unique_<?php echo esc_attr( $field['id'] ); ?>]" id="frm_uniq_field_<?php echo esc_attr( $field['id'] ); ?>" value="1" <?php checked( $field['unique'], 1 ); ?> class="frm_mark_unique" />
134 + <label <?php FrmAppHelper::array_to_html_params( $unique_values_label_atts, true ); ?>>
135 + <input <?php FrmAppHelper::array_to_html_params( FrmSettingsUpsellHelper::get_unique_element_atts( $field ), true ); ?> />
110 136 <?php esc_html_e( 'Unique', 'formidable' ); ?>
111 137 </label>
112 138 </div>
113 139 <?php
@@ -112,13 +138,13 @@
112 138 </div>
113 139 <?php
114 140 }
115 141
116 - if ( $display['read_only'] ) {
142 + if ( $display['read_only'] || ! empty( $show_upsell_for_read_only ) ) {
117 143 ?>
118 144 <div class="frm_form_field">
119 - <label for="frm_read_only_field_<?php echo esc_attr( $field['id'] ); ?>" class="frm_help frm-mb-0" title="<?php esc_attr_e( 'Read Only: Show this field but do not allow the field value to be edited from the front-end.', 'formidable' ); ?>" data-trigger="hover">
120 - <input type="checkbox" id="frm_read_only_field_<?php echo esc_attr( $field['id'] ); ?>" name="field_options[read_only_<?php echo esc_attr( $field['id'] ); ?>]" value="1" <?php checked( $field['read_only'], 1 ); ?>/>
145 + <label <?php FrmAppHelper::array_to_html_params( $read_only_label_atts, true ); ?>>
146 + <input <?php FrmAppHelper::array_to_html_params( FrmSettingsUpsellHelper::get_read_only_element_atts( $field ), true ); ?> />
121 147 <?php esc_html_e( 'Read Only', 'formidable' ); ?>
122 148 </label>
123 149 </div>
124 150 <?php
@@ -145,9 +171,9 @@
145 171 <label class="frm-h-stack-xs" for="frm_classes_<?php echo esc_attr( $field['id'] ); ?>">
146 172 <span><?php esc_html_e( 'CSS Layout Classes', 'formidable' ); ?></span>
147 173 <?php FrmAppHelper::tooltip_icon( __( 'Add a CSS class to the field container. Use our predefined classes to align multiple fields in single row.', 'formidable' ), array( 'class' => 'frm-flex' ) ); ?>
148 174 </label>
149 - <span class="frm-with-right-icon">
175 + <span class="frm-with-right-icon frm-block">
150 176 <?php
151 177 $css_layout_classes_attrs = array(
152 178 'type' => 'text',
153 179 'name' => 'field_options[classes_' . $field['id'] . ']',
@@ -162,9 +188,9 @@
162 188 ?>
163 189 <input <?php FrmAppHelper::array_to_html_params( $css_layout_classes_attrs, true ); ?> />
164 190 <?php
165 191 FrmAppHelper::icon_by_class(
166 - 'frm_icon_font frm_more_horiz_solid_icon frm-show-inline-modal frm-input-icon',
192 + 'frmfont frm_more_horiz_solid_icon frm-show-inline-modal frm-input-icon',
167 193 array(
168 194 'data-open' => 'frm-layout-classes-box',
169 195 'title' => esc_attr__( 'Toggle Options', 'formidable' ),
170 196 'tabindex' => '0',
@@ -217,9 +243,9 @@
217 243 // Backwards compatibility "@since 6.24".
218 244 if ( FrmAppHelper::pro_is_connected() && ! is_callable( array( 'FrmProHtmlHelper', 'echo_radio_group' ) ) ) {
219 245 switch ( $type ) {
220 246 case 'calc':
221 - $default_value_type['data'] = array(
247 + $default_value_type['data'] = array(
222 248 'show' => '#calc-for-{id}',
223 249 'disable' => '#default-value-for-{id}',
224 250 );
225 251 break;
@@ -244,9 +270,9 @@
244 270 ),
245 271 );
246 272
247 273 foreach ( $default_value_type['data'] as $data_key => $data_value ) {
248 - $toggle_args['input_html'][ 'data-' . $data_key ] = $data_value . ( substr( $data_value, -1 ) === '-' ? $field['id'] : '' );
274 + $toggle_args['input_html'][ 'data-' . $data_key ] = $data_value . ( str_ends_with( $data_value, '-' ) ? $field['id'] : '' );
249 275 }
250 276
251 277 ?>
252 278 <div class="frm-flex frm-gap-xs frm-items-center">
@@ -329,11 +355,23 @@
329 355 if ( $display['size'] && ! in_array( $field['type'], array( 'select', 'data', 'time' ), true ) ) {
330 356 $display_max = $display['max'];
331 357 include FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/pixels-wide.php';
332 358 }
333 - ?>
334 359
335 - <?php if ( $display['show_image'] ) { ?>
360 + if ( ! empty( $show_upsell_for_before_after_contents ) ) {
361 + include FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/upsell/before-after-contents.php';
362 + }
363 +
364 + if ( ! empty( $show_upsell_for_autocomplete ) ) {
365 + include FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/upsell/autocomplete.php';
366 + }
367 +
368 + if ( ! empty( $show_upsell_for_visibility ) ) {
369 + include FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/upsell/visibility.php';
370 + }
371 +
372 + if ( $display['show_image'] ) {
373 + ?>
336 374 <p class="frm_form_field">
337 375 <label class="frm-force-flex frm-gap-xs" for="frm_show_image_<?php echo esc_attr( $field['id'] ); ?>">
338 376 <input class="frm-m-0" type="checkbox" id="frm_show_image_<?php echo esc_attr( $field['id'] ); ?>" name="field_options[show_image_<?php echo esc_attr( $field['id'] ); ?>]" value="1" <?php checked( $field['show_image'], 1 ); ?> />
339 377 <span class="-frm-mt-2xs"><?php esc_html_e( 'If this URL points to an image, show to image on the entries listing page.', 'formidable' ); ?></span>
@@ -408,8 +446,9 @@
408 446 'value' => $pos,
409 447 )
410 448 );
411 449 }
450 +
412 451 if ( $field['type'] === 'divider' ) {
413 452 FrmHtmlHelper::echo_dropdown_option(
414 453 __( 'Center', 'formidable' ),
415 454 'center' === $field['label'],
@@ -443,14 +482,15 @@
443 482 // We need to avoid the word "select" in POST requests.
444 483 // When "dropdown" is sent as a type value, we'll map it back to "select" with PHP.
445 484 $type_option_value = 'select' === $fkey ? 'dropdown' : $fkey;
446 485 $type_option_params = array( 'value' => $type_option_value );
486 +
447 487 if ( array_key_exists( $fkey, $disabled_fields ) ) {
448 488 $type_option_params['disabled'] = 'disabled';
449 489 }
450 490
451 491 FrmHtmlHelper::echo_dropdown_option(
452 - is_array( $ftype ) ? $ftype['name'] : $ftyp,
492 + is_array( $ftype ) ? $ftype['name'] : $ftype,
453 493 $fkey === $field['type'],
454 494 $type_option_params
455 495 );
456 496 unset( $fkey, $ftype, $type_option_value, $type_option_params );
@@ -474,9 +514,9 @@
474 514
475 515 <?php if ( $display['required'] || $display['invalid'] || $display['unique'] || $display['conf_field'] ) { ?>
476 516 <?php
477 517 $hidden_invalid = FrmField::is_field_type( $field, 'text' ) && ! FrmField::is_option_true( $field, 'format' ) && FrmField::is_option_empty( $field, 'max' );
478 - $has_validation = ( ( $display['invalid'] && ! $hidden_invalid ) || $field['required'] || FrmField::is_option_true( $field, 'unique' ) || FrmField::is_option_true( $field, 'conf_field' ) );
518 + $has_validation = ( $display['invalid'] && ! $hidden_invalid ) || $field['required'] || FrmField::is_option_true( $field, 'unique' ) || FrmField::is_option_true( $field, 'conf_field' );
479 519 ?>
480 520 <div class="frm_validation_msg <?php echo esc_attr( $has_validation ? '' : 'frm_hidden' ); ?>">
481 521 <h3 class="frm-collapsed" aria-expanded="false" tabindex="0" role="button" aria-label="<?php esc_attr_e( 'Collapsible Validation Messages Settings', 'formidable' ); ?>" aria-controls="collapsible-section">
482 522 <?php
@@ -525,8 +565,16 @@
525 565 <input type="text" name="field_options[conf_msg_<?php echo esc_attr( $field['id'] ); ?>]" value="<?php echo esc_attr( $field['conf_msg'] ); ?>" id="field_options_conf_msg_<?php echo esc_attr( $field['id'] ); ?>" />
526 566 </p>
527 567 <?php
528 568 }
569 +
570 + /**
571 + * @since 6.28
572 + *
573 + * @param array $display
574 + * @param array $field
575 + */
576 + do_action( 'frm_field_validation_messages', $display, $field );
529 577 ?>
530 578 </div>
531 579 </div>
532 580 <?php