| @@ -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>' ); |
| @@ -34,18 +56,18 @@ | ||
| 34 | 56 | <?php |
| 35 | 57 | } |
| 36 | 58 | |
| 37 | 59 | if ( $field['type'] === 'credit_card' && ! FrmAppHelper::pro_is_installed() ) { |
| 38 | - 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() ) { | |
| 39 | 61 | FrmStrpLiteAppHelper::not_connected_warning(); |
| 40 | 62 | } elseif ( ! FrmTransLiteActionsController::get_actions_for_form( $field['form_id'] ) ) { |
| 41 | 63 | ?> |
| 42 | 64 | <div class="frm_warning_style frm-with-icon"> |
| 43 | - <?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' ) ); ?> | |
| 44 | 66 | <span> |
| 45 | 67 | <?php |
| 46 | 68 | /* translators: %1$s: Link HTML, %2$s: End link */ |
| 47 | - 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>' ); | |
| 48 | 70 | ?> |
| 49 | 71 | </span> |
| 50 | 72 | </div> |
| 51 | 73 | <?php |
| @@ -56,9 +78,9 @@ | ||
| 56 | 78 | <?php |
| 57 | 79 | if ( $field['type'] === FrmFieldGdprHelper::FIELD_TYPE && FrmFieldGdprHelper::hide_gdpr_field() ) { |
| 58 | 80 | ?> |
| 59 | 81 | <div class="frm_note_style"> |
| 60 | - <?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' ) ); ?> | |
| 61 | 83 | <span> |
| 62 | 84 | <?php |
| 63 | 85 | /* translators: %1$s: Link HTML, %2$s: End link */ |
| 64 | 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>' ); |
| @@ -83,9 +105,12 @@ | ||
| 83 | 105 | ?> |
| 84 | 106 | <?php if ( $display['label'] ) { ?> |
| 85 | 107 | <p class="frm-mt-xs"> |
| 86 | 108 | <label for="frm_name_<?php echo esc_attr( $field['id'] ); ?>"> |
| 87 | - <?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 | + ?> | |
| 88 | 113 | </label> |
| 89 | 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'] ); ?>" /> |
| 90 | 115 | </p> |
| 91 | 116 | <?php } else { ?> |
| @@ -102,13 +127,13 @@ | ||
| 102 | 127 | </div> |
| 103 | 128 | <?php |
| 104 | 129 | } |
| 105 | 130 | |
| 106 | - if ( $display['unique'] ) { | |
| 131 | + if ( $display['unique'] || ! empty( $show_upsell_for_unique_value ) ) { | |
| 107 | 132 | ?> |
| 108 | 133 | <div class="frm_form_field"> |
| 109 | - <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"> | |
| 110 | - <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 ); ?> /> | |
| 111 | 136 | <?php esc_html_e( 'Unique', 'formidable' ); ?> |
| 112 | 137 | </label> |
| 113 | 138 | </div> |
| 114 | 139 | <?php |
| @@ -113,13 +138,13 @@ | ||
| 113 | 138 | </div> |
| 114 | 139 | <?php |
| 115 | 140 | } |
| 116 | 141 | |
| 117 | - if ( $display['read_only'] ) { | |
| 142 | + if ( $display['read_only'] || ! empty( $show_upsell_for_read_only ) ) { | |
| 118 | 143 | ?> |
| 119 | 144 | <div class="frm_form_field"> |
| 120 | - <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"> | |
| 121 | - <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 ); ?> /> | |
| 122 | 147 | <?php esc_html_e( 'Read Only', 'formidable' ); ?> |
| 123 | 148 | </label> |
| 124 | 149 | </div> |
| 125 | 150 | <?php |
| @@ -163,9 +188,9 @@ | ||
| 163 | 188 | ?> |
| 164 | 189 | <input <?php FrmAppHelper::array_to_html_params( $css_layout_classes_attrs, true ); ?> /> |
| 165 | 190 | <?php |
| 166 | 191 | FrmAppHelper::icon_by_class( |
| 167 | - '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', | |
| 168 | 193 | array( |
| 169 | 194 | 'data-open' => 'frm-layout-classes-box', |
| 170 | 195 | 'title' => esc_attr__( 'Toggle Options', 'formidable' ), |
| 171 | 196 | 'tabindex' => '0', |
| @@ -218,9 +243,9 @@ | ||
| 218 | 243 | // Backwards compatibility "@since 6.24". |
| 219 | 244 | if ( FrmAppHelper::pro_is_connected() && ! is_callable( array( 'FrmProHtmlHelper', 'echo_radio_group' ) ) ) { |
| 220 | 245 | switch ( $type ) { |
| 221 | 246 | case 'calc': |
| 222 | - $default_value_type['data'] = array( | |
| 247 | + $default_value_type['data'] = array( | |
| 223 | 248 | 'show' => '#calc-for-{id}', |
| 224 | 249 | 'disable' => '#default-value-for-{id}', |
| 225 | 250 | ); |
| 226 | 251 | break; |
| @@ -245,9 +270,9 @@ | ||
| 245 | 270 | ), |
| 246 | 271 | ); |
| 247 | 272 | |
| 248 | 273 | foreach ( $default_value_type['data'] as $data_key => $data_value ) { |
| 249 | - $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'] : '' ); | |
| 250 | 275 | } |
| 251 | 276 | |
| 252 | 277 | ?> |
| 253 | 278 | <div class="frm-flex frm-gap-xs frm-items-center"> |
| @@ -330,11 +355,23 @@ | ||
| 330 | 355 | if ( $display['size'] && ! in_array( $field['type'], array( 'select', 'data', 'time' ), true ) ) { |
| 331 | 356 | $display_max = $display['max']; |
| 332 | 357 | include FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/pixels-wide.php'; |
| 333 | 358 | } |
| 334 | - ?> | |
| 335 | 359 | |
| 336 | - <?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 | + ?> | |
| 337 | 374 | <p class="frm_form_field"> |
| 338 | 375 | <label class="frm-force-flex frm-gap-xs" for="frm_show_image_<?php echo esc_attr( $field['id'] ); ?>"> |
| 339 | 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 ); ?> /> |
| 340 | 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> |
| @@ -451,9 +488,9 @@ | ||
| 451 | 488 | $type_option_params['disabled'] = 'disabled'; |
| 452 | 489 | } |
| 453 | 490 | |
| 454 | 491 | FrmHtmlHelper::echo_dropdown_option( |
| 455 | - is_array( $ftype ) ? $ftype['name'] : $ftyp, | |
| 492 | + is_array( $ftype ) ? $ftype['name'] : $ftype, | |
| 456 | 493 | $fkey === $field['type'], |
| 457 | 494 | $type_option_params |
| 458 | 495 | ); |
| 459 | 496 | unset( $fkey, $ftype, $type_option_value, $type_option_params ); |
| @@ -477,9 +514,9 @@ | ||
| 477 | 514 | |
| 478 | 515 | <?php if ( $display['required'] || $display['invalid'] || $display['unique'] || $display['conf_field'] ) { ?> |
| 479 | 516 | <?php |
| 480 | 517 | $hidden_invalid = FrmField::is_field_type( $field, 'text' ) && ! FrmField::is_option_true( $field, 'format' ) && FrmField::is_option_empty( $field, 'max' ); |
| 481 | - $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' ); | |
| 482 | 519 | ?> |
| 483 | 520 | <div class="frm_validation_msg <?php echo esc_attr( $has_validation ? '' : 'frm_hidden' ); ?>"> |
| 484 | 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"> |
| 485 | 522 | <?php |
| @@ -528,8 +565,16 @@ | ||
| 528 | 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'] ); ?>" /> |
| 529 | 566 | </p> |
| 530 | 567 | <?php |
| 531 | 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 ); | |
| 532 | 577 | ?> |
| 533 | 578 | </div> |
| 534 | 579 | </div> |
| 535 | 580 | <?php |