| @@ -60,9 +60,9 @@ | ||
| 60 | 60 | |
| 61 | 61 | if ( ! $form || ! isset( $form->id ) ) { |
| 62 | 62 | $form = FrmForm::getOne( $field->form_id ); |
| 63 | 63 | } |
| 64 | - } | |
| 64 | + }//end foreach | |
| 65 | 65 | |
| 66 | 66 | FrmAppHelper::unserialize_or_decode( $form->options ); |
| 67 | 67 | if ( is_array( $form->options ) ) { |
| 68 | 68 | $values = array_merge( $values, $form->options ); |
| @@ -81,9 +81,9 @@ | ||
| 81 | 81 | * |
| 82 | 82 | * @param object $field |
| 83 | 83 | */ |
| 84 | 84 | private static function prepare_field_default_value( &$field ) { |
| 85 | - //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. | |
| 86 | 86 | $return_array = FrmField::is_field_with_multiple_values( $field ); |
| 87 | 87 | |
| 88 | 88 | /** |
| 89 | 89 | * Do any shortcodes in default value and allow customization of default value. |
| @@ -101,13 +101,13 @@ | ||
| 101 | 101 | * This function is used when the form is first loaded and on all page turns *for a new entry* |
| 102 | 102 | * |
| 103 | 103 | * @since 2.0.13 |
| 104 | 104 | * |
| 105 | - * @param object $field - this is passed by reference since it is an object | |
| 106 | - * @param boolean $reset | |
| 107 | - * @param array $args | |
| 105 | + * @param object $field - this is passed by reference since it is an object. | |
| 106 | + * @param bool $reset | |
| 107 | + * @param array $args | |
| 108 | 108 | * |
| 109 | - * @return string|array $new_value | |
| 109 | + * @return array|string $new_value | |
| 110 | 110 | */ |
| 111 | 111 | private static function get_field_value_for_new_entry( $field, $reset, $args ) { |
| 112 | 112 | $new_value = $field->default_value; |
| 113 | 113 | |
| @@ -127,11 +127,11 @@ | ||
| 127 | 127 | * |
| 128 | 128 | * @since 2.01.0 |
| 129 | 129 | * |
| 130 | 130 | * @param object $field |
| 131 | - * @param array $args | |
| 131 | + * @param array $args | |
| 132 | 132 | * |
| 133 | - * @return boolean $value_is_posted | |
| 133 | + * @return bool $value_is_posted | |
| 134 | 134 | */ |
| 135 | 135 | public static function value_is_posted( $field, $args ) { |
| 136 | 136 | $value_is_posted = false; |
| 137 | 137 | if ( $_POST ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing |
| @@ -212,10 +212,13 @@ | ||
| 212 | 212 | |
| 213 | 213 | if ( ! FrmAppHelper::pro_is_installed() ) { |
| 214 | 214 | return ''; |
| 215 | 215 | } |
| 216 | + if ( is_callable( 'FrmProEntriesHelper::prepare_child_display_value' ) ) { | |
| 217 | + return FrmProEntriesHelper::prepare_child_display_value( $entry, $field, $atts ); | |
| 218 | + } | |
| 216 | 219 | |
| 217 | - // This is an embeded form. | |
| 220 | + // This is an embedded form. | |
| 218 | 221 | if ( strpos( $atts['embedded_field_id'], 'form' ) === 0 ) { |
| 219 | 222 | // This is a repeating section. |
| 220 | 223 | $child_entries = FrmEntry::getAll( array( 'it.parent_item_id' => $entry->id ), '', '', true ); |
| 221 | 224 | } else { |
| @@ -248,12 +251,12 @@ | ||
| 248 | 251 | unset( $child_entry ); |
| 249 | 252 | } |
| 250 | 253 | |
| 251 | 254 | $sep = ', '; |
| 252 | - if ( strpos( implode( ' ', (array) $field_value ), '<img' ) !== false ) { | |
| 255 | + if ( strpos( implode( ' ', $field_value ), '<img' ) !== false ) { | |
| 253 | 256 | $sep = '<br/>'; |
| 254 | 257 | } |
| 255 | - $val = implode( $sep, (array) $field_value ); | |
| 258 | + $val = implode( $sep, $field_value ); | |
| 256 | 259 | |
| 257 | 260 | return FrmAppHelper::kses( $val, 'all' ); |
| 258 | 261 | } |
| 259 | 262 | |
| @@ -260,10 +263,10 @@ | ||
| 260 | 263 | /** |
| 261 | 264 | * Prepare the saved value for display |
| 262 | 265 | * |
| 263 | 266 | * @param array|string $value |
| 264 | - * @param object $field | |
| 265 | - * @param array $atts | |
| 267 | + * @param object $field | |
| 268 | + * @param array $atts | |
| 266 | 269 | * |
| 267 | 270 | * @return string |
| 268 | 271 | */ |
| 269 | 272 | public static function display_value( $value, $field, $atts = array() ) { |
| @@ -282,9 +285,9 @@ | ||
| 282 | 285 | ); |
| 283 | 286 | |
| 284 | 287 | $atts = wp_parse_args( $atts, $defaults ); |
| 285 | 288 | |
| 286 | - if ( FrmField::is_image( $field ) || $field->type == 'star' ) { | |
| 289 | + if ( FrmField::is_image( $field ) || $field->type === 'star' ) { | |
| 287 | 290 | $atts['truncate'] = false; |
| 288 | 291 | $atts['html'] = true; |
| 289 | 292 | } |
| 290 | 293 | |
| @@ -289,8 +292,12 @@ | ||
| 289 | 292 | } |
| 290 | 293 | |
| 291 | 294 | $atts = apply_filters( 'frm_display_value_atts', $atts, $field, $value ); |
| 292 | 295 | |
| 296 | + if ( is_string( $field->field_options ) ) { | |
| 297 | + $field->field_options = array(); | |
| 298 | + } | |
| 299 | + | |
| 293 | 300 | if ( ! isset( $field->field_options['post_field'] ) ) { |
| 294 | 301 | $field->field_options['post_field'] = ''; |
| 295 | 302 | } |
| 296 | 303 | |
| @@ -297,9 +304,9 @@ | ||
| 297 | 304 | if ( ! isset( $field->field_options['custom_field'] ) ) { |
| 298 | 305 | $field->field_options['custom_field'] = ''; |
| 299 | 306 | } |
| 300 | 307 | |
| 301 | - if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) { | |
| 308 | + if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] === 'tag' ) ) { | |
| 302 | 309 | $atts['pre_truncate'] = $atts['truncate']; |
| 303 | 310 | $atts['truncate'] = true; |
| 304 | 311 | $atts['exclude_cat'] = isset( $field->field_options['exclude_cat'] ) ? $field->field_options['exclude_cat'] : 0; |
| 305 | 312 | |
| @@ -320,9 +327,9 @@ | ||
| 320 | 327 | if ( $value == $unfiltered_value ) { |
| 321 | 328 | $value = FrmFieldsHelper::get_unfiltered_display_value( compact( 'value', 'field', 'atts' ) ); |
| 322 | 329 | } |
| 323 | 330 | |
| 324 | - if ( $atts['truncate'] && $atts['type'] != 'url' ) { | |
| 331 | + if ( $atts['truncate'] && $atts['type'] !== 'url' ) { | |
| 325 | 332 | $value = FrmAppHelper::truncate( $value, 50 ); |
| 326 | 333 | } |
| 327 | 334 | |
| 328 | 335 | if ( ! $atts['keepjs'] && ! is_array( $value ) ) { |
| @@ -333,9 +340,9 @@ | ||
| 333 | 340 | } |
| 334 | 341 | |
| 335 | 342 | public static function set_posted_value( $field, $value, $args ) { |
| 336 | 343 | // If validating a field with "other" opt, set back to prev value now. |
| 337 | - if ( isset( $args['other'] ) && $args['other'] ) { | |
| 344 | + if ( ! empty( $args['other'] ) ) { | |
| 338 | 345 | $value = $args['temp_value']; |
| 339 | 346 | } |
| 340 | 347 | if ( empty( $args['parent_field_id'] ) ) { |
| 341 | 348 | $_POST['item_meta'][ $field->id ] = $value; |
| @@ -401,11 +408,11 @@ | ||
| 401 | 408 | * Check if field has an "Other" option and if any other values are posted |
| 402 | 409 | * |
| 403 | 410 | * @since 2.0 |
| 404 | 411 | * |
| 405 | - * @param object $field | |
| 406 | - * @param string|array $value | |
| 407 | - * @param array $args | |
| 412 | + * @param object $field | |
| 413 | + * @param array|string $value | |
| 414 | + * @param array $args | |
| 408 | 415 | */ |
| 409 | 416 | public static function maybe_set_other_validation( $field, &$value, &$args ) { |
| 410 | 417 | $args['other'] = false; |
| 411 | 418 | if ( ! $value || ! FrmAppHelper::pro_is_installed() ) { |
| @@ -442,11 +449,11 @@ | ||
| 442 | 449 | * Sets radio or checkbox value equal to "other" value if it is set - FOR REPEATING SECTIONS |
| 443 | 450 | * |
| 444 | 451 | * @since 2.0 |
| 445 | 452 | * |
| 446 | - * @param object $field | |
| 447 | - * @param string|array $value | |
| 448 | - * @param array $args | |
| 453 | + * @param object $field | |
| 454 | + * @param array|string $value | |
| 455 | + * @param array $args | |
| 449 | 456 | */ |
| 450 | 457 | public static function set_other_repeating_vals( $field, &$value, &$args ) { |
| 451 | 458 | if ( ! $args['parent_field_id'] ) { |
| 452 | 459 | return; |
| @@ -474,12 +481,12 @@ | ||
| 474 | 481 | * Needs to accommodate for times when other opt is selected, but no other free text is entered |
| 475 | 482 | * |
| 476 | 483 | * @since 2.0 |
| 477 | 484 | * |
| 478 | - * @param string|array $value | |
| 479 | - * @param string|array $other_vals (usually of posted values) | |
| 480 | - * @param object $field | |
| 481 | - * @param array $args | |
| 485 | + * @param array|string $value | |
| 486 | + * @param array|string $other_vals (usually of posted values). | |
| 487 | + * @param object $field | |
| 488 | + * @param array $args | |
| 482 | 489 | */ |
| 483 | 490 | public static function set_other_validation_val( &$value, $other_vals, $field, &$args ) { |
| 484 | 491 | // Checkboxes and multi-select dropdowns. |
| 485 | 492 | if ( is_array( $value ) && $field->type === 'checkbox' ) { |
| @@ -521,10 +528,10 @@ | ||
| 521 | 528 | } |
| 522 | 529 | } |
| 523 | 530 | } elseif ( $field->options[ $other_key ] == $value ) { |
| 524 | 531 | $value = $other_vals; |
| 525 | - } | |
| 526 | - } | |
| 532 | + }//end if | |
| 533 | + }//end if | |
| 527 | 534 | } |
| 528 | 535 | |
| 529 | 536 | /** |
| 530 | 537 | * Add submitted values to a string for spam checking. |
| @@ -560,9 +567,9 @@ | ||
| 560 | 567 | * @return string |
| 561 | 568 | */ |
| 562 | 569 | public static function get_browser( $u_agent ) { |
| 563 | 570 | $bname = __( 'Unknown', 'formidable' ); |
| 564 | - $platform = __( 'Unknown', 'formidable' ); | |
| 571 | + $platform = $bname; | |
| 565 | 572 | $ub = ''; |
| 566 | 573 | |
| 567 | 574 | // Get the operating system |
| 568 | 575 | if ( preg_match( '/windows|win32/i', $u_agent ) ) { |
| @@ -582,9 +589,9 @@ | ||
| 582 | 589 | 'Netscape' => 'Netscape', |
| 583 | 590 | 'Firefox' => 'Mozilla Firefox', |
| 584 | 591 | ); |
| 585 | 592 | |
| 586 | - // Next get the name of the useragent yes seperately and for good reason | |
| 593 | + // Next get the name of the useragent yes separately and for good reason. | |
| 587 | 594 | if ( strpos( $u_agent, 'MSIE' ) !== false && strpos( $u_agent, 'Opera' ) === false ) { |
| 588 | 595 | $bname = 'Internet Explorer'; |
| 589 | 596 | $ub = 'MSIE'; |
| 590 | 597 | } else { |
| @@ -599,16 +606,17 @@ | ||
| 599 | 606 | |
| 600 | 607 | // finally get the correct version number |
| 601 | 608 | $known = array( 'Version', $ub, 'other' ); |
| 602 | 609 | $pattern = '#(?<browser>' . join( '|', $known ) . ')[/ ]+(?<version>[0-9.|a-zA-Z.]*)#'; |
| 603 | - preg_match_all( $pattern, $u_agent, $matches ); // get the matching numbers | |
| 610 | + // Get the matching numbers. | |
| 611 | + preg_match_all( $pattern, $u_agent, $matches ); | |
| 604 | 612 | |
| 605 | 613 | // see how many we have |
| 606 | 614 | $i = count( $matches['browser'] ); |
| 607 | 615 | |
| 608 | 616 | if ( $i > 1 ) { |
| 609 | - //we will have two since we are not using 'other' argument yet | |
| 610 | - //see if version is before or after the name | |
| 617 | + // We will have two since we are not using 'other' argument yet | |
| 618 | + // see if version is before or after the name. | |
| 611 | 619 | if ( strripos( $u_agent, 'Version' ) < strripos( $u_agent, $ub ) ) { |
| 612 | 620 | $version = $matches['version'][0]; |
| 613 | 621 | } else { |
| 614 | 622 | $version = $matches['version'][1]; |
| @@ -656,9 +664,9 @@ | ||
| 656 | 664 | <span class="frm_link_label"><?php echo esc_html( $link['label'] ); ?></span> |
| 657 | 665 | </a> |
| 658 | 666 | </div> |
| 659 | 667 | <?php |
| 660 | - } | |
| 668 | + }//end foreach | |
| 661 | 669 | } |
| 662 | 670 | |
| 663 | 671 | /** |
| 664 | 672 | * @since 3.0 |
| @@ -666,9 +674,9 @@ | ||
| 666 | 674 | private static function get_action_links( $id, $entry ) { |
| 667 | 675 | $page = FrmAppHelper::get_param( 'frm_action' ); |
| 668 | 676 | $actions = array(); |
| 669 | 677 | |
| 670 | - if ( $page != 'show' ) { | |
| 678 | + if ( $page !== 'show' ) { | |
| 671 | 679 | $actions['frm_view'] = array( |
| 672 | 680 | 'url' => admin_url( 'admin.php?page=formidable-entries&frm_action=show&id=' . $id . '&form=' . $entry->form_id ), |
| 673 | 681 | 'label' => __( 'View Entry', 'formidable' ), |
| 674 | 682 | 'icon' => 'frm_icon_font frm_save_icon', |
| @@ -680,14 +688,15 @@ | ||
| 680 | 688 | 'url' => wp_nonce_url( admin_url( 'admin.php?page=formidable-entries&frm_action=destroy&id=' . $id . '&form=' . $entry->form_id ) ), |
| 681 | 689 | 'label' => __( 'Delete Entry', 'formidable' ), |
| 682 | 690 | 'icon' => 'frm_icon_font frm_delete_icon', |
| 683 | 691 | 'data' => array( |
| 684 | - 'frmverify' => __( 'Delete this form entry?', 'formidable' ), | |
| 692 | + 'frmverify' => __( 'Permanently delete this entry?', 'formidable' ), | |
| 693 | + 'frmverify-btn' => 'frm-button-red', | |
| 685 | 694 | ), |
| 686 | 695 | ); |
| 687 | 696 | } |
| 688 | 697 | |
| 689 | - if ( $page == 'show' ) { | |
| 698 | + if ( $page === 'show' ) { | |
| 690 | 699 | $actions['frm_print'] = array( |
| 691 | 700 | 'url' => '#', |
| 692 | 701 | 'label' => __( 'Print Entry', 'formidable' ), |
| 693 | 702 | 'data' => array( |
| @@ -760,9 +769,9 @@ | ||
| 760 | 769 | |
| 761 | 770 | /** |
| 762 | 771 | * @since 5.0.15 |
| 763 | 772 | * |
| 764 | - * @param string|int $entry_id | |
| 773 | + * @param int|string $entry_id | |
| 765 | 774 | * @return void |
| 766 | 775 | */ |
| 767 | 776 | public static function maybe_render_captcha_score( $entry_id ) { |
| 768 | 777 | $query = array( |
| @@ -798,12 +807,14 @@ | ||
| 798 | 807 | return $status; |
| 799 | 808 | } |
| 800 | 809 | |
| 801 | 810 | if ( empty( $status ) ) { |
| 802 | - return self::SUBMITTED_ENTRY_STATUS; // If the status is empty, let's default to 0. | |
| 811 | + // If the status is empty, let's default to 0. | |
| 812 | + return self::SUBMITTED_ENTRY_STATUS; | |
| 803 | 813 | } |
| 804 | 814 | |
| 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. | |
| 815 | + // 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. | |
| 816 | + return self::DRAFT_ENTRY_STATUS; | |
| 806 | 817 | } |
| 807 | 818 | |
| 808 | 819 | /** |
| 809 | 820 | * Return entry status label based on passed value. |
| @@ -823,12 +834,13 @@ | ||
| 823 | 834 | /** |
| 824 | 835 | * Get all entry statuses. |
| 825 | 836 | * |
| 826 | 837 | * @since 6.5 |
| 838 | + * @since 6.6 function went from private to public. | |
| 827 | 839 | * |
| 828 | 840 | * @return array<string> |
| 829 | 841 | */ |
| 830 | - private static function get_entry_statuses() { | |
| 842 | + public static function get_entry_statuses() { | |
| 831 | 843 | |
| 832 | 844 | $default_entry_statuses = array( |
| 833 | 845 | self::SUBMITTED_ENTRY_STATUS => __( 'Submitted', 'formidable' ), |
| 834 | 846 | self::DRAFT_ENTRY_STATUS => __( 'Draft', 'formidable' ), |
| @@ -846,9 +858,9 @@ | ||
| 846 | 858 | */ |
| 847 | 859 | $extended_entry_status = apply_filters( 'frm_entry_statuses', array() ); |
| 848 | 860 | |
| 849 | 861 | if ( ! is_array( $extended_entry_status ) ) { |
| 850 | - _doing_it_wrong( __METHOD__, esc_html__( 'Entry status must be return in array format.', 'formidable' ), 'x.x' ); | |
| 862 | + _doing_it_wrong( __METHOD__, esc_html__( 'Entry status must be return in array format.', 'formidable' ), '6.5' ); | |
| 851 | 863 | $extended_entry_status = array(); |
| 852 | 864 | } |
| 853 | 865 | |
| 854 | 866 | $existing_entry_statuses = array_replace( $default_entry_statuses, $extended_entry_status ); |
| @@ -855,5 +867,32 @@ | ||
| 855 | 867 | |
| 856 | 868 | return $existing_entry_statuses; |
| 857 | 869 | } |
| 858 | 870 | |
| 871 | + /** | |
| 872 | + * @since 6.17 | |
| 873 | + * | |
| 874 | + * @return int | |
| 875 | + */ | |
| 876 | + public static function get_visible_unread_inbox_count() { | |
| 877 | + $menu_name = FrmAppHelper::get_menu_name(); | |
| 878 | + if ( ! in_array( $menu_name, array( 'Formidable', 'Forms' ), true ) ) { | |
| 879 | + return 0; | |
| 880 | + } | |
| 881 | + | |
| 882 | + $inbox = new FrmInbox(); | |
| 883 | + $inbox_count = count( $inbox->unread() ); | |
| 884 | + | |
| 885 | + if ( ! $inbox_count ) { | |
| 886 | + return 0; | |
| 887 | + } | |
| 888 | + | |
| 889 | + if ( is_callable( 'FrmProSettingsController::inbox_badge' ) ) { | |
| 890 | + $inbox_count = FrmProSettingsController::inbox_badge( $inbox_count ); | |
| 891 | + if ( ! $inbox_count ) { | |
| 892 | + return 0; | |
| 893 | + } | |
| 894 | + } | |
| 895 | + | |
| 896 | + return $inbox_count; | |
| 897 | + } | |
| 859 | 898 | } |