PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / trunk
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More vtrunk
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
← All changes | classes/helpers/FrmFormsHelper.php +83 -22 6.28 → trunk View file →
@@ -418,11 +418,9 @@
418 418 * @return array
419 419 */
420 420 public static function fill_default_opts( $values, $record, $post_values ) { // phpcs:ignore SlevomatCodingStandard.Complexity.Cognitive.ComplexityTooHigh
421 421
422 - $defaults = self::get_default_opts();
423 -
424 - foreach ( $defaults as $var => $default ) {
422 + foreach ( self::get_default_opts() as $var => $default ) {
425 423 if ( is_array( $default ) ) {
426 424 if ( ! isset( $values[ $var ] ) ) {
427 425 $values[ $var ] = $record && isset( $record->options[ $var ] ) ? $record->options[ $var ] : array();
428 426 }
@@ -485,11 +483,9 @@
485 483 *
486 484 * @return void
487 485 */
488 486 public static function fill_form_options( &$options, $values ) {
489 - $defaults = self::get_default_opts();
490 -
491 - foreach ( $defaults as $var => $default ) {
487 + foreach ( self::get_default_opts() as $var => $default ) {
492 488 $options[ $var ] = $values['options'][ $var ] ?? $default;
493 489 unset( $var, $default );
494 490 }
495 491 }
@@ -677,9 +673,12 @@
677 673
678 674 /**
679 675 * @since 4.0
680 676 *
681 - * @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.
682 681 *
683 682 * @return void
684 683 */
685 684 public static function insert_opt_html( $args ) {
@@ -702,9 +701,10 @@
702 701 if ( 'url' === $args['type'] ) {
703 702 $class .= ' frm_insert_url';
704 703 }
705 704
706 - $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'] ?? '' );
707 707
708 708 // phpcs:disable Generic.WhiteSpace.ScopeIndent
709 709 ?>
710 710 <li class="<?php echo esc_attr( $class ); ?>">
@@ -713,11 +713,15 @@
713 713 if ( isset( $field['icon'] ) ) {
714 714 FrmAppHelper::icon_by_class( $field['icon'], array( 'aria-hidden' => 'true' ) );
715 715 }
716 716
717 - echo esc_html( $truncated_name );
717 + printf(
718 + '<span title="%s">%s</span>',
719 + esc_attr( $full_name ),
720 + esc_html( $truncated_name )
721 + );
718 722 ?>
719 - <span>[<?php echo esc_attr( $args['id_label'] ?? $args['id'] ); ?>]</span>
723 + <span>[<?php echo esc_html( $args['id_label'] ?? $args['id'] ); ?>]</span>
720 724 </a>
721 725 <a href="javascript:void(0)" class="frmkeys frm_insert_code frm_hidden" data-code="<?php echo esc_attr( $args['key'] ); ?>">
722 726 <?php
723 727 if ( isset( $field['icon'] ) ) {
@@ -723,11 +727,15 @@
723 727 if ( isset( $field['icon'] ) ) {
724 728 FrmAppHelper::icon_by_class( $field['icon'], array( 'aria-hidden' => 'true' ) );
725 729 }
726 730
727 - echo esc_html( $truncated_name );
731 + printf(
732 + '<span title="%s">%s</span>',
733 + esc_attr( $full_name ),
734 + esc_html( $truncated_name )
735 + );
728 736 ?>
729 - <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>
730 738 </a>
731 739 </li>
732 740 <?php
733 741 // phpcs:enable Generic.WhiteSpace.ScopeIndent
@@ -771,11 +779,11 @@
771 779 <li class="<?php echo esc_attr( $args['class'] ); ?>">
772 780 <a href="javascript:void(0)" class="frm_insert_code <?php echo $has_tooltip ? 'frm_help' : ''; ?>"
773 781 <?php echo $has_tooltip ? 'title="' . esc_attr( $args['title'] ) . '"' : ''; ?>
774 782 data-code="<?php echo esc_attr( $args['code'] ); ?>">
775 - <?php echo esc_attr( FrmAppHelper::truncate( $args['label'], 60 ) ); ?>
783 + <?php echo esc_html( FrmAppHelper::truncate( $args['label'], 60 ) ); ?>
776 784 <span>
777 - [<?php echo esc_attr( FrmAppHelper::truncate( $args['code'], 10 ) ); ?>]
785 + [<?php echo esc_html( FrmAppHelper::truncate( $args['code'], 10 ) ); ?>]
778 786 </span>
779 787 </a>
780 788 </li>
781 789 <?php
@@ -917,9 +925,9 @@
917 925 $replace_with = $form->name;
918 926 } elseif ( $code === 'form_description' ) {
919 927 $replace_with = FrmAppHelper::use_wpautop( $form->description );
920 928 } elseif ( $code === 'entry_key' && ! empty( $_GET ) && isset( $_GET['entry'] ) ) {
921 - $replace_with = FrmAppHelper::simple_get( 'entry' );
929 + $replace_with = FrmAppHelper::simple_get( 'entry', 'sanitize_title' );
922 930 } else {
923 931 $replace_with = '';
924 932 }
925 933
@@ -1141,13 +1149,13 @@
1141 1149 */
1142 1150 public static function show_errors( $args ) {
1143 1151 $invalid_msg = self::get_invalid_error_message( $args );
1144 1152
1145 - if ( ! $invalid_msg ) {
1146 - $show_img = false;
1147 - } else {
1153 + if ( $invalid_msg ) {
1148 1154 echo wp_kses_post( $invalid_msg );
1149 1155 $show_img = true;
1156 + } else {
1157 + $show_img = false;
1150 1158 }
1151 1159
1152 1160 self::show_error(
1153 1161 array(
@@ -1251,9 +1259,9 @@
1251 1259 );
1252 1260 } else {
1253 1261 $actions['duplicate'] = array(
1254 1262 'url' => wp_nonce_url( $duplicate_link ),
1255 - 'label' => __( 'Duplicate Form', 'formidable' ),
1263 + 'label' => __( 'Duplicate', 'formidable' ),
1256 1264 'icon' => 'frmfont frm_clone_icon',
1257 1265 );
1258 1266 }
1259 1267
@@ -1847,10 +1855,9 @@
1847 1855 }
1848 1856
1849 1857 parse_str( $redirect_components['query'], $redirect_params );
1850 1858 $redirect_param_names = array_keys( $redirect_params );
1851 - $reserved_words = self::reserved_words();
1852 - $unsafe_params_in_redirect = array_intersect( $redirect_param_names, $reserved_words );
1859 + $unsafe_params_in_redirect = array_intersect( $redirect_param_names, self::reserved_words() );
1853 1860
1854 1861 return array_values( $unsafe_params_in_redirect );
1855 1862 }
1856 1863
@@ -2074,12 +2081,23 @@
2074 2081 if ( ! empty( $frm_vars['inplace_edit'] ) ) {
2075 2082 return true;
2076 2083 }
2077 2084
2078 - 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();
2079 2086 }
2080 2087
2081 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 + /**
2082 2100 * @since 6.21
2083 2101 *
2084 2102 * @return bool
2085 2103 */
@@ -2142,6 +2160,49 @@
2142 2160 }
2143 2161 }
2144 2162
2145 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 );
2146 2207 }
2147 2208 }