PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 5.5.4
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v5.5.4
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 +55 -319 6.26 → 5.5.4 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,11 +26,11 @@
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
@@ -71,12 +44,11 @@
71 44
72 45 if ( ! $form || ! isset( $form->id ) ) {
73 46 $form = FrmForm::getOne( $field->form_id );
74 47 }
75 - }//end foreach
48 + }
76 49
77 50 FrmAppHelper::unserialize_or_decode( $form->options );
78 -
79 51 if ( is_array( $form->options ) ) {
80 52 $values = array_merge( $values, $form->options );
81 53 }
82 54
@@ -91,13 +63,11 @@
91 63 /**
92 64 * @since 2.05
93 65 *
94 66 * @param object $field
95 - *
96 - * @return void
97 67 */
98 68 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.
69 + //If checkbox, multi-select dropdown, or checkbox data from entries field, the value should be an array
100 70 $return_array = FrmField::is_field_with_multiple_values( $field );
101 71
102 72 /**
103 73 * Do any shortcodes in default value and allow customization of default value.
@@ -115,13 +85,13 @@
115 85 * This function is used when the form is first loaded and on all page turns *for a new entry*
116 86 *
117 87 * @since 2.0.13
118 88 *
119 - * @param object $field - this is passed by reference since it is an object.
120 - * @param bool $reset
121 - * @param array $args
89 + * @param object $field - this is passed by reference since it is an object
90 + * @param boolean $reset
91 + * @param array $args
122 92 *
123 - * @return array|string $new_value
93 + * @return string|array $new_value
124 94 */
125 95 private static function get_field_value_for_new_entry( $field, $reset, $args ) {
126 96 $new_value = $field->default_value;
127 97
@@ -141,18 +111,16 @@
141 111 *
142 112 * @since 2.01.0
143 113 *
144 114 * @param object $field
145 - * @param array $args
115 + * @param array $args
146 116 *
147 - * @return bool $value_is_posted
117 + * @return boolean $value_is_posted
148 118 */
149 119 public static function value_is_posted( $field, $args ) {
150 120 $value_is_posted = false;
151 -
152 121 if ( $_POST ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
153 122 $repeating = isset( $args['repeating'] ) && $args['repeating'];
154 -
155 123 if ( $repeating ) {
156 124 if ( isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
157 125 $value_is_posted = true;
158 126 }
@@ -163,14 +131,8 @@
163 131
164 132 return $value_is_posted;
165 133 }
166 134
167 - /**
168 - * @param array $values
169 - * @param object $record
170 - *
171 - * @return array
172 - */
173 135 public static function setup_edit_vars( $values, $record ) {
174 136 remove_action( 'media_buttons', 'FrmFormsController::insert_form_button' );
175 137
176 138 $values['item_key'] = FrmAppHelper::get_post_param( 'item_key', $record->item_key, 'sanitize_title' );
@@ -179,14 +141,8 @@
179 141
180 142 return apply_filters( 'frm_setup_edit_entry_vars', $values, $record );
181 143 }
182 144
183 - /**
184 - * @param string $message
185 - * @param array $atts
186 - *
187 - * @return string
188 - */
189 145 public static function replace_default_message( $message, $atts ) {
190 146 if ( strpos( $message, '[default-message' ) === false &&
191 147 strpos( $message, '[default_message' ) === false &&
192 148 ! empty( $message ) ) {
@@ -200,9 +156,8 @@
200 156 preg_match_all( "/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER );
201 157
202 158 foreach ( $shortcodes[0] as $short_key => $tag ) {
203 159 $add_atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][ $short_key ] );
204 -
205 160 if ( ! empty( $add_atts ) ) {
206 161 $this_atts = array_merge( $atts, $add_atts );
207 162 } else {
208 163 $this_atts = $atts;
@@ -216,22 +171,14 @@
216 171
217 172 return $message;
218 173 }
219 174
220 - /**
221 - * @param stdClass $entry
222 - * @param stdClass $field
223 - * @param array $atts
224 - *
225 - * @return string
226 - */
227 175 public static function prepare_display_value( $entry, $field, $atts ) {
228 - $field_value = $entry->metas[ $field->id ] ?? false;
176 + $field_value = isset( $entry->metas[ $field->id ] ) ? $entry->metas[ $field->id ] : false;
229 177
230 178 if ( FrmAppHelper::pro_is_installed() ) {
231 179 $empty = empty( $field_value );
232 180 FrmProEntriesHelper::get_dynamic_list_values( $field, $entry, $field_value );
233 -
234 181 if ( $empty && ! empty( $field_value ) ) {
235 182 // We've got an entry id, so switch it to a value.
236 183 $atts['force_id'] = true;
237 184 }
@@ -240,23 +187,17 @@
240 187 if ( $field->form_id == $entry->form_id || empty( $atts['embedded_field_id'] ) ) {
241 188 return self::display_value( $field_value, $field, $atts );
242 189 }
243 190
244 - if ( ! FrmAppHelper::pro_is_installed() ) {
245 - return '';
246 - }
191 + // This is an embeded form.
192 + $val = '';
247 193
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 194 if ( strpos( $atts['embedded_field_id'], 'form' ) === 0 ) {
254 195 // This is a repeating section.
255 - $child_entries = FrmEntry::getAll( array( 'it.parent_item_id' => $entry->id ), '', '', true );
196 + $child_entries = FrmEntry::getAll( array( 'it.parent_item_id' => $entry->id ) );
256 197 } else {
257 198 // Get all values for this field.
258 - $child_values = $entry->metas[ $atts['embedded_field_id'] ] ?? false;
199 + $child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false;
259 200
260 201 if ( $child_values ) {
261 202 $child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) );
262 203 }
@@ -263,10 +204,10 @@
263 204 }
264 205
265 206 $field_value = array();
266 207
267 - if ( empty( $child_entries ) ) {
268 - return '';
208 + if ( ! isset( $child_entries ) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) {
209 + return $val;
269 210 }
270 211
271 212 foreach ( $child_entries as $child_entry ) {
272 213 $atts['item_id'] = $child_entry->id;
@@ -283,15 +224,13 @@
283 224 unset( $child_entry );
284 225 }
285 226
286 227 $sep = ', ';
287 -
288 - if ( strpos( implode( ' ', $field_value ), '<img' ) !== false ) {
228 + if ( strpos( implode( ' ', (array) $field_value ), '<img' ) !== false ) {
289 229 $sep = '<br/>';
290 230 }
231 + $val = implode( $sep, (array) $field_value );
291 232
292 - $val = implode( $sep, $field_value );
293 -
294 233 return FrmAppHelper::kses( $val, 'all' );
295 234 }
296 235
297 236 /**
@@ -297,10 +236,10 @@
297 236 /**
298 237 * Prepare the saved value for display
299 238 *
300 239 * @param array|string $value
301 - * @param object $field
302 - * @param array $atts
240 + * @param object $field
241 + * @param array $atts
303 242 *
304 243 * @return string
305 244 */
306 245 public static function display_value( $value, $field, $atts = array() ) {
@@ -319,9 +258,9 @@
319 258 );
320 259
321 260 $atts = wp_parse_args( $atts, $defaults );
322 261
323 - if ( FrmField::is_image( $field ) || $field->type === 'star' ) {
262 + if ( FrmField::is_image( $field ) || $field->type == 'star' ) {
324 263 $atts['truncate'] = false;
325 264 $atts['html'] = true;
326 265 }
327 266
@@ -326,12 +265,8 @@
326 265 }
327 266
328 267 $atts = apply_filters( 'frm_display_value_atts', $atts, $field, $value );
329 268
330 - if ( is_string( $field->field_options ) ) {
331 - $field->field_options = array();
332 - }
333 -
334 269 if ( ! isset( $field->field_options['post_field'] ) ) {
335 270 $field->field_options['post_field'] = '';
336 271 }
337 272
@@ -338,12 +273,12 @@
338 273 if ( ! isset( $field->field_options['custom_field'] ) ) {
339 274 $field->field_options['custom_field'] = '';
340 275 }
341 276
342 - if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] === 'tag' ) ) {
277 + if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) {
343 278 $atts['pre_truncate'] = $atts['truncate'];
344 279 $atts['truncate'] = true;
345 - $atts['exclude_cat'] = $field->field_options['exclude_cat'] ?? 0;
280 + $atts['exclude_cat'] = isset( $field->field_options['exclude_cat'] ) ? $field->field_options['exclude_cat'] : 0;
346 281
347 282 $value = FrmProEntryMetaHelper::get_post_value( $atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts );
348 283 $atts['truncate'] = $atts['pre_truncate'];
349 284 }
@@ -352,9 +287,9 @@
352 287 return $value;
353 288 }
354 289
355 290 $unfiltered_value = $value;
356 - FrmFieldsHelper::prepare_field_value( $unfiltered_value, $field->type );
291 + FrmAppHelper::unserialize_or_decode( $unfiltered_value );
357 292
358 293 $value = apply_filters( 'frm_display_value_custom', $unfiltered_value, $field, $atts );
359 294 $value = apply_filters( 'frm_display_' . $field->type . '_value_custom', $value, compact( 'field', 'atts' ) );
360 295
@@ -361,9 +296,9 @@
361 296 if ( $value == $unfiltered_value ) {
362 297 $value = FrmFieldsHelper::get_unfiltered_display_value( compact( 'value', 'field', 'atts' ) );
363 298 }
364 299
365 - if ( $atts['truncate'] && $atts['type'] !== 'url' ) {
300 + if ( $atts['truncate'] && $atts['type'] != 'url' ) {
366 301 $value = FrmAppHelper::truncate( $value, 50 );
367 302 }
368 303
369 304 if ( ! $atts['keepjs'] && ! is_array( $value ) ) {
@@ -372,21 +307,13 @@
372 307
373 308 return apply_filters( 'frm_display_value', $value, $field, $atts );
374 309 }
375 310
376 - /**
377 - * @param object $field
378 - * @param mixed $value
379 - * @param array $args
380 - *
381 - * @return void
382 - */
383 311 public static function set_posted_value( $field, $value, $args ) {
384 312 // If validating a field with "other" opt, set back to prev value now.
385 - if ( ! empty( $args['other'] ) ) {
313 + if ( isset( $args['other'] ) && $args['other'] ) {
386 314 $value = $args['temp_value'];
387 315 }
388 -
389 316 if ( empty( $args['parent_field_id'] ) ) {
390 317 $_POST['item_meta'][ $field->id ] = $value;
391 318 } else {
392 319 self::set_parent_field_posted_value( $field, $value, $args );
@@ -396,14 +323,8 @@
396 323 /**
397 324 * Init arrays if necessary, else we get fatal error.
398 325 *
399 326 * @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 327 */
407 328 private static function set_parent_field_posted_value( $field, $value, $args ) {
408 329 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 330 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
@@ -417,15 +338,8 @@
417 338
418 339 $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value; // phpcs:ignore WordPress.Security.NonceVerification.Missing
419 340 }
420 341
421 - /**
422 - * @param array|int|object $field
423 - * @param mixed $value
424 - * @param array $args
425 - *
426 - * @return void
427 - */
428 342 public static function get_posted_value( $field, &$value, $args ) {
429 343 if ( is_array( $field ) ) {
430 344 $field_id = $field['id'];
431 345 $field_obj = FrmFieldFactory::get_field_object( $field['id'] );
@@ -430,14 +344,9 @@
430 344 $field_id = $field['id'];
431 345 $field_obj = FrmFieldFactory::get_field_object( $field['id'] );
432 346 } elseif ( is_object( $field ) ) {
433 347 $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 - }
348 + $field_obj = FrmFieldFactory::get_field_object( $field );
440 349 } elseif ( is_numeric( $field ) ) {
441 350 $field_id = $field;
442 351 $field_obj = FrmFieldFactory::get_field_object( $field );
443 352 } else {
@@ -452,13 +361,8 @@
452 361 }
453 362
454 363 /**
455 364 * @since 4.02.04
456 - *
457 - * @param int|string $field_id Field ID.
458 - * @param array $args Additional arguments.
459 - *
460 - * @return mixed
461 365 */
462 366 private static function get_posted_meta( $field_id, $args ) {
463 367 if ( empty( $args['parent_field_id'] ) ) {
464 368 // Sanitizing is done next.
@@ -473,17 +377,14 @@
473 377 * Check if field has an "Other" option and if any other values are posted
474 378 *
475 379 * @since 2.0
476 380 *
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
381 + * @param object $field
382 + * @param string|array $value
383 + * @param array $args
482 384 */
483 385 public static function maybe_set_other_validation( $field, &$value, &$args ) {
484 386 $args['other'] = false;
485 -
486 387 if ( ! $value || ! FrmAppHelper::pro_is_installed() ) {
487 388 return;
488 389 }
489 390
@@ -517,13 +418,11 @@
517 418 * Sets radio or checkbox value equal to "other" value if it is set - FOR REPEATING SECTIONS
518 419 *
519 420 * @since 2.0
520 421 *
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
422 + * @param object $field
423 + * @param string|array $value
424 + * @param array $args
526 425 */
527 426 public static function set_other_repeating_vals( $field, &$value, &$args ) {
528 427 if ( ! $args['parent_field_id'] ) {
529 428 return;
@@ -551,14 +450,12 @@
551 450 * Needs to accommodate for times when other opt is selected, but no other free text is entered
552 451 *
553 452 * @since 2.0
554 453 *
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
454 + * @param string|array $value
455 + * @param string|array $other_vals (usually of posted values)
456 + * @param object $field
457 + * @param array $args
561 458 */
562 459 public static function set_other_validation_val( &$value, $other_vals, $field, &$args ) {
563 460 // Checkboxes and multi-select dropdowns.
564 461 if ( is_array( $value ) && $field->type === 'checkbox' ) {
@@ -594,9 +491,8 @@
594 491 }
595 492
596 493 $args['temp_value'] = $value;
597 494 $value[ $other_key ] = reset( $other_vals );
598 -
599 495 if ( FrmAppHelper::is_empty_value( $value[ $other_key ] ) ) {
600 496 unset( $value[ $other_key ] );
601 497 }
602 498 }
@@ -601,10 +497,10 @@
601 497 }
602 498 }
603 499 } elseif ( $field->options[ $other_key ] == $value ) {
604 500 $value = $other_vals;
605 - }//end if
606 - }//end if
501 + }
502 + }
607 503 }
608 504
609 505 /**
610 506 * Add submitted values to a string for spam checking.
@@ -609,16 +505,14 @@
609 505 /**
610 506 * Add submitted values to a string for spam checking.
611 507 *
612 508 * @param array $values
613 - *
614 509 * @return string
615 510 */
616 511 public static function entry_array_to_string( $values ) {
617 512 $content = '';
618 -
619 513 foreach ( $values['item_meta'] as $val ) {
620 - if ( $content !== '' ) {
514 + if ( $content != '' ) {
621 515 $content .= "\n\n";
622 516 }
623 517
624 518 if ( is_array( $val ) ) {
@@ -642,9 +536,9 @@
642 536 * @return string
643 537 */
644 538 public static function get_browser( $u_agent ) {
645 539 $bname = __( 'Unknown', 'formidable' );
646 - $platform = $bname;
540 + $platform = __( 'Unknown', 'formidable' );
647 541 $ub = '';
648 542
649 543 // Get the operating system
650 544 if ( preg_match( '/windows|win32/i', $u_agent ) ) {
@@ -664,9 +558,9 @@
664 558 'Netscape' => 'Netscape',
665 559 'Firefox' => 'Mozilla Firefox',
666 560 );
667 561
668 - // Next get the name of the useragent yes separately and for good reason.
562 + // Next get the name of the useragent yes seperately and for good reason
669 563 if ( strpos( $u_agent, 'MSIE' ) !== false && strpos( $u_agent, 'Opera' ) === false ) {
670 564 $bname = 'Internet Explorer';
671 565 $ub = 'MSIE';
672 566 } else {
@@ -680,18 +574,17 @@
680 574 }
681 575
682 576 // finally get the correct version number
683 577 $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 );
578 + $pattern = '#(?<browser>' . join( '|', $known ) . ')[/ ]+(?<version>[0-9.|a-zA-Z.]*)#';
579 + preg_match_all( $pattern, $u_agent, $matches ); // get the matching numbers
687 580
688 581 // see how many we have
689 582 $i = count( $matches['browser'] );
690 583
691 584 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.
585 + //we will have two since we are not using 'other' argument yet
586 + //see if version is before or after the name
694 587 if ( strripos( $u_agent, 'Version' ) < strripos( $u_agent, $ub ) ) {
695 588 $version = $matches['version'][0];
696 589 } else {
697 590 $version = $matches['version'][1];
@@ -702,9 +595,9 @@
702 595 $version = '';
703 596 }
704 597
705 598 // check if we have a number
706 - if ( $version === '' ) {
599 + if ( $version == '' ) {
707 600 $version = '?';
708 601 }
709 602
710 603 return $bname . ' ' . $version . ' / ' . $platform;
@@ -711,15 +604,11 @@
711 604 }
712 605
713 606 /**
714 607 * @since 3.0
715 - *
716 - * @param array $atts Action dropdown attributes.
717 - *
718 - * @return void
719 608 */
720 609 public static function actions_dropdown( $atts ) {
721 - $id = $atts['id'] ?? FrmAppHelper::get_param( 'id', 0, 'get', 'absint' );
610 + $id = isset( $atts['id'] ) ? $atts['id'] : FrmAppHelper::get_param( 'id', 0, 'get', 'absint' );
722 611 $links = self::get_action_links( $id, $atts['entry'] );
723 612
724 613 foreach ( $links as $link ) {
725 614 ?>
@@ -730,13 +619,11 @@
730 619 foreach ( $link['data'] as $data => $value ) {
731 620 echo 'data-' . esc_attr( $data ) . '="' . esc_attr( $value ) . '" ';
732 621 }
733 622 }
734 -
735 623 if ( isset( $link['class'] ) ) {
736 624 echo 'class="' . esc_attr( $link['class'] ) . '" ';
737 625 }
738 -
739 626 if ( isset( $link['id'] ) ) {
740 627 echo 'id="' . esc_attr( $link['id'] ) . '" ';
741 628 }
742 629 ?>
@@ -745,24 +632,19 @@
745 632 <span class="frm_link_label"><?php echo esc_html( $link['label'] ); ?></span>
746 633 </a>
747 634 </div>
748 635 <?php
749 - }//end foreach
636 + }
750 637 }
751 638
752 639 /**
753 640 * @since 3.0
754 - *
755 - * @param int $id Entry ID.
756 - * @param array|object $entry Entry object.
757 - *
758 - * @return array
759 641 */
760 642 private static function get_action_links( $id, $entry ) {
761 643 $page = FrmAppHelper::get_param( 'frm_action' );
762 644 $actions = array();
763 645
764 - if ( $page !== 'show' ) {
646 + if ( $page != 'show' ) {
765 647 $actions['frm_view'] = array(
766 648 'url' => admin_url( 'admin.php?page=formidable-entries&frm_action=show&id=' . $id . '&form=' . $entry->form_id ),
767 649 'label' => __( 'View Entry', 'formidable' ),
768 650 'icon' => 'frm_icon_font frm_save_icon',
@@ -770,19 +652,18 @@
770 652 }
771 653
772 654 if ( current_user_can( 'frm_delete_entries' ) ) {
773 655 $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 ) ),
656 + 'url' => admin_url( 'admin.php?page=formidable-entries&frm_action=destroy&id=' . $id . '&form=' . $entry->form_id ),
775 657 'label' => __( 'Delete Entry', 'formidable' ),
776 658 'icon' => 'frm_icon_font frm_delete_icon',
777 659 'data' => array(
778 - 'frmverify' => __( 'Permanently delete this entry?', 'formidable' ),
779 - 'frmverify-btn' => 'frm-button-red',
660 + 'frmverify' => __( 'Delete this form entry?', 'formidable' ),
780 661 ),
781 662 );
782 663 }
783 664
784 - if ( $page === 'show' ) {
665 + if ( $page == 'show' ) {
785 666 $actions['frm_print'] = array(
786 667 'url' => '#',
787 668 'label' => __( 'Print Entry', 'formidable' ),
788 669 'data' => array(
@@ -803,18 +684,8 @@
803 684 ),
804 685 'icon' => 'frm_icon_font frm_email_icon',
805 686 );
806 687
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 688 $actions['frm_edit'] = array(
818 689 'url' => '#',
819 690 'label' => __( 'Edit Entry', 'formidable' ),
820 691 'class' => 'frm_noallow',
@@ -829,38 +700,11 @@
829 700 return apply_filters( 'frm_entry_actions_dropdown', $actions, compact( 'id', 'entry' ) );
830 701 }
831 702
832 703 /**
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 704 * @since 5.0.15
860 705 *
861 - * @param int|string $entry_id
862 - *
706 + * @param string|int $entry_id
863 707 * @return void
864 708 */
865 709 public static function maybe_render_captcha_score( $entry_id ) {
866 710 $query = array(
@@ -867,9 +711,8 @@
867 711 'item_id' => (int) $entry_id,
868 712 'field_id' => 0,
869 713 );
870 714 $metas_without_a_field = (array) FrmEntryMeta::getAll( $query, ' ORDER BY it.created_at DESC', '', true );
871 -
872 715 foreach ( $metas_without_a_field as $meta ) {
873 716 if ( ! empty( $meta->meta_value['captcha_score'] ) ) {
874 717 echo '<div class="misc-pub-section">';
875 718 FrmAppHelper::icon_by_class( 'frm_icon_font frm_shield_check_icon', array( 'aria-hidden' => 'true' ) );
@@ -878,113 +721,6 @@
878 721 echo '</div>';
879 722 return;
880 723 }
881 724 }
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 725 }
990 726 }