PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 5.0.01
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v5.0.01
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/FrmXMLHelper.php +43 -362 6.5.15.0.01 View file →
@@ -4,13 +4,8 @@
4 4 }
5 5
6 6 class FrmXMLHelper {
7 7
8 - /**
9 - * @var bool $installing_template true if importing an XML from API, false if importing an XML file manually.
10 - */
11 - private static $installing_template = false;
12 -
13 8 public static function get_xml_values( $opt, $padding ) {
14 9 if ( is_array( $opt ) ) {
15 10 foreach ( $opt as $ok => $ov ) {
16 11 echo "\n" . esc_html( $padding );
@@ -22,9 +17,9 @@
22 17 }
23 18 echo '</' . esc_html( $tag ) . '>';
24 19 }
25 20 } else {
26 - echo self::cdata( $opt ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
21 + echo self::cdata( $opt ); // WPCS: XSS ok.
27 22 }
28 23 }
29 24
30 25 public static function import_xml( $file ) {
@@ -32,25 +27,13 @@
32 27 define( 'WP_IMPORTING', true );
33 28 }
34 29
35 30 if ( ! class_exists( 'DOMDocument' ) ) {
36 - $error_message = sprintf(
37 - /* translators: 1: Documentation link */
38 - __( 'In order to install XML, your server must have DOMDocument installed. Follow our documentation on %1$s to ensure DOMDocument is properly set up and XML support is enabled.', 'formidable' ),
39 - '<a href="https://formidableforms.com/knowledgebase/import-forms-entries-and-views/#kb-your-server-does-not-have-xml-enabled" target="_blank">Importing Forms, Entries, and Views</a>'
40 - );
41 -
42 - return new WP_Error( 'SimpleXML_parse_error', $error_message, libxml_get_errors() );
31 + return new WP_Error( 'SimpleXML_parse_error', __( 'Your server does not have XML enabled', 'formidable' ), libxml_get_errors() );
43 32 }
44 33
45 - $xml_string = file_get_contents( $file );
46 - self::maybe_fix_xml( $xml_string );
47 -
48 - $dom = new DOMDocument();
49 -
50 - // LIBXML_COMPACT activates small nodes allocation optimization.
51 - // Use LIBXML_PARSEHUGE to avoid "parser error : internal error: Huge input lookup" for large (300MB) files.
52 - $success = $dom->loadXML( $xml_string, LIBXML_COMPACT | LIBXML_PARSEHUGE );
34 + $dom = new DOMDocument();
35 + $success = $dom->loadXML( file_get_contents( $file ) );
53 36 if ( ! $success ) {
54 37 return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this XML file', 'formidable' ), libxml_get_errors() );
55 38 }
56 39
@@ -69,50 +52,19 @@
69 52 return self::import_xml_now( $xml );
70 53 }
71 54
72 55 /**
73 - * @since 6.2.3
74 - *
75 - * @param string $xml_string
76 - * @return void
77 - */
78 - private static function maybe_fix_xml( &$xml_string ) {
79 - if ( '<?xml' !== substr( $xml_string, 0, 5 ) ) {
80 - // Some XML files have may have unexpected characters at the start.
81 - $xml_string = substr( $xml_string, strpos( $xml_string, '<?xml' ) );
82 - }
83 -
84 - // The Equity theme adds a <meta name="generator" content="Equity 1.7.13" /> tag using the "the_generator" filter.
85 - // Strip that out as it breaks the XML import.
86 - $channel_start_position = strpos( $xml_string, '<channel>' );
87 - $content_before_channel_tag = substr( $xml_string, 0, $channel_start_position );
88 - if ( 0 !== strpos( $content_before_channel_tag, '<meta name="generator" ' ) ) {
89 - $content_before_channel_tag = preg_replace(
90 - '/<meta\s+[^>]*name="generator"[^>]*\/>/i',
91 - '',
92 - $content_before_channel_tag,
93 - 1
94 - );
95 - $xml_string = $content_before_channel_tag . substr( $xml_string, $channel_start_position );
96 - }
97 - }
98 -
99 - /**
100 56 * Add terms, forms (form and field ids), posts (post ids), and entries to db, in that order
101 57 *
102 58 * @since 3.06
103 - *
104 - * @param object $xml
105 - * @param bool $installing_template
106 59 * @return array The number of items imported
107 60 */
108 - public static function import_xml_now( $xml, $installing_template = false ) {
61 + public static function import_xml_now( $xml ) {
109 62 if ( ! defined( 'WP_IMPORTING' ) ) {
110 63 define( 'WP_IMPORTING', true );
111 64 }
112 65
113 - self::$installing_template = $installing_template;
114 - $imported = self::pre_import_data();
66 + $imported = self::pre_import_data();
115 67
116 68 foreach ( array( 'term', 'form', 'view' ) as $item_type ) {
117 69 // Grab cats, tags, and terms, or forms or posts.
118 70 if ( isset( $xml->{$item_type} ) ) {
@@ -126,9 +78,9 @@
126 78
127 79 if ( ! isset( $imported['form_status'] ) || empty( $imported['form_status'] ) ) {
128 80 // Check for an error message in the XML.
129 81 if ( isset( $xml->Code ) && isset( $xml->Message ) ) { // phpcs:ignore WordPress.NamingConventions
130 - $imported['error'] = (string) $xml->Message; // phpcs:ignore WordPress.NamingConventions
82 + $imported['error'] = reset( $xml->Message ); // phpcs:ignore WordPress.NamingConventions
131 83 }
132 84 }
133 85
134 86 return $imported;
@@ -283,13 +235,8 @@
283 235 }
284 236
285 237 $form['options'] = FrmAppHelper::maybe_json_decode( $form['options'] );
286 238
287 - if ( self::$installing_template ) {
288 - // Templates don't necessarily have antispam on, but we want our templates to all have antispam on by default.
289 - $form['options']['antispam'] = 1;
290 - }
291 -
292 239 return $form;
293 240 }
294 241
295 242 private static function maybe_get_form( $form ) {
@@ -303,15 +250,9 @@
303 250 }
304 251
305 252 $edit_query = apply_filters( 'frm_match_xml_form', $edit_query, $form );
306 253
307 - $form = FrmForm::getAll( $edit_query, '', 1 );
308 - if ( is_object( $form ) && $form->status === 'trash' ) {
309 - FrmForm::destroy( $form->id );
310 - return false;
311 - }
312 -
313 - return $form;
254 + return FrmForm::getAll( $edit_query, '', 1 );
314 255 }
315 256
316 257 private static function update_form( $this_form, $form, &$imported ) {
317 258 $form_id = $this_form->id;
@@ -673,12 +614,8 @@
673 614 private static function create_imported_field( $f, &$imported ) {
674 615 $defaults = self::default_field_options( $f['type'] );
675 616 $f['field_options'] = array_merge( $defaults, $f['field_options'] );
676 617
677 - if ( is_callable( 'FrmProFileImport::import_attachment' ) ) {
678 - $f = self::maybe_import_images_for_options( $f );
679 - }
680 -
681 618 $new_id = FrmField::create( $f );
682 619 if ( $new_id != false ) {
683 620 $imported['imported']['fields'] ++;
684 621 do_action( 'frm_after_field_is_imported', $f, $new_id );
@@ -685,40 +622,8 @@
685 622 }
686 623 }
687 624
688 625 /**
689 - * Import images for radio buttons and checkboxes from image src if available.
690 - *
691 - * @since 5.5.1
692 - *
693 - * @param array $field
694 - * @return array
695 - */
696 - private static function maybe_import_images_for_options( $field ) {
697 - if ( empty( $field['options'] ) || ! is_array( $field['options'] ) ) {
698 - return $field;
699 - }
700 -
701 - foreach ( $field['options'] as $key => $option ) {
702 - if ( ! is_array( $option ) || empty( $option['src'] ) ) {
703 - continue;
704 - }
705 -
706 - $field_object = (object) $field;
707 - $field_object->type = 'file'; // Fake the file type as FrmProImport::import_attachment checks for file type.
708 -
709 - $image_id = FrmProFileImport::import_attachment( $option['src'], $field_object );
710 - unset( $field['options'][ $key ]['src'] ); // Remove the src from options as it isn't required after import.
711 -
712 - if ( is_numeric( $image_id ) ) {
713 - $field['options'][ $key ]['image'] = $image_id;
714 - }
715 - }
716 -
717 - return $field;
718 - }
719 -
720 - /**
721 626 * Fix field ids for fields that already exist prior to import.
722 627 *
723 628 * @since 4.07
724 629 * @param int $form_id
@@ -769,9 +674,9 @@
769 674 if ( ! isset( $form['options']['custom_style'] ) ) {
770 675 return;
771 676 }
772 677
773 - if ( is_numeric( $form['options']['custom_style'] ) && 1 === intval( $form['options']['custom_style'] ) ) {
678 + if ( is_numeric( $form['options']['custom_style'] ) ) {
774 679 // Set to default
775 680 $form['options']['custom_style'] = 1;
776 681 } else {
777 682 // Replace the style name with the style ID on import
@@ -826,11 +731,8 @@
826 731 $form_action_type => 'actions',
827 732 'frm_styles' => 'styles',
828 733 );
829 734
830 - $view_ids = array();
831 - $posts_with_shortcodes = array();
832 -
833 735 foreach ( $views as $item ) {
834 736 $post = array(
835 737 'post_title' => (string) $item->title,
836 738 'post_name' => (string) $item->post_name,
@@ -853,10 +755,8 @@
853 755 'layout' => array(),
854 756 'tax_input' => array(),
855 757 );
856 758
857 - $post['post_content'] = self::switch_form_ids( $post['post_content'], $imported['forms'] );
858 -
859 759 $old_id = $post['post_id'];
860 760 self::populate_post( $post, $item, $imported );
861 761
862 762 unset( $item );
@@ -861,26 +761,26 @@
861 761
862 762 unset( $item );
863 763
864 764 $post_id = false;
865 - if ( $post['post_type'] === $form_action_type ) {
765 + if ( $post['post_type'] == $form_action_type ) {
866 766 $action_control = FrmFormActionsController::get_form_actions( $post['post_excerpt'] );
867 767 if ( $action_control && is_object( $action_control ) ) {
868 768 $post_id = $action_control->maybe_create_action( $post, $imported['form_status'] );
869 769 }
870 770 unset( $action_control );
871 - } elseif ( $post['post_type'] === 'frm_styles' ) {
771 + } elseif ( $post['post_type'] == 'frm_styles' ) {
872 772 // Properly encode post content before inserting the post
873 773 $post['post_content'] = FrmAppHelper::maybe_json_decode( $post['post_content'] );
774 + $custom_css = isset( $post['post_content']['custom_css'] ) ? $post['post_content']['custom_css'] : '';
874 775 $post['post_content'] = FrmAppHelper::prepare_and_encode( $post['post_content'] );
875 776
876 777 // Create/update post now
877 778 $post_id = wp_insert_post( $post );
779 + self::maybe_update_custom_css( $custom_css );
878 780 } else {
879 781 if ( $post['post_type'] === 'frm_display' ) {
880 782 $post['post_content'] = self::maybe_prepare_json_view_content( $post['post_content'] );
881 - } elseif ( 'page' === $post['post_type'] && isset( $imported['posts'][ $post['post_parent'] ] ) ) {
882 - $post['post_parent'] = $imported['posts'][ $post['post_parent'] ];
883 783 }
884 784 // Create/update post now
885 785 $post_id = wp_insert_post( $post );
886 786 }
@@ -888,12 +788,8 @@
888 788 if ( ! is_numeric( $post_id ) ) {
889 789 continue;
890 790 }
891 791
892 - if ( false !== strpos( $post['post_content'], '[display-frm-data' ) || false !== strpos( $post['post_content'], '[formidable' ) ) {
893 - $posts_with_shortcodes[ $post_id ] = $post;
894 - }
895 -
896 792 self::update_postmeta( $post, $post_id );
897 793 self::update_layout( $post, $post_id );
898 794
899 795 $this_type = 'posts';
@@ -908,154 +804,19 @@
908 804 }
909 805
910 806 $imported['posts'][ (int) $old_id ] = $post_id;
911 807
912 - if ( $post['post_type'] === 'frm_display' ) {
913 - $view_ids[ (int) $old_id ] = $post_id;
914 - }
915 -
916 808 do_action( 'frm_after_import_view', $post_id, $post );
917 809
918 810 unset( $post );
919 811 }
920 812
921 - if ( $posts_with_shortcodes && $view_ids ) {
922 - self::maybe_switch_view_ids_after_importing_posts( $posts_with_shortcodes, $view_ids );
923 - }
924 - unset( $posts_with_shortcodes, $view_ids );
925 -
926 - if ( ! empty( $imported['forms'] ) ) {
927 - // clear imported forms style cache to make sure the new styles are applied to the forms
928 - self::clear_forms_style_caches( $imported['forms'] );
929 - }
930 -
931 813 self::maybe_update_stylesheet( $imported );
932 814
933 - flush_rewrite_rules();
934 -
935 815 return $imported;
936 816 }
937 817
938 818 /**
939 - * Clears styles from cache for imported forms
940 - *
941 - * @param array $imported_forms
942 - */
943 - private static function clear_forms_style_caches( $imported_forms ) {
944 - $where = array(
945 - 'id' => $imported_forms,
946 - 'options LIKE' => '"old_style"',
947 - );
948 - $forms = FrmDb::get_results( 'frm_forms', $where );
949 -
950 - foreach ( $forms as $form ) {
951 - FrmAppHelper::unserialize_or_decode( $form->options );
952 - if ( ! $form->options ) {
953 - continue;
954 - }
955 - $where = array(
956 - 'post_name' => $form->options['old_style'],
957 - 'post_type' => FrmStylesController::$post_type,
958 - );
959 -
960 - $select = 'ID';
961 -
962 - $cache_key = FrmDb::generate_cache_key( $where, array( 'limit' => 1 ), $select, 'var' );
963 - FrmDb::delete_cache_and_transient( $cache_key, 'post' );
964 - }
965 - }
966 -
967 - /**
968 - * Replace old form ids with new ones in a string.
969 - *
970 - * @param string $string
971 - * @param array<int> $form_ids new form ids indexed by old form id.
972 - * @return string
973 - */
974 - private static function switch_form_ids( $string, $form_ids ) {
975 - if ( false === strpos( $string, '[formidable' ) ) {
976 - // Skip string replacing if there are no form shortcodes in string.
977 - return $string;
978 - }
979 -
980 - foreach ( $form_ids as $old_id => $new_id ) {
981 - $string = str_replace(
982 - array(
983 - '[formidable id="' . $old_id . '"',
984 - '[formidable id=' . $old_id . ']',
985 - '[formidable id=' . $old_id . ' ',
986 - '"formId":"' . $old_id . '"',
987 - ),
988 - array(
989 - '[formidable id="' . $new_id . '"',
990 - '[formidable id=' . $new_id . ']',
991 - '[formidable id=' . $new_id . ' ',
992 - '"formId":"' . $new_id . '"',
993 - ),
994 - $string
995 - );
996 - }
997 -
998 - return $string;
999 - }
1000 -
1001 - /**
1002 - * @param array<array> $posts_with_shortcodes indexed by current post id.
1003 - * @param array<int> $view_ids new view ids indexed by old view id.
1004 - * @return void
1005 - */
1006 - private static function maybe_switch_view_ids_after_importing_posts( $posts_with_shortcodes, $view_ids ) {
1007 - foreach ( $posts_with_shortcodes as $imported_post_id => $post ) {
1008 - $post_content = self::switch_view_ids( $post['post_content'], $view_ids );
1009 - if ( $post_content === $post['post_content'] ) {
1010 - continue;
1011 - }
1012 -
1013 - wp_update_post(
1014 - array(
1015 - 'ID' => $imported_post_id,
1016 - 'post_content' => $post_content,
1017 - )
1018 - );
1019 - }
1020 - }
1021 -
1022 - /**
1023 - * Replace old view ids with new ones in a string.
1024 - *
1025 - * @param string $string
1026 - * @param array<int> $view_ids new view ids indexed by old view id.
1027 - * @return string
1028 - */
1029 - private static function switch_view_ids( $string, $view_ids ) {
1030 - if ( false === strpos( $string, '[display-frm-data' ) ) {
1031 - // Skip string replacing if there are no view shortcodes in string.
1032 - return $string;
1033 - }
1034 -
1035 - foreach ( $view_ids as $old_id => $new_id ) {
1036 - $string = str_replace(
1037 - array(
1038 - '[display-frm-data id="' . $old_id . '"',
1039 - '[display-frm-data id=' . $old_id . ']',
1040 - '[display-frm-data id=' . $old_id . ' ',
1041 - '"viewId":"' . $old_id . '"',
1042 - ),
1043 - array(
1044 - '[display-frm-data id="' . $new_id . '"',
1045 - '[display-frm-data id=' . $new_id . ']',
1046 - '[display-frm-data id=' . $new_id . ' ',
1047 - '"viewId":"' . $new_id . '"',
1048 - ),
1049 - $string
1050 - );
1051 - unset( $old_id, $new_id );
1052 - }
1053 -
1054 - return $string;
1055 - }
1056 -
1057 - /**
1058 819 * @param string $content
1059 820 * @return string
1060 821 */
1061 822 private static function maybe_prepare_json_view_content( $content ) {
@@ -1220,40 +981,24 @@
1220 981 $post['ID'] = current( $editing )->ID;
1221 982 }
1222 983 }
1223 984
1224 - /**
1225 - * @param array $post
1226 - * @param int $post_id
1227 - * @return void
1228 - */
1229 985 private static function update_postmeta( &$post, $post_id ) {
1230 986 foreach ( $post['postmeta'] as $k => $v ) {
1231 - switch ( $k ) {
1232 - case '_edit_last':
1233 - $v = FrmAppHelper::get_user_id_param( $v );
1234 - break;
987 + if ( '_edit_last' == $k ) {
988 + $v = FrmAppHelper::get_user_id_param( $v );
989 + } elseif ( '_thumbnail_id' == $k && FrmAppHelper::pro_is_installed() ) {
990 + // Change the attachment ID.
991 + $field_obj = FrmFieldFactory::get_field_type( 'file' );
992 + $v = $field_obj->get_file_id( $v );
993 + }
1235 994
1236 - case '_thumbnail_id':
1237 - if ( FrmAppHelper::pro_is_installed() ) {
1238 - // Change the attachment ID.
1239 - $field_obj = FrmFieldFactory::get_field_type( 'file' );
1240 - $v = $field_obj->get_file_id( $v );
1241 - }
1242 - break;
1243 -
1244 - case 'frm_dyncontent':
1245 - if ( is_array( $v ) ) {
1246 - $v = json_encode( $v );
1247 - }
1248 - break;
1249 -
1250 - case 'frm_param':
1251 - add_rewrite_endpoint( $v, EP_PERMALINK | EP_PAGES );
1252 - break;
995 + if ( 'frm_dyncontent' === $k && is_array( $v ) ) {
996 + $v = json_encode( $v );
1253 997 }
1254 998
1255 999 update_post_meta( $post_id, $k, $v );
1000 +
1256 1001 unset( $k, $v );
1257 1002 }
1258 1003 }
1259 1004
@@ -1270,8 +1015,25 @@
1270 1015 }
1271 1016 }
1272 1017 }
1273 1018
1019 + /**
1020 + * If a template includes custom css, let's include it.
1021 + * The custom css is included on the default style.
1022 + *
1023 + * @since 2.03
1024 + */
1025 + private static function maybe_update_custom_css( $custom_css ) {
1026 + if ( empty( $custom_css ) ) {
1027 + return;
1028 + }
1029 +
1030 + $frm_style = new FrmStyle();
1031 + $default_style = $frm_style->get_default_style();
1032 + $default_style->post_content['custom_css'] .= "\r\n\r\n" . $custom_css;
1033 + $frm_style->save( $default_style );
1034 + }
1035 +
1274 1036 private static function maybe_update_stylesheet( $imported ) {
1275 1037 $new_styles = isset( $imported['imported']['styles'] ) && ! empty( $imported['imported']['styles'] );
1276 1038 $updated_styles = isset( $imported['updated']['styles'] ) && ! empty( $imported['updated']['styles'] );
1277 1039 if ( $new_styles || $updated_styles ) {
@@ -1290,29 +1052,8 @@
1290 1052 */
1291 1053 public static function parse_message( $result, &$message, &$errors ) {
1292 1054 if ( is_wp_error( $result ) ) {
1293 1055 $errors[] = $result->get_error_message();
1294 -
1295 - // Remove the SimpleXML_parse_error from the WP_Error object to avoid
1296 - // displaying duplicate error messages from $result->get_error_message()
1297 - $error_codes = $result->get_error_codes();
1298 - $error_details = array();
1299 - foreach ( $error_codes as $error_code ) {
1300 - // Clone WP_Error data because WP_Error removes all error messages and data
1301 - // associated with the specified error code when an item is removed.
1302 - // Source: https://developer.wordpress.org/reference/classes/wp_error/remove/#source
1303 - $error_details = $result->get_error_data( $error_code );
1304 - if ( $error_code === 'SimpleXML_parse_error' ) {
1305 - $result->remove( $error_code );
1306 - break;
1307 - }
1308 - }
1309 -
1310 - if ( ! empty( $error_details ) ) {
1311 - $errors[] = '<br />' . esc_html_x( 'Error details:', 'import xml message', 'formidable' ) . '<br />' . esc_html( print_r( $error_details, 1 ) );
1312 - }
1313 -
1314 - return;
1315 1056 } elseif ( ! $result ) {
1316 1057 return;
1317 1058 }
1318 1059
@@ -1352,24 +1093,12 @@
1352 1093 $errors[] = __( 'Nothing was imported or updated', 'formidable' );
1353 1094 } else {
1354 1095 self::add_form_link_to_message( $result, $message );
1355 1096
1356 - /**
1357 - * @since 5.3
1358 - *
1359 - * @param string $message
1360 - * @param array $result
1361 - */
1362 - $message = apply_filters( 'frm_xml_parsed_message', $message, $result );
1363 1097 $message .= '</ul>';
1364 1098 }
1365 1099 }
1366 1100
1367 - /**
1368 - * @param int $m
1369 - * @param string $type
1370 - * @param array<string> $s_message
1371 - */
1372 1101 public static function item_count_message( $m, $type, &$s_message ) {
1373 1102 if ( ! $m ) {
1374 1103 return;
1375 1104 }
@@ -1383,9 +1112,9 @@
1383 1112 'items' => sprintf( _n( '%1$s Entry', '%1$s Entries', $m, 'formidable' ), $m ),
1384 1113 /* translators: %1$s: Number of items */
1385 1114 'views' => sprintf( _n( '%1$s View', '%1$s Views', $m, 'formidable' ), $m ),
1386 1115 /* translators: %1$s: Number of items */
1387 - 'posts' => sprintf( _n( '%1$s Page/Post', '%1$s Pages/Posts', $m, 'formidable' ), $m ),
1116 + 'posts' => sprintf( _n( '%1$s Post', '%1$s Posts', $m, 'formidable' ), $m ),
1388 1117 /* translators: %1$s: Number of items */
1389 1118 'styles' => sprintf( _n( '%1$s Style', '%1$s Styles', $m, 'formidable' ), $m ),
1390 1119 /* translators: %1$s: Number of items */
1391 1120 'terms' => sprintf( _n( '%1$s Term', '%1$s Terms', $m, 'formidable' ), $m ),
@@ -1392,23 +1121,9 @@
1392 1121 /* translators: %1$s: Number of items */
1393 1122 'actions' => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ),
1394 1123 );
1395 1124
1396 - if ( isset( $strings[ $type ] ) ) {
1397 - $s_message[] = $strings[ $type ];
1398 - } else {
1399 - $string = ' ' . $m . ' ' . ucfirst( $type );
1400 -
1401 - /**
1402 - * @since 5.3
1403 - *
1404 - * @param string $string Message string for imported item.
1405 - * @param int $m Number of item that was imported.
1406 - * }
1407 - */
1408 - $string = apply_filters( 'frm_xml_' . $type . '_count_message', $string, $m );
1409 - $s_message[] = $string;
1410 - }
1125 + $s_message[] = isset( $strings[ $type ] ) ? $strings[ $type ] : ' ' . $m . ' ' . ucfirst( $type );
1411 1126 }
1412 1127
1413 1128 /**
1414 1129 * If a single form was imported, include a link in the success message.
@@ -1485,9 +1200,8 @@
1485 1200 * @since 3.06
1486 1201 */
1487 1202 public static function prepare_field_for_export( &$field ) {
1488 1203 self::remove_default_field_options( $field );
1489 - self::add_image_src_to_image_options( $field );
1490 1204 }
1491 1205
1492 1206 /**
1493 1207 * Remove defaults from field options too
@@ -1519,41 +1233,8 @@
1519 1233 $field->field_options = serialize( $options );
1520 1234 }
1521 1235
1522 1236 /**
1523 - * Add image "src" key to each image option so the image can be imported to another website.
1524 - *
1525 - * @since 5.5.1
1526 - *
1527 - * @param stdClass $field
1528 - * @return void
1529 - */
1530 - private static function add_image_src_to_image_options( $field ) {
1531 - if ( empty( $field->options ) || false === strpos( $field->options, 'image' ) ) {
1532 - return;
1533 - }
1534 -
1535 - $updated = false;
1536 - $options = $field->options;
1537 - FrmAppHelper::unserialize_or_decode( $options );
1538 -
1539 - if ( ! $options || ! is_array( $options ) ) {
1540 - return;
1541 - }
1542 -
1543 - foreach ( $options as $key => $option ) {
1544 - if ( is_array( $option ) && ! empty( $option['image'] ) ) {
1545 - $options[ $key ]['src'] = wp_get_attachment_url( $option['image'] );
1546 - $updated = true;
1547 - }
1548 - }
1549 -
1550 - if ( $updated ) {
1551 - $field->options = maybe_serialize( $options );
1552 - }
1553 - }
1554 -
1555 - /**
1556 1237 * @since 3.06.03
1557 1238 */
1558 1239 private static function default_field_options( $type ) {
1559 1240 $defaults = FrmFieldsHelper::get_default_field_options( $type );
@@ -1606,9 +1287,9 @@
1606 1287 FrmAppHelper::unserialize_or_decode( $str );
1607 1288 if ( is_array( $str ) ) {
1608 1289 $str = json_encode( $str );
1609 1290 } elseif ( seems_utf8( $str ) === false ) {
1610 - $str = FrmAppHelper::maybe_utf8_encode( $str );
1291 + $str = utf8_encode( $str );
1611 1292 }
1612 1293
1613 1294 if ( is_numeric( $str ) ) {
1614 1295 return $str;