PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 5.0
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v5.0
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/helpers/FrmEntriesHelper.php +79 -365 6.265.0 View file →
@@ -4,34 +4,8 @@
4 4 }
5 5
6 6 class FrmEntriesHelper {
7 7
8 - /**
9 - * "Submitted" entry status.
10 - *
11 - * @since 6.4.2
12 - *
13 - * @var int
14 - */
15 - const SUBMITTED_ENTRY_STATUS = 0;
16 -
17 - /**
18 - * "Draft" entry status.
19 - *
20 - * @since 6.4.2
21 - *
22 - * @var int
23 - */
24 - const DRAFT_ENTRY_STATUS = 1;
25 -
26 - /**
27 - * @param mixed $fields
28 - * @param object|string $form
29 - * @param bool $reset
30 - * @param array $args
31 - *
32 - * @return array
33 - */
34 8 public static function setup_new_vars( $fields, $form = '', $reset = false, $args = array() ) {
35 9 remove_action( 'media_buttons', 'FrmFormsController::insert_form_button' );
36 10
37 11 $values = array(
@@ -40,9 +14,8 @@
40 14 'item_key' => '',
41 15 );
42 16
43 17 $values['fields'] = array();
44 -
45 18 if ( empty( $fields ) ) {
46 19 return apply_filters( 'frm_setup_new_entry', $values );
47 20 }
48 21
@@ -53,19 +26,15 @@
53 26
54 27 $field_array = FrmAppHelper::start_field_array( $field );
55 28 $field_array['value'] = $new_value;
56 29 $field_array['type'] = apply_filters( 'frm_field_type', $field->type, $field, $new_value );
57 - $field_array['parent_form_id'] = $args['parent_form_id'] ?? $field->form_id;
30 + $field_array['parent_form_id'] = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id;
58 31 $field_array['reset_value'] = $reset;
59 - $field_array['in_embed_form'] = $args['in_embed_form'] ?? '0';
32 + $field_array['in_embed_form'] = isset( $args['in_embed_form'] ) ? $args['in_embed_form'] : '0';
60 33 $field_array['original_default'] = $original_default;
61 34
62 35 FrmFieldsHelper::prepare_new_front_field( $field_array, $field, $args );
63 36
64 - if ( ! is_array( $field->field_options ) ) {
65 - $field->field_options = array();
66 - }
67 -
68 37 $field_array = array_merge( $field->field_options, $field_array );
69 38
70 39 $values['fields'][] = $field_array;
71 40
@@ -71,12 +40,11 @@
71 40
72 41 if ( ! $form || ! isset( $form->id ) ) {
73 42 $form = FrmForm::getOne( $field->form_id );
74 43 }
75 - }//end foreach
44 + }
76 45
77 46 FrmAppHelper::unserialize_or_decode( $form->options );
78 -
79 47 if ( is_array( $form->options ) ) {
80 48 $values = array_merge( $values, $form->options );
81 49 }
82 50
@@ -91,13 +59,11 @@
91 59 /**
92 60 * @since 2.05
93 61 *
94 62 * @param object $field
95 - *
96 - * @return void
97 63 */
98 64 private static function prepare_field_default_value( &$field ) {
99 - // If checkbox, multi-select dropdown, or checkbox data from entries field, the value should be an array.
65 + //If checkbox, multi-select dropdown, or checkbox data from entries field, the value should be an array
100 66 $return_array = FrmField::is_field_with_multiple_values( $field );
101 67
102 68 /**
103 69 * Do any shortcodes in default value and allow customization of default value.
@@ -115,13 +81,13 @@
115 81 * This function is used when the form is first loaded and on all page turns *for a new entry*
116 82 *
117 83 * @since 2.0.13
118 84 *
119 - * @param object $field - this is passed by reference since it is an object.
120 - * @param bool $reset
121 - * @param array $args
85 + * @param object $field - this is passed by reference since it is an object
86 + * @param boolean $reset
87 + * @param array $args
122 88 *
123 - * @return array|string $new_value
89 + * @return string|array $new_value
124 90 */
125 91 private static function get_field_value_for_new_entry( $field, $reset, $args ) {
126 92 $new_value = $field->default_value;
127 93
@@ -141,23 +107,21 @@
141 107 *
142 108 * @since 2.01.0
143 109 *
144 110 * @param object $field
145 - * @param array $args
111 + * @param array $args
146 112 *
147 - * @return bool $value_is_posted
113 + * @return boolean $value_is_posted
148 114 */
149 115 public static function value_is_posted( $field, $args ) {
150 116 $value_is_posted = false;
151 -
152 - if ( $_POST ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
117 + if ( $_POST ) {
153 118 $repeating = isset( $args['repeating'] ) && $args['repeating'];
154 -
155 119 if ( $repeating ) {
156 - if ( isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
120 + if ( isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] ) ) {
157 121 $value_is_posted = true;
158 122 }
159 - } elseif ( isset( $_POST['item_meta'][ $field->id ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
123 + } elseif ( isset( $_POST['item_meta'][ $field->id ] ) ) {
160 124 $value_is_posted = true;
161 125 }
162 126 }
163 127
@@ -163,14 +127,8 @@
163 127
164 128 return $value_is_posted;
165 129 }
166 130
167 - /**
168 - * @param array $values
169 - * @param object $record
170 - *
171 - * @return array
172 - */
173 131 public static function setup_edit_vars( $values, $record ) {
174 132 remove_action( 'media_buttons', 'FrmFormsController::insert_form_button' );
175 133
176 134 $values['item_key'] = FrmAppHelper::get_post_param( 'item_key', $record->item_key, 'sanitize_title' );
@@ -179,14 +137,8 @@
179 137
180 138 return apply_filters( 'frm_setup_edit_entry_vars', $values, $record );
181 139 }
182 140
183 - /**
184 - * @param string $message
185 - * @param array $atts
186 - *
187 - * @return string
188 - */
189 141 public static function replace_default_message( $message, $atts ) {
190 142 if ( strpos( $message, '[default-message' ) === false &&
191 143 strpos( $message, '[default_message' ) === false &&
192 144 ! empty( $message ) ) {
@@ -200,9 +152,8 @@
200 152 preg_match_all( "/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER );
201 153
202 154 foreach ( $shortcodes[0] as $short_key => $tag ) {
203 155 $add_atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][ $short_key ] );
204 -
205 156 if ( ! empty( $add_atts ) ) {
206 157 $this_atts = array_merge( $atts, $add_atts );
207 158 } else {
208 159 $this_atts = $atts;
@@ -216,22 +167,14 @@
216 167
217 168 return $message;
218 169 }
219 170
220 - /**
221 - * @param stdClass $entry
222 - * @param stdClass $field
223 - * @param array $atts
224 - *
225 - * @return string
226 - */
227 171 public static function prepare_display_value( $entry, $field, $atts ) {
228 - $field_value = $entry->metas[ $field->id ] ?? false;
172 + $field_value = isset( $entry->metas[ $field->id ] ) ? $entry->metas[ $field->id ] : false;
229 173
230 174 if ( FrmAppHelper::pro_is_installed() ) {
231 175 $empty = empty( $field_value );
232 176 FrmProEntriesHelper::get_dynamic_list_values( $field, $entry, $field_value );
233 -
234 177 if ( $empty && ! empty( $field_value ) ) {
235 178 // We've got an entry id, so switch it to a value.
236 179 $atts['force_id'] = true;
237 180 }
@@ -240,23 +183,17 @@
240 183 if ( $field->form_id == $entry->form_id || empty( $atts['embedded_field_id'] ) ) {
241 184 return self::display_value( $field_value, $field, $atts );
242 185 }
243 186
244 - if ( ! FrmAppHelper::pro_is_installed() ) {
245 - return '';
246 - }
187 + // This is an embeded form.
188 + $val = '';
247 189
248 - if ( is_callable( 'FrmProEntriesHelper::prepare_child_display_value' ) ) {
249 - return FrmProEntriesHelper::prepare_child_display_value( $entry, $field, $atts );
250 - }
251 -
252 - // This is an embedded form.
253 190 if ( strpos( $atts['embedded_field_id'], 'form' ) === 0 ) {
254 191 // This is a repeating section.
255 - $child_entries = FrmEntry::getAll( array( 'it.parent_item_id' => $entry->id ), '', '', true );
192 + $child_entries = FrmEntry::getAll( array( 'it.parent_item_id' => $entry->id ) );
256 193 } else {
257 194 // Get all values for this field.
258 - $child_values = $entry->metas[ $atts['embedded_field_id'] ] ?? false;
195 + $child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false;
259 196
260 197 if ( $child_values ) {
261 198 $child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) );
262 199 }
@@ -263,10 +200,10 @@
263 200 }
264 201
265 202 $field_value = array();
266 203
267 - if ( empty( $child_entries ) ) {
268 - return '';
204 + if ( ! isset( $child_entries ) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) {
205 + return $val;
269 206 }
270 207
271 208 foreach ( $child_entries as $child_entry ) {
272 209 $atts['item_id'] = $child_entry->id;
@@ -283,15 +220,13 @@
283 220 unset( $child_entry );
284 221 }
285 222
286 223 $sep = ', ';
287 -
288 - if ( strpos( implode( ' ', $field_value ), '<img' ) !== false ) {
224 + if ( strpos( implode( ' ', (array) $field_value ), '<img' ) !== false ) {
289 225 $sep = '<br/>';
290 226 }
227 + $val = implode( $sep, (array) $field_value );
291 228
292 - $val = implode( $sep, $field_value );
293 -
294 229 return FrmAppHelper::kses( $val, 'all' );
295 230 }
296 231
297 232 /**
@@ -297,10 +232,10 @@
297 232 /**
298 233 * Prepare the saved value for display
299 234 *
300 235 * @param array|string $value
301 - * @param object $field
302 - * @param array $atts
236 + * @param object $field
237 + * @param array $atts
303 238 *
304 239 * @return string
305 240 */
306 241 public static function display_value( $value, $field, $atts = array() ) {
@@ -319,9 +254,9 @@
319 254 );
320 255
321 256 $atts = wp_parse_args( $atts, $defaults );
322 257
323 - if ( FrmField::is_image( $field ) || $field->type === 'star' ) {
258 + if ( FrmField::is_image( $field ) || $field->type == 'star' ) {
324 259 $atts['truncate'] = false;
325 260 $atts['html'] = true;
326 261 }
327 262
@@ -326,12 +261,8 @@
326 261 }
327 262
328 263 $atts = apply_filters( 'frm_display_value_atts', $atts, $field, $value );
329 264
330 - if ( is_string( $field->field_options ) ) {
331 - $field->field_options = array();
332 - }
333 -
334 265 if ( ! isset( $field->field_options['post_field'] ) ) {
335 266 $field->field_options['post_field'] = '';
336 267 }
337 268
@@ -338,12 +269,12 @@
338 269 if ( ! isset( $field->field_options['custom_field'] ) ) {
339 270 $field->field_options['custom_field'] = '';
340 271 }
341 272
342 - if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] === 'tag' ) ) {
273 + if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) {
343 274 $atts['pre_truncate'] = $atts['truncate'];
344 275 $atts['truncate'] = true;
345 - $atts['exclude_cat'] = $field->field_options['exclude_cat'] ?? 0;
276 + $atts['exclude_cat'] = isset( $field->field_options['exclude_cat'] ) ? $field->field_options['exclude_cat'] : 0;
346 277
347 278 $value = FrmProEntryMetaHelper::get_post_value( $atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts );
348 279 $atts['truncate'] = $atts['pre_truncate'];
349 280 }
@@ -352,9 +283,9 @@
352 283 return $value;
353 284 }
354 285
355 286 $unfiltered_value = $value;
356 - FrmFieldsHelper::prepare_field_value( $unfiltered_value, $field->type );
287 + FrmAppHelper::unserialize_or_decode( $unfiltered_value );
357 288
358 289 $value = apply_filters( 'frm_display_value_custom', $unfiltered_value, $field, $atts );
359 290 $value = apply_filters( 'frm_display_' . $field->type . '_value_custom', $value, compact( 'field', 'atts' ) );
360 291
@@ -361,9 +292,9 @@
361 292 if ( $value == $unfiltered_value ) {
362 293 $value = FrmFieldsHelper::get_unfiltered_display_value( compact( 'value', 'field', 'atts' ) );
363 294 }
364 295
365 - if ( $atts['truncate'] && $atts['type'] !== 'url' ) {
296 + if ( $atts['truncate'] && $atts['type'] != 'url' ) {
366 297 $value = FrmAppHelper::truncate( $value, 50 );
367 298 }
368 299
369 300 if ( ! $atts['keepjs'] && ! is_array( $value ) ) {
@@ -372,21 +303,13 @@
372 303
373 304 return apply_filters( 'frm_display_value', $value, $field, $atts );
374 305 }
375 306
376 - /**
377 - * @param object $field
378 - * @param mixed $value
379 - * @param array $args
380 - *
381 - * @return void
382 - */
383 307 public static function set_posted_value( $field, $value, $args ) {
384 308 // If validating a field with "other" opt, set back to prev value now.
385 - if ( ! empty( $args['other'] ) ) {
309 + if ( isset( $args['other'] ) && $args['other'] ) {
386 310 $value = $args['temp_value'];
387 311 }
388 -
389 312 if ( empty( $args['parent_field_id'] ) ) {
390 313 $_POST['item_meta'][ $field->id ] = $value;
391 314 } else {
392 315 self::set_parent_field_posted_value( $field, $value, $args );
@@ -396,49 +319,34 @@
396 319 /**
397 320 * Init arrays if necessary, else we get fatal error.
398 321 *
399 322 * @since 4.01
400 - *
401 - * @param object $field Field object.
402 - * @param mixed $value Value to set.
403 - * @param array $args Additional arguments.
404 - *
405 - * @return void
406 323 */
407 324 private static function set_parent_field_posted_value( $field, $value, $args ) {
408 - if ( isset( $_POST['item_meta'][ $args['parent_field_id'] ] ) && is_array( $_POST['item_meta'][ $args['parent_field_id'] ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
409 - if ( ! isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ] ) || ! is_array( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
410 - $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ] = array(); // phpcs:ignore WordPress.Security.NonceVerification.Missing
325 + if ( isset( $_POST['item_meta'][ $args['parent_field_id'] ] ) &&
326 + is_array( $_POST['item_meta'][ $args['parent_field_id'] ] ) ) {
327 +
328 + if ( ! isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ] ) ||
329 + ! is_array( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ] ) ) {
330 + $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ] = array();
411 331 }
412 332 } else {
413 333 // All of the section was probably removed.
414 - $_POST['item_meta'][ $args['parent_field_id'] ] = array(); // phpcs:ignore WordPress.Security.NonceVerification.Missing
415 - $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ] = array(); // phpcs:ignore WordPress.Security.NonceVerification.Missing
334 + $_POST['item_meta'][ $args['parent_field_id'] ] = array();
335 + $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ] = array();
416 336 }
417 337
418 - $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value; // phpcs:ignore WordPress.Security.NonceVerification.Missing
338 + $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value;
419 339 }
420 340
421 - /**
422 - * @param array|int|object $field
423 - * @param mixed $value
424 - * @param array $args
425 - *
426 - * @return void
427 - */
428 341 public static function get_posted_value( $field, &$value, $args ) {
429 342 if ( is_array( $field ) ) {
430 343 $field_id = $field['id'];
431 344 $field_obj = FrmFieldFactory::get_field_object( $field['id'] );
432 - } elseif ( is_object( $field ) ) {
345 + } else if ( is_object( $field ) ) {
433 346 $field_id = $field->id;
434 -
435 - if ( 'hidden' === $field->type && ! empty( $field->field_options['original_type'] ) ) {
436 - $field_obj = FrmFieldFactory::get_field_type( $field->field_options['original_type'], $field );
437 - } else {
438 - $field_obj = FrmFieldFactory::get_field_object( $field );
439 - }
440 - } elseif ( is_numeric( $field ) ) {
347 + $field_obj = FrmFieldFactory::get_field_object( $field );
348 + } else if ( is_numeric( $field ) ) {
441 349 $field_id = $field;
442 350 $field_obj = FrmFieldFactory::get_field_object( $field );
443 351 } else {
444 352 $value = self::get_posted_meta( $field, $args );
@@ -452,20 +360,17 @@
452 360 }
453 361
454 362 /**
455 363 * @since 4.02.04
456 - *
457 - * @param int|string $field_id Field ID.
458 - * @param array $args Additional arguments.
459 - *
460 - * @return mixed
461 364 */
462 365 private static function get_posted_meta( $field_id, $args ) {
463 366 if ( empty( $args['parent_field_id'] ) ) {
464 367 // Sanitizing is done next.
465 - $value = isset( $_POST['item_meta'][ $field_id ] ) ? wp_unslash( $_POST['item_meta'][ $field_id ] ) : ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing
368 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
369 + $value = isset( $_POST['item_meta'][ $field_id ] ) ? wp_unslash( $_POST['item_meta'][ $field_id ] ) : '';
466 370 } else {
467 - $value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? wp_unslash( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) : ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing
371 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
372 + $value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? wp_unslash( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) : '';
468 373 }
469 374 return $value;
470 375 }
471 376
@@ -473,17 +378,14 @@
473 378 * Check if field has an "Other" option and if any other values are posted
474 379 *
475 380 * @since 2.0
476 381 *
477 - * @param object $field Field object.
478 - * @param array|string $value Field value, passed by reference.
479 - * @param array $args Arguments array, passed by reference.
480 - *
481 - * @return void
382 + * @param object $field
383 + * @param string|array $value
384 + * @param array $args
482 385 */
483 386 public static function maybe_set_other_validation( $field, &$value, &$args ) {
484 387 $args['other'] = false;
485 -
486 388 if ( ! $value || ! FrmAppHelper::pro_is_installed() ) {
487 389 return;
488 390 }
489 391
@@ -497,9 +399,9 @@
497 399 // Get other value for fields in repeating section.
498 400 self::set_other_repeating_vals( $field, $value, $args );
499 401
500 402 // Check if there are any posted "Other" values.
501 - if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][ $field->id ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
403 + if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][ $field->id ] ) ) {
502 404
503 405 // Save original value.
504 406 $args['temp_value'] = $value;
505 407 $args['other'] = true;
@@ -504,9 +406,10 @@
504 406 $args['temp_value'] = $value;
505 407 $args['other'] = true;
506 408
507 409 // Sanitizing is done next.
508 - $other_vals = wp_unslash( $_POST['item_meta']['other'][ $field->id ] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing
410 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
411 + $other_vals = wp_unslash( $_POST['item_meta']['other'][ $field->id ] );
509 412 FrmAppHelper::sanitize_value( 'sanitize_text_field', $other_vals );
510 413
511 414 // Set the validation value now
512 415 self::set_other_validation_val( $value, $other_vals, $field, $args );
@@ -517,13 +420,11 @@
517 420 * Sets radio or checkbox value equal to "other" value if it is set - FOR REPEATING SECTIONS
518 421 *
519 422 * @since 2.0
520 423 *
521 - * @param object $field Field object.
522 - * @param array|string $value Field value, passed by reference.
523 - * @param array $args Arguments array, passed by reference.
524 - *
525 - * @return void
424 + * @param object $field
425 + * @param string|array $value
426 + * @param array $args
526 427 */
527 428 public static function set_other_repeating_vals( $field, &$value, &$args ) {
528 429 if ( ! $args['parent_field_id'] ) {
529 430 return;
@@ -529,14 +430,15 @@
529 430 return;
530 431 }
531 432
532 433 // Check if there are any other posted "other" values for this field.
533 - if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
434 + if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ) ) {
534 435 // Save original value
535 436 $args['temp_value'] = $value;
536 437 $args['other'] = true;
537 438
538 - $other_vals = wp_unslash( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing
439 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
440 + $other_vals = wp_unslash( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] );
539 441 FrmAppHelper::sanitize_value( 'sanitize_text_field', $other_vals );
540 442
541 443 // Set the validation value now.
542 444 self::set_other_validation_val( $value, $other_vals, $field, $args );
@@ -551,14 +453,12 @@
551 453 * Needs to accommodate for times when other opt is selected, but no other free text is entered
552 454 *
553 455 * @since 2.0
554 456 *
555 - * @param array|string $value
556 - * @param array|string $other_vals (usually of posted values).
557 - * @param object $field
558 - * @param array $args
559 - *
560 - * @return void
457 + * @param string|array $value
458 + * @param string|array $other_vals (usually of posted values)
459 + * @param object $field
460 + * @param array $args
561 461 */
562 462 public static function set_other_validation_val( &$value, $other_vals, $field, &$args ) {
563 463 // Checkboxes and multi-select dropdowns.
564 464 if ( is_array( $value ) && $field->type === 'checkbox' ) {
@@ -594,9 +494,8 @@
594 494 }
595 495
596 496 $args['temp_value'] = $value;
597 497 $value[ $other_key ] = reset( $other_vals );
598 -
599 498 if ( FrmAppHelper::is_empty_value( $value[ $other_key ] ) ) {
600 499 unset( $value[ $other_key ] );
601 500 }
602 501 }
@@ -601,10 +500,10 @@
601 500 }
602 501 }
603 502 } elseif ( $field->options[ $other_key ] == $value ) {
604 503 $value = $other_vals;
605 - }//end if
606 - }//end if
504 + }
505 + }
607 506 }
608 507
609 508 /**
610 509 * Add submitted values to a string for spam checking.
@@ -609,16 +508,13 @@
609 508 /**
610 509 * Add submitted values to a string for spam checking.
611 510 *
612 511 * @param array $values
613 - *
614 - * @return string
615 512 */
616 513 public static function entry_array_to_string( $values ) {
617 514 $content = '';
618 -
619 515 foreach ( $values['item_meta'] as $val ) {
620 - if ( $content !== '' ) {
516 + if ( $content != '' ) {
621 517 $content .= "\n\n";
622 518 }
623 519
624 520 if ( is_array( $val ) ) {
@@ -642,9 +538,9 @@
642 538 * @return string
643 539 */
644 540 public static function get_browser( $u_agent ) {
645 541 $bname = __( 'Unknown', 'formidable' );
646 - $platform = $bname;
542 + $platform = __( 'Unknown', 'formidable' );
647 543 $ub = '';
648 544
649 545 // Get the operating system
650 546 if ( preg_match( '/windows|win32/i', $u_agent ) ) {
@@ -664,9 +560,9 @@
664 560 'Netscape' => 'Netscape',
665 561 'Firefox' => 'Mozilla Firefox',
666 562 );
667 563
668 - // Next get the name of the useragent yes separately and for good reason.
564 + // Next get the name of the useragent yes seperately and for good reason
669 565 if ( strpos( $u_agent, 'MSIE' ) !== false && strpos( $u_agent, 'Opera' ) === false ) {
670 566 $bname = 'Internet Explorer';
671 567 $ub = 'MSIE';
672 568 } else {
@@ -680,18 +576,17 @@
680 576 }
681 577
682 578 // finally get the correct version number
683 579 $known = array( 'Version', $ub, 'other' );
684 - $pattern = '#(?<browser>' . implode( '|', $known ) . ')[/ ]+(?<version>[0-9.|a-zA-Z.]*)#';
685 - // Get the matching numbers.
686 - preg_match_all( $pattern, $u_agent, $matches );
580 + $pattern = '#(?<browser>' . join( '|', $known ) . ')[/ ]+(?<version>[0-9.|a-zA-Z.]*)#';
581 + preg_match_all( $pattern, $u_agent, $matches ); // get the matching numbers
687 582
688 583 // see how many we have
689 584 $i = count( $matches['browser'] );
690 585
691 586 if ( $i > 1 ) {
692 - // We will have two since we are not using 'other' argument yet
693 - // see if version is before or after the name.
587 + //we will have two since we are not using 'other' argument yet
588 + //see if version is before or after the name
694 589 if ( strripos( $u_agent, 'Version' ) < strripos( $u_agent, $ub ) ) {
695 590 $version = $matches['version'][0];
696 591 } else {
697 592 $version = $matches['version'][1];
@@ -702,9 +597,9 @@
702 597 $version = '';
703 598 }
704 599
705 600 // check if we have a number
706 - if ( $version === '' ) {
601 + if ( $version == '' ) {
707 602 $version = '?';
708 603 }
709 604
710 605 return $bname . ' ' . $version . ' / ' . $platform;
@@ -711,21 +606,17 @@
711 606 }
712 607
713 608 /**
714 609 * @since 3.0
715 - *
716 - * @param array $atts Action dropdown attributes.
717 - *
718 - * @return void
719 610 */
720 611 public static function actions_dropdown( $atts ) {
721 - $id = $atts['id'] ?? FrmAppHelper::get_param( 'id', 0, 'get', 'absint' );
612 + $id = isset( $atts['id'] ) ? $atts['id'] : FrmAppHelper::get_param( 'id', 0, 'get', 'absint' );
722 613 $links = self::get_action_links( $id, $atts['entry'] );
723 614
724 615 foreach ( $links as $link ) {
725 616 ?>
726 617 <div class="misc-pub-section">
727 - <a href="<?php echo esc_url( $link['url'] ); ?>"
618 + <a href="<?php echo esc_url( FrmAppHelper::maybe_full_screen_link( $link['url'] ) ); ?>"
728 619 <?php
729 620 if ( isset( $link['data'] ) ) {
730 621 foreach ( $link['data'] as $data => $value ) {
731 622 echo 'data-' . esc_attr( $data ) . '="' . esc_attr( $value ) . '" ';
@@ -730,13 +621,11 @@
730 621 foreach ( $link['data'] as $data => $value ) {
731 622 echo 'data-' . esc_attr( $data ) . '="' . esc_attr( $value ) . '" ';
732 623 }
733 624 }
734 -
735 625 if ( isset( $link['class'] ) ) {
736 626 echo 'class="' . esc_attr( $link['class'] ) . '" ';
737 627 }
738 -
739 628 if ( isset( $link['id'] ) ) {
740 629 echo 'id="' . esc_attr( $link['id'] ) . '" ';
741 630 }
742 631 ?>
@@ -745,24 +634,19 @@
745 634 <span class="frm_link_label"><?php echo esc_html( $link['label'] ); ?></span>
746 635 </a>
747 636 </div>
748 637 <?php
749 - }//end foreach
638 + }
750 639 }
751 640
752 641 /**
753 642 * @since 3.0
754 - *
755 - * @param int $id Entry ID.
756 - * @param array|object $entry Entry object.
757 - *
758 - * @return array
759 643 */
760 644 private static function get_action_links( $id, $entry ) {
761 645 $page = FrmAppHelper::get_param( 'frm_action' );
762 646 $actions = array();
763 647
764 - if ( $page !== 'show' ) {
648 + if ( $page != 'show' ) {
765 649 $actions['frm_view'] = array(
766 650 'url' => admin_url( 'admin.php?page=formidable-entries&frm_action=show&id=' . $id . '&form=' . $entry->form_id ),
767 651 'label' => __( 'View Entry', 'formidable' ),
768 652 'icon' => 'frm_icon_font frm_save_icon',
@@ -770,19 +654,18 @@
770 654 }
771 655
772 656 if ( current_user_can( 'frm_delete_entries' ) ) {
773 657 $actions['frm_delete'] = array(
774 - 'url' => wp_nonce_url( admin_url( 'admin.php?page=formidable-entries&frm_action=destroy&id=' . $id . '&form=' . $entry->form_id ) ),
658 + 'url' => admin_url( 'admin.php?page=formidable-entries&frm_action=destroy&id=' . $id . '&form=' . $entry->form_id ),
775 659 'label' => __( 'Delete Entry', 'formidable' ),
776 660 'icon' => 'frm_icon_font frm_delete_icon',
777 661 'data' => array(
778 - 'frmverify' => __( 'Permanently delete this entry?', 'formidable' ),
779 - 'frmverify-btn' => 'frm-button-red',
662 + 'frmverify' => __( 'Delete this form entry?', 'formidable' ),
780 663 ),
781 664 );
782 665 }
783 666
784 - if ( $page === 'show' ) {
667 + if ( $page == 'show' ) {
785 668 $actions['frm_print'] = array(
786 669 'url' => '#',
787 670 'label' => __( 'Print Entry', 'formidable' ),
788 671 'data' => array(
@@ -803,18 +686,8 @@
803 686 ),
804 687 'icon' => 'frm_icon_font frm_email_icon',
805 688 );
806 689
807 - if ( ! function_exists( 'frm_pdfs_autoloader' ) ) {
808 - $actions['frm_download_pdf'] = array(
809 - 'url' => '#',
810 - 'label' => __( 'Download as PDF', 'formidable' ),
811 - 'class' => 'frm_noallow',
812 - 'data' => self::get_pdfs_upgrade_link_data( 'download-pdf-entry' ),
813 - 'icon' => 'frm_icon_font frm_download_icon',
814 - );
815 - }
816 -
817 690 $actions['frm_edit'] = array(
818 691 'url' => '#',
819 692 'label' => __( 'Edit Entry', 'formidable' ),
820 693 'class' => 'frm_noallow',
@@ -826,165 +699,6 @@
826 699 'icon' => 'frm_icon_font frm_pencil_icon',
827 700 );
828 701
829 702 return apply_filters( 'frm_entry_actions_dropdown', $actions, compact( 'id', 'entry' ) );
830 - }
831 -
832 - /**
833 - * Gets data attributes for PDFs addon upgrade link.
834 - *
835 - * @param string $medium The source of the upgrade link used for analytics data.
836 - *
837 - * @return array
838 - */
839 - private static function get_pdfs_upgrade_link_data( $medium = 'pdfs' ) {
840 - $data = array(
841 - 'oneclick' => '',
842 - 'requires' => '',
843 - 'upgrade' => __( 'Forms to PDF', 'formidable' ),
844 - 'medium' => $medium,
845 - );
846 -
847 - $upgrading = FrmAddonsController::install_link( 'pdfs' );
848 -
849 - if ( isset( $upgrading['url'] ) ) {
850 - $data['oneclick'] = json_encode( $upgrading );
851 - } else {
852 - $data['requires'] = FrmAddonsController::get_addon_required_plan( 28136428 );
853 - }
854 -
855 - return $data;
856 - }
857 -
858 - /**
859 - * @since 5.0.15
860 - *
861 - * @param int|string $entry_id
862 - *
863 - * @return void
864 - */
865 - public static function maybe_render_captcha_score( $entry_id ) {
866 - $query = array(
867 - 'item_id' => (int) $entry_id,
868 - 'field_id' => 0,
869 - );
870 - $metas_without_a_field = (array) FrmEntryMeta::getAll( $query, ' ORDER BY it.created_at DESC', '', true );
871 -
872 - foreach ( $metas_without_a_field as $meta ) {
873 - if ( ! empty( $meta->meta_value['captcha_score'] ) ) {
874 - echo '<div class="misc-pub-section">';
875 - FrmAppHelper::icon_by_class( 'frm_icon_font frm_shield_check_icon', array( 'aria-hidden' => 'true' ) );
876 - echo ' ' . esc_html__( 'reCAPTCHA Score', 'formidable' ) . ': ';
877 - echo '<b>' . esc_html( $meta->meta_value['captcha_score'] ) . '</b>';
878 - echo '</div>';
879 - return;
880 - }
881 - }
882 - }
883 -
884 - /**
885 - * Return entry status based on is_draft column value.
886 - *
887 - * @since 6.5
888 - *
889 - * @param int $status is_draft column.
890 - *
891 - * @return int
892 - */
893 - public static function get_entry_status( $status ) {
894 - $statuses = self::get_entry_statuses();
895 -
896 - if ( array_key_exists( $status, $statuses ) ) {
897 - return $status;
898 - }
899 -
900 - if ( empty( $status ) ) {
901 - // If the status is empty, let's default to 0.
902 - return self::SUBMITTED_ENTRY_STATUS;
903 - }
904 -
905 - // If it has a value that isn't in the array, let's default to 1. There may be old entries that don't have a value for is_draft.
906 - return self::DRAFT_ENTRY_STATUS;
907 - }
908 -
909 - /**
910 - * Return entry status label based on passed value.
911 - *
912 - * @since 6.5
913 - *
914 - * @param int $status is_draft column.
915 - *
916 - * @return string
917 - */
918 - public static function get_entry_status_label( $status ) {
919 - $statuses = self::get_entry_statuses();
920 -
921 - return $statuses[ self::get_entry_status( $status ) ];
922 - }
923 -
924 - /**
925 - * Get all entry statuses.
926 - *
927 - * @since 6.5
928 - * @since 6.6 function went from private to public.
929 - *
930 - * @return array<string>
931 - */
932 - public static function get_entry_statuses() {
933 -
934 - $default_entry_statuses = array(
935 - self::SUBMITTED_ENTRY_STATUS => __( 'Submitted', 'formidable' ),
936 - self::DRAFT_ENTRY_STATUS => __( 'Draft', 'formidable' ),
937 - );
938 -
939 - /**
940 - * Register entry status.
941 - *
942 - * "2" is used in abandonment-addon and reserved for "In progress".
943 - * "3" is used in abandonment-addon and reserved for "Abandoned".
944 - *
945 - * @since 6.5
946 - *
947 - * @param array<string> $extended_entry_status Entry statuses.
948 - */
949 - $extended_entry_status = apply_filters( 'frm_entry_statuses', array() );
950 -
951 - if ( ! is_array( $extended_entry_status ) ) {
952 - _doing_it_wrong( __METHOD__, esc_html__( 'Entry status must be return in array format.', 'formidable' ), '6.5' );
953 - $extended_entry_status = array();
954 - }
955 -
956 - $existing_entry_statuses = array_replace( $default_entry_statuses, $extended_entry_status );
957 -
958 - return $existing_entry_statuses;
959 - }
960 -
961 - /**
962 - * @since 6.17
963 - *
964 - * @return int
965 - */
966 - public static function get_visible_unread_inbox_count() {
967 - $menu_name = FrmAppHelper::get_menu_name();
968 -
969 - if ( ! in_array( $menu_name, array( 'Formidable', 'Forms' ), true ) ) {
970 - return 0;
971 - }
972 -
973 - $inbox = new FrmInbox();
974 - $inbox_count = count( $inbox->unread() );
975 -
976 - if ( ! $inbox_count ) {
977 - return 0;
978 - }
979 -
980 - if ( is_callable( 'FrmProSettingsController::inbox_badge' ) ) {
981 - $inbox_count = FrmProSettingsController::inbox_badge( $inbox_count );
982 -
983 - if ( ! $inbox_count ) {
984 - return 0;
985 - }
986 - }
987 -
988 - return $inbox_count;
989 703 }
990 704 }