PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 5.1
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v5.1
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 +7 -52 6.255.1 View file →
@@ -4,9 +4,9 @@
4 4 }
5 5
6 6 /**
7 7 * A class for the field value selector
8 - * Used in field conditional logic, action conditional logic, Mailchimp action, etc.
8 + * Used in field conditional logic, action conditional logic, MailChimp action, etc.
9 9 *
10 10 * @since 2.03.05
11 11 */
12 12 class FrmFieldValueSelector {
@@ -25,13 +25,13 @@
25 25 */
26 26 protected $field_key = '';
27 27
28 28 /**
29 - * @var FrmProFieldSettings|null
29 + * @var null
30 30 *
31 31 * @since 2.03.05
32 32 */
33 - protected $field_settings;
33 + protected $field_settings = null;
34 34
35 35 /**
36 36 * @var array
37 37 *
@@ -67,24 +67,15 @@
67 67 */
68 68 protected $blank_option_label = '';
69 69
70 70 /**
71 - * @var object|null
71 + * @var object
72 72 *
73 73 * @since 2.03.05
74 74 */
75 - protected $db_row;
75 + protected $db_row = null;
76 76
77 77 /**
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 78 * FrmFieldValueSelector constructor
88 79 *
89 80 * @param int|string $field_id
90 81 */
@@ -91,9 +82,8 @@
91 82 public function __construct( $field_id, $args ) {
92 83 $this->set_html_name( $args );
93 84 $this->set_value( $args );
94 85 $this->set_source( $args );
95 - $this->set_truncate( $args );
96 86
97 87 $this->field_id = (int) $field_id;
98 88 if ( $this->field_id === 0 ) {
99 89 return;
@@ -111,10 +101,8 @@
111 101 /**
112 102 * Set the db_row property
113 103 *
114 104 * @since 2.03.05
115 - *
116 - * @return void
117 105 */
118 106 private function set_db_row() {
119 107 $where = array(
120 108 'id' => $this->field_id,
@@ -130,10 +118,8 @@
130 118 /**
131 119 * Set the field_key property
132 120 *
133 121 * @since 2.03.05
134 - *
135 - * @return void
136 122 */
137 123 private function set_field_key() {
138 124 $this->field_key = $this->db_row->field_key;
139 125 }
@@ -141,10 +127,8 @@
141 127 /**
142 128 * Set the field_settings property
143 129 *
144 130 * @since 2.03.05
145 - *
146 - * @return void
147 131 */
148 132 protected function set_field_settings() {
149 133 // Leave as null for free version
150 134 }
@@ -152,10 +136,8 @@
152 136 /**
153 137 * Set the options property
154 138 *
155 139 * @since 2.03.05
156 - *
157 - * @return void
158 140 */
159 141 protected function set_options() {
160 142 $field_obj = FrmFieldFactory::get_field_object( $this->db_row );
161 143 $this->options = $field_obj->get_options( array() );
@@ -166,10 +148,8 @@
166 148 *
167 149 * @since 2.03.05
168 150 *
169 151 * @param array $args
170 - *
171 - * @return void
172 152 */
173 153 protected function set_html_name( $args ) {
174 154 if ( isset( $args['html_name'] ) ) {
175 155 $this->html_name = (string) $args['html_name'];
@@ -181,10 +161,8 @@
181 161 *
182 162 * @since 2.03.05
183 163 *
184 164 * @param array $args
185 - *
186 - * @return void
187 165 */
188 166 protected function set_value( $args ) {
189 167 if ( isset( $args['value'] ) ) {
190 168 $this->value = (string) $args['value'];
@@ -196,10 +174,8 @@
196 174 *
197 175 * @since 2.03.05
198 176 *
199 177 * @param array $args
200 - *
201 - * @return void
202 178 */
203 179 protected function set_source( $args ) {
204 180 if ( isset( $args['source'] ) ) {
205 181 $this->source = (string) $args['source'];
@@ -206,21 +182,8 @@
206 182 }
207 183 }
208 184
209 185 /**
210 - * @since 6.16.2
211 - *
212 - * @param array $args
213 - *
214 - * @return void
215 - */
216 - protected function set_truncate( $args ) {
217 - if ( isset( $args['truncate'] ) && is_numeric( $args['truncate'] ) ) {
218 - $this->truncate = (int) $args['truncate'];
219 - }
220 - }
221 -
222 - /**
223 186 * Check if object has any options
224 187 *
225 188 * @since 2.03.05
226 189 *
@@ -244,10 +207,8 @@
244 207 /**
245 208 * Display the field value selector (dropdown or text field)
246 209 *
247 210 * @since 2.03.05
248 - *
249 - * @return void
250 211 */
251 212 public function display() {
252 213 if ( $this->has_options() ) {
253 214 $this->display_dropdown();
@@ -259,10 +220,8 @@
259 220 /**
260 221 * Print the field value text box
261 222 *
262 223 * @since 2.03.05
263 - *
264 - * @return void
265 224 */
266 225 public function display_text_box() {
267 226 echo '<input type="text" name="' . esc_attr( $this->html_name ) . '" value="' . esc_attr( trim( $this->value ) ) . '" />';
268 227 }
@@ -270,18 +229,14 @@
270 229 /**
271 230 * Display the field value selector
272 231 *
273 232 * @since 2.03.05
274 - *
275 - * @return void
276 233 */
277 234 protected function display_dropdown() {
278 235 echo '<select name="' . esc_attr( $this->html_name ) . '">';
279 - echo '<option value="">' . esc_html( $this->blank_option_label ) . '</option>';
236 + echo '<option value="">' . esc_attr( $this->blank_option_label ) . '</option>';
280 237
281 238 if ( ! empty( $this->options ) ) {
282 - $truncate = $this->truncate ?? 25;
283 -
284 239 foreach ( $this->options as $key => $value ) {
285 240 if ( $value == '' ) {
286 241 continue;
287 242 }
@@ -286,9 +241,9 @@
286 241 continue;
287 242 }
288 243
289 244 $option = $this->get_single_field_option( $key, $value );
290 - $option->print_single_option( $this->value, $truncate );
245 + $option->print_single_option( $this->value, 25 );
291 246 }
292 247 }
293 248
294 249 echo '</select>';