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/models/FrmFieldValueSelector.php +10 -70 6.263.06.06 View file →
@@ -1,12 +1,9 @@
1 1 <?php
2 -if ( ! defined( 'ABSPATH' ) ) {
3 - die( 'You are not allowed to call this page directly.' );
4 -}
5 2
6 3 /**
7 4 * A class for the field value selector
8 - * Used in field conditional logic, action conditional logic, Mailchimp action, etc.
5 + * Used in field conditional logic, action conditional logic, MailChimp action, etc.
9 6 *
10 7 * @since 2.03.05
11 8 */
12 9 class FrmFieldValueSelector {
@@ -25,13 +22,13 @@
25 22 */
26 23 protected $field_key = '';
27 24
28 25 /**
29 - * @var FrmProFieldSettings|null
26 + * @var null
30 27 *
31 28 * @since 2.03.05
32 29 */
33 - protected $field_settings;
30 + protected $field_settings = null;
34 31
35 32 /**
36 33 * @var array
37 34 *
@@ -38,8 +35,9 @@
38 35 * @since 2.03.05
39 36 */
40 37 protected $options = array();
41 38
39 +
42 40 /**
43 41 * @var string
44 42 *
45 43 * @since 2.03.05
@@ -67,37 +65,25 @@
67 65 */
68 66 protected $blank_option_label = '';
69 67
70 68 /**
71 - * @var object|null
69 + * @var object
72 70 *
73 71 * @since 2.03.05
74 72 */
75 - protected $db_row;
73 + protected $db_row = null;
76 74
77 75 /**
78 - * Field dropdowns will truncate at 25 characters by default.
79 - *
80 - * @var int|null
81 - *
82 - * @since 6.16.2
83 - */
84 - protected $truncate;
85 -
86 - /**
87 76 * FrmFieldValueSelector constructor
88 77 *
89 - * @param int|string $field_id Field ID.
90 - * @param array $args Arguments for configuring the value selector.
78 + * @param int|string $field_id
91 79 */
92 80 public function __construct( $field_id, $args ) {
93 81 $this->set_html_name( $args );
94 82 $this->set_value( $args );
95 83 $this->set_source( $args );
96 - $this->set_truncate( $args );
97 84
98 85 $this->field_id = (int) $field_id;
99 -
100 86 if ( $this->field_id === 0 ) {
101 87 return;
102 88 }
103 89
@@ -113,10 +99,8 @@
113 99 /**
114 100 * Set the db_row property
115 101 *
116 102 * @since 2.03.05
117 - *
118 - * @return void
119 103 */
120 104 private function set_db_row() {
121 105 $where = array(
122 106 'id' => $this->field_id,
@@ -132,10 +116,8 @@
132 116 /**
133 117 * Set the field_key property
134 118 *
135 119 * @since 2.03.05
136 - *
137 - * @return void
138 120 */
139 121 private function set_field_key() {
140 122 $this->field_key = $this->db_row->field_key;
141 123 }
@@ -143,10 +125,8 @@
143 125 /**
144 126 * Set the field_settings property
145 127 *
146 128 * @since 2.03.05
147 - *
148 - * @return void
149 129 */
150 130 protected function set_field_settings() {
151 131 // Leave as null for free version
152 132 }
@@ -154,13 +134,11 @@
154 134 /**
155 135 * Set the options property
156 136 *
157 137 * @since 2.03.05
158 - *
159 - * @return void
160 138 */
161 139 protected function set_options() {
162 - $field_obj = FrmFieldFactory::get_field_object( $this->db_row );
140 + $field_obj = FrmFieldFactory::get_field_object( $this->db_row );
163 141 $this->options = $field_obj->get_options( array() );
164 142 }
165 143
166 144 /**
@@ -168,10 +146,8 @@
168 146 *
169 147 * @since 2.03.05
170 148 *
171 149 * @param array $args
172 - *
173 - * @return void
174 150 */
175 151 protected function set_html_name( $args ) {
176 152 if ( isset( $args['html_name'] ) ) {
177 153 $this->html_name = (string) $args['html_name'];
@@ -183,10 +159,8 @@
183 159 *
184 160 * @since 2.03.05
185 161 *
186 162 * @param array $args
187 - *
188 - * @return void
189 163 */
190 164 protected function set_value( $args ) {
191 165 if ( isset( $args['value'] ) ) {
192 166 $this->value = (string) $args['value'];
@@ -198,10 +172,8 @@
198 172 *
199 173 * @since 2.03.05
200 174 *
201 175 * @param array $args
202 - *
203 - * @return void
204 176 */
205 177 protected function set_source( $args ) {
206 178 if ( isset( $args['source'] ) ) {
207 179 $this->source = (string) $args['source'];
@@ -208,21 +180,8 @@
208 180 }
209 181 }
210 182
211 183 /**
212 - * @since 6.16.2
213 - *
214 - * @param array $args
215 - *
216 - * @return void
217 - */
218 - protected function set_truncate( $args ) {
219 - if ( isset( $args['truncate'] ) && is_numeric( $args['truncate'] ) ) {
220 - $this->truncate = (int) $args['truncate'];
221 - }
222 - }
223 -
224 - /**
225 184 * Check if object has any options
226 185 *
227 186 * @since 2.03.05
228 187 *
@@ -246,10 +205,8 @@
246 205 /**
247 206 * Display the field value selector (dropdown or text field)
248 207 *
249 208 * @since 2.03.05
250 - *
251 - * @return void
252 209 */
253 210 public function display() {
254 211 if ( $this->has_options() ) {
255 212 $this->display_dropdown();
@@ -261,10 +218,8 @@
261 218 /**
262 219 * Print the field value text box
263 220 *
264 221 * @since 2.03.05
265 - *
266 - * @return void
267 222 */
268 223 public function display_text_box() {
269 224 echo '<input type="text" name="' . esc_attr( $this->html_name ) . '" value="' . esc_attr( trim( $this->value ) ) . '" />';
270 225 }
@@ -272,18 +227,14 @@
272 227 /**
273 228 * Display the field value selector
274 229 *
275 230 * @since 2.03.05
276 - *
277 - * @return void
278 231 */
279 232 protected function display_dropdown() {
280 233 echo '<select name="' . esc_attr( $this->html_name ) . '">';
281 - echo '<option value="">' . esc_html( $this->blank_option_label ) . '</option>';
234 + echo '<option value="">' . esc_attr( $this->blank_option_label ) . '</option>';
282 235
283 236 if ( ! empty( $this->options ) ) {
284 - $truncate = $this->truncate ?? 25;
285 -
286 237 foreach ( $this->options as $key => $value ) {
287 238 if ( $value == '' ) {
288 239 continue;
289 240 }
@@ -288,24 +239,13 @@
288 239 continue;
289 240 }
290 241
291 242 $option = $this->get_single_field_option( $key, $value );
292 - $option->print_single_option( $this->value, $truncate, $this->use_value_as_label_in_dropdown() );
243 + $option->print_single_option( $this->value, 25 );
293 244 }
294 245 }
295 246
296 247 echo '</select>';
297 - }
298 -
299 - /**
300 - * Whether to use the field value as the option label in the dropdown when the label is empty.
301 - *
302 - * @since 6.25.1
303 - *
304 - * @return bool
305 - */
306 - protected function use_value_as_label_in_dropdown() {
307 - return false;
308 248 }
309 249
310 250 /**
311 251 * Get an instance of FrmFieldOption