| @@ -123,9 +123,9 @@ | ||
| 123 | 123 | * @param object $field |
| 124 | 124 | * @param array $values |
| 125 | 125 | */ |
| 126 | 126 | private static function fill_default_field_opts( $field, array &$values ) { |
| 127 | - $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'] ); | |
| 128 | 128 | |
| 129 | 129 | $defaults = self::get_default_field_options_from_field( $field, $values ); |
| 130 | 130 | if ( ! $check_post ) { |
| 131 | 131 | $defaults['required_indicator'] = ''; |
| @@ -158,9 +158,9 @@ | ||
| 158 | 158 | if ( '' == $field_array['blank'] && '1' === $field_array['required'] ) { |
| 159 | 159 | $field_array['blank'] = $frm_settings->blank_msg; |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - if ( '' === $field_array['invalid'] ) { | |
| 162 | + if ( '' == $field_array['invalid'] ) { | |
| 163 | 163 | if ( 'captcha' === $field->type ) { |
| 164 | 164 | $field_array['invalid'] = $frm_settings->re_msg; |
| 165 | 165 | } else { |
| 166 | 166 | /* translators: %s: Field name */ |
| @@ -179,20 +179,22 @@ | ||
| 179 | 179 | * @param string $setting |
| 180 | 180 | * @param mixed $value |
| 181 | 181 | */ |
| 182 | 182 | private static function get_posted_field_setting( $setting, &$value ) { |
| 183 | - if ( ! isset( $_POST['field_options'][ $setting ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 183 | + if ( ! isset( $_POST['field_options'][ $setting ] ) ) { | |
| 184 | 184 | return; |
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | if ( strpos( $setting, 'html' ) !== false ) { |
| 188 | 188 | // Strip slashes from HTML but not regex or script tags. |
| 189 | - $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 ] ); | |
| 190 | 191 | } elseif ( strpos( $setting, 'format_' ) === 0 ) { |
| 191 | 192 | // TODO: Remove stripslashes on output, and use on input only. |
| 192 | - $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. | |
| 193 | 194 | } else { |
| 194 | - $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 ] ); | |
| 195 | 197 | FrmAppHelper::sanitize_value( 'wp_kses_post', $value ); |
| 196 | 198 | } |
| 197 | 199 | } |
| 198 | 200 | |
| @@ -389,13 +391,11 @@ | ||
| 389 | 391 | /** |
| 390 | 392 | * Check if this field type allows placeholders |
| 391 | 393 | * |
| 392 | 394 | * @since 2.05 |
| 393 | - * @param string $type | |
| 394 | - * @return bool | |
| 395 | 395 | */ |
| 396 | 396 | public static function is_placeholder_field_type( $type ) { |
| 397 | - return ! in_array( $type, array( 'radio', 'checkbox', 'hidden', 'file' ), true ); | |
| 397 | + return ! in_array( $type, array( 'radio', 'checkbox', 'hidden', 'file' ) ); | |
| 398 | 398 | } |
| 399 | 399 | |
| 400 | 400 | public static function get_checkbox_id( $field, $opt_key, $type = 'checkbox' ) { |
| 401 | 401 | $id = $field['id']; |
| @@ -568,37 +568,27 @@ | ||
| 568 | 568 | return self::array_value_condition( $observed_value, $cond, $hide_opt ); |
| 569 | 569 | } |
| 570 | 570 | |
| 571 | 571 | $m = false; |
| 572 | - if ( $cond === '==' ) { | |
| 572 | + if ( $cond == '==' ) { | |
| 573 | 573 | $m = $observed_value == $hide_opt; |
| 574 | - } elseif ( $cond === '!=' ) { | |
| 574 | + } elseif ( $cond == '!=' ) { | |
| 575 | 575 | $m = $observed_value != $hide_opt; |
| 576 | - } elseif ( $cond === '>' ) { | |
| 576 | + } elseif ( $cond == '>' ) { | |
| 577 | 577 | $m = $observed_value > $hide_opt; |
| 578 | - } elseif ( $cond === '>=' ) { | |
| 578 | + } elseif ( $cond == '>=' ) { | |
| 579 | 579 | $m = $observed_value >= $hide_opt; |
| 580 | - } elseif ( $cond === '<' ) { | |
| 580 | + } elseif ( $cond == '<' ) { | |
| 581 | 581 | $m = $observed_value < $hide_opt; |
| 582 | - } elseif ( $cond === '<=' ) { | |
| 582 | + } elseif ( $cond == '<=' ) { | |
| 583 | 583 | $m = $observed_value <= $hide_opt; |
| 584 | - } elseif ( $cond === 'LIKE' || $cond === 'not LIKE' ) { | |
| 584 | + } elseif ( $cond == 'LIKE' || $cond == 'not LIKE' ) { | |
| 585 | 585 | $m = stripos( $observed_value, $hide_opt ); |
| 586 | - if ( $cond === 'not LIKE' ) { | |
| 586 | + if ( $cond == 'not LIKE' ) { | |
| 587 | 587 | $m = ( $m === false ) ? true : false; |
| 588 | 588 | } else { |
| 589 | 589 | $m = ( $m === false ) ? false : true; |
| 590 | 590 | } |
| 591 | - } elseif ( $cond === '%LIKE' ) { | |
| 592 | - // ends with | |
| 593 | - $length = strlen( $hide_opt ); | |
| 594 | - $substr = substr( $observed_value, strlen( $observed_value ) - $length ); | |
| 595 | - $m = 0 === strcasecmp( $substr, $hide_opt ); | |
| 596 | - } elseif ( 'LIKE%' === $cond ) { | |
| 597 | - // starts with | |
| 598 | - $length = strlen( $hide_opt ); | |
| 599 | - $substr = substr( $observed_value, 0, $length ); | |
| 600 | - $m = 0 === strcasecmp( $substr, $hide_opt ); | |
| 601 | 591 | } |
| 602 | 592 | |
| 603 | 593 | return $m; |
| 604 | 594 | } |
| @@ -620,9 +610,9 @@ | ||
| 620 | 610 | } |
| 621 | 611 | |
| 622 | 612 | public static function array_value_condition( $observed_value, $cond, $hide_opt ) { |
| 623 | 613 | $m = false; |
| 624 | - if ( $cond === '==' ) { | |
| 614 | + if ( $cond == '==' ) { | |
| 625 | 615 | if ( is_array( $hide_opt ) ) { |
| 626 | 616 | $m = array_intersect( $hide_opt, $observed_value ); |
| 627 | 617 | $m = empty( $m ) ? false : true; |
| 628 | 618 | } else { |
| @@ -627,17 +617,17 @@ | ||
| 627 | 617 | $m = empty( $m ) ? false : true; |
| 628 | 618 | } else { |
| 629 | 619 | $m = in_array( $hide_opt, $observed_value ); |
| 630 | 620 | } |
| 631 | - } elseif ( $cond === '!=' ) { | |
| 621 | + } elseif ( $cond == '!=' ) { | |
| 632 | 622 | $m = ! in_array( $hide_opt, $observed_value ); |
| 633 | - } elseif ( $cond === '>' ) { | |
| 623 | + } elseif ( $cond == '>' ) { | |
| 634 | 624 | $min = min( $observed_value ); |
| 635 | 625 | $m = $min > $hide_opt; |
| 636 | - } elseif ( $cond === '<' ) { | |
| 626 | + } elseif ( $cond == '<' ) { | |
| 637 | 627 | $max = max( $observed_value ); |
| 638 | 628 | $m = $max < $hide_opt; |
| 639 | - } elseif ( $cond === 'LIKE' || $cond === 'not LIKE' ) { | |
| 629 | + } elseif ( $cond == 'LIKE' || $cond == 'not LIKE' ) { | |
| 640 | 630 | foreach ( $observed_value as $ob ) { |
| 641 | 631 | $m = strpos( $ob, $hide_opt ); |
| 642 | 632 | if ( $m !== false ) { |
| 643 | 633 | $m = true; |
| @@ -644,27 +634,11 @@ | ||
| 644 | 634 | break; |
| 645 | 635 | } |
| 646 | 636 | } |
| 647 | 637 | |
| 648 | - if ( $cond === 'not LIKE' ) { | |
| 638 | + if ( $cond == 'not LIKE' ) { | |
| 649 | 639 | $m = ( $m === false ) ? true : false; |
| 650 | 640 | } |
| 651 | - } elseif ( $cond === '%LIKE' ) { | |
| 652 | - // ends with | |
| 653 | - foreach ( $observed_value as $ob ) { | |
| 654 | - if ( $hide_opt === substr( $ob, strlen( $ob ) - strlen( $hide_opt ) ) ) { | |
| 655 | - $m = true; | |
| 656 | - break; | |
| 657 | - } | |
| 658 | - } | |
| 659 | - } elseif ( $cond === 'LIKE%' ) { | |
| 660 | - // starts with | |
| 661 | - foreach ( $observed_value as $ob ) { | |
| 662 | - if ( $hide_opt === substr( $ob, 0, strlen( $hide_opt ) ) ) { | |
| 663 | - $m = true; | |
| 664 | - break; | |
| 665 | - } | |
| 666 | - } | |
| 667 | 641 | } |
| 668 | 642 | |
| 669 | 643 | return $m; |
| 670 | 644 | } |
| @@ -745,9 +719,8 @@ | ||
| 745 | 719 | $atts['tag'] = $tag; |
| 746 | 720 | $replace_with = self::get_value_for_shortcode( $atts ); |
| 747 | 721 | |
| 748 | 722 | if ( $replace_with !== null ) { |
| 749 | - $replace_with = self::trigger_shortcode_atts( $replace_with, $atts ); | |
| 750 | 723 | self::sanitize_embedded_shortcodes( compact( 'entry' ), $replace_with ); |
| 751 | 724 | $content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content ); |
| 752 | 725 | } |
| 753 | 726 | |
| @@ -757,56 +730,8 @@ | ||
| 757 | 730 | return $content; |
| 758 | 731 | } |
| 759 | 732 | |
| 760 | 733 | /** |
| 761 | - * @param string $replace_with | |
| 762 | - * @param array $atts | |
| 763 | - * @return string | |
| 764 | - */ | |
| 765 | - private static function trigger_shortcode_atts( $replace_with, $atts ) { | |
| 766 | - $supported_atts = array( 'remove_accents', 'sanitize', 'sanitize_url' ); | |
| 767 | - $included_atts = array_intersect( $supported_atts, array_keys( $atts ) ); | |
| 768 | - foreach ( $included_atts as $included_att ) { | |
| 769 | - if ( '0' === $atts[ $included_att ] ) { | |
| 770 | - // Skip any option that uses 0 so sanitize_url=0 does not encode. | |
| 771 | - continue; | |
| 772 | - } | |
| 773 | - $function = 'atts_' . $included_att; | |
| 774 | - $replace_with = self::$function( $replace_with, $atts ); | |
| 775 | - } | |
| 776 | - return $replace_with; | |
| 777 | - } | |
| 778 | - | |
| 779 | - /** | |
| 780 | - * Converts all accent characters to ASCII characters. | |
| 781 | - * | |
| 782 | - * @since 6.3.1 | |
| 783 | - * | |
| 784 | - * @param string $replace_with The text to remove accents from. | |
| 785 | - * | |
| 786 | - * @return string | |
| 787 | - */ | |
| 788 | - public static function atts_remove_accents( $replace_with ) { | |
| 789 | - return remove_accents( $replace_with ); | |
| 790 | - } | |
| 791 | - | |
| 792 | - /** | |
| 793 | - * @param string $replace_with | |
| 794 | - * @return string | |
| 795 | - */ | |
| 796 | - private static function atts_sanitize( $replace_with ) { | |
| 797 | - return sanitize_title_with_dashes( $replace_with ); | |
| 798 | - } | |
| 799 | - | |
| 800 | - /** | |
| 801 | - * @param string $replace_with | |
| 802 | - * @return string | |
| 803 | - */ | |
| 804 | - private static function atts_sanitize_url( $replace_with ) { | |
| 805 | - return urlencode( $replace_with ); | |
| 806 | - } | |
| 807 | - | |
| 808 | - /** | |
| 809 | 734 | * Prevent shortcodes in fields from being processed |
| 810 | 735 | * |
| 811 | 736 | * @since 3.01.02 |
| 812 | 737 | * |
| @@ -888,11 +813,11 @@ | ||
| 888 | 813 | if ( empty( $field ) ) { |
| 889 | 814 | return null; |
| 890 | 815 | } |
| 891 | 816 | |
| 892 | - if ( isset( $atts['show'] ) && $atts['show'] === 'field_label' ) { | |
| 817 | + if ( isset( $atts['show'] ) && $atts['show'] == 'field_label' ) { | |
| 893 | 818 | $replace_with = $field->name; |
| 894 | - } elseif ( isset( $atts['show'] ) && $atts['show'] === 'description' ) { | |
| 819 | + } elseif ( isset( $atts['show'] ) && $atts['show'] == 'description' ) { | |
| 895 | 820 | $replace_with = $field->description; |
| 896 | 821 | } else { |
| 897 | 822 | $replace_with = FrmEntryMeta::get_meta_value( $atts['entry'], $field->id ); |
| 898 | 823 | $string_value = $replace_with; |
| @@ -1054,9 +979,9 @@ | ||
| 1054 | 979 | } elseif ( isset( $field_selection[ $type ] ) ) { |
| 1055 | 980 | $field_types[ $type ] = $field_selection[ $type ]; |
| 1056 | 981 | } |
| 1057 | 982 | |
| 1058 | - $field_types = apply_filters( 'frm_switch_field_types', $field_types, compact( 'type', 'field_selection' ) ); | |
| 983 | + $field_types = apply_filters( 'frm_switch_field_types', $field_types, compact( 'type' ) ); | |
| 1059 | 984 | |
| 1060 | 985 | return $field_types; |
| 1061 | 986 | } |
| 1062 | 987 | |
| @@ -1132,26 +1057,24 @@ | ||
| 1132 | 1057 | } |
| 1133 | 1058 | |
| 1134 | 1059 | // Check posted vals before checking saved values |
| 1135 | 1060 | // For fields inside repeating sections - note, don't check if $pointer is true because it will often be zero |
| 1136 | - if ( $parent && isset( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 1061 | + if ( $parent && isset( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] ) ) { | |
| 1137 | 1062 | if ( FrmField::is_field_with_multiple_values( $field ) ) { |
| 1138 | - // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 1139 | 1063 | $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 ] ) ) : ''; |
| 1140 | 1064 | } else { |
| 1141 | - $other_val = sanitize_text_field( wp_unslash( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 1065 | + $other_val = sanitize_text_field( wp_unslash( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] ) ); | |
| 1142 | 1066 | } |
| 1143 | 1067 | |
| 1144 | 1068 | return $other_val; |
| 1145 | 1069 | |
| 1146 | - } elseif ( isset( $field['id'] ) && isset( $_POST['item_meta']['other'][ $field['id'] ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 1070 | + } elseif ( isset( $field['id'] ) && isset( $_POST['item_meta']['other'][ $field['id'] ] ) ) { | |
| 1147 | 1071 | // For normal fields |
| 1148 | 1072 | |
| 1149 | 1073 | if ( FrmField::is_field_with_multiple_values( $field ) ) { |
| 1150 | - // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 1151 | 1074 | $other_val = isset( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) ? sanitize_text_field( wp_unslash( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) ) : ''; |
| 1152 | 1075 | } else { |
| 1153 | - $other_val = sanitize_text_field( wp_unslash( $_POST['item_meta']['other'][ $field['id'] ] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 1076 | + $other_val = sanitize_text_field( wp_unslash( $_POST['item_meta']['other'][ $field['id'] ] ) ); | |
| 1154 | 1077 | } |
| 1155 | 1078 | |
| 1156 | 1079 | return $other_val; |
| 1157 | 1080 | } |
| @@ -1156,9 +1079,9 @@ | ||
| 1156 | 1079 | return $other_val; |
| 1157 | 1080 | } |
| 1158 | 1081 | |
| 1159 | 1082 | // For checkboxes |
| 1160 | - if ( $field['type'] === 'checkbox' && is_array( $field['value'] ) ) { | |
| 1083 | + if ( $field['type'] == 'checkbox' && is_array( $field['value'] ) ) { | |
| 1161 | 1084 | // Check if there is an "other" val in saved value and make sure the |
| 1162 | 1085 | // "other" val is not equal to the Other checkbox option |
| 1163 | 1086 | if ( isset( $field['value'][ $opt_key ] ) && $field['options'][ $opt_key ] != $field['value'][ $opt_key ] ) { |
| 1164 | 1087 | $other_val = $field['value'][ $opt_key ]; |
| @@ -1352,32 +1275,22 @@ | ||
| 1352 | 1275 | $replace[] = '[if ' . $old . ' '; |
| 1353 | 1276 | $replace_with[] = '[if ' . $new . ' '; |
| 1354 | 1277 | $replace[] = '[/if ' . $old . ']'; |
| 1355 | 1278 | $replace_with[] = '[/if ' . $new . ']'; |
| 1356 | - $replace[] = '[\/if ' . $old . ']'; | |
| 1357 | - $replace_with[] = '[\/if ' . $new . ']'; | |
| 1358 | 1279 | $replace[] = '[foreach ' . $old . ']'; |
| 1359 | 1280 | $replace_with[] = '[foreach ' . $new . ']'; |
| 1360 | 1281 | $replace[] = '[/foreach ' . $old . ']'; |
| 1361 | 1282 | $replace_with[] = '[/foreach ' . $new . ']'; |
| 1362 | - $replace[] = '[\/foreach ' . $old . ']'; | |
| 1363 | - $replace_with[] = '[\/foreach ' . $new . ']'; | |
| 1364 | 1283 | $replace[] = '[' . $old . ']'; |
| 1365 | 1284 | $replace_with[] = '[' . $new . ']'; |
| 1366 | 1285 | $replace[] = '[' . $old . ' '; |
| 1367 | 1286 | $replace_with[] = '[' . $new . ' '; |
| 1368 | - $replace[] = 'field_id="' . $old . '"'; | |
| 1369 | - $replace_with[] = 'field_id="' . $new . '"'; | |
| 1370 | - $replace[] = 'field_id=\"' . $old . '\"'; | |
| 1371 | - $replace_with[] = 'field_id=\"' . $new . '\"'; | |
| 1372 | 1287 | unset( $old, $new ); |
| 1373 | 1288 | } |
| 1374 | 1289 | if ( is_array( $val ) ) { |
| 1375 | 1290 | foreach ( $val as $k => $v ) { |
| 1376 | - if ( is_string( $v ) ) { | |
| 1377 | - $val[ $k ] = str_replace( $replace, $replace_with, $v ); | |
| 1378 | - unset( $k, $v ); | |
| 1379 | - } | |
| 1291 | + $val[ $k ] = str_replace( $replace, $replace_with, $v ); | |
| 1292 | + unset( $k, $v ); | |
| 1380 | 1293 | } |
| 1381 | 1294 | } else { |
| 1382 | 1295 | $val = str_replace( $replace, $replace_with, $val ); |
| 1383 | 1296 | } |
| @@ -1389,9 +1302,9 @@ | ||
| 1389 | 1302 | * @since 4.0 |
| 1390 | 1303 | */ |
| 1391 | 1304 | public static function bulk_options_overlay() { |
| 1392 | 1305 | $prepop = array(); |
| 1393 | - self::get_bulk_prefilled_opts( $prepop, true ); | |
| 1306 | + self::get_bulk_prefilled_opts( $prepop ); | |
| 1394 | 1307 | |
| 1395 | 1308 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/bulk-options-overlay.php' ); |
| 1396 | 1309 | } |
| 1397 | 1310 | |
| @@ -1711,47 +1624,22 @@ | ||
| 1711 | 1624 | sort( $countries, SORT_LOCALE_STRING ); |
| 1712 | 1625 | return apply_filters( 'frm_countries', $countries ); |
| 1713 | 1626 | } |
| 1714 | 1627 | |
| 1715 | - /** | |
| 1716 | - * Gets bulk prefilled options. | |
| 1717 | - * | |
| 1718 | - * @since 5.0.04 Add `$include_class` param. | |
| 1719 | - * | |
| 1720 | - * @param array $prepop Bulk options. | |
| 1721 | - * @param array|false $include_class Include the class in the bulk options. | |
| 1722 | - */ | |
| 1723 | - public static function get_bulk_prefilled_opts( array &$prepop, $include_class = false ) { | |
| 1724 | - // Countries. | |
| 1725 | - $countries = self::get_countries(); | |
| 1726 | - if ( $include_class ) { | |
| 1727 | - $countries['class'] = 'frm-countries-opts'; | |
| 1728 | - } | |
| 1628 | + public static function get_bulk_prefilled_opts( array &$prepop ) { | |
| 1629 | + $prepop[ __( 'Countries', 'formidable' ) ] = self::get_countries(); | |
| 1729 | 1630 | |
| 1730 | - $prepop[ __( 'Countries', 'formidable' ) ] = $countries; | |
| 1731 | - | |
| 1732 | - // State abv. | |
| 1733 | 1631 | $states = self::get_us_states(); |
| 1734 | 1632 | $state_abv = array_keys( $states ); |
| 1735 | 1633 | sort( $state_abv ); |
| 1736 | - if ( $include_class ) { | |
| 1737 | - $state_abv['class'] = 'frm-state-abv-opts'; | |
| 1738 | - } | |
| 1739 | - | |
| 1740 | 1634 | $prepop[ __( 'U.S. State Abbreviations', 'formidable' ) ] = $state_abv; |
| 1741 | 1635 | |
| 1742 | - // States. | |
| 1743 | 1636 | $states = array_values( $states ); |
| 1744 | 1637 | sort( $states ); |
| 1745 | - if ( $include_class ) { | |
| 1746 | - $states['class'] = 'frm-states-opts'; | |
| 1747 | - } | |
| 1748 | - | |
| 1749 | 1638 | $prepop[ __( 'U.S. States', 'formidable' ) ] = $states; |
| 1750 | 1639 | unset( $state_abv, $states ); |
| 1751 | 1640 | |
| 1752 | - // Age. | |
| 1753 | - $ages = array( | |
| 1641 | + $prepop[ __( 'Age', 'formidable' ) ] = array( | |
| 1754 | 1642 | __( 'Under 18', 'formidable' ), |
| 1755 | 1643 | __( '18-24', 'formidable' ), |
| 1756 | 1644 | __( '25-34', 'formidable' ), |
| 1757 | 1645 | __( '35-44', 'formidable' ), |
| @@ -1759,74 +1647,36 @@ | ||
| 1759 | 1647 | __( '55-64', 'formidable' ), |
| 1760 | 1648 | __( '65 or Above', 'formidable' ), |
| 1761 | 1649 | __( 'Prefer Not to Answer', 'formidable' ), |
| 1762 | 1650 | ); |
| 1763 | - if ( $include_class ) { | |
| 1764 | - $ages['class'] = 'frm-age-opts'; | |
| 1765 | - } | |
| 1766 | 1651 | |
| 1767 | - $prepop[ __( 'Age', 'formidable' ) ] = $ages; | |
| 1768 | - | |
| 1769 | - // Satisfaction. | |
| 1770 | - $satisfaction = array( | |
| 1652 | + $prepop[ __( 'Satisfaction', 'formidable' ) ] = array( | |
| 1653 | + __( 'Very Satisfied', 'formidable' ), | |
| 1654 | + __( 'Satisfied', 'formidable' ), | |
| 1655 | + __( 'Neutral', 'formidable' ), | |
| 1656 | + __( 'Unsatisfied', 'formidable' ), | |
| 1771 | 1657 | __( 'Very Unsatisfied', 'formidable' ), |
| 1772 | - __( 'Unsatisfied', 'formidable' ), | |
| 1773 | - __( 'Neutral', 'formidable' ), | |
| 1774 | - __( 'Satisfied', 'formidable' ), | |
| 1775 | - __( 'Very Satisfied', 'formidable' ), | |
| 1776 | 1658 | __( 'N/A', 'formidable' ), |
| 1777 | 1659 | ); |
| 1778 | - if ( $include_class ) { | |
| 1779 | - $satisfaction['class'] = 'frm-satisfaction-opts'; | |
| 1780 | - } | |
| 1781 | 1660 | |
| 1782 | - $prepop[ __( 'Satisfaction', 'formidable' ) ] = $satisfaction; | |
| 1783 | - | |
| 1784 | - // Importance. | |
| 1785 | - $importance = array( | |
| 1661 | + $prepop[ __( 'Importance', 'formidable' ) ] = array( | |
| 1662 | + __( 'Very Important', 'formidable' ), | |
| 1663 | + __( 'Important', 'formidable' ), | |
| 1664 | + __( 'Neutral', 'formidable' ), | |
| 1665 | + __( 'Somewhat Important', 'formidable' ), | |
| 1786 | 1666 | __( 'Not at all Important', 'formidable' ), |
| 1787 | - __( 'Somewhat Important', 'formidable' ), | |
| 1788 | - __( 'Neutral', 'formidable' ), | |
| 1789 | - __( 'Important', 'formidable' ), | |
| 1790 | - __( 'Very Important', 'formidable' ), | |
| 1791 | 1667 | __( 'N/A', 'formidable' ), |
| 1792 | 1668 | ); |
| 1793 | - if ( $include_class ) { | |
| 1794 | - $importance['class'] = 'frm-importance-opts'; | |
| 1795 | - } | |
| 1796 | 1669 | |
| 1797 | - $prepop[ __( 'Importance', 'formidable' ) ] = $importance; | |
| 1798 | - | |
| 1799 | - // Agreement. | |
| 1800 | - $agreement = array( | |
| 1801 | - __( 'Strongly Disagree', 'formidable' ), | |
| 1802 | - __( 'Disagree', 'formidable' ), | |
| 1803 | - __( 'Neutral', 'formidable' ), | |
| 1670 | + $prepop[ __( 'Agreement', 'formidable' ) ] = array( | |
| 1671 | + __( 'Strongly Agree', 'formidable' ), | |
| 1804 | 1672 | __( 'Agree', 'formidable' ), |
| 1805 | - __( 'Strongly Agree', 'formidable' ), | |
| 1806 | - __( 'N/A', 'formidable' ), | |
| 1807 | - ); | |
| 1808 | - if ( $include_class ) { | |
| 1809 | - $agreement['class'] = 'frm-agreement-opts'; | |
| 1810 | - } | |
| 1811 | - | |
| 1812 | - $prepop[ __( 'Agreement', 'formidable' ) ] = $agreement; | |
| 1813 | - | |
| 1814 | - // Likely. | |
| 1815 | - $likely = array( | |
| 1816 | - __( 'Extremely Unlikely', 'formidable' ), | |
| 1817 | - __( 'Unlikely', 'formidable' ), | |
| 1818 | 1673 | __( 'Neutral', 'formidable' ), |
| 1819 | - __( 'Likely', 'formidable' ), | |
| 1820 | - __( 'Extremely Likely', 'formidable' ), | |
| 1674 | + __( 'Disagree', 'formidable' ), | |
| 1675 | + __( 'Strongly Disagree', 'formidable' ), | |
| 1821 | 1676 | __( 'N/A', 'formidable' ), |
| 1822 | 1677 | ); |
| 1823 | - if ( $include_class ) { | |
| 1824 | - $likely['class'] = 'frm-likely-opts'; | |
| 1825 | - } | |
| 1826 | 1678 | |
| 1827 | - $prepop[ __( 'Likely', 'formidable' ) ] = $likely; | |
| 1828 | - | |
| 1829 | 1679 | $prepop = apply_filters( 'frm_bulk_field_choices', $prepop ); |
| 1830 | 1680 | } |
| 1831 | 1681 | |
| 1832 | 1682 | /** |
| @@ -1860,29 +1710,27 @@ | ||
| 1860 | 1710 | } |
| 1861 | 1711 | |
| 1862 | 1712 | /** |
| 1863 | 1713 | * @since 4.04 |
| 1864 | - * | |
| 1865 | - * @param array $args | |
| 1866 | - * @return void | |
| 1867 | 1714 | */ |
| 1868 | 1715 | public static function show_add_field_buttons( $args ) { |
| 1869 | - $field_key = $args['field_key']; | |
| 1870 | - $field_type = $args['field_type']; | |
| 1871 | - $field_label = FrmAppHelper::icon_by_class( FrmFormsHelper::get_field_link_icon( $field_type ), array( 'echo' => false ) ); | |
| 1872 | - $field_name = FrmFormsHelper::get_field_link_name( $field_type ); | |
| 1873 | - $field_label .= ' <span>' . $field_name . '</span>'; | |
| 1716 | + $field_key = $args['field_key']; | |
| 1717 | + $field_type = $args['field_type']; | |
| 1718 | + $field_label = FrmAppHelper::icon_by_class( FrmFormsHelper::get_field_link_icon( $field_type ), array( 'echo' => false ) ); | |
| 1719 | + $field_name = FrmFormsHelper::get_field_link_name( $field_type ); | |
| 1720 | + $field_label .= ' <span>' . $field_name . '</span>'; | |
| 1874 | 1721 | |
| 1722 | + /* translators: %s: Field name */ | |
| 1723 | + $upgrade_label = sprintf( esc_html__( '%s fields', 'formidable' ), $field_name ); | |
| 1724 | + | |
| 1875 | 1725 | // If the individual field isn't allowed, disable it. |
| 1876 | - $run_filter = true; | |
| 1877 | - $single_no_allow = ' '; | |
| 1878 | - $install_data = ''; | |
| 1879 | - $requires = ''; | |
| 1880 | - $link = isset( $field_type['link'] ) ? esc_url_raw( $field_type['link'] ) : ''; | |
| 1881 | - $has_show_upgrade_class = strpos( $field_type['icon'], ' frm_show_upgrade' ); | |
| 1882 | - $show_upgrade = $has_show_upgrade_class || false !== strpos( $args['no_allow_class'], 'frm_show_upgrade' ); | |
| 1883 | - | |
| 1884 | - if ( $has_show_upgrade_class ) { | |
| 1726 | + $run_filter = true; | |
| 1727 | + $single_no_allow = ' '; | |
| 1728 | + $install_data = ''; | |
| 1729 | + $requires = ''; | |
| 1730 | + $upgrade_message = ''; | |
| 1731 | + $link = isset( $field_type['link'] ) ? esc_url_raw( $field_type['link'] ) : ''; | |
| 1732 | + if ( strpos( $field_type['icon'], ' frm_show_upgrade' ) ) { | |
| 1885 | 1733 | $single_no_allow .= 'frm_show_upgrade'; |
| 1886 | 1734 | $field_type['icon'] = str_replace( ' frm_show_upgrade', '', $field_type['icon'] ); |
| 1887 | 1735 | $run_filter = false; |
| 1888 | 1736 | if ( isset( $field_type['addon'] ) ) { |
| @@ -1895,40 +1743,19 @@ | ||
| 1895 | 1743 | $requires = $field_type['require']; |
| 1896 | 1744 | } |
| 1897 | 1745 | } |
| 1898 | 1746 | |
| 1899 | - $upgrade_label = ''; | |
| 1900 | - $upgrade_message = ''; | |
| 1901 | - if ( $show_upgrade ) { | |
| 1902 | - /* translators: %s: Field name */ | |
| 1903 | - $upgrade_label = sprintf( esc_html__( '%s fields', 'formidable' ), $field_name ); | |
| 1904 | - | |
| 1905 | - if ( isset( $field_type['message'] ) ) { | |
| 1906 | - $upgrade_message = FrmAppHelper::kses( $field_type['message'], array( 'a', 'img' ) ); | |
| 1907 | - } | |
| 1747 | + if ( isset( $field_type['message'] ) ) { | |
| 1748 | + $upgrade_message = FrmAppHelper::kses( $field_type['message'], array( 'a', 'img' ) ); | |
| 1908 | 1749 | } |
| 1909 | 1750 | |
| 1910 | - $li_params = array( | |
| 1911 | - 'class' => 'frmbutton frm6 ' . $args['no_allow_class'] . $single_no_allow . ' frm_t' . str_replace( '|', '-', $field_key ), | |
| 1912 | - 'id' => $field_key, | |
| 1913 | - 'data-upgrade' => $upgrade_label, | |
| 1914 | - 'data-link' => $link, | |
| 1915 | - 'data-medium' => 'builder', | |
| 1916 | - 'data-oneclick' => $install_data, | |
| 1917 | - 'data-content' => $field_key, | |
| 1918 | - 'data-requires' => $requires, | |
| 1919 | - ); | |
| 1920 | - | |
| 1921 | - if ( $upgrade_message ) { | |
| 1922 | - $li_params['data-message'] = $upgrade_message; | |
| 1923 | - } | |
| 1924 | 1751 | ?> |
| 1925 | - <li <?php FrmAppHelper::array_to_html_params( $li_params, true ); ?>> | |
| 1752 | + <li class="frmbutton <?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 ); ?>"> | |
| 1926 | 1753 | <?php |
| 1927 | 1754 | if ( $run_filter ) { |
| 1928 | 1755 | $field_label = apply_filters( 'frmpro_field_links', $field_label, $args['id'], $field_key ); |
| 1929 | 1756 | } |
| 1930 | - echo FrmAppHelper::kses( $field_label, array( 'a', 'i', 'span', 'use', 'svg' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 1757 | + echo FrmAppHelper::kses( $field_label, array( 'a', 'i', 'span', 'use', 'svg' ) ); // WPCS: XSS ok. | |
| 1931 | 1758 | ?> |
| 1932 | 1759 | </li> |
| 1933 | 1760 | <?php |
| 1934 | 1761 | } |
| @@ -1933,173 +1760,8 @@ | ||
| 1933 | 1760 | <?php |
| 1934 | 1761 | } |
| 1935 | 1762 | |
| 1936 | 1763 | /** |
| 1937 | - * Shows Display format option. | |
| 1938 | - * | |
| 1939 | - * @since 5.0.04 | |
| 1940 | - * | |
| 1941 | - * @param array $field Field data. | |
| 1942 | - */ | |
| 1943 | - public static function show_radio_display_format( $field ) { | |
| 1944 | - $options = self::get_display_format_options( $field ); | |
| 1945 | - | |
| 1946 | - $args = self::get_display_format_args( $field, $options ); | |
| 1947 | - | |
| 1948 | - include FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/radio-display-format.php'; | |
| 1949 | - } | |
| 1950 | - | |
| 1951 | - /** | |
| 1952 | - * Creates an array that contains variables used for display format options setting. | |
| 1953 | - * | |
| 1954 | - * @since 6.3.2 | |
| 1955 | - * | |
| 1956 | - * @param array $field The field. | |
| 1957 | - * | |
| 1958 | - * @return array | |
| 1959 | - */ | |
| 1960 | - public static function get_display_format_options( $field ) { | |
| 1961 | - $options = array( | |
| 1962 | - '0' => array( | |
| 1963 | - 'text' => __( 'Simple', 'formidable' ), | |
| 1964 | - 'svg' => 'frm_simple_radio', | |
| 1965 | - ), | |
| 1966 | - '1' => array( | |
| 1967 | - 'text' => __( 'Images', 'formidable' ), | |
| 1968 | - 'svg' => 'frm_image_as_option', | |
| 1969 | - 'addon' => 'pro', | |
| 1970 | - 'upgrade' => __( 'Image Options', 'formidable' ), | |
| 1971 | - '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" />', | |
| 1972 | - 'content' => 'image-options', | |
| 1973 | - ), | |
| 1974 | - 'buttons' => array( | |
| 1975 | - 'text' => __( 'Buttons', 'formidable' ), | |
| 1976 | - 'svg' => 'frm_button_as_option', | |
| 1977 | - 'addon' => 'surveys', | |
| 1978 | - 'upgrade' => __( 'Button Options', 'formidable' ), | |
| 1979 | - 'message' => __( 'Show buttons for radio buttons or check boxes. This is ideal for polls, surveys, segmenting questionnaires and more.', 'formidable' ), | |
| 1980 | - 'content' => 'button-options', | |
| 1981 | - ), | |
| 1982 | - ); | |
| 1983 | - | |
| 1984 | - /** | |
| 1985 | - * Allows modifying the options of Display format setting of Radio field. | |
| 1986 | - * | |
| 1987 | - * @since 5.0.04 | |
| 1988 | - * | |
| 1989 | - * @param array $options Options. | |
| 1990 | - * @param array $field | |
| 1991 | - */ | |
| 1992 | - $options = apply_filters( 'frm_' . $field['type'] . '_display_format_options', $options, $field ); | |
| 1993 | - | |
| 1994 | - return $options; | |
| 1995 | - } | |
| 1996 | - | |
| 1997 | - /** | |
| 1998 | - * Gets display format arguments to pass to the images_dropdown() method. | |
| 1999 | - * | |
| 2000 | - * @since 5.0.04 | |
| 2001 | - * | |
| 2002 | - * @param array $field Field data. | |
| 2003 | - * @param array $options Options array. | |
| 2004 | - * @return array | |
| 2005 | - */ | |
| 2006 | - public static function get_display_format_args( $field, $options ) { | |
| 2007 | - $args = array( | |
| 2008 | - 'selected' => '0', | |
| 2009 | - 'options' => array(), | |
| 2010 | - 'name' => 'field_options[image_options_' . $field['id'] . ']', | |
| 2011 | - 'input_attrs' => array( | |
| 2012 | - 'class' => 'frm_toggle_image_options', | |
| 2013 | - ), | |
| 2014 | - ); | |
| 2015 | - | |
| 2016 | - self::fill_image_setting_options( $options, $args ); | |
| 2017 | - | |
| 2018 | - /** | |
| 2019 | - * Allows modifying the arguments of Display format setting of Radio field. | |
| 2020 | - * | |
| 2021 | - * @since 5.0.04 | |
| 2022 | - * | |
| 2023 | - * @param array $args Arguments. | |
| 2024 | - * @param array $method_args The arguments from the method. Contains `field`, `options`. | |
| 2025 | - */ | |
| 2026 | - return apply_filters( 'frm_' . $field['type'] . '_display_format_args', $args, compact( 'field', 'options' ) ); | |
| 2027 | - } | |
| 2028 | - | |
| 2029 | - /** | |
| 2030 | - * @since 5.0.04 | |
| 2031 | - */ | |
| 2032 | - private static function fill_image_setting_options( $options, &$args ) { | |
| 2033 | - foreach ( $options as $key => $option ) { | |
| 2034 | - $args['options'][ $key ] = $option; | |
| 2035 | - | |
| 2036 | - if ( ! empty( $option['addon'] ) ) { | |
| 2037 | - $args['options'][ $key ]['custom_attrs'] = self::fill_image_setting_addon_link( $option ); | |
| 2038 | - } | |
| 2039 | - | |
| 2040 | - unset( $args['options'][ $key ]['addon'] ); | |
| 2041 | - $fill = array( 'upgrade', 'message', 'content' ); | |
| 2042 | - foreach ( $fill as $f ) { | |
| 2043 | - unset( $args['options'][ $key ][ $f ], $f ); | |
| 2044 | - } | |
| 2045 | - } | |
| 2046 | - } | |
| 2047 | - | |
| 2048 | - /** | |
| 2049 | - * @since 5.0.04 | |
| 2050 | - * | |
| 2051 | - * @return array | |
| 2052 | - */ | |
| 2053 | - private static function fill_image_setting_addon_link( $option ) { | |
| 2054 | - $custom_attrs = array( | |
| 2055 | - 'class' => 'frm_noallow frm_show_upgrade', | |
| 2056 | - 'data-medium' => 'builder', | |
| 2057 | - ); | |
| 2058 | - | |
| 2059 | - // translators: Add-on name. | |
| 2060 | - $custom_attrs['data-upgrade'] = sprintf( __( 'Formidable %s', 'formidable' ), ucwords( $option['addon'] ) ); | |
| 2061 | - | |
| 2062 | - $fill = array( 'upgrade', 'message', 'content' ); | |
| 2063 | - foreach ( $fill as $f ) { | |
| 2064 | - if ( isset( $option[ $f ] ) ) { | |
| 2065 | - $custom_attrs[ 'data-' . $f ] = $option[ $f ]; | |
| 2066 | - } | |
| 2067 | - } | |
| 2068 | - | |
| 2069 | - if ( 'pro' === $option['addon'] ) { | |
| 2070 | - return $custom_attrs; | |
| 2071 | - } | |
| 2072 | - | |
| 2073 | - $upgrading = FrmAddonsController::install_link( $option['addon'] ); | |
| 2074 | - if ( isset( $upgrading['url'] ) ) { | |
| 2075 | - $install_data = wp_json_encode( $upgrading ); | |
| 2076 | - } else { | |
| 2077 | - $install_data = ''; | |
| 2078 | - } | |
| 2079 | - | |
| 2080 | - $custom_attrs['data-oneclick'] = $install_data; | |
| 2081 | - $custom_attrs['data-requires'] = FrmFormsHelper::get_plan_required( $upgrading ); | |
| 2082 | - | |
| 2083 | - return $custom_attrs; | |
| 2084 | - } | |
| 2085 | - | |
| 2086 | - /** | |
| 2087 | - * Maybe adjust a field value based on type. | |
| 2088 | - * Some types require unserializing an array (@see self::field_type_requires_unserialize). | |
| 2089 | - * | |
| 2090 | - * @since 6.2 | |
| 2091 | - * | |
| 2092 | - * @param mixed $value | |
| 2093 | - * @param string $field_type | |
| 2094 | - * @return void | |
| 2095 | - */ | |
| 2096 | - public static function prepare_field_value( &$value, $field_type ) { | |
| 2097 | - $field_object = FrmFieldFactory::get_field_type( $field_type ); | |
| 2098 | - $value = $field_object->maybe_decode_value( $value ); | |
| 2099 | - } | |
| 2100 | - | |
| 2101 | - /** | |
| 2102 | 1764 | * @deprecated 4.0 |
| 2103 | 1765 | */ |
| 2104 | 1766 | public static function show_icon_link_js( $atts ) { |
| 2105 | 1767 | _deprecated_function( __METHOD__, '4.0' ); |
| @@ -2158,13 +1820,13 @@ | ||
| 2158 | 1820 | /** |
| 2159 | 1821 | * @deprecated 3.0 |
| 2160 | 1822 | * @codeCoverageIgnore |
| 2161 | 1823 | * |
| 2162 | - * @param string $html | |
| 2163 | - * @param array $field | |
| 2164 | - * @param array $errors | |
| 2165 | - * @param object|false $form | |
| 2166 | - * @param array $args | |
| 1824 | + * @param string $html | |
| 1825 | + * @param array $field | |
| 1826 | + * @param array $errors | |
| 1827 | + * @param object $form | |
| 1828 | + * @param array $args | |
| 2167 | 1829 | * |
| 2168 | 1830 | * @return string |
| 2169 | 1831 | */ |
| 2170 | 1832 | public static function replace_shortcodes( $html, $field, $errors = array(), $form = false, $args = array() ) { |
| @@ -2179,13 +1841,10 @@ | ||
| 2179 | 1841 | return FrmDeprecated::get_default_field_opts( $type, $field, $limit ); |
| 2180 | 1842 | } |
| 2181 | 1843 | |
| 2182 | 1844 | /** |
| 2183 | - * @deprecated 2.02.07 This is still referenced in the Highrise add on as of v1.06. | |
| 1845 | + * @deprecated 2.02.07 | |
| 2184 | 1846 | * @codeCoverageIgnore |
| 2185 | - * | |
| 2186 | - * @param array $args | |
| 2187 | - * @return string | |
| 2188 | 1847 | */ |
| 2189 | 1848 | public static function dropdown_categories( $args ) { |
| 2190 | 1849 | return FrmDeprecated::dropdown_categories( $args ); |
| 2191 | 1850 | } |