| @@ -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,9 +713,13 @@ | ||
| 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 | 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'] ); ?>"> |
| @@ -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_html( 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 |
| @@ -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 | |
| @@ -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 | |
| @@ -2153,6 +2160,49 @@ | ||
| 2153 | 2160 | } |
| 2154 | 2161 | } |
| 2155 | 2162 | |
| 2156 | 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 ); | |
| 2157 | 2207 | } |
| 2158 | 2208 | } |