PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.7
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.7
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 +52 -182 6.266.7 View file →
@@ -8,9 +8,8 @@
8 8 /**
9 9 * "Submitted" entry status.
10 10 *
11 11 * @since 6.4.2
12 - *
13 12 * @var int
14 13 */
15 14 const SUBMITTED_ENTRY_STATUS = 0;
16 15
@@ -17,21 +16,12 @@
17 16 /**
18 17 * "Draft" entry status.
19 18 *
20 19 * @since 6.4.2
21 - *
22 20 * @var int
23 21 */
24 22 const DRAFT_ENTRY_STATUS = 1;
25 23
26 - /**
27 - * @param mixed $fields
28 - * @param object|string $form
29 - * @param bool $reset
30 - * @param array $args
31 - *
32 - * @return array
33 - */
34 24 public static function setup_new_vars( $fields, $form = '', $reset = false, $args = array() ) {
35 25 remove_action( 'media_buttons', 'FrmFormsController::insert_form_button' );
36 26
37 27 $values = array(
@@ -40,9 +30,8 @@
40 30 'item_key' => '',
41 31 );
42 32
43 33 $values['fields'] = array();
44 -
45 34 if ( empty( $fields ) ) {
46 35 return apply_filters( 'frm_setup_new_entry', $values );
47 36 }
48 37
@@ -53,11 +42,11 @@
53 42
54 43 $field_array = FrmAppHelper::start_field_array( $field );
55 44 $field_array['value'] = $new_value;
56 45 $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;
46 + $field_array['parent_form_id'] = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id;
58 47 $field_array['reset_value'] = $reset;
59 - $field_array['in_embed_form'] = $args['in_embed_form'] ?? '0';
48 + $field_array['in_embed_form'] = isset( $args['in_embed_form'] ) ? $args['in_embed_form'] : '0';
60 49 $field_array['original_default'] = $original_default;
61 50
62 51 FrmFieldsHelper::prepare_new_front_field( $field_array, $field, $args );
63 52
@@ -71,12 +60,11 @@
71 60
72 61 if ( ! $form || ! isset( $form->id ) ) {
73 62 $form = FrmForm::getOne( $field->form_id );
74 63 }
75 - }//end foreach
64 + }
76 65
77 66 FrmAppHelper::unserialize_or_decode( $form->options );
78 -
79 67 if ( is_array( $form->options ) ) {
80 68 $values = array_merge( $values, $form->options );
81 69 }
82 70
@@ -91,13 +79,11 @@
91 79 /**
92 80 * @since 2.05
93 81 *
94 82 * @param object $field
95 - *
96 - * @return void
97 83 */
98 84 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.
85 + //If checkbox, multi-select dropdown, or checkbox data from entries field, the value should be an array
100 86 $return_array = FrmField::is_field_with_multiple_values( $field );
101 87
102 88 /**
103 89 * Do any shortcodes in default value and allow customization of default value.
@@ -115,13 +101,13 @@
115 101 * This function is used when the form is first loaded and on all page turns *for a new entry*
116 102 *
117 103 * @since 2.0.13
118 104 *
119 - * @param object $field - this is passed by reference since it is an object.
120 - * @param bool $reset
121 - * @param array $args
105 + * @param object $field - this is passed by reference since it is an object
106 + * @param boolean $reset
107 + * @param array $args
122 108 *
123 - * @return array|string $new_value
109 + * @return string|array $new_value
124 110 */
125 111 private static function get_field_value_for_new_entry( $field, $reset, $args ) {
126 112 $new_value = $field->default_value;
127 113
@@ -141,18 +127,16 @@
141 127 *
142 128 * @since 2.01.0
143 129 *
144 130 * @param object $field
145 - * @param array $args
131 + * @param array $args
146 132 *
147 - * @return bool $value_is_posted
133 + * @return boolean $value_is_posted
148 134 */
149 135 public static function value_is_posted( $field, $args ) {
150 136 $value_is_posted = false;
151 -
152 137 if ( $_POST ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
153 138 $repeating = isset( $args['repeating'] ) && $args['repeating'];
154 -
155 139 if ( $repeating ) {
156 140 if ( isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
157 141 $value_is_posted = true;
158 142 }
@@ -163,14 +147,8 @@
163 147
164 148 return $value_is_posted;
165 149 }
166 150
167 - /**
168 - * @param array $values
169 - * @param object $record
170 - *
171 - * @return array
172 - */
173 151 public static function setup_edit_vars( $values, $record ) {
174 152 remove_action( 'media_buttons', 'FrmFormsController::insert_form_button' );
175 153
176 154 $values['item_key'] = FrmAppHelper::get_post_param( 'item_key', $record->item_key, 'sanitize_title' );
@@ -179,14 +157,8 @@
179 157
180 158 return apply_filters( 'frm_setup_edit_entry_vars', $values, $record );
181 159 }
182 160
183 - /**
184 - * @param string $message
185 - * @param array $atts
186 - *
187 - * @return string
188 - */
189 161 public static function replace_default_message( $message, $atts ) {
190 162 if ( strpos( $message, '[default-message' ) === false &&
191 163 strpos( $message, '[default_message' ) === false &&
192 164 ! empty( $message ) ) {
@@ -200,9 +172,8 @@
200 172 preg_match_all( "/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER );
201 173
202 174 foreach ( $shortcodes[0] as $short_key => $tag ) {
203 175 $add_atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][ $short_key ] );
204 -
205 176 if ( ! empty( $add_atts ) ) {
206 177 $this_atts = array_merge( $atts, $add_atts );
207 178 } else {
208 179 $this_atts = $atts;
@@ -220,18 +191,16 @@
220 191 /**
221 192 * @param stdClass $entry
222 193 * @param stdClass $field
223 194 * @param array $atts
224 - *
225 195 * @return string
226 196 */
227 197 public static function prepare_display_value( $entry, $field, $atts ) {
228 - $field_value = $entry->metas[ $field->id ] ?? false;
198 + $field_value = isset( $entry->metas[ $field->id ] ) ? $entry->metas[ $field->id ] : false;
229 199
230 200 if ( FrmAppHelper::pro_is_installed() ) {
231 201 $empty = empty( $field_value );
232 202 FrmProEntriesHelper::get_dynamic_list_values( $field, $entry, $field_value );
233 -
234 203 if ( $empty && ! empty( $field_value ) ) {
235 204 // We've got an entry id, so switch it to a value.
236 205 $atts['force_id'] = true;
237 206 }
@@ -244,19 +213,15 @@
244 213 if ( ! FrmAppHelper::pro_is_installed() ) {
245 214 return '';
246 215 }
247 216
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.
217 + // This is an embeded form.
253 218 if ( strpos( $atts['embedded_field_id'], 'form' ) === 0 ) {
254 219 // This is a repeating section.
255 220 $child_entries = FrmEntry::getAll( array( 'it.parent_item_id' => $entry->id ), '', '', true );
256 221 } else {
257 222 // Get all values for this field.
258 - $child_values = $entry->metas[ $atts['embedded_field_id'] ] ?? false;
223 + $child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false;
259 224
260 225 if ( $child_values ) {
261 226 $child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) );
262 227 }
@@ -283,15 +248,13 @@
283 248 unset( $child_entry );
284 249 }
285 250
286 251 $sep = ', ';
287 -
288 - if ( strpos( implode( ' ', $field_value ), '<img' ) !== false ) {
252 + if ( strpos( implode( ' ', (array) $field_value ), '<img' ) !== false ) {
289 253 $sep = '<br/>';
290 254 }
255 + $val = implode( $sep, (array) $field_value );
291 256
292 - $val = implode( $sep, $field_value );
293 -
294 257 return FrmAppHelper::kses( $val, 'all' );
295 258 }
296 259
297 260 /**
@@ -297,10 +260,10 @@
297 260 /**
298 261 * Prepare the saved value for display
299 262 *
300 263 * @param array|string $value
301 - * @param object $field
302 - * @param array $atts
264 + * @param object $field
265 + * @param array $atts
303 266 *
304 267 * @return string
305 268 */
306 269 public static function display_value( $value, $field, $atts = array() ) {
@@ -319,9 +282,9 @@
319 282 );
320 283
321 284 $atts = wp_parse_args( $atts, $defaults );
322 285
323 - if ( FrmField::is_image( $field ) || $field->type === 'star' ) {
286 + if ( FrmField::is_image( $field ) || $field->type == 'star' ) {
324 287 $atts['truncate'] = false;
325 288 $atts['html'] = true;
326 289 }
327 290
@@ -326,12 +289,8 @@
326 289 }
327 290
328 291 $atts = apply_filters( 'frm_display_value_atts', $atts, $field, $value );
329 292
330 - if ( is_string( $field->field_options ) ) {
331 - $field->field_options = array();
332 - }
333 -
334 293 if ( ! isset( $field->field_options['post_field'] ) ) {
335 294 $field->field_options['post_field'] = '';
336 295 }
337 296
@@ -338,12 +297,12 @@
338 297 if ( ! isset( $field->field_options['custom_field'] ) ) {
339 298 $field->field_options['custom_field'] = '';
340 299 }
341 300
342 - if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] === 'tag' ) ) {
301 + if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) {
343 302 $atts['pre_truncate'] = $atts['truncate'];
344 303 $atts['truncate'] = true;
345 - $atts['exclude_cat'] = $field->field_options['exclude_cat'] ?? 0;
304 + $atts['exclude_cat'] = isset( $field->field_options['exclude_cat'] ) ? $field->field_options['exclude_cat'] : 0;
346 305
347 306 $value = FrmProEntryMetaHelper::get_post_value( $atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts );
348 307 $atts['truncate'] = $atts['pre_truncate'];
349 308 }
@@ -361,9 +320,9 @@
361 320 if ( $value == $unfiltered_value ) {
362 321 $value = FrmFieldsHelper::get_unfiltered_display_value( compact( 'value', 'field', 'atts' ) );
363 322 }
364 323
365 - if ( $atts['truncate'] && $atts['type'] !== 'url' ) {
324 + if ( $atts['truncate'] && $atts['type'] != 'url' ) {
366 325 $value = FrmAppHelper::truncate( $value, 50 );
367 326 }
368 327
369 328 if ( ! $atts['keepjs'] && ! is_array( $value ) ) {
@@ -372,21 +331,13 @@
372 331
373 332 return apply_filters( 'frm_display_value', $value, $field, $atts );
374 333 }
375 334
376 - /**
377 - * @param object $field
378 - * @param mixed $value
379 - * @param array $args
380 - *
381 - * @return void
382 - */
383 335 public static function set_posted_value( $field, $value, $args ) {
384 336 // If validating a field with "other" opt, set back to prev value now.
385 - if ( ! empty( $args['other'] ) ) {
337 + if ( isset( $args['other'] ) && $args['other'] ) {
386 338 $value = $args['temp_value'];
387 339 }
388 -
389 340 if ( empty( $args['parent_field_id'] ) ) {
390 341 $_POST['item_meta'][ $field->id ] = $value;
391 342 } else {
392 343 self::set_parent_field_posted_value( $field, $value, $args );
@@ -396,14 +347,8 @@
396 347 /**
397 348 * Init arrays if necessary, else we get fatal error.
398 349 *
399 350 * @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 351 */
407 352 private static function set_parent_field_posted_value( $field, $value, $args ) {
408 353 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 354 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 +362,8 @@
417 362
418 363 $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value; // phpcs:ignore WordPress.Security.NonceVerification.Missing
419 364 }
420 365
421 - /**
422 - * @param array|int|object $field
423 - * @param mixed $value
424 - * @param array $args
425 - *
426 - * @return void
427 - */
428 366 public static function get_posted_value( $field, &$value, $args ) {
429 367 if ( is_array( $field ) ) {
430 368 $field_id = $field['id'];
431 369 $field_obj = FrmFieldFactory::get_field_object( $field['id'] );
@@ -430,14 +368,9 @@
430 368 $field_id = $field['id'];
431 369 $field_obj = FrmFieldFactory::get_field_object( $field['id'] );
432 370 } elseif ( is_object( $field ) ) {
433 371 $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 - }
372 + $field_obj = FrmFieldFactory::get_field_object( $field );
440 373 } elseif ( is_numeric( $field ) ) {
441 374 $field_id = $field;
442 375 $field_obj = FrmFieldFactory::get_field_object( $field );
443 376 } else {
@@ -452,13 +385,8 @@
452 385 }
453 386
454 387 /**
455 388 * @since 4.02.04
456 - *
457 - * @param int|string $field_id Field ID.
458 - * @param array $args Additional arguments.
459 - *
460 - * @return mixed
461 389 */
462 390 private static function get_posted_meta( $field_id, $args ) {
463 391 if ( empty( $args['parent_field_id'] ) ) {
464 392 // Sanitizing is done next.
@@ -473,17 +401,14 @@
473 401 * Check if field has an "Other" option and if any other values are posted
474 402 *
475 403 * @since 2.0
476 404 *
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
405 + * @param object $field
406 + * @param string|array $value
407 + * @param array $args
482 408 */
483 409 public static function maybe_set_other_validation( $field, &$value, &$args ) {
484 410 $args['other'] = false;
485 -
486 411 if ( ! $value || ! FrmAppHelper::pro_is_installed() ) {
487 412 return;
488 413 }
489 414
@@ -517,13 +442,11 @@
517 442 * Sets radio or checkbox value equal to "other" value if it is set - FOR REPEATING SECTIONS
518 443 *
519 444 * @since 2.0
520 445 *
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
446 + * @param object $field
447 + * @param string|array $value
448 + * @param array $args
526 449 */
527 450 public static function set_other_repeating_vals( $field, &$value, &$args ) {
528 451 if ( ! $args['parent_field_id'] ) {
529 452 return;
@@ -551,14 +474,12 @@
551 474 * Needs to accommodate for times when other opt is selected, but no other free text is entered
552 475 *
553 476 * @since 2.0
554 477 *
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
478 + * @param string|array $value
479 + * @param string|array $other_vals (usually of posted values)
480 + * @param object $field
481 + * @param array $args
561 482 */
562 483 public static function set_other_validation_val( &$value, $other_vals, $field, &$args ) {
563 484 // Checkboxes and multi-select dropdowns.
564 485 if ( is_array( $value ) && $field->type === 'checkbox' ) {
@@ -594,9 +515,8 @@
594 515 }
595 516
596 517 $args['temp_value'] = $value;
597 518 $value[ $other_key ] = reset( $other_vals );
598 -
599 519 if ( FrmAppHelper::is_empty_value( $value[ $other_key ] ) ) {
600 520 unset( $value[ $other_key ] );
601 521 }
602 522 }
@@ -601,10 +521,10 @@
601 521 }
602 522 }
603 523 } elseif ( $field->options[ $other_key ] == $value ) {
604 524 $value = $other_vals;
605 - }//end if
606 - }//end if
525 + }
526 + }
607 527 }
608 528
609 529 /**
610 530 * Add submitted values to a string for spam checking.
@@ -609,16 +529,14 @@
609 529 /**
610 530 * Add submitted values to a string for spam checking.
611 531 *
612 532 * @param array $values
613 - *
614 533 * @return string
615 534 */
616 535 public static function entry_array_to_string( $values ) {
617 536 $content = '';
618 -
619 537 foreach ( $values['item_meta'] as $val ) {
620 - if ( $content !== '' ) {
538 + if ( $content != '' ) {
621 539 $content .= "\n\n";
622 540 }
623 541
624 542 if ( is_array( $val ) ) {
@@ -642,9 +560,9 @@
642 560 * @return string
643 561 */
644 562 public static function get_browser( $u_agent ) {
645 563 $bname = __( 'Unknown', 'formidable' );
646 - $platform = $bname;
564 + $platform = __( 'Unknown', 'formidable' );
647 565 $ub = '';
648 566
649 567 // Get the operating system
650 568 if ( preg_match( '/windows|win32/i', $u_agent ) ) {
@@ -664,9 +582,9 @@
664 582 'Netscape' => 'Netscape',
665 583 'Firefox' => 'Mozilla Firefox',
666 584 );
667 585
668 - // Next get the name of the useragent yes separately and for good reason.
586 + // Next get the name of the useragent yes seperately and for good reason
669 587 if ( strpos( $u_agent, 'MSIE' ) !== false && strpos( $u_agent, 'Opera' ) === false ) {
670 588 $bname = 'Internet Explorer';
671 589 $ub = 'MSIE';
672 590 } else {
@@ -680,18 +598,17 @@
680 598 }
681 599
682 600 // finally get the correct version number
683 601 $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 );
602 + $pattern = '#(?<browser>' . join( '|', $known ) . ')[/ ]+(?<version>[0-9.|a-zA-Z.]*)#';
603 + preg_match_all( $pattern, $u_agent, $matches ); // get the matching numbers
687 604
688 605 // see how many we have
689 606 $i = count( $matches['browser'] );
690 607
691 608 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.
609 + //we will have two since we are not using 'other' argument yet
610 + //see if version is before or after the name
694 611 if ( strripos( $u_agent, 'Version' ) < strripos( $u_agent, $ub ) ) {
695 612 $version = $matches['version'][0];
696 613 } else {
697 614 $version = $matches['version'][1];
@@ -702,9 +619,9 @@
702 619 $version = '';
703 620 }
704 621
705 622 // check if we have a number
706 - if ( $version === '' ) {
623 + if ( $version == '' ) {
707 624 $version = '?';
708 625 }
709 626
710 627 return $bname . ' ' . $version . ' / ' . $platform;
@@ -711,15 +628,11 @@
711 628 }
712 629
713 630 /**
714 631 * @since 3.0
715 - *
716 - * @param array $atts Action dropdown attributes.
717 - *
718 - * @return void
719 632 */
720 633 public static function actions_dropdown( $atts ) {
721 - $id = $atts['id'] ?? FrmAppHelper::get_param( 'id', 0, 'get', 'absint' );
634 + $id = isset( $atts['id'] ) ? $atts['id'] : FrmAppHelper::get_param( 'id', 0, 'get', 'absint' );
722 635 $links = self::get_action_links( $id, $atts['entry'] );
723 636
724 637 foreach ( $links as $link ) {
725 638 ?>
@@ -730,13 +643,11 @@
730 643 foreach ( $link['data'] as $data => $value ) {
731 644 echo 'data-' . esc_attr( $data ) . '="' . esc_attr( $value ) . '" ';
732 645 }
733 646 }
734 -
735 647 if ( isset( $link['class'] ) ) {
736 648 echo 'class="' . esc_attr( $link['class'] ) . '" ';
737 649 }
738 -
739 650 if ( isset( $link['id'] ) ) {
740 651 echo 'id="' . esc_attr( $link['id'] ) . '" ';
741 652 }
742 653 ?>
@@ -745,24 +656,19 @@
745 656 <span class="frm_link_label"><?php echo esc_html( $link['label'] ); ?></span>
746 657 </a>
747 658 </div>
748 659 <?php
749 - }//end foreach
660 + }
750 661 }
751 662
752 663 /**
753 664 * @since 3.0
754 - *
755 - * @param int $id Entry ID.
756 - * @param array|object $entry Entry object.
757 - *
758 - * @return array
759 665 */
760 666 private static function get_action_links( $id, $entry ) {
761 667 $page = FrmAppHelper::get_param( 'frm_action' );
762 668 $actions = array();
763 669
764 - if ( $page !== 'show' ) {
670 + if ( $page != 'show' ) {
765 671 $actions['frm_view'] = array(
766 672 'url' => admin_url( 'admin.php?page=formidable-entries&frm_action=show&id=' . $id . '&form=' . $entry->form_id ),
767 673 'label' => __( 'View Entry', 'formidable' ),
768 674 'icon' => 'frm_icon_font frm_save_icon',
@@ -774,15 +680,14 @@
774 680 'url' => wp_nonce_url( admin_url( 'admin.php?page=formidable-entries&frm_action=destroy&id=' . $id . '&form=' . $entry->form_id ) ),
775 681 'label' => __( 'Delete Entry', 'formidable' ),
776 682 'icon' => 'frm_icon_font frm_delete_icon',
777 683 'data' => array(
778 - 'frmverify' => __( 'Permanently delete this entry?', 'formidable' ),
779 - 'frmverify-btn' => 'frm-button-red',
684 + 'frmverify' => __( 'Delete this form entry?', 'formidable' ),
780 685 ),
781 686 );
782 687 }
783 688
784 - if ( $page === 'show' ) {
689 + if ( $page == 'show' ) {
785 690 $actions['frm_print'] = array(
786 691 'url' => '#',
787 692 'label' => __( 'Print Entry', 'formidable' ),
788 693 'data' => array(
@@ -803,9 +708,9 @@
803 708 ),
804 709 'icon' => 'frm_icon_font frm_email_icon',
805 710 );
806 711
807 - if ( ! function_exists( 'frm_pdfs_autoloader' ) ) {
712 + if ( ! function_exists( 'frm_pdfs_autoloader' ) && FrmAppHelper::show_new_feature( 'pdfs' ) ) {
808 713 $actions['frm_download_pdf'] = array(
809 714 'url' => '#',
810 715 'label' => __( 'Download as PDF', 'formidable' ),
811 716 'class' => 'frm_noallow',
@@ -832,9 +737,8 @@
832 737 /**
833 738 * Gets data attributes for PDFs addon upgrade link.
834 739 *
835 740 * @param string $medium The source of the upgrade link used for analytics data.
836 - *
837 741 * @return array
838 742 */
839 743 private static function get_pdfs_upgrade_link_data( $medium = 'pdfs' ) {
840 744 $data = array(
@@ -844,9 +748,8 @@
844 748 'medium' => $medium,
845 749 );
846 750
847 751 $upgrading = FrmAddonsController::install_link( 'pdfs' );
848 -
849 752 if ( isset( $upgrading['url'] ) ) {
850 753 $data['oneclick'] = json_encode( $upgrading );
851 754 } else {
852 755 $data['requires'] = FrmAddonsController::get_addon_required_plan( 28136428 );
@@ -857,10 +760,9 @@
857 760
858 761 /**
859 762 * @since 5.0.15
860 763 *
861 - * @param int|string $entry_id
862 - *
764 + * @param string|int $entry_id
863 765 * @return void
864 766 */
865 767 public static function maybe_render_captcha_score( $entry_id ) {
866 768 $query = array(
@@ -867,9 +769,8 @@
867 769 'item_id' => (int) $entry_id,
868 770 'field_id' => 0,
869 771 );
870 772 $metas_without_a_field = (array) FrmEntryMeta::getAll( $query, ' ORDER BY it.created_at DESC', '', true );
871 -
872 773 foreach ( $metas_without_a_field as $meta ) {
873 774 if ( ! empty( $meta->meta_value['captcha_score'] ) ) {
874 775 echo '<div class="misc-pub-section">';
875 776 FrmAppHelper::icon_by_class( 'frm_icon_font frm_shield_check_icon', array( 'aria-hidden' => 'true' ) );
@@ -897,14 +798,12 @@
897 798 return $status;
898 799 }
899 800
900 801 if ( empty( $status ) ) {
901 - // If the status is empty, let's default to 0.
902 - return self::SUBMITTED_ENTRY_STATUS;
802 + return self::SUBMITTED_ENTRY_STATUS; // If the status is empty, let's default to 0.
903 803 }
904 804
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;
805 + return self::DRAFT_ENTRY_STATUS; // 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.
907 806 }
908 807
909 808 /**
910 809 * Return entry status label based on passed value.
@@ -957,34 +856,5 @@
957 856
958 857 return $existing_entry_statuses;
959 858 }
960 859
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 - }
990 860 }