PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 5.3.2
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v5.3.2
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 +118 -687 6.26.1 → 5.3.2 View file →
@@ -5,18 +5,12 @@
5 5
6 6 class FrmXMLHelper {
7 7
8 8 /**
9 - * @var bool true if importing an XML from API, false if importing an XML file manually.
9 + * @var bool $installing_template true if importing an XML from API, false if importing an XML file manually.
10 10 */
11 11 private static $installing_template = false;
12 12
13 - /**
14 - * @param array|string $opt
15 - * @param string $padding
16 - *
17 - * @return void
18 - */
19 13 public static function get_xml_values( $opt, $padding ) {
20 14 if ( is_array( $opt ) ) {
21 15 foreach ( $opt as $ok => $ov ) {
22 16 echo "\n" . esc_html( $padding );
@@ -22,9 +16,8 @@
22 16 echo "\n" . esc_html( $padding );
23 17 $tag = ( is_numeric( $ok ) ? 'key:' : '' ) . $ok;
24 18 echo '<' . esc_html( $tag ) . '>';
25 19 self::get_xml_values( $ov, $padding . ' ' );
26 -
27 20 if ( is_array( $ov ) ) {
28 21 echo "\n" . esc_html( $padding );
29 22 }
30 23 echo '</' . esc_html( $tag ) . '>';
@@ -33,13 +26,8 @@
33 26 echo self::cdata( $opt ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
34 27 }
35 28 }
36 29
37 - /**
38 - * @param string $file
39 - *
40 - * @return array|WP_Error The items imported
41 - */
42 30 public static function import_xml( $file ) {
43 31 if ( ! defined( 'WP_IMPORTING' ) ) {
44 32 define( 'WP_IMPORTING', true );
45 33 }
@@ -44,26 +32,13 @@
44 32 define( 'WP_IMPORTING', true );
45 33 }
46 34
47 35 if ( ! class_exists( 'DOMDocument' ) ) {
48 - $error_message = sprintf(
49 - /* translators: 1: Documentation link */
50 - __( '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' ),
51 - '<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>'
52 - );
53 -
54 - return new WP_Error( 'SimpleXML_parse_error', $error_message, libxml_get_errors() );
36 + return new WP_Error( 'SimpleXML_parse_error', __( 'Your server does not have XML enabled', 'formidable' ), libxml_get_errors() );
55 37 }
56 38
57 - $xml_string = file_get_contents( $file );
58 - self::maybe_fix_xml( $xml_string );
59 -
60 - $dom = new DOMDocument();
61 -
62 - // LIBXML_COMPACT activates small nodes allocation optimization.
63 - // Use LIBXML_PARSEHUGE to avoid "parser error : internal error: Huge input lookup" for large (300MB) files.
64 - $success = $dom->loadXML( $xml_string, LIBXML_COMPACT | LIBXML_PARSEHUGE );
65 -
39 + $dom = new DOMDocument();
40 + $success = $dom->loadXML( file_get_contents( $file ) );
66 41 if ( ! $success ) {
67 42 return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this XML file', 'formidable' ), libxml_get_errors() );
68 43 }
69 44
@@ -82,37 +57,8 @@
82 57 return self::import_xml_now( $xml );
83 58 }
84 59
85 60 /**
86 - * @since 6.2.3
87 - *
88 - * @param string $xml_string
89 - *
90 - * @return void
91 - */
92 - private static function maybe_fix_xml( &$xml_string ) {
93 - if ( '<?xml' !== substr( $xml_string, 0, 5 ) ) {
94 - // Some XML files have may have unexpected characters at the start.
95 - $xml_string = substr( $xml_string, strpos( $xml_string, '<?xml' ) );
96 - }
97 -
98 - // The Equity theme adds a <meta name="generator" content="Equity 1.7.13" /> tag using the "the_generator" filter.
99 - // Strip that out as it breaks the XML import.
100 - $channel_start_position = strpos( $xml_string, '<channel>' );
101 - $content_before_channel_tag = substr( $xml_string, 0, $channel_start_position );
102 -
103 - if ( 0 !== strpos( $content_before_channel_tag, '<meta name="generator" ' ) ) {
104 - $content_before_channel_tag = preg_replace(
105 - '/<meta\s+[^>]*name="generator"[^>]*\/>/i',
106 - '',
107 - $content_before_channel_tag,
108 - 1
109 - );
110 - $xml_string = $content_before_channel_tag . substr( $xml_string, $channel_start_position );
111 - }
112 - }
113 -
114 - /**
115 61 * Add terms, forms (form and field ids), posts (post ids), and entries to db, in that order
116 62 *
117 63 * @since 3.06
118 64 *
@@ -117,9 +63,8 @@
117 63 * @since 3.06
118 64 *
119 65 * @param object $xml
120 66 * @param bool $installing_template
121 - *
122 67 * @return array The number of items imported
123 68 */
124 69 public static function import_xml_now( $xml, $installing_template = false ) {
125 70 if ( ! defined( 'WP_IMPORTING' ) ) {
@@ -139,9 +84,9 @@
139 84 }
140 85
141 86 $imported = apply_filters( 'frm_importing_xml', $imported, $xml );
142 87
143 - if ( empty( $imported['form_status'] ) ) {
88 + if ( ! isset( $imported['form_status'] ) || empty( $imported['form_status'] ) ) {
144 89 // Check for an error message in the XML.
145 90 if ( isset( $xml->Code ) && isset( $xml->Message ) ) { // phpcs:ignore WordPress.NamingConventions
146 91 $imported['error'] = (string) $xml->Message; // phpcs:ignore WordPress.NamingConventions
147 92 }
@@ -151,9 +96,8 @@
151 96 }
152 97
153 98 /**
154 99 * @since 3.06
155 - *
156 100 * @return array
157 101 */
158 102 private static function pre_import_data() {
159 103 $defaults = array(
@@ -173,14 +117,8 @@
173 117 'terms' => array(),
174 118 );
175 119 }
176 120
177 - /**
178 - * @param SimpleXMLElement $terms
179 - * @param array $imported
180 - *
181 - * @return array
182 - */
183 121 public static function import_xml_terms( $terms, $imported ) {
184 122 foreach ( $terms as $t ) {
185 123 if ( term_exists( (string) $t->term_slug, (string) $t->term_taxonomy ) ) {
186 124 continue;
@@ -198,14 +136,14 @@
198 136 )
199 137 );
200 138
201 139 if ( $term && is_array( $term ) ) {
202 - ++$imported['imported']['terms'];
140 + $imported['imported']['terms'] ++;
203 141 $imported['terms'][ (int) $t->term_id ] = $term['term_id'];
204 142 }
205 143
206 144 unset( $term, $t );
207 - }//end foreach
145 + }
208 146
209 147 return $imported;
210 148 }
211 149
@@ -210,19 +148,13 @@
210 148 }
211 149
212 150 /**
213 151 * @since 2.0.8
214 - *
215 - * @param object $t
216 - *
217 - * @return int|string
218 152 */
219 153 private static function get_term_parent_id( $t ) {
220 154 $parent = (string) $t->term_parent;
221 -
222 155 if ( ! empty( $parent ) ) {
223 156 $parent = term_exists( (string) $t->term_parent, (string) $t->term_taxonomy );
224 -
225 157 if ( $parent ) {
226 158 $parent = $parent['term_id'];
227 159 } else {
228 160 $parent = 0;
@@ -231,14 +163,8 @@
231 163
232 164 return $parent;
233 165 }
234 166
235 - /**
236 - * @param SimpleXMLElement $forms
237 - * @param array $imported
238 - *
239 - * @return array
240 - */
241 167 public static function import_xml_forms( $forms, $imported ) {
242 168 $child_forms = array();
243 169
244 170 // Import child forms first
@@ -252,9 +178,8 @@
252 178 $this_form = self::maybe_get_form( $form );
253 179
254 180 $old_id = false;
255 181 $form_fields = false;
256 -
257 182 if ( ! empty( $this_form ) ) {
258 183 $form_id = $this_form->id;
259 184 $old_id = $this_form->id;
260 185 self::update_form( $this_form, $form, $imported );
@@ -261,13 +186,12 @@
261 186
262 187 $form_fields = self::get_form_fields( $form_id );
263 188 } else {
264 189 $form_id = FrmForm::create( $form );
265 -
266 190 if ( $form_id ) {
267 191 if ( empty( $form['parent_form_id'] ) ) {
268 192 // Don't include the repeater form in the imported count.
269 - ++$imported['imported']['forms'];
193 + $imported['imported']['forms'] ++;
270 194 }
271 195
272 196 // Keep track of whether this specific form was updated or not.
273 197 $imported['form_status'][ $form_id ] = 'imported';
@@ -292,9 +216,9 @@
292 216
293 217 do_action( 'frm_after_import_form', $form_id, $form );
294 218
295 219 unset( $form, $item );
296 - }//end foreach
220 + }
297 221
298 222 self::maybe_update_child_form_parent_id( $imported['forms'], $child_forms );
299 223
300 224 return $imported;
@@ -299,13 +223,8 @@
299 223
300 224 return $imported;
301 225 }
302 226
303 - /**
304 - * @param object $item
305 - *
306 - * @return array
307 - */
308 227 private static function fill_form( $item ) {
309 228 $form = array(
310 229 'id' => (int) $item->id,
311 230 'form_key' => (string) $item->form_key,
@@ -333,13 +252,8 @@
333 252
334 253 return $form;
335 254 }
336 255
337 - /**
338 - * @param array $form
339 - *
340 - * @return false|object
341 - */
342 256 private static function maybe_get_form( $form ) {
343 257 // if template, allow to edit if form keys match, otherwise, creation date must also match
344 258 $edit_query = array(
345 259 'form_key' => $form['form_key'],
@@ -344,9 +258,8 @@
344 258 $edit_query = array(
345 259 'form_key' => $form['form_key'],
346 260 'is_template' => $form['is_template'],
347 261 );
348 -
349 262 if ( ! $form['is_template'] ) {
350 263 $edit_query['created_at'] = $form['created_at'];
351 264 }
352 265
@@ -351,32 +264,17 @@
351 264 }
352 265
353 266 $edit_query = apply_filters( 'frm_match_xml_form', $edit_query, $form );
354 267
355 - $form = FrmForm::getAll( $edit_query, '', 1 );
356 -
357 - if ( is_object( $form ) && $form->status === 'trash' ) {
358 - FrmForm::destroy( $form->id );
359 - return false;
360 - }
361 -
362 - return $form;
268 + return FrmForm::getAll( $edit_query, '', 1 );
363 269 }
364 270
365 - /**
366 - * @param object $this_form
367 - * @param array $form
368 - * @param array $imported
369 - *
370 - * @return void
371 - */
372 271 private static function update_form( $this_form, $form, &$imported ) {
373 272 $form_id = $this_form->id;
374 273 FrmForm::update( $form_id, $form );
375 -
376 274 if ( empty( $form['parent_form_id'] ) ) {
377 275 // Don't include the repeater form in the updated count.
378 - ++$imported['updated']['forms'];
276 + $imported['updated']['forms'] ++;
379 277 }
380 278
381 279 // Keep track of whether this specific form was updated or not
382 280 $imported['form_status'][ $form_id ] = 'updated';
@@ -381,23 +279,16 @@
381 279 // Keep track of whether this specific form was updated or not
382 280 $imported['form_status'][ $form_id ] = 'updated';
383 281 }
384 282
385 - /**
386 - * @param int|string $form_id
387 - *
388 - * @return array
389 - */
390 283 private static function get_form_fields( $form_id ) {
391 284 $form_fields = FrmField::get_all_for_form( $form_id, '', 'exclude', 'exclude' );
392 285 $old_fields = array();
393 -
394 286 foreach ( $form_fields as $f ) {
395 287 $old_fields[ $f->id ] = $f;
396 288 $old_fields[ $f->field_key ] = $f->id;
397 289 unset( $f );
398 290 }
399 -
400 291 $form_fields = $old_fields;
401 292
402 293 return $form_fields;
403 294 }
@@ -403,12 +294,8 @@
403 294 }
404 295
405 296 /**
406 297 * Delete any fields attached to this form that were not included in the template
407 - *
408 - * @param array $form_fields
409 - *
410 - * @return void
411 298 */
412 299 private static function delete_removed_fields( $form_fields ) {
413 300 if ( ! empty( $form_fields ) ) {
414 301 foreach ( $form_fields as $field ) {
@@ -448,10 +335,10 @@
448 335 * Keep track of all imported child forms
449 336 *
450 337 * @since 2.0.16
451 338 *
452 - * @param int $form_id
453 - * @param int $parent_form_id
339 + * @param int $form_id
340 + * @param int $parent_form_id
454 341 * @param array $child_forms
455 342 */
456 343 private static function track_imported_child_forms( $form_id, $parent_form_id, &$child_forms ) {
457 344 if ( $parent_form_id ) {
@@ -484,14 +371,8 @@
484 371 *
485 372 * @since 2.0.13
486 373 *
487 374 * TODO: Cut down on params
488 - *
489 - * @param SimpleXMLElement $xml_fields
490 - * @param int|string $form_id
491 - * @param object $this_form
492 - * @param array $form_fields
493 - * @param array $imported
494 375 */
495 376 private static function import_xml_fields( $xml_fields, $form_id, $this_form, &$form_fields, &$imported ) {
496 377 $in_section = 0;
497 378 $keys_by_original_field_id = array();
@@ -509,13 +390,13 @@
509 390 if ( ! empty( $this_form ) ) {
510 391 // check for field to edit by field id
511 392 if ( isset( $form_fields[ $f['id'] ] ) ) {
512 393 FrmField::update( $f['id'], $f );
513 - ++$imported['updated']['fields'];
394 + $imported['updated']['fields'] ++;
514 395
515 396 unset( $form_fields[ $f['id'] ] );
516 397
517 - // Unset old field key.
398 + //unset old field key
518 399 if ( isset( $form_fields[ $f['field_key'] ] ) ) {
519 400 unset( $form_fields[ $f['field_key'] ] );
520 401 }
521 402 } elseif ( isset( $form_fields[ $f['field_key'] ] ) ) {
@@ -520,32 +401,25 @@
520 401 }
521 402 } elseif ( isset( $form_fields[ $f['field_key'] ] ) ) {
522 403 $keys_by_original_field_id[ $f['id'] ] = $f['field_key'];
523 404
524 - $old_field_id = $f['id'];
525 -
526 405 // check for field to edit by field key
527 406 unset( $f['id'] );
528 407
529 408 FrmField::update( $form_fields[ $f['field_key'] ], $f );
530 - ++$imported['updated']['fields'];
409 + $imported['updated']['fields'] ++;
531 410
532 - self::do_after_field_imported_action( $f, $form_fields, $old_field_id );
533 -
534 - // Unset old field id.
535 - unset( $form_fields[ $form_fields[ $f['field_key'] ] ] );
536 -
537 - // Unset old field key.
538 - unset( $form_fields[ $f['field_key'] ] );
411 + unset( $form_fields[ $form_fields[ $f['field_key'] ] ] ); //unset old field id
412 + unset( $form_fields[ $f['field_key'] ] ); //unset old field key
539 413 } else {
540 - // If no matching field id or key in this form, create the field.
414 + // if no matching field id or key in this form, create the field
541 415 self::create_imported_field( $f, $imported );
542 - }//end if
416 + }
543 417 } else {
544 418
545 419 self::create_imported_field( $f, $imported );
546 - }//end if
547 - }//end foreach
420 + }
421 + }
548 422
549 423 if ( $keys_by_original_field_id ) {
550 424 self::maybe_update_field_ids( $form_id, $keys_by_original_field_id );
551 425 }
@@ -550,53 +424,8 @@
550 424 self::maybe_update_field_ids( $form_id, $keys_by_original_field_id );
551 425 }
552 426 }
553 427
554 - /**
555 - * @since 6.8.4
556 - *
557 - * @param array $field_array
558 - *
559 - * @return array
560 - */
561 - private static function update_field_options_with_defaults( $field_array ) {
562 - $defaults = self::default_field_options( $field_array['type'] );
563 - $field_array['field_options'] = array_merge( $defaults, $field_array['field_options'] );
564 -
565 - return $field_array;
566 - }
567 -
568 - /**
569 - * @since 6.8.4
570 - *
571 - * @param array $field_array
572 - * @param array $form_fields
573 - * @param int $old_field_id
574 - *
575 - * @return void
576 - */
577 - private static function do_after_field_imported_action( $field_array, $form_fields, $old_field_id ) {
578 - // Assign field array the update field's ID.
579 - $field_array['id'] = $form_fields[ $field_array['field_key'] ];
580 -
581 - /**
582 - * Fires when an existing field is imported.
583 - *
584 - * @since 6.8.4
585 - *
586 - * @param array $field_array
587 - * @param int $field_id
588 - * @param int $old_field_id
589 - */
590 - do_action( 'frm_after_existing_field_is_imported', $field_array, $form_fields[ $field_array['field_key'] ], $old_field_id );
591 - }
592 -
593 - /**
594 - * @param object $field
595 - * @param int|string $form_id
596 - *
597 - * @return array
598 - */
599 428 private static function fill_field( $field, $form_id ) {
600 429 return array(
601 430 'id' => (int) $field->id,
602 431 'field_key' => (string) $field->field_key,
@@ -613,12 +442,8 @@
613 442 }
614 443
615 444 /**
616 445 * @since 4.06
617 - *
618 - * @param array $f
619 - *
620 - * @return void
621 446 */
622 447 private static function set_default_value( &$f ) {
623 448 $has_default = array(
624 449 'text',
@@ -645,12 +470,8 @@
645 470 /**
646 471 * Make sure the required indicator is set.
647 472 *
648 473 * @since 4.05
649 - *
650 - * @param array $f
651 - *
652 - * @return void
653 474 */
654 475 private static function maybe_add_required( &$f ) {
655 476 if ( $f['required'] && ! isset( $f['field_options']['required_indicator'] ) ) {
656 477 $f['field_options']['required_indicator'] = '*';
@@ -660,13 +481,10 @@
660 481 /**
661 482 * Update the current in_section value at the beginning of the field loop
662 483 *
663 484 * @since 2.0.25
664 - *
665 - * @param int $in_section
485 + * @param int $in_section
666 486 * @param array $f
667 - *
668 - * @return void
669 487 */
670 488 private static function maybe_update_in_section_variable( &$in_section, &$f ) {
671 489 // If we're at the end of a section, switch $in_section is 0
672 490 if ( in_array( $f['type'], array( 'end_divider', 'break', 'form' ) ) ) {
@@ -678,9 +496,9 @@
678 496 $f['field_options']['in_section'] = $in_section;
679 497 }
680 498
681 499 // If we're starting a new section, switch $in_section to ID of divider
682 - if ( $f['type'] === 'divider' ) {
500 + if ( $f['type'] == 'divider' ) {
683 501 $in_section = $f['id'];
684 502 }
685 503 }
686 504
@@ -696,12 +514,11 @@
696 514 if ( ! isset( $imported['forms'] ) ) {
697 515 return;
698 516 }
699 517
700 - if ( $f['type'] === 'form' || ( $f['type'] === 'divider' && FrmField::is_option_true( $f['field_options'], 'repeat' ) ) ) {
518 + if ( $f['type'] == 'form' || ( $f['type'] == 'divider' && FrmField::is_option_true( $f['field_options'], 'repeat' ) ) ) {
701 519 if ( FrmField::is_option_true( $f['field_options'], 'form_select' ) ) {
702 520 $form_select = (int) $f['field_options']['form_select'];
703 -
704 521 if ( isset( $imported['forms'][ $form_select ] ) ) {
705 522 $f['field_options']['form_select'] = $imported['forms'][ $form_select ];
706 523 }
707 524 }
@@ -714,10 +531,8 @@
714 531 * @since 2.01.0
715 532 *
716 533 * @param array $imported
717 534 * @param array $f
718 - *
719 - * @return void
720 535 */
721 536 private static function maybe_update_get_values_form_setting( $imported, &$f ) {
722 537 if ( ! isset( $imported['forms'] ) ) {
723 538 return;
@@ -724,9 +539,8 @@
724 539 }
725 540
726 541 if ( FrmField::is_option_true_in_array( $f['field_options'], 'get_values_form' ) ) {
727 542 $old_form = $f['field_options']['get_values_form'];
728 -
729 543 if ( isset( $imported['forms'][ $old_form ] ) ) {
730 544 $f['field_options']['get_values_form'] = $imported['forms'][ $old_form ];
731 545 }
732 546 }
@@ -732,23 +546,27 @@
732 546 }
733 547 }
734 548
735 549 /**
550 + * If field settings have been migrated, update the values during import.
551 + *
736 552 * @since 4.0
737 - *
738 - * @param array $f
739 - *
740 - * @return void
741 553 */
554 + private static function run_field_migrations( &$f ) {
555 + self::migrate_placeholders( $f );
556 + $f = apply_filters( 'frm_import_xml_field', $f );
557 + }
558 +
559 + /**
560 + * @since 4.0
561 + */
742 562 private static function migrate_placeholders( &$f ) {
743 563 $update_values = self::migrate_field_placeholder( $f, 'clear_on_focus' );
744 -
745 564 foreach ( $update_values as $k => $v ) {
746 565 $f[ $k ] = $v;
747 566 }
748 567
749 568 $update_values = self::migrate_field_placeholder( $f, 'default_blank' );
750 -
751 569 foreach ( $update_values as $k => $v ) {
752 570 $f[ $k ] = $v;
753 571 }
754 572 }
@@ -757,18 +575,13 @@
757 575 * Move clear_on_focus or default_blank to placeholder.
758 576 * Also called during database migration in FrmMigrate.
759 577 *
760 578 * @since 4.0
761 - *
762 - * @param array|object $field
763 - * @param string $type
764 - *
765 579 * @return array
766 580 */
767 581 public static function migrate_field_placeholder( $field, $type ) {
768 - $field = (array) $field;
582 + $field = (array) $field;
769 583 $field_options = $field['field_options'];
770 -
771 584 if ( empty( $field_options[ $type ] ) || empty( $field['default_value'] ) ) {
772 585 return array();
773 586 }
774 587
@@ -781,12 +594,10 @@
781 594 );
782 595
783 596 // If a dropdown placeholder was used, remove the option so it won't be included twice.
784 597 $options = $field['options'];
785 -
786 598 if ( $type === 'default_blank' && is_array( $options ) ) {
787 599 $default_value = $field['default_value'];
788 -
789 600 if ( is_array( $default_value ) ) {
790 601 $default_value = reset( $default_value );
791 602 }
792 603
@@ -791,9 +602,9 @@
791 602 }
792 603
793 604 foreach ( $options as $opt_key => $opt ) {
794 605 if ( is_array( $opt ) ) {
795 - $opt = $opt['value'] ?? $opt['label'] ?? reset( $opt );
606 + $opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) );
796 607 }
797 608
798 609 if ( $opt == $default_value ) {
799 610 unset( $options[ $opt_key ] );
@@ -812,70 +623,26 @@
812 623 * @since 2.0.25
813 624 *
814 625 * @param array $f
815 626 * @param array $imported
816 - *
817 - * @return void
818 627 */
819 628 private static function create_imported_field( $f, &$imported ) {
820 - $f = self::update_field_options_with_defaults( $f );
629 + $defaults = self::default_field_options( $f['type'] );
630 + $f['field_options'] = array_merge( $defaults, $f['field_options'] );
821 631
822 - if ( is_callable( 'FrmProFileImport::import_attachment' ) ) {
823 - $f = self::maybe_import_images_for_options( $f );
824 - }
825 -
826 632 $new_id = FrmField::create( $f );
827 -
828 633 if ( $new_id != false ) {
829 - ++$imported['imported']['fields'];
634 + $imported['imported']['fields'] ++;
830 635 do_action( 'frm_after_field_is_imported', $f, $new_id );
831 636 }
832 637 }
833 638
834 639 /**
835 - * Import images for radio buttons and checkboxes from image src if available.
836 - *
837 - * @since 5.5.1
838 - *
839 - * @param array $field
840 - *
841 - * @return array
842 - */
843 - private static function maybe_import_images_for_options( $field ) {
844 - if ( empty( $field['options'] ) || ! is_array( $field['options'] ) ) {
845 - return $field;
846 - }
847 -
848 - foreach ( $field['options'] as $key => $option ) {
849 - if ( ! is_array( $option ) || empty( $option['src'] ) ) {
850 - continue;
851 - }
852 -
853 - $field_object = (object) $field;
854 - // Fake the file type as FrmProImport::import_attachment checks for file type.
855 - $field_object->type = 'file';
856 -
857 - $image_id = FrmProFileImport::import_attachment( $option['src'], $field_object );
858 - // Remove the src from options as it isn't required after import.
859 - unset( $field['options'][ $key ]['src'] );
860 -
861 - if ( is_numeric( $image_id ) ) {
862 - $field['options'][ $key ]['image'] = $image_id;
863 - }
864 - }
865 -
866 - return $field;
867 - }
868 -
869 - /**
870 640 * Fix field ids for fields that already exist prior to import.
871 641 *
872 642 * @since 4.07
873 - *
874 - * @param int $form_id
643 + * @param int $form_id
875 644 * @param array $keys_by_original_field_id
876 - *
877 - * @return void
878 645 */
879 646 protected static function maybe_update_field_ids( $form_id, $keys_by_original_field_id ) {
880 647 global $frm_duplicate_ids;
881 648
@@ -915,10 +682,8 @@
915 682 *
916 683 * @since 2.0.19
917 684 *
918 685 * @param array $form
919 - *
920 - * @return void
921 686 */
922 687 private static function update_custom_style_setting_on_import( &$form ) {
923 688 if ( ! isset( $form['options']['custom_style'] ) ) {
924 689 return;
@@ -923,9 +688,9 @@
923 688 if ( ! isset( $form['options']['custom_style'] ) ) {
924 689 return;
925 690 }
926 691
927 - if ( is_numeric( $form['options']['custom_style'] ) && 1 === intval( $form['options']['custom_style'] ) ) {
692 + if ( is_numeric( $form['options']['custom_style'] ) ) {
928 693 // Set to default
929 694 $form['options']['custom_style'] = 1;
930 695 } else {
931 696 // Replace the style name with the style ID on import
@@ -946,9 +711,9 @@
946 711
947 712 // Set to default
948 713 $form['options']['custom_style'] = 1;
949 714 }
950 - }//end if
715 + }
951 716 }
952 717
953 718 /**
954 719 * After styles are imported, check for any forms that were linked
@@ -954,12 +719,8 @@
954 719 * After styles are imported, check for any forms that were linked
955 720 * and link them back up.
956 721 *
957 722 * @since 2.2.7
958 - *
959 - * @param int|string $form_id
960 - *
961 - * @return void
962 723 */
963 724 private static function update_custom_style_setting_after_import( $form_id ) {
964 725 $form = FrmForm::getOne( $form_id );
965 726
@@ -968,9 +729,8 @@
968 729 $saved_style = $form['options']['custom_style'];
969 730 $form['options']['custom_style'] = $form['options']['old_style'];
970 731 self::update_custom_style_setting_on_import( $form );
971 732 $has_changed = ( $form['options']['custom_style'] != $saved_style && $form['options']['custom_style'] != $form['options']['old_style'] );
972 -
973 733 if ( $has_changed ) {
974 734 FrmForm::update( $form['id'], $form );
975 735 }
976 736 }
@@ -975,16 +735,8 @@
975 735 }
976 736 }
977 737 }
978 738
979 - /**
980 - * Handle import for all posts. This includes views, styles, pages, and form actions.
981 - *
982 - * @param SimpleXMLElement $views
983 - * @param array $imported
984 - *
985 - * @return array
986 - */
987 739 public static function import_xml_views( $views, $imported ) {
988 740 $imported['posts'] = array();
989 741 $form_action_type = FrmFormActionsController::$action_post_type;
990 742
@@ -1022,13 +774,8 @@
1022 774 );
1023 775
1024 776 $post['post_content'] = self::switch_form_ids( $post['post_content'], $imported['forms'] );
1025 777
1026 - // Fix issue with line breaks appearing in descriptions as "rn".
1027 - if ( $post['post_type'] === $form_action_type ) {
1028 - $post['post_content'] = str_replace( '\\\\r\\\\n', '\\r\\n', $post['post_content'] );
1029 - }
1030 -
1031 778 $old_id = $post['post_id'];
1032 779 self::populate_post( $post, $item, $imported );
1033 780
1034 781 unset( $item );
@@ -1033,13 +780,11 @@
1033 780
1034 781 unset( $item );
1035 782
1036 783 $post_id = false;
1037 -
1038 784 if ( $post['post_type'] === $form_action_type ) {
1039 785 $action_control = FrmFormActionsController::get_form_actions( $post['post_excerpt'] );
1040 -
1041 - if ( $action_control && is_object( $action_control ) && isset( $imported['form_status'] ) ) {
786 + if ( $action_control && is_object( $action_control ) ) {
1042 787 $post_id = $action_control->maybe_create_action( $post, $imported['form_status'] );
1043 788 }
1044 789 unset( $action_control );
1045 790 } elseif ( $post['post_type'] === 'frm_styles' ) {
@@ -1044,29 +789,27 @@
1044 789 unset( $action_control );
1045 790 } elseif ( $post['post_type'] === 'frm_styles' ) {
1046 791 // Properly encode post content before inserting the post
1047 792 $post['post_content'] = FrmAppHelper::maybe_json_decode( $post['post_content'] );
793 + $custom_css = isset( $post['post_content']['custom_css'] ) ? $post['post_content']['custom_css'] : '';
1048 794 $post['post_content'] = FrmAppHelper::prepare_and_encode( $post['post_content'] );
1049 - // Store template data additionally to a postmeta that can be used to revert the style to default template style.
1050 - $post['postmeta']['frm_style_default'] = $post['post_content'];
1051 795
1052 796 // Create/update post now
1053 797 $post_id = wp_insert_post( $post );
798 + self::maybe_update_custom_css( $custom_css );
1054 799 } else {
1055 800 if ( $post['post_type'] === 'frm_display' ) {
1056 801 $post['post_content'] = self::maybe_prepare_json_view_content( $post['post_content'] );
1057 - } elseif ( 'page' === $post['post_type'] && isset( $imported['posts'][ $post['post_parent'] ] ) ) {
1058 - $post['post_parent'] = $imported['posts'][ $post['post_parent'] ];
1059 802 }
1060 803 // Create/update post now
1061 804 $post_id = wp_insert_post( $post );
1062 - }//end if
805 + }
1063 806
1064 807 if ( ! is_numeric( $post_id ) ) {
1065 808 continue;
1066 809 }
1067 810
1068 - if ( false !== strpos( $post['post_content'], '[display-frm-data' ) || false !== strpos( $post['post_content'], '[formidable' ) ) {
811 + if ( false !== strpos( $post['post_content'], '[frm-display-data' ) || false !== strpos( $post['post_content'], '[formidable' ) ) {
1069 812 $posts_with_shortcodes[ $post_id ] = $post;
1070 813 }
1071 814
1072 815 self::update_postmeta( $post, $post_id );
@@ -1072,29 +815,28 @@
1072 815 self::update_postmeta( $post, $post_id );
1073 816 self::update_layout( $post, $post_id );
1074 817
1075 818 $this_type = 'posts';
1076 -
1077 819 if ( isset( $post_types[ $post['post_type'] ] ) ) {
1078 820 $this_type = $post_types[ $post['post_type'] ];
1079 821 }
1080 822
1081 823 if ( isset( $post['ID'] ) && $post_id == $post['ID'] ) {
1082 - ++$imported['updated'][ $this_type ];
824 + $imported['updated'][ $this_type ] ++;
1083 825 } else {
1084 - ++$imported['imported'][ $this_type ];
826 + $imported['imported'][ $this_type ] ++;
1085 827 }
1086 828
1087 - $imported['posts'][ $old_id ] = $post_id;
829 + $imported['posts'][ (int) $old_id ] = $post_id;
1088 830
1089 831 if ( $post['post_type'] === 'frm_display' ) {
1090 - $view_ids[ $old_id ] = $post_id;
832 + $view_ids[ (int) $old_id ] = $post_id;
1091 833 }
1092 834
1093 835 do_action( 'frm_after_import_view', $post_id, $post );
1094 836
1095 837 unset( $post );
1096 - }//end foreach
838 + }
1097 839
1098 840 if ( $posts_with_shortcodes && $view_ids ) {
1099 841 self::maybe_switch_view_ids_after_importing_posts( $posts_with_shortcodes, $view_ids );
1100 842 }
@@ -1099,59 +841,18 @@
1099 841 self::maybe_switch_view_ids_after_importing_posts( $posts_with_shortcodes, $view_ids );
1100 842 }
1101 843 unset( $posts_with_shortcodes, $view_ids );
1102 844
1103 - if ( ! empty( $imported['forms'] ) ) {
1104 - // clear imported forms style cache to make sure the new styles are applied to the forms
1105 - self::clear_forms_style_caches( $imported['forms'] );
1106 - }
1107 -
1108 845 self::maybe_update_stylesheet( $imported );
1109 846
1110 - flush_rewrite_rules();
1111 -
1112 847 return $imported;
1113 848 }
1114 849
1115 850 /**
1116 - * Clears styles from cache for imported forms
1117 - *
1118 - * @param array $imported_forms
1119 - *
1120 - * @return void
1121 - */
1122 - private static function clear_forms_style_caches( $imported_forms ) {
1123 - $where = array(
1124 - 'id' => $imported_forms,
1125 - 'options LIKE' => '"old_style"',
1126 - );
1127 - $forms = FrmDb::get_results( 'frm_forms', $where );
1128 -
1129 - foreach ( $forms as $form ) {
1130 - FrmAppHelper::unserialize_or_decode( $form->options );
1131 -
1132 - if ( ! $form->options ) {
1133 - continue;
1134 - }
1135 -
1136 - $where = array(
1137 - 'post_name' => $form->options['old_style'],
1138 - 'post_type' => FrmStylesController::$post_type,
1139 - );
1140 -
1141 - $select = 'ID';
1142 -
1143 - $cache_key = FrmDb::generate_cache_key( $where, array( 'limit' => 1 ), $select, 'var' );
1144 - FrmDb::delete_cache_and_transient( $cache_key, 'post' );
1145 - }
1146 - }
1147 -
1148 - /**
1149 851 * Replace old form ids with new ones in a string.
1150 852 *
1151 853 * @param string $string
1152 854 * @param array<int> $form_ids new form ids indexed by old form id.
1153 - *
1154 855 * @return string
1155 856 */
1156 857 private static function switch_form_ids( $string, $form_ids ) {
1157 858 if ( false === strpos( $string, '[formidable' ) ) {
@@ -1182,15 +883,13 @@
1182 883
1183 884 /**
1184 885 * @param array<array> $posts_with_shortcodes indexed by current post id.
1185 886 * @param array<int> $view_ids new view ids indexed by old view id.
1186 - *
1187 887 * @return void
1188 888 */
1189 889 private static function maybe_switch_view_ids_after_importing_posts( $posts_with_shortcodes, $view_ids ) {
1190 890 foreach ( $posts_with_shortcodes as $imported_post_id => $post ) {
1191 891 $post_content = self::switch_view_ids( $post['post_content'], $view_ids );
1192 -
1193 892 if ( $post_content === $post['post_content'] ) {
1194 893 continue;
1195 894 }
1196 895
@@ -1207,9 +906,8 @@
1207 906 * Replace old view ids with new ones in a string.
1208 907 *
1209 908 * @param string $string
1210 909 * @param array<int> $view_ids new view ids indexed by old view id.
1211 - *
1212 910 * @return string
1213 911 */
1214 912 private static function switch_view_ids( $string, $view_ids ) {
1215 913 if ( false === strpos( $string, '[display-frm-data' ) ) {
@@ -1240,14 +938,12 @@
1240 938 }
1241 939
1242 940 /**
1243 941 * @param string $content
1244 - *
1245 942 * @return string
1246 943 */
1247 944 private static function maybe_prepare_json_view_content( $content ) {
1248 945 $maybe_decoded = FrmAppHelper::maybe_json_decode( $content );
1249 -
1250 946 if ( is_array( $maybe_decoded ) && isset( $maybe_decoded[0] ) && isset( $maybe_decoded[0]['box'] ) ) {
1251 947 return FrmAppHelper::prepare_and_encode( $maybe_decoded );
1252 948 }
1253 949 return $content;
@@ -1252,15 +948,8 @@
1252 948 }
1253 949 return $content;
1254 950 }
1255 951
1256 - /**
1257 - * @param array $post
1258 - * @param object $item
1259 - * @param array $imported
1260 - *
1261 - * @return void
1262 - */
1263 952 private static function populate_post( &$post, $item, $imported ) {
1264 953 if ( isset( $item->attachment_url ) ) {
1265 954 $post['attachment_url'] = (string) $item->attachment_url;
1266 955 }
@@ -1302,9 +991,9 @@
1302 991 'key' => (string) $meta->meta_key,
1303 992 'value' => (string) $meta->meta_value,
1304 993 );
1305 994
1306 - // Switch old form and field ids to new ones.
995 + //switch old form and field ids to new ones
1307 996 if ( 'frm_form_id' === $m['key'] && isset( $imported['forms'][ (int) $m['value'] ] ) ) {
1308 997 $m['value'] = $imported['forms'][ (int) $m['value'] ];
1309 998 } else {
1310 999 $m['value'] = FrmAppHelper::maybe_json_decode( $m['value'] );
@@ -1320,37 +1009,10 @@
1320 1009 $m['value'][ $setting_name ] = $frm_duplicate_ids[ $m['value'][ $setting_name ] ];
1321 1010 }
1322 1011 }
1323 1012
1324 - if ( ! empty( $m['value']['map_address_fields'] ) ) {
1325 - foreach ( $m['value']['map_address_fields'] as $address_field_key => $address_field_id ) {
1326 - if ( isset( $frm_duplicate_ids[ $address_field_id ] ) ) {
1327 - $m['value']['map_address_fields'][ $address_field_key ] = $frm_duplicate_ids[ $address_field_id ];
1328 - }
1329 - }
1330 - }
1331 -
1332 - if ( ! empty( $m['value']['calendar_options'] ) ) {
1333 - foreach ( $m['value']['calendar_options'] as $calendar_option_group_key => $calendar_option ) {
1334 - if ( isset( $frm_duplicate_ids[ $calendar_option['value'] ] ) ) {
1335 - $m['value']['calendar_options'][ $calendar_option_group_key ]['value'] = $frm_duplicate_ids[ $calendar_option['value'] ];
1336 - }
1337 - }
1338 - }
1339 -
1340 - if ( ! empty( $m['value']['timeline_options'] ) ) {
1341 - foreach ( $m['value']['timeline_options'] as $timeline_option_group_key => $timeline_group_option ) {
1342 - foreach ( $timeline_group_option as $timeline_option_key => $timeline_option ) {
1343 - if ( isset( $frm_duplicate_ids[ $timeline_option ] ) ) {
1344 - $m['value']['timeline_options'][ $timeline_option_group_key ][ $timeline_option_key ] = $frm_duplicate_ids[ $timeline_option ];
1345 - }
1346 - }
1347 - }
1348 - }
1349 -
1350 1013 $check_dup_array = array();
1351 -
1352 - if ( ! empty( $m['value']['order_by'] ) ) {
1014 + if ( isset( $m['value']['order_by'] ) && ! empty( $m['value']['order_by'] ) ) {
1353 1015 if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[ $m['value']['order_by'] ] ) ) {
1354 1016 $m['value']['order_by'] = $frm_duplicate_ids[ $m['value']['order_by'] ];
1355 1017 } elseif ( is_array( $m['value']['order_by'] ) ) {
1356 1018 $check_dup_array[] = 'order_by';
@@ -1356,9 +1018,9 @@
1356 1018 $check_dup_array[] = 'order_by';
1357 1019 }
1358 1020 }
1359 1021
1360 - if ( ! empty( $m['value']['where'] ) ) {
1022 + if ( isset( $m['value']['where'] ) && ! empty( $m['value']['where'] ) ) {
1361 1023 $check_dup_array[] = 'where';
1362 1024 }
1363 1025
1364 1026 foreach ( $check_dup_array as $check_k ) {
@@ -1368,11 +1030,11 @@
1368 1030 }
1369 1031 unset( $mk, $mv );
1370 1032 }
1371 1033 }
1372 - }//end if
1373 - }//end if
1374 - }//end if
1034 + }
1035 + }
1036 + }
1375 1037
1376 1038 if ( ! is_array( $m['value'] ) ) {
1377 1039 $m['value'] = FrmAppHelper::maybe_json_decode( $m['value'] );
1378 1040 }
@@ -1379,14 +1041,8 @@
1379 1041
1380 1042 $post['postmeta'][ (string) $meta->meta_key ] = $m['value'];
1381 1043 }
1382 1044
1383 - /**
1384 - * @param array $post
1385 - * @param object $layout
1386 - *
1387 - * @return void
1388 - */
1389 1045 private static function populate_layout( &$post, $layout ) {
1390 1046 $post['layout'][ (string) $layout->type ] = (string) $layout->data;
1391 1047 }
1392 1048
@@ -1392,25 +1048,22 @@
1392 1048
1393 1049 /**
1394 1050 * Add terms to post
1395 1051 *
1396 - * @param array $post By reference.
1397 - * @param object $item The XML object data.
1052 + * @param array $post by reference
1053 + * @param object $item The XML object data
1398 1054 */
1399 1055 private static function populate_taxonomies( &$post, $item ) {
1400 1056 foreach ( $item->category as $c ) {
1401 1057 $att = $c->attributes();
1402 -
1403 1058 if ( ! isset( $att['nicename'] ) ) {
1404 1059 continue;
1405 1060 }
1406 1061
1407 1062 $taxonomy = (string) $att['domain'];
1408 -
1409 1063 if ( is_taxonomy_hierarchical( $taxonomy ) ) {
1410 1064 $name = (string) $att['nicename'];
1411 1065 $h_term = get_term_by( 'slug', $name, $taxonomy );
1412 -
1413 1066 if ( $h_term ) {
1414 1067 $name = $h_term->term_id;
1415 1068 }
1416 1069 unset( $h_term );
@@ -1423,17 +1076,13 @@
1423 1076 }
1424 1077
1425 1078 $post['tax_input'][ $taxonomy ][] = $name;
1426 1079 unset( $name );
1427 - }//end foreach
1080 + }
1428 1081 }
1429 1082
1430 1083 /**
1431 - * Edit post if the key and created time match.
1432 - *
1433 - * @param array $post By reference.
1434 - *
1435 - * @return void
1084 + * Edit post if the key and created time match
1436 1085 */
1437 1086 private static function maybe_editing_post( &$post ) {
1438 1087 $match_by = array(
1439 1088 'post_type' => $post['post_type'],
@@ -1441,9 +1090,9 @@
1441 1090 'post_status' => $post['post_status'],
1442 1091 'posts_per_page' => 1,
1443 1092 );
1444 1093
1445 - if ( in_array( $post['post_status'], array( 'trash', 'draft' ), true ) ) {
1094 + if ( in_array( $post['post_status'], array( 'trash', 'draft' ) ) ) {
1446 1095 $match_by['include'] = $post['post_id'];
1447 1096 unset( $match_by['name'] );
1448 1097 }
1449 1098
@@ -1454,43 +1103,26 @@
1454 1103 $post['ID'] = current( $editing )->ID;
1455 1104 }
1456 1105 }
1457 1106
1458 - /**
1459 - * @param array $post
1460 - * @param int $post_id
1461 - *
1462 - * @return void
1463 - */
1464 1107 private static function update_postmeta( &$post, $post_id ) {
1465 1108 foreach ( $post['postmeta'] as $k => $v ) {
1466 - switch ( $k ) {
1467 - case '_edit_last':
1468 - $v = FrmAppHelper::get_user_id_param( $v );
1469 - break;
1109 + if ( '_edit_last' == $k ) {
1110 + $v = FrmAppHelper::get_user_id_param( $v );
1111 + } elseif ( '_thumbnail_id' == $k && FrmAppHelper::pro_is_installed() ) {
1112 + // Change the attachment ID.
1113 + $field_obj = FrmFieldFactory::get_field_type( 'file' );
1114 + $v = $field_obj->get_file_id( $v );
1115 + }
1470 1116
1471 - case '_thumbnail_id':
1472 - if ( FrmAppHelper::pro_is_installed() ) {
1473 - // Change the attachment ID.
1474 - $field_obj = FrmFieldFactory::get_field_type( 'file' );
1475 - $v = $field_obj->get_file_id( $v );
1476 - }
1477 - break;
1117 + if ( 'frm_dyncontent' === $k && is_array( $v ) ) {
1118 + $v = json_encode( $v );
1119 + }
1478 1120
1479 - case 'frm_dyncontent':
1480 - if ( is_array( $v ) ) {
1481 - $v = json_encode( $v );
1482 - }
1483 - break;
1121 + update_post_meta( $post_id, $k, $v );
1484 1122
1485 - case 'frm_param':
1486 - add_rewrite_endpoint( $v, EP_PERMALINK | EP_PAGES );
1487 - break;
1488 - }//end switch
1489 -
1490 - update_post_meta( $post_id, $k, $v );
1491 1123 unset( $k, $v );
1492 - }//end foreach
1124 + }
1493 1125 }
1494 1126
1495 1127 /**
1496 1128 * @param array $post
@@ -1499,9 +1131,8 @@
1499 1131 private static function update_layout( &$post, $post_id ) {
1500 1132 if ( is_callable( 'FrmViewsLayout::maybe_create_layouts_for_view' ) ) {
1501 1133 $listing_layout = ! empty( $post['layout']['listing'] ) ? json_decode( $post['layout']['listing'], true ) : array();
1502 1134 $detail_layout = ! empty( $post['layout']['detail'] ) ? json_decode( $post['layout']['detail'], true ) : array();
1503 -
1504 1135 if ( $listing_layout || $detail_layout ) {
1505 1136 FrmViewsLayout::maybe_create_layouts_for_view( $post_id, $listing_layout, $detail_layout );
1506 1137 }
1507 1138 }
@@ -1507,22 +1138,32 @@
1507 1138 }
1508 1139 }
1509 1140
1510 1141 /**
1511 - * @param array $imported
1142 + * If a template includes custom css, let's include it.
1143 + * The custom css is included on the default style.
1512 1144 *
1513 - * @return void
1145 + * @since 2.03
1514 1146 */
1147 + private static function maybe_update_custom_css( $custom_css ) {
1148 + if ( empty( $custom_css ) ) {
1149 + return;
1150 + }
1151 +
1152 + $frm_style = new FrmStyle();
1153 + $default_style = $frm_style->get_default_style();
1154 + $default_style->post_content['custom_css'] .= "\r\n\r\n" . $custom_css;
1155 + $frm_style->save( $default_style );
1156 + }
1157 +
1515 1158 private static function maybe_update_stylesheet( $imported ) {
1516 - $new_styles = ! empty( $imported['imported']['styles'] );
1517 - $updated_styles = ! empty( $imported['updated']['styles'] );
1518 -
1159 + $new_styles = isset( $imported['imported']['styles'] ) && ! empty( $imported['imported']['styles'] );
1160 + $updated_styles = isset( $imported['updated']['styles'] ) && ! empty( $imported['updated']['styles'] );
1519 1161 if ( $new_styles || $updated_styles ) {
1520 1162 if ( is_admin() && function_exists( 'get_filesystem_method' ) ) {
1521 1163 $frm_style = new FrmStyle();
1522 1164 $frm_style->update( 'default' );
1523 1165 }
1524 -
1525 1166 foreach ( $imported['forms'] as $form_id ) {
1526 1167 self::update_custom_style_setting_after_import( $form_id );
1527 1168 }
1528 1169 }
@@ -1528,46 +1169,20 @@
1528 1169 }
1529 1170 }
1530 1171
1531 1172 /**
1532 - * @param mixed $result
1533 1173 * @param string $message
1534 - * @param array $errors
1535 1174 */
1536 1175 public static function parse_message( $result, &$message, &$errors ) {
1537 1176 if ( is_wp_error( $result ) ) {
1538 1177 $errors[] = $result->get_error_message();
1539 -
1540 - // Remove the SimpleXML_parse_error from the WP_Error object to avoid
1541 - // displaying duplicate error messages from $result->get_error_message()
1542 - $error_codes = $result->get_error_codes();
1543 - $error_details = array();
1544 -
1545 - foreach ( $error_codes as $error_code ) {
1546 - // Clone WP_Error data because WP_Error removes all error messages and data
1547 - // associated with the specified error code when an item is removed.
1548 - // Source: https://developer.wordpress.org/reference/classes/wp_error/remove/#source
1549 - $error_details = $result->get_error_data( $error_code );
1550 -
1551 - if ( $error_code === 'SimpleXML_parse_error' ) {
1552 - $result->remove( $error_code );
1553 - break;
1554 - }
1555 - }
1556 -
1557 - if ( ! empty( $error_details ) ) {
1558 - $errors[] = '<br />' . esc_html_x( 'Error details:', 'import xml message', 'formidable' ) . '<br />' . esc_html( print_r( $error_details, 1 ) );
1559 - }
1560 -
1178 + } elseif ( ! $result ) {
1561 1179 return;
1562 - }//end if
1563 -
1564 - if ( ! $result ) {
1565 - return;
1566 1180 }
1567 1181
1568 1182 if ( ! is_array( $result ) ) {
1569 1183 $message = is_string( $result ) ? $result : htmlentities( print_r( $result, 1 ) );
1184 +
1570 1185 return;
1571 1186 }
1572 1187
1573 1188 $t_strings = array(
@@ -1575,9 +1190,8 @@
1575 1190 'updated' => __( 'Updated', 'formidable' ),
1576 1191 );
1577 1192
1578 1193 $message = '<ul>';
1579 -
1580 1194 foreach ( $result as $type => $results ) {
1581 1195 if ( ! isset( $t_strings[ $type ] ) ) {
1582 1196 // only print imported and updated
1583 1197 continue;
@@ -1583,9 +1197,8 @@
1583 1197 continue;
1584 1198 }
1585 1199
1586 1200 $s_message = array();
1587 -
1588 1201 foreach ( $results as $k => $m ) {
1589 1202 self::item_count_message( $m, $k, $s_message );
1590 1203 unset( $k, $m );
1591 1204 }
@@ -1596,9 +1209,9 @@
1596 1209 $message .= '</li>';
1597 1210 }
1598 1211 }
1599 1212
1600 - if ( $message === '<ul>' ) {
1213 + if ( $message == '<ul>' ) {
1601 1214 $message = '';
1602 1215 $errors[] = __( 'Nothing was imported or updated', 'formidable' );
1603 1216 } else {
1604 1217 self::add_form_link_to_message( $result, $message );
@@ -1663,21 +1276,18 @@
1663 1276 /**
1664 1277 * If a single form was imported, include a link in the success message.
1665 1278 *
1666 1279 * @since 4.0
1667 - *
1668 1280 * @param array $result The response from the XML import.
1669 1281 * @param string $message The response shown on the page after import.
1670 1282 */
1671 1283 private static function add_form_link_to_message( $result, &$message ) {
1672 1284 $total_forms = $result['imported']['forms'] + $result['updated']['forms'];
1673 -
1674 1285 if ( $total_forms > 1 ) {
1675 1286 return;
1676 1287 }
1677 1288
1678 1289 $primary_form = reset( $result['forms'] );
1679 -
1680 1290 if ( ! empty( $primary_form ) ) {
1681 1291 $primary_form = FrmForm::getOne( $primary_form );
1682 1292 $form_id = empty( $primary_form->parent_form_id ) ? $primary_form->id : $primary_form->parent_form_id;
1683 1293
@@ -1697,9 +1307,8 @@
1697 1307 public static function prepare_form_options_for_export( $options ) {
1698 1308 FrmAppHelper::unserialize_or_decode( $options );
1699 1309 // Change custom_style to the post_name instead of ID (1 may be a string)
1700 1310 $not_default = isset( $options['custom_style'] ) && 1 != $options['custom_style'];
1701 -
1702 1311 if ( $not_default ) {
1703 1312 global $wpdb;
1704 1313 $table = $wpdb->prefix . 'posts';
1705 1314 $where = array( 'ID' => $options['custom_style'] );
@@ -1723,16 +1332,11 @@
1723 1332 * If the saved value is the same as the default, remove it from the export
1724 1333 * This keeps file size down and prevents overriding global settings after import
1725 1334 *
1726 1335 * @since 3.06
1727 - *
1728 - * @param array $options By reference.
1729 - *
1730 - * @return void
1731 1336 */
1732 1337 private static function remove_default_form_options( &$options ) {
1733 1338 $defaults = FrmFormsHelper::get_default_opts();
1734 -
1735 1339 if ( is_callable( 'FrmProFormsHelper::get_default_opts' ) ) {
1736 1340 $defaults += FrmProFormsHelper::get_default_opts();
1737 1341 }
1738 1342 self::remove_defaults( $defaults, $options );
@@ -1741,16 +1345,11 @@
1741 1345 /**
1742 1346 * Remove extra settings from field to keep file size down
1743 1347 *
1744 1348 * @since 3.06
1745 - *
1746 - * @param object $field
1747 - *
1748 - * @return void
1749 1349 */
1750 1350 public static function prepare_field_for_export( &$field ) {
1751 1351 self::remove_default_field_options( $field );
1752 - self::add_image_src_to_image_options( $field );
1753 1352 }
1754 1353
1755 1354 /**
1756 1355 * Remove defaults from field options too
@@ -1755,16 +1354,11 @@
1755 1354 /**
1756 1355 * Remove defaults from field options too
1757 1356 *
1758 1357 * @since 3.06
1759 - *
1760 - * @param object $field
1761 - *
1762 - * @return void
1763 1358 */
1764 1359 private static function remove_default_field_options( &$field ) {
1765 1360 $defaults = self::default_field_options( $field->type );
1766 -
1767 1361 if ( empty( $defaults['blank'] ) ) {
1768 1362 $global_settings = new FrmSettings();
1769 1363 $global_defaults = $global_settings->default_options();
1770 1364 $defaults['blank'] = $global_defaults['blank_msg'];
@@ -1787,51 +1381,12 @@
1787 1381 $field->field_options = serialize( $options );
1788 1382 }
1789 1383
1790 1384 /**
1791 - * Add image "src" key to each image option so the image can be imported to another website.
1792 - *
1793 - * @since 5.5.1
1794 - *
1795 - * @param stdClass $field
1796 - *
1797 - * @return void
1798 - */
1799 - private static function add_image_src_to_image_options( $field ) {
1800 - if ( empty( $field->options ) || false === strpos( $field->options, 'image' ) ) {
1801 - return;
1802 - }
1803 -
1804 - $updated = false;
1805 - $options = $field->options;
1806 - FrmAppHelper::unserialize_or_decode( $options );
1807 -
1808 - if ( ! $options || ! is_array( $options ) ) {
1809 - return;
1810 - }
1811 -
1812 - foreach ( $options as $key => $option ) {
1813 - if ( is_array( $option ) && ! empty( $option['image'] ) ) {
1814 - $options[ $key ]['src'] = wp_get_attachment_url( $option['image'] );
1815 - $updated = true;
1816 - }
1817 - }
1818 -
1819 - if ( $updated ) {
1820 - $field->options = maybe_serialize( $options );
1821 - }
1822 - }
1823 -
1824 - /**
1825 1385 * @since 3.06.03
1826 - *
1827 - * @param string $type
1828 - *
1829 - * @return array
1830 1386 */
1831 1387 private static function default_field_options( $type ) {
1832 1388 $defaults = FrmFieldsHelper::get_default_field_options( $type );
1833 -
1834 1389 if ( empty( $defaults['custom_html'] ) ) {
1835 1390 $defaults['custom_html'] = FrmFieldsHelper::get_default_html( $type );
1836 1391 }
1837 1392 return $defaults;
@@ -1841,13 +1396,8 @@
1841 1396 * Compare the default array to the saved values and
1842 1397 * remove if they are the same
1843 1398 *
1844 1399 * @since 3.06
1845 - *
1846 - * @param array $defaults
1847 - * @param array $saved
1848 - *
1849 - * @return void
1850 1400 */
1851 1401 private static function remove_defaults( $defaults, &$saved ) {
1852 1402 foreach ( $saved as $key => $value ) {
1853 1403 if ( isset( $defaults[ $key ] ) && $defaults[ $key ] === $value ) {
@@ -1859,14 +1409,8 @@
1859 1409 /**
1860 1410 * The line endings may prevent html from being equal when it should
1861 1411 *
1862 1412 * @since 3.06
1863 - *
1864 - * @param string $html_name
1865 - * @param array $defaults
1866 - * @param array $options
1867 - *
1868 - * @return void
1869 1413 */
1870 1414 private static function remove_default_html( $html_name, $defaults, &$options ) {
1871 1415 if ( ! isset( $options[ $html_name ] ) || ! isset( $defaults[ $html_name ] ) ) {
1872 1416 return;
@@ -1873,9 +1417,8 @@
1873 1417 }
1874 1418
1875 1419 $old_html = str_replace( "\r\n", "\n", $options[ $html_name ] );
1876 1420 $default_html = $defaults[ $html_name ];
1877 -
1878 1421 if ( $old_html == $default_html ) {
1879 1422 unset( $options[ $html_name ] );
1880 1423
1881 1424 return;
@@ -1882,26 +1425,19 @@
1882 1425 }
1883 1426
1884 1427 // Account for some of the older field default HTML.
1885 1428 $default_html = str_replace( ' id="frm_desc_field_[key]"', '', $default_html );
1886 -
1887 - if ( $old_html === $default_html ) {
1429 + if ( $old_html == $default_html ) {
1888 1430 unset( $options[ $html_name ] );
1889 1431 }
1890 1432 }
1891 1433
1892 - /**
1893 - * @param string $str
1894 - *
1895 - * @return string
1896 - */
1897 1434 public static function cdata( $str ) {
1898 1435 FrmAppHelper::unserialize_or_decode( $str );
1899 -
1900 1436 if ( is_array( $str ) ) {
1901 1437 $str = json_encode( $str );
1902 - } elseif ( FrmAppHelper::is_valid_utf8( $str ) === false ) {
1903 - $str = FrmAppHelper::maybe_utf8_encode( $str );
1438 + } elseif ( seems_utf8( $str ) === false ) {
1439 + $str = utf8_encode( $str );
1904 1440 }
1905 1441
1906 1442 if ( is_numeric( $str ) ) {
1907 1443 return $str;
@@ -1920,10 +1456,8 @@
1920 1456 *
1921 1457 * @since 2.0.22
1922 1458 *
1923 1459 * @param string $str
1924 - *
1925 - * @return void
1926 1460 */
1927 1461 private static function remove_invalid_characters_from_xml( &$str ) {
1928 1462 // Remove <US> character
1929 1463 $str = str_replace( '\x1F', '', $str );
@@ -1928,18 +1462,8 @@
1928 1462 // Remove <US> character
1929 1463 $str = str_replace( '\x1F', '', $str );
1930 1464 }
1931 1465
1932 - /**
1933 - * Migrate form settings to actions
1934 - *
1935 - * @param array $form_options
1936 - * @param int $form_id
1937 - * @param array $imported
1938 - * @param bool $switch
1939 - *
1940 - * @return void
1941 - */
1942 1466 public static function migrate_form_settings_to_actions( $form_options, $form_id, &$imported = array(), $switch = false ) {
1943 1467 // Get post type
1944 1468 $post_type = FrmFormActionsController::$action_post_type;
1945 1469
@@ -1957,13 +1481,9 @@
1957 1481
1958 1482 /**
1959 1483 * Migrate post settings to form action
1960 1484 *
1961 - * @param array $form_options
1962 - * @param int $form_id
1963 1485 * @param string $post_type
1964 - * @param array $imported
1965 - * @param bool $switch
1966 1486 */
1967 1487 private static function migrate_post_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
1968 1488 if ( ! isset( $form_options['create_post'] ) || ! $form_options['create_post'] ) {
1969 1489 return;
@@ -2032,9 +1552,9 @@
2032 1552
2033 1553 if ( ! $exists ) {
2034 1554 // this isn't an email, but we need to use a class that will always be included
2035 1555 FrmDb::save_json_post( $new_action );
2036 - ++$imported['imported']['actions'];
1556 + $imported['imported']['actions'] ++;
2037 1557 }
2038 1558 }
2039 1559
2040 1560 /**
@@ -2041,11 +1561,11 @@
2041 1561 * Switch old field IDs for new field IDs in emails and post
2042 1562 *
2043 1563 * @since 2.0
2044 1564 *
2045 - * @param array $post_content Check for old field IDs.
2046 - * @param array $basic_fields Fields with string or int saved.
2047 - * @param array $array_fields Fields with arrays saved.
1565 + * @param array $post_content - check for old field IDs
1566 + * @param array $basic_fields - fields with string or int saved
1567 + * @param array $array_fields - fields with arrays saved
2048 1568 *
2049 1569 * @return string $post_content - new field IDs
2050 1570 */
2051 1571 private static function switch_action_field_ids( $post_content, $basic_fields, $array_fields = array() ) {
@@ -2078,19 +1598,8 @@
2078 1598
2079 1599 return $post_content;
2080 1600 }
2081 1601
2082 - /**
2083 - * Migrate email settings to action
2084 - *
2085 - * @param array $form_options
2086 - * @param int $form_id
2087 - * @param string $post_type
2088 - * @param array $imported
2089 - * @param bool $switch
2090 - *
2091 - * @return void
2092 - */
2093 1602 private static function migrate_email_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
2094 1603 // No old notifications or autoresponders to carry over
2095 1604 if ( ! isset( $form_options['auto_responder'] ) && ! isset( $form_options['notification'] ) && ! isset( $form_options['email_to'] ) ) {
2096 1605 return;
@@ -2137,12 +1646,12 @@
2137 1646 );
2138 1647
2139 1648 if ( empty( $exists ) ) {
2140 1649 FrmDb::save_json_post( $new_notification );
2141 - ++$imported['imported']['actions'];
1650 + $imported['imported']['actions'] ++;
2142 1651 }
2143 1652 unset( $new_notification );
2144 - }//end foreach
1653 + }
2145 1654
2146 1655 self::remove_deprecated_notification_settings( $form_id, $form_options );
2147 1656 }
2148 1657
@@ -2151,15 +1660,12 @@
2151 1660 *
2152 1661 * @since 2.05
2153 1662 *
2154 1663 * @param int|string $form_id
2155 - * @param array $form_options
2156 - *
2157 - * @return void
1664 + * @param array $form_options
2158 1665 */
2159 1666 private static function remove_deprecated_notification_settings( $form_id, $form_options ) {
2160 1667 $delete_settings = array( 'notification', 'autoresponder', 'email_to' );
2161 -
2162 1668 foreach ( $delete_settings as $index ) {
2163 1669 if ( isset( $form_options[ $index ] ) ) {
2164 1670 unset( $form_options[ $index ] );
2165 1671 }
@@ -2166,19 +1672,10 @@
2166 1672 }
2167 1673 FrmForm::update( $form_id, array( 'options' => $form_options ) );
2168 1674 }
2169 1675
2170 - /**
2171 - * Migrate notifications to action
2172 - *
2173 - * @param array $form_options
2174 - * @param int $form_id
2175 - * @param array $notifications
2176 - *
2177 - * @return void
2178 - */
2179 1676 private static function migrate_notifications_to_action( $form_options, $form_id, &$notifications ) {
2180 - if ( ! isset( $form_options['notification'] ) && ! empty( $form_options['email_to'] ) ) {
1677 + if ( ! isset( $form_options['notification'] ) && isset( $form_options['email_to'] ) && ! empty( $form_options['email_to'] ) ) {
2181 1678 // add old settings into notification array
2182 1679 $form_options['notification'] = array( 0 => $form_options );
2183 1680 } elseif ( isset( $form_options['notification']['email_to'] ) ) {
2184 1681 // make sure it's in the correct format
@@ -2208,20 +1705,12 @@
2208 1705 $new_notification = array();
2209 1706 self::setup_new_notification( $new_notification, $notification, $atts );
2210 1707
2211 1708 $notifications[] = $new_notification;
2212 - }//end foreach
2213 - }//end if
1709 + }
1710 + }
2214 1711 }
2215 1712
2216 - /**
2217 - * Format email data
2218 - *
2219 - * @param array $atts
2220 - * @param array $notification
2221 - *
2222 - * @return void
2223 - */
2224 1713 private static function format_email_data( &$atts, $notification ) {
2225 1714 // Format email_to
2226 1715 self::format_email_to_data( $atts, $notification );
2227 1716
@@ -2229,13 +1718,11 @@
2229 1718 $reply_fields = array(
2230 1719 'reply_to' => '',
2231 1720 'reply_to_name' => '',
2232 1721 );
2233 -
2234 1722 foreach ( $reply_fields as $f => $val ) {
2235 1723 if ( isset( $notification[ $f ] ) ) {
2236 1724 $atts[ $f ] = $notification[ $f ];
2237 -
2238 1725 if ( 'custom' == $notification[ $f ] ) {
2239 1726 $atts[ $f ] = $notification[ 'cust_' . $f ];
2240 1727 } elseif ( is_numeric( $atts[ $f ] ) && ! empty( $atts[ $f ] ) ) {
2241 1728 $atts[ $f ] = '[' . $atts[ $f ] . ']';
@@ -2245,9 +1732,8 @@
2245 1732 }
2246 1733
2247 1734 // Format event
2248 1735 $atts['event'] = array( 'create' );
2249 -
2250 1736 if ( isset( $notification['update_email'] ) && 1 == $notification['update_email'] ) {
2251 1737 $atts['event'][] = 'update';
2252 1738 } elseif ( isset( $notification['update_email'] ) && 2 == $notification['update_email'] ) {
2253 1739 $atts['event'] = array( 'update' );
@@ -2253,16 +1739,8 @@
2253 1739 $atts['event'] = array( 'update' );
2254 1740 }
2255 1741 }
2256 1742
2257 - /**
2258 - * Format email_to data
2259 - *
2260 - * @param array $atts
2261 - * @param array $notification
2262 - *
2263 - * @return void
2264 - */
2265 1743 private static function format_email_to_data( &$atts, $notification ) {
2266 1744 if ( isset( $notification['email_to'] ) ) {
2267 1745 $atts['email_to'] = preg_split( '/ (,|;) /', $notification['email_to'] );
2268 1746 } else {
@@ -2282,9 +1760,8 @@
2282 1760 }
2283 1761
2284 1762 if ( strpos( $email_field, '|' ) ) {
2285 1763 $email_opt = explode( '|', $email_field );
2286 -
2287 1764 if ( isset( $email_opt[0] ) ) {
2288 1765 $atts['email_to'][ $key ] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']';
2289 1766 }
2290 1767 unset( $email_opt );
@@ -2292,17 +1769,8 @@
2292 1769 }
2293 1770 $atts['email_to'] = implode( ', ', $atts['email_to'] );
2294 1771 }
2295 1772
2296 - /**
2297 - * Setup new notification
2298 - *
2299 - * @param array $new_notification
2300 - * @param array $notification
2301 - * @param array $atts
2302 - *
2303 - * @return void
2304 - */
2305 1773 private static function setup_new_notification( &$new_notification, $notification, $atts ) {
2306 1774 // Set up new notification
2307 1775 $new_notification = array(
2308 1776 'post_content' => array(
@@ -2313,9 +1781,8 @@
2313 1781 );
2314 1782
2315 1783 // Add more fields to the new notification
2316 1784 $add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' );
2317 -
2318 1785 foreach ( $add_fields as $add_field ) {
2319 1786 if ( isset( $notification[ $add_field ] ) ) {
2320 1787 $new_notification['post_content'][ $add_field ] = $notification[ $add_field ];
2321 1788 } elseif ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) {
@@ -2337,11 +1804,9 @@
2337 1804
2338 1805 /**
2339 1806 * Switch field IDs in pre-2.0 email conditional logic
2340 1807 *
2341 - * @param array $post_content Pass by reference.
2342 - *
2343 - * @return void
1808 + * @param $post_content array, pass by reference
2344 1809 */
2345 1810 private static function switch_email_condition_field_ids( &$post_content ) {
2346 1811 // Switch field IDs in conditional logic
2347 1812 if ( isset( $post_content['conditions'] ) && is_array( $post_content['conditions'] ) ) {
@@ -2353,32 +1818,20 @@
2353 1818 }
2354 1819 }
2355 1820 }
2356 1821
2357 - /**
2358 - * Migrate autoresponder to action
2359 - *
2360 - * @param array $form_options
2361 - * @param int $form_id
2362 - * @param array $notifications
2363 - *
2364 - * @return void
2365 - */
2366 1822 private static function migrate_autoresponder_to_action( $form_options, $form_id, &$notifications ) {
2367 1823 if ( isset( $form_options['auto_responder'] ) && $form_options['auto_responder'] && isset( $form_options['ar_email_message'] ) && $form_options['ar_email_message'] ) {
2368 1824 // migrate autoresponder
2369 1825
2370 - $email_field = $form_options['ar_email_to'] ?? 0;
2371 -
1826 + $email_field = isset( $form_options['ar_email_to'] ) ? $form_options['ar_email_to'] : 0;
2372 1827 if ( strpos( $email_field, '|' ) ) {
2373 1828 // data from entries field
2374 1829 $email_field = explode( '|', $email_field );
2375 -
2376 1830 if ( isset( $email_field[1] ) ) {
2377 1831 $email_field = $email_field[1];
2378 1832 }
2379 1833 }
2380 -
2381 1834 if ( is_numeric( $email_field ) && ! empty( $email_field ) ) {
2382 1835 $email_field = '[' . $email_field . ']';
2383 1836 }
2384 1837
@@ -2385,18 +1838,18 @@
2385 1838 $notification = $form_options;
2386 1839 $new_notification2 = array(
2387 1840 'post_content' => array(
2388 1841 'email_message' => $notification['ar_email_message'],
2389 - 'email_subject' => $notification['ar_email_subject'] ?? '',
1842 + 'email_subject' => isset( $notification['ar_email_subject'] ) ? $notification['ar_email_subject'] : '',
2390 1843 'email_to' => $email_field,
2391 - 'plain_text' => $notification['ar_plain_text'] ?? 0,
1844 + 'plain_text' => isset( $notification['ar_plain_text'] ) ? $notification['ar_plain_text'] : 0,
2392 1845 'inc_user_info' => 0,
2393 1846 ),
2394 1847 'post_name' => $form_id . '_email_' . count( $notifications ),
2395 1848 );
2396 1849
2397 - $reply_to = $notification['ar_reply_to'] ?? '';
2398 - $reply_to_name = $notification['ar_reply_to_name'] ?? '';
1850 + $reply_to = isset( $notification['ar_reply_to'] ) ? $notification['ar_reply_to'] : '';
1851 + $reply_to_name = isset( $notification['ar_reply_to_name'] ) ? $notification['ar_reply_to_name'] : '';
2399 1852
2400 1853 if ( ! empty( $reply_to ) ) {
2401 1854 $new_notification2['post_content']['reply_to'] = $reply_to;
2402 1855 }
@@ -2406,17 +1859,17 @@
2406 1859 }
2407 1860
2408 1861 $notifications[] = $new_notification2;
2409 1862 unset( $new_notification2 );
2410 - }//end if
1863 + }
2411 1864 }
2412 1865
2413 1866 /**
2414 1867 * PHP 8 backward compatibility for the libxml_disable_entity_loader function
2415 1868 *
2416 - * @param bool $loader
1869 + * @param boolean $disable
2417 1870 *
2418 - * @return bool
1871 + * @return boolean
2419 1872 */
2420 1873 public static function maybe_libxml_disable_entity_loader( $loader ) {
2421 1874 if ( version_compare( phpversion(), '8.0', '<' ) && function_exists( 'libxml_disable_entity_loader' ) ) {
2422 1875 $loader = libxml_disable_entity_loader( $loader ); // phpcs:disable Generic.PHP.DeprecatedFunctions.Deprecated
@@ -2424,31 +1877,9 @@
2424 1877
2425 1878 return $loader;
2426 1879 }
2427 1880
2428 - /**
2429 - * PHP 8 backward compatibility for the libxml_disable_entity_loader function
2430 - *
2431 - * @return bool
2432 - */
2433 1881 public static function check_if_libxml_disable_entity_loader_exists() {
2434 1882 return version_compare( phpversion(), '8.0', '<' ) && ! function_exists( 'libxml_disable_entity_loader' );
2435 1883 }
1884 +}
2436 1885
2437 - /**
2438 - * Get the file types allowed for importing.
2439 - * This is used in the "accept" attribute for the file upload input on the XML import page.
2440 - *
2441 - * @since 6.8.3
2442 - *
2443 - * @return array
2444 - */
2445 - public static function get_supported_upload_file_types() {
2446 - $file_types = array( '.xml' );
2447 -
2448 - if ( FrmAppHelper::pro_is_installed() ) {
2449 - // CSV Importing is only available in Pro.
2450 - $file_types[] = '.csv';
2451 - }
2452 - return $file_types;
2453 - }
2454 -}