PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / trunk
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More vtrunk
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
← All changes | classes/helpers/FrmXMLHelper.php +28 -1 6.32.1 → trunk View file →
@@ -619,10 +619,37 @@
619 619 'field_order' => (int) $field->field_order,
620 620 'form_id' => (int) $form_id,
621 621 'required' => (int) $field->required,
622 622 'options' => FrmAppHelper::maybe_json_decode( (string) $field->options ),
623 - 'field_options' => FrmAppHelper::maybe_json_decode( (string) $field->field_options ),
623 + 'field_options' => self::fill_field_options( $field ),
624 624 );
625 + }
626 +
627 + /**
628 + * Reads a field's options out of the file as an array.
629 + *
630 + * Field options are a settings map, and every step of the import reads them
631 + * as one. A file whose value there cannot be read, because it is empty or
632 + * was written by something other than an export, used to end the whole
633 + * import with a fatal error on the first field it reached. An empty set of
634 + * options is recoverable, since the defaults for the field type fill the
635 + * gaps, so prefer that over stopping.
636 + *
637 + * Unserialize is tried as well as JSON so options written by an older
638 + * version are still read rather than thrown away.
639 + *
640 + * @since 6.35
641 + *
642 + * @param object $field Field element from the file.
643 + *
644 + * @return array
645 + */
646 + private static function fill_field_options( $field ) {
647 + $options = (string) $field->field_options;
648 +
649 + FrmAppHelper::unserialize_or_decode( $options );
650 +
651 + return is_array( $options ) ? $options : array();
625 652 }
626 653
627 654 /**
628 655 * @since 4.06