| @@ -67,8 +67,9 @@ | ||
| 67 | 67 | $add_html = array(); |
| 68 | 68 | self::add_html_attr( $args['onchange'], 'onchange', $add_html ); |
| 69 | 69 | self::add_html_attr( $args['class'], 'class', $add_html ); |
| 70 | 70 | |
| 71 | + // phpcs:disable Generic.WhiteSpace.ScopeIndent | |
| 71 | 72 | ?> |
| 72 | 73 | <select name="<?php echo esc_attr( $field_name ); ?>" |
| 73 | 74 | id="<?php echo esc_attr( $args['field_id'] ); ?>" |
| 74 | 75 | <?php echo wp_strip_all_tags( implode( ' ', $add_html ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>> |
| @@ -81,8 +82,9 @@ | ||
| 81 | 82 | </option> |
| 82 | 83 | <?php } ?> |
| 83 | 84 | </select> |
| 84 | 85 | <?php |
| 86 | + // phpcs:enable Generic.WhiteSpace.ScopeIndent | |
| 85 | 87 | } |
| 86 | 88 | |
| 87 | 89 | /** |
| 88 | 90 | * @since 2.0.6 |
| @@ -94,9 +96,9 @@ | ||
| 94 | 96 | * @return void |
| 95 | 97 | */ |
| 96 | 98 | public static function add_html_attr( $class, $param, &$add_html ) { |
| 97 | 99 | if ( $class ) { |
| 98 | - $add_html[ $param ] = sanitize_title( $param ) . '="' . esc_attr( trim( sanitize_text_field( $class ) ) ) . '"'; | |
| 100 | + $add_html[ $param ] = sanitize_title( $param ) . '="' . esc_attr( sanitize_text_field( $class ) ) . '"'; | |
| 99 | 101 | } |
| 100 | 102 | } |
| 101 | 103 | |
| 102 | 104 | /** |
| @@ -153,8 +155,9 @@ | ||
| 153 | 155 | $name = $selected === false ? __( 'Switch Form', 'formidable' ) : $selected; |
| 154 | 156 | $name = '' === $name || is_null( $name ) ? self::get_no_title_text() : strip_tags( $name ); |
| 155 | 157 | $truncated_name = FrmAppHelper::truncate( $name, 25 ); |
| 156 | 158 | |
| 159 | + // phpcs:disable Generic.WhiteSpace.ScopeIndent | |
| 157 | 160 | if ( count( $forms ) < 2 ) { |
| 158 | 161 | ?> |
| 159 | 162 | <div id="frm_bs_dropdown"> |
| 160 | 163 | <h1> |
| @@ -207,9 +210,9 @@ | ||
| 207 | 210 | $args['form'] = $form->id; |
| 208 | 211 | } |
| 209 | 212 | |
| 210 | 213 | $url = isset( $base ) ? add_query_arg( $args, $base ) : add_query_arg( $args ); |
| 211 | - $form_name = empty( $form->name ) ? self::get_no_title_text() : $form->name; | |
| 214 | + $form_name = ! empty( $form->name ) ? $form->name : self::get_no_title_text(); | |
| 212 | 215 | ?> |
| 213 | 216 | <li class="frm-dropdown-form"> |
| 214 | 217 | <a href="<?php echo esc_url( $url ); ?>" tabindex="-1" class="frm-justify-between"> |
| 215 | 218 | <?php echo esc_html( $form_name ); ?> |
| @@ -231,8 +234,9 @@ | ||
| 231 | 234 | ?> |
| 232 | 235 | </ul> |
| 233 | 236 | </div> |
| 234 | 237 | <?php |
| 238 | + // phpcs:enable Generic.WhiteSpace.ScopeIndent | |
| 235 | 239 | } |
| 236 | 240 | |
| 237 | 241 | /** |
| 238 | 242 | * @param string $col |
| @@ -414,11 +418,9 @@ | ||
| 414 | 418 | * @return array |
| 415 | 419 | */ |
| 416 | 420 | public static function fill_default_opts( $values, $record, $post_values ) { // phpcs:ignore SlevomatCodingStandard.Complexity.Cognitive.ComplexityTooHigh |
| 417 | 421 | |
| 418 | - $defaults = self::get_default_opts(); | |
| 419 | - | |
| 420 | - foreach ( $defaults as $var => $default ) { | |
| 422 | + foreach ( self::get_default_opts() as $var => $default ) { | |
| 421 | 423 | if ( is_array( $default ) ) { |
| 422 | 424 | if ( ! isset( $values[ $var ] ) ) { |
| 423 | 425 | $values[ $var ] = $record && isset( $record->options[ $var ] ) ? $record->options[ $var ] : array(); |
| 424 | 426 | } |
| @@ -481,11 +483,9 @@ | ||
| 481 | 483 | * |
| 482 | 484 | * @return void |
| 483 | 485 | */ |
| 484 | 486 | public static function fill_form_options( &$options, $values ) { |
| 485 | - $defaults = self::get_default_opts(); | |
| 486 | - | |
| 487 | - foreach ( $defaults as $var => $default ) { | |
| 487 | + foreach ( self::get_default_opts() as $var => $default ) { | |
| 488 | 488 | $options[ $var ] = $values['options'][ $var ] ?? $default; |
| 489 | 489 | unset( $var, $default ); |
| 490 | 490 | } |
| 491 | 491 | } |
| @@ -673,9 +673,12 @@ | ||
| 673 | 673 | |
| 674 | 674 | /** |
| 675 | 675 | * @since 4.0 |
| 676 | 676 | * |
| 677 | - * @param array $args | |
| 677 | + * @param array $args Includes 'id', 'key', 'name', 'type' and 'class'. Optionally 'id_label' | |
| 678 | + * and 'key_label' to show something other than the id or key, and | |
| 679 | + * 'name_suffix'/'key_suffix' for text appended after the name or key is | |
| 680 | + * truncated, so a shortcode option like ' show=first' survives the truncation. | |
| 678 | 681 | * |
| 679 | 682 | * @return void |
| 680 | 683 | */ |
| 681 | 684 | public static function insert_opt_html( $args ) { |
| @@ -698,10 +701,12 @@ | ||
| 698 | 701 | if ( 'url' === $args['type'] ) { |
| 699 | 702 | $class .= ' frm_insert_url'; |
| 700 | 703 | } |
| 701 | 704 | |
| 702 | - $truncated_name = FrmAppHelper::truncate( $args['name'], 60 ); | |
| 705 | + $full_name = $args['name'] . ( $args['name_suffix'] ?? '' ); | |
| 706 | + $truncated_name = FrmAppHelper::truncate( $args['name'], 60 ) . ( $args['name_suffix'] ?? '' ); | |
| 703 | 707 | |
| 708 | + // phpcs:disable Generic.WhiteSpace.ScopeIndent | |
| 704 | 709 | ?> |
| 705 | 710 | <li class="<?php echo esc_attr( $class ); ?>"> |
| 706 | 711 | <a href="javascript:void(0)" class="frmids frm_insert_code" data-code="<?php echo esc_attr( $args['id'] ); ?>"> |
| 707 | 712 | <?php |
| @@ -708,11 +713,15 @@ | ||
| 708 | 713 | if ( isset( $field['icon'] ) ) { |
| 709 | 714 | FrmAppHelper::icon_by_class( $field['icon'], array( 'aria-hidden' => 'true' ) ); |
| 710 | 715 | } |
| 711 | 716 | |
| 712 | - echo esc_html( $truncated_name ); | |
| 717 | + printf( | |
| 718 | + '<span title="%s">%s</span>', | |
| 719 | + esc_attr( $full_name ), | |
| 720 | + esc_html( $truncated_name ) | |
| 721 | + ); | |
| 713 | 722 | ?> |
| 714 | - <span>[<?php echo esc_attr( $args['id_label'] ?? $args['id'] ); ?>]</span> | |
| 723 | + <span>[<?php echo esc_html( $args['id_label'] ?? $args['id'] ); ?>]</span> | |
| 715 | 724 | </a> |
| 716 | 725 | <a href="javascript:void(0)" class="frmkeys frm_insert_code frm_hidden" data-code="<?php echo esc_attr( $args['key'] ); ?>"> |
| 717 | 726 | <?php |
| 718 | 727 | if ( isset( $field['icon'] ) ) { |
| @@ -718,14 +727,19 @@ | ||
| 718 | 727 | if ( isset( $field['icon'] ) ) { |
| 719 | 728 | FrmAppHelper::icon_by_class( $field['icon'], array( 'aria-hidden' => 'true' ) ); |
| 720 | 729 | } |
| 721 | 730 | |
| 722 | - echo esc_html( $truncated_name ); | |
| 731 | + printf( | |
| 732 | + '<span title="%s">%s</span>', | |
| 733 | + esc_attr( $full_name ), | |
| 734 | + esc_html( $truncated_name ) | |
| 735 | + ); | |
| 723 | 736 | ?> |
| 724 | - <span>[<?php echo esc_attr( FrmAppHelper::truncate( $args['key_label'] ?? $args['key'], 7 ) ); ?>]</span> | |
| 737 | + <span>[<?php echo esc_html( FrmAppHelper::truncate( $args['key_label'] ?? $args['key'], 7 ) . ( $args['key_suffix'] ?? '' ) ); ?>]</span> | |
| 725 | 738 | </a> |
| 726 | 739 | </li> |
| 727 | 740 | <?php |
| 741 | + // phpcs:enable Generic.WhiteSpace.ScopeIndent | |
| 728 | 742 | } |
| 729 | 743 | |
| 730 | 744 | /** |
| 731 | 745 | * Store and re-use field selection data for use when outputting shortcodes options in shortcode pop up. |
| @@ -759,20 +773,22 @@ | ||
| 759 | 773 | |
| 760 | 774 | $args = array_merge( $defaults, $args ); |
| 761 | 775 | $has_tooltip = ! empty( $args['title'] ); |
| 762 | 776 | |
| 777 | + // phpcs:disable Generic.WhiteSpace.ScopeIndent | |
| 763 | 778 | ?> |
| 764 | 779 | <li class="<?php echo esc_attr( $args['class'] ); ?>"> |
| 765 | 780 | <a href="javascript:void(0)" class="frm_insert_code <?php echo $has_tooltip ? 'frm_help' : ''; ?>" |
| 766 | 781 | <?php echo $has_tooltip ? 'title="' . esc_attr( $args['title'] ) . '"' : ''; ?> |
| 767 | 782 | data-code="<?php echo esc_attr( $args['code'] ); ?>"> |
| 768 | - <?php echo esc_attr( FrmAppHelper::truncate( $args['label'], 60 ) ); ?> | |
| 783 | + <?php echo esc_html( FrmAppHelper::truncate( $args['label'], 60 ) ); ?> | |
| 769 | 784 | <span> |
| 770 | - [<?php echo esc_attr( FrmAppHelper::truncate( $args['code'], 10 ) ); ?>] | |
| 785 | + [<?php echo esc_html( FrmAppHelper::truncate( $args['code'], 10 ) ); ?>] | |
| 771 | 786 | </span> |
| 772 | 787 | </a> |
| 773 | 788 | </li> |
| 774 | 789 | <?php |
| 790 | + // phpcs:enable Generic.WhiteSpace.ScopeIndent | |
| 775 | 791 | } |
| 776 | 792 | |
| 777 | 793 | /** |
| 778 | 794 | * Some field types in add-ons may have been added with only |
| @@ -878,9 +894,9 @@ | ||
| 878 | 894 | |
| 879 | 895 | FrmField::create( $end_section_values ); |
| 880 | 896 | |
| 881 | 897 | if ( $move === 'move' ) { |
| 882 | - // bump the order of current field unless we're at the end of the form | |
| 898 | + // Bump the order of current field unless we're at the end of the form | |
| 883 | 899 | FrmField::update( $field->id, array( 'field_order' => $field->field_order + 2 ) ); |
| 884 | 900 | } |
| 885 | 901 | |
| 886 | 902 | $add_order += 2; |
| @@ -909,14 +925,14 @@ | ||
| 909 | 925 | $replace_with = $form->name; |
| 910 | 926 | } elseif ( $code === 'form_description' ) { |
| 911 | 927 | $replace_with = FrmAppHelper::use_wpautop( $form->description ); |
| 912 | 928 | } elseif ( $code === 'entry_key' && ! empty( $_GET ) && isset( $_GET['entry'] ) ) { |
| 913 | - $replace_with = FrmAppHelper::simple_get( 'entry' ); | |
| 929 | + $replace_with = FrmAppHelper::simple_get( 'entry', 'sanitize_title' ); | |
| 914 | 930 | } else { |
| 915 | 931 | $replace_with = ''; |
| 916 | 932 | } |
| 917 | 933 | |
| 918 | - FrmShortcodeHelper::remove_inline_conditions( ( FrmAppHelper::is_true( $show ) && $replace_with != '' ), $code, $replace_with, $html ); // phpcs:ignore Universal.Operators.StrictComparisons, SlevomatCodingStandard.Files.LineLength.LineTooLong | |
| 934 | + FrmShortcodeHelper::remove_inline_conditions( FrmAppHelper::is_true( $show ) && $replace_with != '', $code, $replace_with, $html ); // phpcs:ignore Universal.Operators.StrictComparisons, SlevomatCodingStandard.Files.LineLength.LineTooLong | |
| 919 | 935 | } |
| 920 | 936 | |
| 921 | 937 | // Replace [form_key]. |
| 922 | 938 | $html = str_replace( '[form_key]', $form->form_key, $html ); |
| @@ -945,9 +961,9 @@ | ||
| 945 | 961 | $html = preg_replace( '/(\[if\s+start_over\])(.*?)(\[\/if\s+start_over\])/mis', '', $html ); |
| 946 | 962 | } |
| 947 | 963 | |
| 948 | 964 | if ( apply_filters( 'frm_do_html_shortcodes', true ) ) { |
| 949 | - $html = do_shortcode( $html ); | |
| 965 | + return do_shortcode( $html ); | |
| 950 | 966 | } |
| 951 | 967 | |
| 952 | 968 | return $html; |
| 953 | 969 | } |
| @@ -1030,9 +1046,9 @@ | ||
| 1030 | 1046 | * @return bool |
| 1031 | 1047 | */ |
| 1032 | 1048 | private static function form_should_be_inline_and_missing_class( $form ) { |
| 1033 | 1049 | if ( isset( $form['form_class'] ) && str_contains( ' ' . $form['form_class'] . ' ', ' frm_inline_form ' ) ) { |
| 1034 | - // not missing class, avoid adding it twice. | |
| 1050 | + // Not missing class, avoid adding it twice. | |
| 1035 | 1051 | return false; |
| 1036 | 1052 | } |
| 1037 | 1053 | return ! empty( $form['submit_html'] ) && str_contains( $form['submit_html'], 'frm_inline_submit' ); |
| 1038 | 1054 | } |
| @@ -1096,9 +1112,9 @@ | ||
| 1096 | 1112 | |
| 1097 | 1113 | /** |
| 1098 | 1114 | * @param array|bool|int|object|string $form |
| 1099 | 1115 | * |
| 1100 | - * @return string | |
| 1116 | + * @return int|string | |
| 1101 | 1117 | */ |
| 1102 | 1118 | public static function get_form_style( $form ) { |
| 1103 | 1119 | $style = 1; |
| 1104 | 1120 | |
| @@ -1106,9 +1122,9 @@ | ||
| 1106 | 1122 | return $style; |
| 1107 | 1123 | } |
| 1108 | 1124 | |
| 1109 | 1125 | if ( is_object( $form ) && $form->parent_form_id ) { |
| 1110 | - // get the parent form if this is a child | |
| 1126 | + // Get the parent form if this is a child | |
| 1111 | 1127 | $form = $form->parent_form_id; |
| 1112 | 1128 | } elseif ( is_array( $form ) && ! empty( $form['parent_form_id'] ) ) { |
| 1113 | 1129 | $form = $form['parent_form_id']; |
| 1114 | 1130 | } elseif ( is_array( $form ) && isset( $form['custom_style'] ) ) { |
| @@ -1133,13 +1149,13 @@ | ||
| 1133 | 1149 | */ |
| 1134 | 1150 | public static function show_errors( $args ) { |
| 1135 | 1151 | $invalid_msg = self::get_invalid_error_message( $args ); |
| 1136 | 1152 | |
| 1137 | - if ( ! $invalid_msg ) { | |
| 1138 | - $show_img = false; | |
| 1139 | - } else { | |
| 1153 | + if ( $invalid_msg ) { | |
| 1140 | 1154 | echo wp_kses_post( $invalid_msg ); |
| 1141 | 1155 | $show_img = true; |
| 1156 | + } else { | |
| 1157 | + $show_img = false; | |
| 1142 | 1158 | } |
| 1143 | 1159 | |
| 1144 | 1160 | self::show_error( |
| 1145 | 1161 | array( |
| @@ -1161,9 +1177,9 @@ | ||
| 1161 | 1177 | * |
| 1162 | 1178 | * @return void |
| 1163 | 1179 | */ |
| 1164 | 1180 | public static function show_error( $args ) { |
| 1165 | - // remove any blank messages | |
| 1181 | + // Remove any blank messages | |
| 1166 | 1182 | $args['errors'] = array_filter( (array) $args['errors'] ); |
| 1167 | 1183 | |
| 1168 | 1184 | $line_break_first = $args['show_img']; |
| 1169 | 1185 | |
| @@ -1243,9 +1259,9 @@ | ||
| 1243 | 1259 | ); |
| 1244 | 1260 | } else { |
| 1245 | 1261 | $actions['duplicate'] = array( |
| 1246 | 1262 | 'url' => wp_nonce_url( $duplicate_link ), |
| 1247 | - 'label' => __( 'Duplicate Form', 'formidable' ), | |
| 1263 | + 'label' => __( 'Duplicate', 'formidable' ), | |
| 1248 | 1264 | 'icon' => 'frmfont frm_clone_icon', |
| 1249 | 1265 | ); |
| 1250 | 1266 | } |
| 1251 | 1267 | |
| @@ -1342,30 +1358,30 @@ | ||
| 1342 | 1358 | */ |
| 1343 | 1359 | public static function format_link_html( $link_details, $length = 'label' ) { |
| 1344 | 1360 | $link = ''; |
| 1345 | 1361 | |
| 1346 | - if ( $link_details ) { | |
| 1347 | - $link = '<a href="' . esc_url( $link_details['url'] ) . '" class="frm-trash-link"'; | |
| 1362 | + if ( ! $link_details ) { | |
| 1363 | + return $link; | |
| 1364 | + } | |
| 1348 | 1365 | |
| 1349 | - if ( isset( $link_details['data'] ) ) { | |
| 1350 | - foreach ( $link_details['data'] as $data => $value ) { | |
| 1351 | - $link .= ' data-' . esc_attr( $data ) . '="' . esc_attr( $value ) . '"'; | |
| 1352 | - } | |
| 1353 | - } elseif ( isset( $link_details['confirm'] ) ) { | |
| 1354 | - $link .= ' onclick="return confirm(\'' . esc_attr( $link_details['confirm'] ) . '\')"'; | |
| 1366 | + $link = '<a href="' . esc_url( $link_details['url'] ) . '" class="frm-trash-link"'; | |
| 1367 | + | |
| 1368 | + if ( isset( $link_details['data'] ) ) { | |
| 1369 | + foreach ( $link_details['data'] as $data => $value ) { | |
| 1370 | + $link .= ' data-' . esc_attr( $data ) . '="' . esc_attr( $value ) . '"'; | |
| 1355 | 1371 | } |
| 1372 | + } elseif ( isset( $link_details['confirm'] ) ) { | |
| 1373 | + $link .= ' onclick="return confirm(\'' . esc_attr( $link_details['confirm'] ) . '\')"'; | |
| 1374 | + } | |
| 1356 | 1375 | |
| 1357 | - $label = $link_details[ $length ] ?? $link_details['label']; | |
| 1376 | + $label = $link_details[ $length ] ?? $link_details['label']; | |
| 1358 | 1377 | |
| 1359 | - if ( $length === 'icon' && isset( $link_details[ $length ] ) ) { | |
| 1360 | - $label = '<span class="' . $label . '" title="' . esc_attr( $link_details['label'] ) . '" aria-hidden="true"></span>'; | |
| 1361 | - $link .= ' aria-label="' . esc_attr( $link_details['label'] ) . '"'; | |
| 1362 | - } | |
| 1363 | - | |
| 1364 | - $link .= '>' . $label . '</a>'; | |
| 1378 | + if ( $length === 'icon' && isset( $link_details[ $length ] ) ) { | |
| 1379 | + $label = '<span class="' . $label . '" title="' . esc_attr( $link_details['label'] ) . '" aria-hidden="true"></span>'; | |
| 1380 | + $link .= ' aria-label="' . esc_attr( $link_details['label'] ) . '"'; | |
| 1365 | 1381 | } |
| 1366 | 1382 | |
| 1367 | - return $link; | |
| 1383 | + return $link . ( '>' . $label . '</a>' ); | |
| 1368 | 1384 | } |
| 1369 | 1385 | |
| 1370 | 1386 | /** |
| 1371 | 1387 | * @since 3.0 |
| @@ -1519,9 +1535,9 @@ | ||
| 1519 | 1535 | 'trash' => __( 'Trash', 'formidable' ), |
| 1520 | 1536 | 'publish' => __( 'Published', 'formidable' ), |
| 1521 | 1537 | ); |
| 1522 | 1538 | |
| 1523 | - if ( ! in_array( $status, array_keys( $nice_names ), true ) ) { | |
| 1539 | + if ( ! array_key_exists( $status, $nice_names ) ) { | |
| 1524 | 1540 | $status = 'publish'; |
| 1525 | 1541 | } |
| 1526 | 1542 | |
| 1527 | 1543 | return $nice_names[ $status ]; |
| @@ -1603,10 +1619,11 @@ | ||
| 1603 | 1619 | |
| 1604 | 1620 | if ( $bg_color && $atts['bg'] ) { |
| 1605 | 1621 | echo ' style="background-color:' . esc_attr( $bg_color ) . '"'; |
| 1606 | 1622 | } |
| 1623 | + | |
| 1607 | 1624 | echo '>'; |
| 1608 | - FrmAppHelper::icon_by_class( 'frmfont frm_' . $icon_name . '_icon' ); | |
| 1625 | + FrmAppHelper::icon_by_class( 'frmfont frm_' . $icon_name . '_icon' ); | |
| 1609 | 1626 | echo '</span>'; |
| 1610 | 1627 | } |
| 1611 | 1628 | |
| 1612 | 1629 | /** |
| @@ -1693,8 +1710,9 @@ | ||
| 1693 | 1710 | if ( ! $requires ) { |
| 1694 | 1711 | return; |
| 1695 | 1712 | } |
| 1696 | 1713 | |
| 1714 | + // phpcs:disable Generic.WhiteSpace.ScopeIndent | |
| 1697 | 1715 | ?> |
| 1698 | 1716 | <p class="frm_plan_required"> |
| 1699 | 1717 | <?php esc_html_e( 'Plan required:', 'formidable' ); ?> |
| 1700 | 1718 | <a href="<?php echo esc_url( $link ); ?>" target="_blank" rel="noopener"> |
| @@ -1701,8 +1719,9 @@ | ||
| 1701 | 1719 | <?php echo esc_html( $requires ); ?> |
| 1702 | 1720 | </a> |
| 1703 | 1721 | </p> |
| 1704 | 1722 | <?php |
| 1723 | + // phpcs:enable Generic.WhiteSpace.ScopeIndent | |
| 1705 | 1724 | } |
| 1706 | 1725 | |
| 1707 | 1726 | /** |
| 1708 | 1727 | * @since 4.0 |
| @@ -1738,9 +1757,9 @@ | ||
| 1738 | 1757 | * @return string The updated package name. |
| 1739 | 1758 | */ |
| 1740 | 1759 | public static function convert_legacy_package_names( $package_name ) { |
| 1741 | 1760 | if ( in_array( $package_name, array( 'Creator', 'Personal' ), true ) ) { |
| 1742 | - $package_name = 'Plus'; | |
| 1761 | + return 'Plus'; | |
| 1743 | 1762 | } |
| 1744 | 1763 | |
| 1745 | 1764 | return $package_name; |
| 1746 | 1765 | } |
| @@ -1766,9 +1785,9 @@ | ||
| 1766 | 1785 | $license_types = array_merge( array( 'free', 'Personal', 'Creator' ), $license_types ); |
| 1767 | 1786 | } |
| 1768 | 1787 | |
| 1769 | 1788 | if ( $args['case_lower'] ) { |
| 1770 | - $license_types = array_map( 'strtolower', $license_types ); | |
| 1789 | + return array_map( 'strtolower', $license_types ); | |
| 1771 | 1790 | } |
| 1772 | 1791 | |
| 1773 | 1792 | return $license_types; |
| 1774 | 1793 | } |
| @@ -1836,10 +1855,9 @@ | ||
| 1836 | 1855 | } |
| 1837 | 1856 | |
| 1838 | 1857 | parse_str( $redirect_components['query'], $redirect_params ); |
| 1839 | 1858 | $redirect_param_names = array_keys( $redirect_params ); |
| 1840 | - $reserved_words = self::reserved_words(); | |
| 1841 | - $unsafe_params_in_redirect = array_intersect( $redirect_param_names, $reserved_words ); | |
| 1859 | + $unsafe_params_in_redirect = array_intersect( $redirect_param_names, self::reserved_words() ); | |
| 1842 | 1860 | |
| 1843 | 1861 | return array_values( $unsafe_params_in_redirect ); |
| 1844 | 1862 | } |
| 1845 | 1863 | |
| @@ -1852,17 +1870,18 @@ | ||
| 1852 | 1870 | * |
| 1853 | 1871 | * @return bool|string A string with an unsafe param message or false. |
| 1854 | 1872 | */ |
| 1855 | 1873 | private static function create_unsafe_param_warning( $unsafe_params_in_redirect ) { |
| 1856 | - $count = count( $unsafe_params_in_redirect ); | |
| 1857 | - $caution = esc_html__( 'Is this intentional?', 'formidable' ); | |
| 1858 | - $reserved_words_intro = esc_html__( 'See the list of reserved words in WordPress.', 'formidable' ); | |
| 1859 | - $reserved_words_link = '<a href="https://codex.wordpress.org/WordPress_Query_Vars" target="_blank"> ' . $reserved_words_intro . '</a>'; | |
| 1874 | + $count = count( $unsafe_params_in_redirect ); | |
| 1860 | 1875 | |
| 1861 | 1876 | if ( $count === 0 ) { |
| 1862 | 1877 | return false; |
| 1863 | 1878 | } |
| 1864 | 1879 | |
| 1880 | + $caution = esc_html__( 'Is this intentional?', 'formidable' ); | |
| 1881 | + $reserved_words_intro = esc_html__( 'See the list of reserved words in WordPress.', 'formidable' ); | |
| 1882 | + $reserved_words_link = '<a href="https://codex.wordpress.org/WordPress_Query_Vars" target="_blank"> ' . $reserved_words_intro . '</a>'; | |
| 1883 | + | |
| 1865 | 1884 | if ( $count === 1 ) { |
| 1866 | 1885 | /* translators: %s: the name of a single parameter in the redirect URL */ |
| 1867 | 1886 | return sprintf( esc_html__( 'The redirect URL is using the parameter "%s", which is reserved by WordPress. ', 'formidable' ), $unsafe_params_in_redirect[0] ) . $caution . $reserved_words_link; // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong |
| 1868 | 1887 | } |
| @@ -2062,12 +2081,23 @@ | ||
| 2062 | 2081 | if ( ! empty( $frm_vars['inplace_edit'] ) ) { |
| 2063 | 2082 | return true; |
| 2064 | 2083 | } |
| 2065 | 2084 | |
| 2066 | - return self::is_formidable_api_form() || self::is_gutenberg_editor() || self::is_elementor_ajax() || self::is_visual_views_preview(); | |
| 2085 | + return self::is_formidable_api_form() || self::is_block_or_page_builder_preview(); | |
| 2067 | 2086 | } |
| 2068 | 2087 | |
| 2069 | 2088 | /** |
| 2089 | + * Checks if the form is rendered inside a block editor or page builder preview. | |
| 2090 | + * | |
| 2091 | + * @since 6.29 | |
| 2092 | + * | |
| 2093 | + * @return bool | |
| 2094 | + */ | |
| 2095 | + public static function is_block_or_page_builder_preview() { | |
| 2096 | + return self::is_gutenberg_editor() || self::is_elementor_ajax() || self::is_visual_views_preview(); | |
| 2097 | + } | |
| 2098 | + | |
| 2099 | + /** | |
| 2070 | 2100 | * @since 6.21 |
| 2071 | 2101 | * |
| 2072 | 2102 | * @return bool |
| 2073 | 2103 | */ |
| @@ -2130,6 +2160,49 @@ | ||
| 2130 | 2160 | } |
| 2131 | 2161 | } |
| 2132 | 2162 | |
| 2133 | 2163 | return false; |
| 2164 | + } | |
| 2165 | + | |
| 2166 | + /** | |
| 2167 | + * @since 6.30 | |
| 2168 | + * | |
| 2169 | + * @return void | |
| 2170 | + */ | |
| 2171 | + public static function load_currency_js() { | |
| 2172 | + global $frm_vars; | |
| 2173 | + | |
| 2174 | + if ( empty( $frm_vars['currency'] ) ) { | |
| 2175 | + return; | |
| 2176 | + } | |
| 2177 | + | |
| 2178 | + echo '<script>'; | |
| 2179 | + echo 'var frmcurrency=' . json_encode( $frm_vars['currency'] ) . ";\n"; | |
| 2180 | + echo 'if(typeof __FRMCURR == "undefined"){__FRMCURR=frmcurrency;}'; | |
| 2181 | + echo 'else{__FRMCURR=jQuery.extend(true,{},__FRMCURR,frmcurrency);}'; | |
| 2182 | + echo '</script>'; | |
| 2183 | + } | |
| 2184 | + | |
| 2185 | + /** | |
| 2186 | + * Returns the form name or the no title text if the form name is empty. | |
| 2187 | + * | |
| 2188 | + * @since 6.30 | |
| 2189 | + * | |
| 2190 | + * @param array|stdClass $form The form data. | |
| 2191 | + * @param int $length The form name length to truncate to. | |
| 2192 | + * | |
| 2193 | + * @return string | |
| 2194 | + */ | |
| 2195 | + public static function get_form_name( $form, $length = 0 ) { | |
| 2196 | + $form_name = is_object( $form ) ? $form->name : $form['name']; | |
| 2197 | + | |
| 2198 | + if ( '' === $form_name || null === $form_name ) { | |
| 2199 | + return self::get_no_title_text(); | |
| 2200 | + } | |
| 2201 | + | |
| 2202 | + if ( ! $length ) { | |
| 2203 | + return $form_name; | |
| 2204 | + } | |
| 2205 | + | |
| 2206 | + return FrmAppHelper::truncate( $form_name, $length ); | |
| 2134 | 2207 | } |
| 2135 | 2208 | } |