| @@ -13,14 +13,9 @@ | ||
| 13 | 13 | |
| 14 | 14 | $values = self::get_default_field( $type ); |
| 15 | 15 | |
| 16 | 16 | global $wpdb; |
| 17 | - $field_count = FrmDb::get_var( | |
| 18 | - 'frm_fields', | |
| 19 | - array( 'form_id' => $form_id ), | |
| 20 | - 'field_order', | |
| 21 | - array( 'order_by' => 'field_order DESC' ) | |
| 22 | - ); | |
| 17 | + $field_count = FrmDb::get_var( 'frm_fields', array( 'form_id' => $form_id ), 'field_order', array( 'order_by' => 'field_order DESC' ) ); | |
| 23 | 18 | |
| 24 | 19 | $values['field_key'] = FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_fields', 'field_key' ); |
| 25 | 20 | $values['form_id'] = $form_id; |
| 26 | 21 | $values['field_order'] = $field_count + 1; |
| @@ -26,10 +21,10 @@ | ||
| 26 | 21 | $values['field_order'] = $field_count + 1; |
| 27 | 22 | |
| 28 | 23 | $values['field_options']['custom_html'] = self::get_default_html( $type ); |
| 29 | 24 | |
| 30 | - if ( ! empty( $setting ) ) { | |
| 31 | - if ( in_array( $type, array( 'data', 'lookup' ), true ) ) { | |
| 25 | + if ( isset( $setting ) && ! empty( $setting ) ) { | |
| 26 | + if ( in_array( $type, array( 'data', 'lookup' ) ) ) { | |
| 32 | 27 | $values['field_options']['data_type'] = $setting; |
| 33 | 28 | } else { |
| 34 | 29 | $values['field_options'][ $setting ] = 1; |
| 35 | 30 | } |
| @@ -128,9 +123,9 @@ | ||
| 128 | 123 | * @param object $field |
| 129 | 124 | * @param array $values |
| 130 | 125 | */ |
| 131 | 126 | private static function fill_default_field_opts( $field, array &$values ) { |
| 132 | - $check_post = FrmAppHelper::is_admin_page() && $_POST && isset( $_POST['field_options'] ); // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 127 | + $check_post = FrmAppHelper::is_admin_page() && $_POST && isset( $_POST['field_options'] ); | |
| 133 | 128 | |
| 134 | 129 | $defaults = self::get_default_field_options_from_field( $field, $values ); |
| 135 | 130 | if ( ! $check_post ) { |
| 136 | 131 | $defaults['required_indicator'] = ''; |
| @@ -163,9 +158,9 @@ | ||
| 163 | 158 | if ( '' == $field_array['blank'] && '1' === $field_array['required'] ) { |
| 164 | 159 | $field_array['blank'] = $frm_settings->blank_msg; |
| 165 | 160 | } |
| 166 | 161 | |
| 167 | - if ( '' === $field_array['invalid'] ) { | |
| 162 | + if ( '' == $field_array['invalid'] ) { | |
| 168 | 163 | if ( 'captcha' === $field->type ) { |
| 169 | 164 | $field_array['invalid'] = $frm_settings->re_msg; |
| 170 | 165 | } else { |
| 171 | 166 | /* translators: %s: Field name */ |
| @@ -184,20 +179,22 @@ | ||
| 184 | 179 | * @param string $setting |
| 185 | 180 | * @param mixed $value |
| 186 | 181 | */ |
| 187 | 182 | private static function get_posted_field_setting( $setting, &$value ) { |
| 188 | - if ( ! isset( $_POST['field_options'][ $setting ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 183 | + if ( ! isset( $_POST['field_options'][ $setting ] ) ) { | |
| 189 | 184 | return; |
| 190 | 185 | } |
| 191 | 186 | |
| 192 | 187 | if ( strpos( $setting, 'html' ) !== false ) { |
| 193 | 188 | // Strip slashes from HTML but not regex or script tags. |
| 194 | - $value = wp_unslash( $_POST['field_options'][ $setting ] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing | |
| 189 | + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 190 | + $value = wp_unslash( $_POST['field_options'][ $setting ] ); | |
| 195 | 191 | } elseif ( strpos( $setting, 'format_' ) === 0 ) { |
| 196 | 192 | // TODO: Remove stripslashes on output, and use on input only. |
| 197 | - $value = sanitize_text_field( $_POST['field_options'][ $setting ] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.NonceVerification.Missing | |
| 193 | + $value = sanitize_text_field( $_POST['field_options'][ $setting ] ); // WPCS: sanitization ok. | |
| 198 | 194 | } else { |
| 199 | - $value = wp_unslash( $_POST['field_options'][ $setting ] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing | |
| 195 | + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 196 | + $value = wp_unslash( $_POST['field_options'][ $setting ] ); | |
| 200 | 197 | FrmAppHelper::sanitize_value( 'wp_kses_post', $value ); |
| 201 | 198 | } |
| 202 | 199 | } |
| 203 | 200 | |
| @@ -496,14 +493,9 @@ | ||
| 496 | 493 | return FrmFieldsController::check_label( $opt ); |
| 497 | 494 | } |
| 498 | 495 | |
| 499 | 496 | /** |
| 500 | - * Shows the inline modal. | |
| 501 | - * | |
| 502 | 497 | * @since 4.0 |
| 503 | - * @since 6.4.1 Added `inside_class` in the arguments. | |
| 504 | - * | |
| 505 | - * @param array $args The arguments. | |
| 506 | 498 | */ |
| 507 | 499 | public static function inline_modal( $args ) { |
| 508 | 500 | $defaults = array( |
| 509 | 501 | 'id' => '', |
| @@ -511,9 +503,8 @@ | ||
| 511 | 503 | 'show' => 0, |
| 512 | 504 | 'callback' => array(), |
| 513 | 505 | 'args' => array(), |
| 514 | 506 | 'title' => '', |
| 515 | - 'inside_class' => 'inside', | |
| 516 | 507 | ); |
| 517 | 508 | $args = array_merge( $defaults, $args ); |
| 518 | 509 | |
| 519 | 510 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/inline-modal.php' ); |
| @@ -579,37 +570,27 @@ | ||
| 579 | 570 | return self::array_value_condition( $observed_value, $cond, $hide_opt ); |
| 580 | 571 | } |
| 581 | 572 | |
| 582 | 573 | $m = false; |
| 583 | - if ( $cond === '==' ) { | |
| 574 | + if ( $cond == '==' ) { | |
| 584 | 575 | $m = $observed_value == $hide_opt; |
| 585 | - } elseif ( $cond === '!=' ) { | |
| 576 | + } elseif ( $cond == '!=' ) { | |
| 586 | 577 | $m = $observed_value != $hide_opt; |
| 587 | - } elseif ( $cond === '>' ) { | |
| 578 | + } elseif ( $cond == '>' ) { | |
| 588 | 579 | $m = $observed_value > $hide_opt; |
| 589 | - } elseif ( $cond === '>=' ) { | |
| 580 | + } elseif ( $cond == '>=' ) { | |
| 590 | 581 | $m = $observed_value >= $hide_opt; |
| 591 | - } elseif ( $cond === '<' ) { | |
| 582 | + } elseif ( $cond == '<' ) { | |
| 592 | 583 | $m = $observed_value < $hide_opt; |
| 593 | - } elseif ( $cond === '<=' ) { | |
| 584 | + } elseif ( $cond == '<=' ) { | |
| 594 | 585 | $m = $observed_value <= $hide_opt; |
| 595 | - } elseif ( $cond === 'LIKE' || $cond === 'not LIKE' ) { | |
| 586 | + } elseif ( $cond == 'LIKE' || $cond == 'not LIKE' ) { | |
| 596 | 587 | $m = stripos( $observed_value, $hide_opt ); |
| 597 | - if ( $cond === 'not LIKE' ) { | |
| 588 | + if ( $cond == 'not LIKE' ) { | |
| 598 | 589 | $m = ( $m === false ) ? true : false; |
| 599 | 590 | } else { |
| 600 | 591 | $m = ( $m === false ) ? false : true; |
| 601 | 592 | } |
| 602 | - } elseif ( $cond === '%LIKE' ) { | |
| 603 | - // ends with | |
| 604 | - $length = strlen( $hide_opt ); | |
| 605 | - $substr = substr( $observed_value, strlen( $observed_value ) - $length ); | |
| 606 | - $m = 0 === strcasecmp( $substr, $hide_opt ); | |
| 607 | - } elseif ( 'LIKE%' === $cond ) { | |
| 608 | - // starts with | |
| 609 | - $length = strlen( $hide_opt ); | |
| 610 | - $substr = substr( $observed_value, 0, $length ); | |
| 611 | - $m = 0 === strcasecmp( $substr, $hide_opt ); | |
| 612 | 593 | } |
| 613 | 594 | |
| 614 | 595 | return $m; |
| 615 | 596 | } |
| @@ -631,9 +612,9 @@ | ||
| 631 | 612 | } |
| 632 | 613 | |
| 633 | 614 | public static function array_value_condition( $observed_value, $cond, $hide_opt ) { |
| 634 | 615 | $m = false; |
| 635 | - if ( $cond === '==' ) { | |
| 616 | + if ( $cond == '==' ) { | |
| 636 | 617 | if ( is_array( $hide_opt ) ) { |
| 637 | 618 | $m = array_intersect( $hide_opt, $observed_value ); |
| 638 | 619 | $m = empty( $m ) ? false : true; |
| 639 | 620 | } else { |
| @@ -638,17 +619,17 @@ | ||
| 638 | 619 | $m = empty( $m ) ? false : true; |
| 639 | 620 | } else { |
| 640 | 621 | $m = in_array( $hide_opt, $observed_value ); |
| 641 | 622 | } |
| 642 | - } elseif ( $cond === '!=' ) { | |
| 623 | + } elseif ( $cond == '!=' ) { | |
| 643 | 624 | $m = ! in_array( $hide_opt, $observed_value ); |
| 644 | - } elseif ( $cond === '>' ) { | |
| 625 | + } elseif ( $cond == '>' ) { | |
| 645 | 626 | $min = min( $observed_value ); |
| 646 | 627 | $m = $min > $hide_opt; |
| 647 | - } elseif ( $cond === '<' ) { | |
| 628 | + } elseif ( $cond == '<' ) { | |
| 648 | 629 | $max = max( $observed_value ); |
| 649 | 630 | $m = $max < $hide_opt; |
| 650 | - } elseif ( $cond === 'LIKE' || $cond === 'not LIKE' ) { | |
| 631 | + } elseif ( $cond == 'LIKE' || $cond == 'not LIKE' ) { | |
| 651 | 632 | foreach ( $observed_value as $ob ) { |
| 652 | 633 | $m = strpos( $ob, $hide_opt ); |
| 653 | 634 | if ( $m !== false ) { |
| 654 | 635 | $m = true; |
| @@ -655,27 +636,11 @@ | ||
| 655 | 636 | break; |
| 656 | 637 | } |
| 657 | 638 | } |
| 658 | 639 | |
| 659 | - if ( $cond === 'not LIKE' ) { | |
| 640 | + if ( $cond == 'not LIKE' ) { | |
| 660 | 641 | $m = ( $m === false ) ? true : false; |
| 661 | 642 | } |
| 662 | - } elseif ( $cond === '%LIKE' ) { | |
| 663 | - // ends with | |
| 664 | - foreach ( $observed_value as $ob ) { | |
| 665 | - if ( $hide_opt === substr( $ob, strlen( $ob ) - strlen( $hide_opt ) ) ) { | |
| 666 | - $m = true; | |
| 667 | - break; | |
| 668 | - } | |
| 669 | - } | |
| 670 | - } elseif ( $cond === 'LIKE%' ) { | |
| 671 | - // starts with | |
| 672 | - foreach ( $observed_value as $ob ) { | |
| 673 | - if ( $hide_opt === substr( $ob, 0, strlen( $hide_opt ) ) ) { | |
| 674 | - $m = true; | |
| 675 | - break; | |
| 676 | - } | |
| 677 | - } | |
| 678 | 643 | } |
| 679 | 644 | |
| 680 | 645 | return $m; |
| 681 | 646 | } |
| @@ -756,9 +721,8 @@ | ||
| 756 | 721 | $atts['tag'] = $tag; |
| 757 | 722 | $replace_with = self::get_value_for_shortcode( $atts ); |
| 758 | 723 | |
| 759 | 724 | if ( $replace_with !== null ) { |
| 760 | - $replace_with = self::trigger_shortcode_atts( $replace_with, $atts ); | |
| 761 | 725 | self::sanitize_embedded_shortcodes( compact( 'entry' ), $replace_with ); |
| 762 | 726 | $content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content ); |
| 763 | 727 | } |
| 764 | 728 | |
| @@ -768,56 +732,8 @@ | ||
| 768 | 732 | return $content; |
| 769 | 733 | } |
| 770 | 734 | |
| 771 | 735 | /** |
| 772 | - * @param string $replace_with | |
| 773 | - * @param array $atts | |
| 774 | - * @return string | |
| 775 | - */ | |
| 776 | - private static function trigger_shortcode_atts( $replace_with, $atts ) { | |
| 777 | - $supported_atts = array( 'remove_accents', 'sanitize', 'sanitize_url' ); | |
| 778 | - $included_atts = array_intersect( $supported_atts, array_keys( $atts ) ); | |
| 779 | - foreach ( $included_atts as $included_att ) { | |
| 780 | - if ( '0' === $atts[ $included_att ] ) { | |
| 781 | - // Skip any option that uses 0 so sanitize_url=0 does not encode. | |
| 782 | - continue; | |
| 783 | - } | |
| 784 | - $function = 'atts_' . $included_att; | |
| 785 | - $replace_with = self::$function( $replace_with, $atts ); | |
| 786 | - } | |
| 787 | - return $replace_with; | |
| 788 | - } | |
| 789 | - | |
| 790 | - /** | |
| 791 | - * Converts all accent characters to ASCII characters. | |
| 792 | - * | |
| 793 | - * @since 6.3.1 | |
| 794 | - * | |
| 795 | - * @param string $replace_with The text to remove accents from. | |
| 796 | - * | |
| 797 | - * @return string | |
| 798 | - */ | |
| 799 | - public static function atts_remove_accents( $replace_with ) { | |
| 800 | - return remove_accents( $replace_with ); | |
| 801 | - } | |
| 802 | - | |
| 803 | - /** | |
| 804 | - * @param string $replace_with | |
| 805 | - * @return string | |
| 806 | - */ | |
| 807 | - private static function atts_sanitize( $replace_with ) { | |
| 808 | - return sanitize_title_with_dashes( $replace_with ); | |
| 809 | - } | |
| 810 | - | |
| 811 | - /** | |
| 812 | - * @param string $replace_with | |
| 813 | - * @return string | |
| 814 | - */ | |
| 815 | - private static function atts_sanitize_url( $replace_with ) { | |
| 816 | - return urlencode( $replace_with ); | |
| 817 | - } | |
| 818 | - | |
| 819 | - /** | |
| 820 | 736 | * Prevent shortcodes in fields from being processed |
| 821 | 737 | * |
| 822 | 738 | * @since 3.01.02 |
| 823 | 739 | * |
| @@ -853,15 +769,15 @@ | ||
| 853 | 769 | if ( isset( $shortcode_values[ $atts['tag'] ] ) ) { |
| 854 | 770 | $replace_with = $shortcode_values[ $atts['tag'] ]; |
| 855 | 771 | } elseif ( in_array( $atts['tag'], $dynamic_default ) ) { |
| 856 | 772 | $replace_with = self::dynamic_default_values( $atts['tag'], $atts ); |
| 857 | - } elseif ( $clean_tag === 'user_agent' ) { | |
| 773 | + } elseif ( $clean_tag == 'user_agent' ) { | |
| 858 | 774 | $description = $atts['entry']->description; |
| 859 | 775 | $replace_with = FrmEntriesHelper::get_browser( $description['browser'] ); |
| 860 | - } elseif ( $clean_tag === 'created_at' || $clean_tag === 'updated_at' ) { | |
| 776 | + } elseif ( $clean_tag == 'created_at' || $clean_tag == 'updated_at' ) { | |
| 861 | 777 | $atts['tag'] = $clean_tag; |
| 862 | 778 | $replace_with = self::get_entry_timestamp( $atts ); |
| 863 | - } elseif ( $clean_tag === 'created_by' || $clean_tag === 'updated_by' ) { | |
| 779 | + } elseif ( $clean_tag == 'created_by' || $clean_tag == 'updated_by' ) { | |
| 864 | 780 | $replace_with = self::get_display_value( $atts['entry']->{$clean_tag}, (object) array( 'type' => 'user_id' ), $atts ); |
| 865 | 781 | } else { |
| 866 | 782 | $replace_with = self::get_field_shortcode_value( $atts ); |
| 867 | 783 | } |
| @@ -899,11 +815,11 @@ | ||
| 899 | 815 | if ( empty( $field ) ) { |
| 900 | 816 | return null; |
| 901 | 817 | } |
| 902 | 818 | |
| 903 | - if ( isset( $atts['show'] ) && $atts['show'] === 'field_label' ) { | |
| 819 | + if ( isset( $atts['show'] ) && $atts['show'] == 'field_label' ) { | |
| 904 | 820 | $replace_with = $field->name; |
| 905 | - } elseif ( isset( $atts['show'] ) && $atts['show'] === 'description' ) { | |
| 821 | + } elseif ( isset( $atts['show'] ) && $atts['show'] == 'description' ) { | |
| 906 | 822 | $replace_with = $field->description; |
| 907 | 823 | } else { |
| 908 | 824 | $replace_with = FrmEntryMeta::get_meta_value( $atts['entry'], $field->id ); |
| 909 | 825 | $string_value = $replace_with; |
| @@ -1065,9 +981,9 @@ | ||
| 1065 | 981 | } elseif ( isset( $field_selection[ $type ] ) ) { |
| 1066 | 982 | $field_types[ $type ] = $field_selection[ $type ]; |
| 1067 | 983 | } |
| 1068 | 984 | |
| 1069 | - $field_types = apply_filters( 'frm_switch_field_types', $field_types, compact( 'type', 'field_selection' ) ); | |
| 985 | + $field_types = apply_filters( 'frm_switch_field_types', $field_types, compact( 'type' ) ); | |
| 1070 | 986 | |
| 1071 | 987 | return $field_types; |
| 1072 | 988 | } |
| 1073 | 989 | |
| @@ -1143,26 +1059,24 @@ | ||
| 1143 | 1059 | } |
| 1144 | 1060 | |
| 1145 | 1061 | // Check posted vals before checking saved values |
| 1146 | 1062 | // For fields inside repeating sections - note, don't check if $pointer is true because it will often be zero |
| 1147 | - if ( $parent && isset( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 1063 | + if ( $parent && isset( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] ) ) { | |
| 1148 | 1064 | if ( FrmField::is_field_with_multiple_values( $field ) ) { |
| 1149 | - // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 1150 | 1065 | $other_val = isset( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ][ $opt_key ] ) ? sanitize_text_field( wp_unslash( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ][ $opt_key ] ) ) : ''; |
| 1151 | 1066 | } else { |
| 1152 | - $other_val = sanitize_text_field( wp_unslash( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 1067 | + $other_val = sanitize_text_field( wp_unslash( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] ) ); | |
| 1153 | 1068 | } |
| 1154 | 1069 | |
| 1155 | 1070 | return $other_val; |
| 1156 | 1071 | |
| 1157 | - } elseif ( isset( $field['id'] ) && isset( $_POST['item_meta']['other'][ $field['id'] ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 1072 | + } elseif ( isset( $field['id'] ) && isset( $_POST['item_meta']['other'][ $field['id'] ] ) ) { | |
| 1158 | 1073 | // For normal fields |
| 1159 | 1074 | |
| 1160 | 1075 | if ( FrmField::is_field_with_multiple_values( $field ) ) { |
| 1161 | - // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 1162 | 1076 | $other_val = isset( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) ? sanitize_text_field( wp_unslash( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) ) : ''; |
| 1163 | 1077 | } else { |
| 1164 | - $other_val = sanitize_text_field( wp_unslash( $_POST['item_meta']['other'][ $field['id'] ] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 1078 | + $other_val = sanitize_text_field( wp_unslash( $_POST['item_meta']['other'][ $field['id'] ] ) ); | |
| 1165 | 1079 | } |
| 1166 | 1080 | |
| 1167 | 1081 | return $other_val; |
| 1168 | 1082 | } |
| @@ -1167,9 +1081,9 @@ | ||
| 1167 | 1081 | return $other_val; |
| 1168 | 1082 | } |
| 1169 | 1083 | |
| 1170 | 1084 | // For checkboxes |
| 1171 | - if ( $field['type'] === 'checkbox' && is_array( $field['value'] ) ) { | |
| 1085 | + if ( $field['type'] == 'checkbox' && is_array( $field['value'] ) ) { | |
| 1172 | 1086 | // Check if there is an "other" val in saved value and make sure the |
| 1173 | 1087 | // "other" val is not equal to the Other checkbox option |
| 1174 | 1088 | if ( isset( $field['value'][ $opt_key ] ) && $field['options'][ $opt_key ] != $field['value'][ $opt_key ] ) { |
| 1175 | 1089 | $other_val = $field['value'][ $opt_key ]; |
| @@ -1363,24 +1277,16 @@ | ||
| 1363 | 1277 | $replace[] = '[if ' . $old . ' '; |
| 1364 | 1278 | $replace_with[] = '[if ' . $new . ' '; |
| 1365 | 1279 | $replace[] = '[/if ' . $old . ']'; |
| 1366 | 1280 | $replace_with[] = '[/if ' . $new . ']'; |
| 1367 | - $replace[] = '[\/if ' . $old . ']'; | |
| 1368 | - $replace_with[] = '[\/if ' . $new . ']'; | |
| 1369 | 1281 | $replace[] = '[foreach ' . $old . ']'; |
| 1370 | 1282 | $replace_with[] = '[foreach ' . $new . ']'; |
| 1371 | 1283 | $replace[] = '[/foreach ' . $old . ']'; |
| 1372 | 1284 | $replace_with[] = '[/foreach ' . $new . ']'; |
| 1373 | - $replace[] = '[\/foreach ' . $old . ']'; | |
| 1374 | - $replace_with[] = '[\/foreach ' . $new . ']'; | |
| 1375 | 1285 | $replace[] = '[' . $old . ']'; |
| 1376 | 1286 | $replace_with[] = '[' . $new . ']'; |
| 1377 | 1287 | $replace[] = '[' . $old . ' '; |
| 1378 | 1288 | $replace_with[] = '[' . $new . ' '; |
| 1379 | - $replace[] = 'field_id="' . $old . '"'; | |
| 1380 | - $replace_with[] = 'field_id="' . $new . '"'; | |
| 1381 | - $replace[] = 'field_id=\"' . $old . '\"'; | |
| 1382 | - $replace_with[] = 'field_id=\"' . $new . '\"'; | |
| 1383 | 1289 | unset( $old, $new ); |
| 1384 | 1290 | } |
| 1385 | 1291 | if ( is_array( $val ) ) { |
| 1386 | 1292 | foreach ( $val as $k => $v ) { |
| @@ -1400,9 +1306,9 @@ | ||
| 1400 | 1306 | * @since 4.0 |
| 1401 | 1307 | */ |
| 1402 | 1308 | public static function bulk_options_overlay() { |
| 1403 | 1309 | $prepop = array(); |
| 1404 | - self::get_bulk_prefilled_opts( $prepop, true ); | |
| 1310 | + self::get_bulk_prefilled_opts( $prepop ); | |
| 1405 | 1311 | |
| 1406 | 1312 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/bulk-options-overlay.php' ); |
| 1407 | 1313 | } |
| 1408 | 1314 | |
| @@ -1722,47 +1628,22 @@ | ||
| 1722 | 1628 | sort( $countries, SORT_LOCALE_STRING ); |
| 1723 | 1629 | return apply_filters( 'frm_countries', $countries ); |
| 1724 | 1630 | } |
| 1725 | 1631 | |
| 1726 | - /** | |
| 1727 | - * Gets bulk prefilled options. | |
| 1728 | - * | |
| 1729 | - * @since 5.0.04 Add `$include_class` param. | |
| 1730 | - * | |
| 1731 | - * @param array $prepop Bulk options. | |
| 1732 | - * @param array|false $include_class Include the class in the bulk options. | |
| 1733 | - */ | |
| 1734 | - public static function get_bulk_prefilled_opts( array &$prepop, $include_class = false ) { | |
| 1735 | - // Countries. | |
| 1736 | - $countries = self::get_countries(); | |
| 1737 | - if ( $include_class ) { | |
| 1738 | - $countries['class'] = 'frm-countries-opts'; | |
| 1739 | - } | |
| 1632 | + public static function get_bulk_prefilled_opts( array &$prepop ) { | |
| 1633 | + $prepop[ __( 'Countries', 'formidable' ) ] = self::get_countries(); | |
| 1740 | 1634 | |
| 1741 | - $prepop[ __( 'Countries', 'formidable' ) ] = $countries; | |
| 1742 | - | |
| 1743 | - // State abv. | |
| 1744 | 1635 | $states = self::get_us_states(); |
| 1745 | 1636 | $state_abv = array_keys( $states ); |
| 1746 | 1637 | sort( $state_abv ); |
| 1747 | - if ( $include_class ) { | |
| 1748 | - $state_abv['class'] = 'frm-state-abv-opts'; | |
| 1749 | - } | |
| 1750 | - | |
| 1751 | 1638 | $prepop[ __( 'U.S. State Abbreviations', 'formidable' ) ] = $state_abv; |
| 1752 | 1639 | |
| 1753 | - // States. | |
| 1754 | 1640 | $states = array_values( $states ); |
| 1755 | 1641 | sort( $states ); |
| 1756 | - if ( $include_class ) { | |
| 1757 | - $states['class'] = 'frm-states-opts'; | |
| 1758 | - } | |
| 1759 | - | |
| 1760 | 1642 | $prepop[ __( 'U.S. States', 'formidable' ) ] = $states; |
| 1761 | 1643 | unset( $state_abv, $states ); |
| 1762 | 1644 | |
| 1763 | - // Age. | |
| 1764 | - $ages = array( | |
| 1645 | + $prepop[ __( 'Age', 'formidable' ) ] = array( | |
| 1765 | 1646 | __( 'Under 18', 'formidable' ), |
| 1766 | 1647 | __( '18-24', 'formidable' ), |
| 1767 | 1648 | __( '25-34', 'formidable' ), |
| 1768 | 1649 | __( '35-44', 'formidable' ), |
| @@ -1770,74 +1651,36 @@ | ||
| 1770 | 1651 | __( '55-64', 'formidable' ), |
| 1771 | 1652 | __( '65 or Above', 'formidable' ), |
| 1772 | 1653 | __( 'Prefer Not to Answer', 'formidable' ), |
| 1773 | 1654 | ); |
| 1774 | - if ( $include_class ) { | |
| 1775 | - $ages['class'] = 'frm-age-opts'; | |
| 1776 | - } | |
| 1777 | 1655 | |
| 1778 | - $prepop[ __( 'Age', 'formidable' ) ] = $ages; | |
| 1779 | - | |
| 1780 | - // Satisfaction. | |
| 1781 | - $satisfaction = array( | |
| 1656 | + $prepop[ __( 'Satisfaction', 'formidable' ) ] = array( | |
| 1657 | + __( 'Very Satisfied', 'formidable' ), | |
| 1658 | + __( 'Satisfied', 'formidable' ), | |
| 1659 | + __( 'Neutral', 'formidable' ), | |
| 1660 | + __( 'Unsatisfied', 'formidable' ), | |
| 1782 | 1661 | __( 'Very Unsatisfied', 'formidable' ), |
| 1783 | - __( 'Unsatisfied', 'formidable' ), | |
| 1784 | - __( 'Neutral', 'formidable' ), | |
| 1785 | - __( 'Satisfied', 'formidable' ), | |
| 1786 | - __( 'Very Satisfied', 'formidable' ), | |
| 1787 | 1662 | __( 'N/A', 'formidable' ), |
| 1788 | 1663 | ); |
| 1789 | - if ( $include_class ) { | |
| 1790 | - $satisfaction['class'] = 'frm-satisfaction-opts'; | |
| 1791 | - } | |
| 1792 | 1664 | |
| 1793 | - $prepop[ __( 'Satisfaction', 'formidable' ) ] = $satisfaction; | |
| 1794 | - | |
| 1795 | - // Importance. | |
| 1796 | - $importance = array( | |
| 1665 | + $prepop[ __( 'Importance', 'formidable' ) ] = array( | |
| 1666 | + __( 'Very Important', 'formidable' ), | |
| 1667 | + __( 'Important', 'formidable' ), | |
| 1668 | + __( 'Neutral', 'formidable' ), | |
| 1669 | + __( 'Somewhat Important', 'formidable' ), | |
| 1797 | 1670 | __( 'Not at all Important', 'formidable' ), |
| 1798 | - __( 'Somewhat Important', 'formidable' ), | |
| 1799 | - __( 'Neutral', 'formidable' ), | |
| 1800 | - __( 'Important', 'formidable' ), | |
| 1801 | - __( 'Very Important', 'formidable' ), | |
| 1802 | 1671 | __( 'N/A', 'formidable' ), |
| 1803 | 1672 | ); |
| 1804 | - if ( $include_class ) { | |
| 1805 | - $importance['class'] = 'frm-importance-opts'; | |
| 1806 | - } | |
| 1807 | 1673 | |
| 1808 | - $prepop[ __( 'Importance', 'formidable' ) ] = $importance; | |
| 1809 | - | |
| 1810 | - // Agreement. | |
| 1811 | - $agreement = array( | |
| 1812 | - __( 'Strongly Disagree', 'formidable' ), | |
| 1813 | - __( 'Disagree', 'formidable' ), | |
| 1814 | - __( 'Neutral', 'formidable' ), | |
| 1674 | + $prepop[ __( 'Agreement', 'formidable' ) ] = array( | |
| 1675 | + __( 'Strongly Agree', 'formidable' ), | |
| 1815 | 1676 | __( 'Agree', 'formidable' ), |
| 1816 | - __( 'Strongly Agree', 'formidable' ), | |
| 1817 | - __( 'N/A', 'formidable' ), | |
| 1818 | - ); | |
| 1819 | - if ( $include_class ) { | |
| 1820 | - $agreement['class'] = 'frm-agreement-opts'; | |
| 1821 | - } | |
| 1822 | - | |
| 1823 | - $prepop[ __( 'Agreement', 'formidable' ) ] = $agreement; | |
| 1824 | - | |
| 1825 | - // Likely. | |
| 1826 | - $likely = array( | |
| 1827 | - __( 'Extremely Unlikely', 'formidable' ), | |
| 1828 | - __( 'Unlikely', 'formidable' ), | |
| 1829 | 1677 | __( 'Neutral', 'formidable' ), |
| 1830 | - __( 'Likely', 'formidable' ), | |
| 1831 | - __( 'Extremely Likely', 'formidable' ), | |
| 1678 | + __( 'Disagree', 'formidable' ), | |
| 1679 | + __( 'Strongly Disagree', 'formidable' ), | |
| 1832 | 1680 | __( 'N/A', 'formidable' ), |
| 1833 | 1681 | ); |
| 1834 | - if ( $include_class ) { | |
| 1835 | - $likely['class'] = 'frm-likely-opts'; | |
| 1836 | - } | |
| 1837 | 1682 | |
| 1838 | - $prepop[ __( 'Likely', 'formidable' ) ] = $likely; | |
| 1839 | - | |
| 1840 | 1683 | $prepop = apply_filters( 'frm_bulk_field_choices', $prepop ); |
| 1841 | 1684 | } |
| 1842 | 1685 | |
| 1843 | 1686 | /** |
| @@ -1871,11 +1714,9 @@ | ||
| 1871 | 1714 | } |
| 1872 | 1715 | |
| 1873 | 1716 | /** |
| 1874 | 1717 | * @since 4.04 |
| 1875 | - * | |
| 1876 | 1718 | * @param array $args |
| 1877 | - * @return void | |
| 1878 | 1719 | */ |
| 1879 | 1720 | public static function show_add_field_buttons( $args ) { |
| 1880 | 1721 | $field_key = $args['field_key']; |
| 1881 | 1722 | $field_type = $args['field_type']; |
| @@ -1917,29 +1758,15 @@ | ||
| 1917 | 1758 | $upgrade_message = FrmAppHelper::kses( $field_type['message'], array( 'a', 'img' ) ); |
| 1918 | 1759 | } |
| 1919 | 1760 | } |
| 1920 | 1761 | |
| 1921 | - $li_params = array( | |
| 1922 | - 'class' => 'frmbutton frm6 ' . $args['no_allow_class'] . $single_no_allow . ' frm_t' . str_replace( '|', '-', $field_key ), | |
| 1923 | - 'id' => $field_key, | |
| 1924 | - 'data-upgrade' => $upgrade_label, | |
| 1925 | - 'data-link' => $link, | |
| 1926 | - 'data-medium' => 'builder', | |
| 1927 | - 'data-oneclick' => $install_data, | |
| 1928 | - 'data-content' => $field_key, | |
| 1929 | - 'data-requires' => $requires, | |
| 1930 | - ); | |
| 1931 | - | |
| 1932 | - if ( $upgrade_message ) { | |
| 1933 | - $li_params['data-message'] = $upgrade_message; | |
| 1934 | - } | |
| 1935 | 1762 | ?> |
| 1936 | - <li <?php FrmAppHelper::array_to_html_params( $li_params, true ); ?>> | |
| 1763 | + <li class="frmbutton frm6 <?php echo esc_attr( $args['no_allow_class'] . $single_no_allow . ' frm_t' . str_replace( '|', '-', $field_key ) ); ?>" id="<?php echo esc_attr( $field_key ); ?>" data-upgrade="<?php echo esc_attr( $upgrade_label ); ?>" data-message="<?php echo esc_attr( $upgrade_message ); ?>" data-link="<?php echo esc_attr( $link ); ?>" data-medium="builder" data-oneclick="<?php echo esc_attr( $install_data ); ?>" data-content="<?php echo esc_attr( $field_key ); ?>" data-requires="<?php echo esc_attr( $requires ); ?>"> | |
| 1937 | 1764 | <?php |
| 1938 | 1765 | if ( $run_filter ) { |
| 1939 | 1766 | $field_label = apply_filters( 'frmpro_field_links', $field_label, $args['id'], $field_key ); |
| 1940 | 1767 | } |
| 1941 | - echo FrmAppHelper::kses( $field_label, array( 'a', 'i', 'span', 'use', 'svg' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 1768 | + echo FrmAppHelper::kses( $field_label, array( 'a', 'i', 'span', 'use', 'svg' ) ); // WPCS: XSS ok. | |
| 1942 | 1769 | ?> |
| 1943 | 1770 | </li> |
| 1944 | 1771 | <?php |
| 1945 | 1772 | } |
| @@ -1944,173 +1771,8 @@ | ||
| 1944 | 1771 | <?php |
| 1945 | 1772 | } |
| 1946 | 1773 | |
| 1947 | 1774 | /** |
| 1948 | - * Shows Display format option. | |
| 1949 | - * | |
| 1950 | - * @since 5.0.04 | |
| 1951 | - * | |
| 1952 | - * @param array $field Field data. | |
| 1953 | - */ | |
| 1954 | - public static function show_radio_display_format( $field ) { | |
| 1955 | - $options = self::get_display_format_options( $field ); | |
| 1956 | - | |
| 1957 | - $args = self::get_display_format_args( $field, $options ); | |
| 1958 | - | |
| 1959 | - include FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/radio-display-format.php'; | |
| 1960 | - } | |
| 1961 | - | |
| 1962 | - /** | |
| 1963 | - * Creates an array that contains variables used for display format options setting. | |
| 1964 | - * | |
| 1965 | - * @since 6.3.2 | |
| 1966 | - * | |
| 1967 | - * @param array $field The field. | |
| 1968 | - * | |
| 1969 | - * @return array | |
| 1970 | - */ | |
| 1971 | - public static function get_display_format_options( $field ) { | |
| 1972 | - $options = array( | |
| 1973 | - '0' => array( | |
| 1974 | - 'text' => __( 'Simple', 'formidable' ), | |
| 1975 | - 'svg' => 'frm_simple_radio', | |
| 1976 | - ), | |
| 1977 | - '1' => array( | |
| 1978 | - 'text' => __( 'Images', 'formidable' ), | |
| 1979 | - 'svg' => 'frm_image_as_option', | |
| 1980 | - 'addon' => 'pro', | |
| 1981 | - 'upgrade' => __( 'Image Options', 'formidable' ), | |
| 1982 | - 'message' => __( 'Show images instead of radio buttons or check boxes. This is ideal for polls, surveys, segmenting questionnaires and more.', 'formidable' ) . '<img src="' . esc_url( FrmAppHelper::plugin_url() ) . '/images/image-options.png" />', | |
| 1983 | - 'content' => 'image-options', | |
| 1984 | - ), | |
| 1985 | - 'buttons' => array( | |
| 1986 | - 'text' => __( 'Buttons', 'formidable' ), | |
| 1987 | - 'svg' => 'frm_button_as_option', | |
| 1988 | - 'addon' => 'surveys', | |
| 1989 | - 'upgrade' => __( 'Button Options', 'formidable' ), | |
| 1990 | - 'message' => __( 'Show buttons for radio buttons or check boxes. This is ideal for polls, surveys, segmenting questionnaires and more.', 'formidable' ), | |
| 1991 | - 'content' => 'button-options', | |
| 1992 | - ), | |
| 1993 | - ); | |
| 1994 | - | |
| 1995 | - /** | |
| 1996 | - * Allows modifying the options of Display format setting of Radio field. | |
| 1997 | - * | |
| 1998 | - * @since 5.0.04 | |
| 1999 | - * | |
| 2000 | - * @param array $options Options. | |
| 2001 | - * @param array $field | |
| 2002 | - */ | |
| 2003 | - $options = apply_filters( 'frm_' . $field['type'] . '_display_format_options', $options, $field ); | |
| 2004 | - | |
| 2005 | - return $options; | |
| 2006 | - } | |
| 2007 | - | |
| 2008 | - /** | |
| 2009 | - * Gets display format arguments to pass to the images_dropdown() method. | |
| 2010 | - * | |
| 2011 | - * @since 5.0.04 | |
| 2012 | - * | |
| 2013 | - * @param array $field Field data. | |
| 2014 | - * @param array $options Options array. | |
| 2015 | - * @return array | |
| 2016 | - */ | |
| 2017 | - public static function get_display_format_args( $field, $options ) { | |
| 2018 | - $args = array( | |
| 2019 | - 'selected' => '0', | |
| 2020 | - 'options' => array(), | |
| 2021 | - 'name' => 'field_options[image_options_' . $field['id'] . ']', | |
| 2022 | - 'input_attrs' => array( | |
| 2023 | - 'class' => 'frm_toggle_image_options', | |
| 2024 | - ), | |
| 2025 | - ); | |
| 2026 | - | |
| 2027 | - self::fill_image_setting_options( $options, $args ); | |
| 2028 | - | |
| 2029 | - /** | |
| 2030 | - * Allows modifying the arguments of Display format setting of Radio field. | |
| 2031 | - * | |
| 2032 | - * @since 5.0.04 | |
| 2033 | - * | |
| 2034 | - * @param array $args Arguments. | |
| 2035 | - * @param array $method_args The arguments from the method. Contains `field`, `options`. | |
| 2036 | - */ | |
| 2037 | - return apply_filters( 'frm_' . $field['type'] . '_display_format_args', $args, compact( 'field', 'options' ) ); | |
| 2038 | - } | |
| 2039 | - | |
| 2040 | - /** | |
| 2041 | - * @since 5.0.04 | |
| 2042 | - */ | |
| 2043 | - private static function fill_image_setting_options( $options, &$args ) { | |
| 2044 | - foreach ( $options as $key => $option ) { | |
| 2045 | - $args['options'][ $key ] = $option; | |
| 2046 | - | |
| 2047 | - if ( ! empty( $option['addon'] ) ) { | |
| 2048 | - $args['options'][ $key ]['custom_attrs'] = self::fill_image_setting_addon_link( $option ); | |
| 2049 | - } | |
| 2050 | - | |
| 2051 | - unset( $args['options'][ $key ]['addon'] ); | |
| 2052 | - $fill = array( 'upgrade', 'message', 'content' ); | |
| 2053 | - foreach ( $fill as $f ) { | |
| 2054 | - unset( $args['options'][ $key ][ $f ], $f ); | |
| 2055 | - } | |
| 2056 | - } | |
| 2057 | - } | |
| 2058 | - | |
| 2059 | - /** | |
| 2060 | - * @since 5.0.04 | |
| 2061 | - * | |
| 2062 | - * @return array | |
| 2063 | - */ | |
| 2064 | - private static function fill_image_setting_addon_link( $option ) { | |
| 2065 | - $custom_attrs = array( | |
| 2066 | - 'class' => 'frm_noallow frm_show_upgrade', | |
| 2067 | - 'data-medium' => 'builder', | |
| 2068 | - ); | |
| 2069 | - | |
| 2070 | - // translators: Add-on name. | |
| 2071 | - $custom_attrs['data-upgrade'] = sprintf( __( 'Formidable %s', 'formidable' ), ucwords( $option['addon'] ) ); | |
| 2072 | - | |
| 2073 | - $fill = array( 'upgrade', 'message', 'content' ); | |
| 2074 | - foreach ( $fill as $f ) { | |
| 2075 | - if ( isset( $option[ $f ] ) ) { | |
| 2076 | - $custom_attrs[ 'data-' . $f ] = $option[ $f ]; | |
| 2077 | - } | |
| 2078 | - } | |
| 2079 | - | |
| 2080 | - if ( 'pro' === $option['addon'] ) { | |
| 2081 | - return $custom_attrs; | |
| 2082 | - } | |
| 2083 | - | |
| 2084 | - $upgrading = FrmAddonsController::install_link( $option['addon'] ); | |
| 2085 | - if ( isset( $upgrading['url'] ) ) { | |
| 2086 | - $install_data = wp_json_encode( $upgrading ); | |
| 2087 | - } else { | |
| 2088 | - $install_data = ''; | |
| 2089 | - } | |
| 2090 | - | |
| 2091 | - $custom_attrs['data-oneclick'] = $install_data; | |
| 2092 | - $custom_attrs['data-requires'] = FrmFormsHelper::get_plan_required( $upgrading ); | |
| 2093 | - | |
| 2094 | - return $custom_attrs; | |
| 2095 | - } | |
| 2096 | - | |
| 2097 | - /** | |
| 2098 | - * Maybe adjust a field value based on type. | |
| 2099 | - * Some types require unserializing an array (@see self::field_type_requires_unserialize). | |
| 2100 | - * | |
| 2101 | - * @since 6.2 | |
| 2102 | - * | |
| 2103 | - * @param mixed $value | |
| 2104 | - * @param string $field_type | |
| 2105 | - * @return void | |
| 2106 | - */ | |
| 2107 | - public static function prepare_field_value( &$value, $field_type ) { | |
| 2108 | - $field_object = FrmFieldFactory::get_field_type( $field_type ); | |
| 2109 | - $value = $field_object->maybe_decode_value( $value ); | |
| 2110 | - } | |
| 2111 | - | |
| 2112 | - /** | |
| 2113 | 1775 | * @deprecated 4.0 |
| 2114 | 1776 | */ |
| 2115 | 1777 | public static function show_icon_link_js( $atts ) { |
| 2116 | 1778 | _deprecated_function( __METHOD__, '4.0' ); |
| @@ -2169,13 +1831,13 @@ | ||
| 2169 | 1831 | /** |
| 2170 | 1832 | * @deprecated 3.0 |
| 2171 | 1833 | * @codeCoverageIgnore |
| 2172 | 1834 | * |
| 2173 | - * @param string $html | |
| 2174 | - * @param array $field | |
| 2175 | - * @param array $errors | |
| 2176 | - * @param object|false $form | |
| 2177 | - * @param array $args | |
| 1835 | + * @param string $html | |
| 1836 | + * @param array $field | |
| 1837 | + * @param array $errors | |
| 1838 | + * @param object $form | |
| 1839 | + * @param array $args | |
| 2178 | 1840 | * |
| 2179 | 1841 | * @return string |
| 2180 | 1842 | */ |
| 2181 | 1843 | public static function replace_shortcodes( $html, $field, $errors = array(), $form = false, $args = array() ) { |
| @@ -2190,13 +1852,10 @@ | ||
| 2190 | 1852 | return FrmDeprecated::get_default_field_opts( $type, $field, $limit ); |
| 2191 | 1853 | } |
| 2192 | 1854 | |
| 2193 | 1855 | /** |
| 2194 | - * @deprecated 2.02.07 This is still referenced in the Highrise add on as of v1.06. | |
| 1856 | + * @deprecated 2.02.07 | |
| 2195 | 1857 | * @codeCoverageIgnore |
| 2196 | - * | |
| 2197 | - * @param array $args | |
| 2198 | - * @return string | |
| 2199 | 1858 | */ |
| 2200 | 1859 | public static function dropdown_categories( $args ) { |
| 2201 | 1860 | return FrmDeprecated::dropdown_categories( $args ); |
| 2202 | 1861 | } |