PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.31
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.31
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
formidable / classes / views / frm-fields / front-end / dropdown-field.php

dropdown-field.php in Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More 6.31, at classes/views/frm-fields/front-end/dropdown-field.php

115 lines 3.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @package Formidable
4 *
5 * @var array $field
6 */
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 die( 'You are not allowed to call this page directly.' );
10 }
11
12 if ( isset( $field['post_field'] ) && $field['post_field'] === 'post_category' && FrmAppHelper::pro_is_installed() ) {
13 $category_dropdown_args = array(
14 'location' => 'front',
15 'name' => $field_name,
16 'id' => $html_id,
17 );
18 echo FrmProPost::get_category_dropdown( $field, $category_dropdown_args ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
19 } else {
20 if ( FrmFieldsHelper::should_skip_rendering_choices_for_field( $field ) ) {
21 return;
22 }
23
24 if ( $read_only ) {
25 ?>
26 <select <?php do_action( 'frm_field_input_html', $field ); ?>>
27 <?php } else { ?>
28 <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $html_id ); ?>" <?php do_action( 'frm_field_input_html', $field ); ?>>
29 <?php
30 }
31
32 $placeholder = FrmFieldsController::add_placeholder_to_select( $field );
33 $skipped = false;
34 $other_opt = false;
35 $other_checked = false;
36
37 if ( empty( $field['options'] ) ) {
38 $field['options'] = array();
39 }
40
41 if ( ! $placeholder ) {
42 /**
43 * @since 6.16.2
44 *
45 * @param array $field
46 */
47 do_action( 'frm_dropdown_field_after_no_placeholder_option', $field );
48 }
49
50 foreach ( $field['options'] as $opt_key => $opt ) {
51 if ( FrmFieldsHelper::should_hide_field_choice( $opt_key, $field ) ) {
52 continue;
53 }
54
55 $field_val = FrmFieldsHelper::get_value_from_array( $opt, $opt_key, $field );
56 $opt = FrmFieldsHelper::get_label_from_array( $opt, $opt_key, $field );
57 $selected = FrmAppHelper::check_selected( $field['value'], $field_val );
58
59 if ( $other_opt === false ) {
60 $other_args = FrmFieldsHelper::prepare_other_input( compact( 'field', 'field_name', 'opt_key' ), $other_opt, $selected );
61
62 if ( FrmFieldsHelper::is_other_opt( $opt_key ) && $selected ) {
63 $other_checked = true;
64 }
65 }
66
67 // phpcs:ignore Universal.Operators.StrictComparisons
68 if ( $placeholder && $opt == '' && ! $skipped ) {
69 $skipped = true;
70 continue;
71 }
72
73 $option_params = array(
74 'value' => $field_val,
75 );
76
77 if ( FrmFieldsHelper::is_other_opt( $opt_key ) ) {
78 $option_params['class'] = 'frm_other_trigger';
79 }
80
81 if ( FrmFieldsHelper::should_disable_choice( $opt_key, $selected, $field ) ) {
82 $option_params['disabled'] = 'disabled';
83 }
84
85 echo '<option ';
86 FrmAppHelper::array_to_html_params( $option_params, true );
87 selected( (bool) $selected );
88 echo '>';
89 echo esc_html( $opt === '' ? ' ' : $opt );
90 FrmFieldsHelper::after_choice_input( $field, $opt_key );
91
92 echo '</option>';
93
94 unset( $option_params );
95 }//end foreach
96 ?>
97 </select>
98 <?php
99
100 if ( isset( $other_args ) ) {
101 FrmFieldsHelper::include_other_input(
102 array(
103 'other_opt' => $other_opt,
104 'read_only' => $read_only,
105 'checked' => $other_checked,
106 'name' => $other_args['name'],
107 'value' => $other_args['value'],
108 'field' => $field,
109 'html_id' => $html_id,
110 'opt_key' => false,
111 )
112 );
113 }
114 }//end if
115