PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.8
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.8
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 +57 -40 6.3.1 → 6.8 View file →
@@ -180,9 +180,9 @@
180 180 $imported['terms'][ (int) $t->term_id ] = $term['term_id'];
181 181 }
182 182
183 183 unset( $term, $t );
184 - }
184 + }//end foreach
185 185
186 186 return $imported;
187 187 }
188 188
@@ -255,9 +255,9 @@
255 255
256 256 do_action( 'frm_after_import_form', $form_id, $form );
257 257
258 258 unset( $form, $item );
259 - }
259 + }//end foreach
260 260
261 261 self::maybe_update_child_form_parent_id( $imported['forms'], $child_forms );
262 262
263 263 return $imported;
@@ -303,9 +303,15 @@
303 303 }
304 304
305 305 $edit_query = apply_filters( 'frm_match_xml_form', $edit_query, $form );
306 306
307 - return FrmForm::getAll( $edit_query, '', 1 );
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;
308 314 }
309 315
310 316 private static function update_form( $this_form, $form, &$imported ) {
311 317 $form_id = $this_form->id;
@@ -374,10 +380,10 @@
374 380 * Keep track of all imported child forms
375 381 *
376 382 * @since 2.0.16
377 383 *
378 - * @param int $form_id
379 - * @param int $parent_form_id
384 + * @param int $form_id
385 + * @param int $parent_form_id
380 386 * @param array $child_forms
381 387 */
382 388 private static function track_imported_child_forms( $form_id, $parent_form_id, &$child_forms ) {
383 389 if ( $parent_form_id ) {
@@ -433,9 +439,9 @@
433 439 $imported['updated']['fields'] ++;
434 440
435 441 unset( $form_fields[ $f['id'] ] );
436 442
437 - //unset old field key
443 + // Unset old field key.
438 444 if ( isset( $form_fields[ $f['field_key'] ] ) ) {
439 445 unset( $form_fields[ $f['field_key'] ] );
440 446 }
441 447 } elseif ( isset( $form_fields[ $f['field_key'] ] ) ) {
@@ -446,19 +452,22 @@
446 452
447 453 FrmField::update( $form_fields[ $f['field_key'] ], $f );
448 454 $imported['updated']['fields'] ++;
449 455
450 - unset( $form_fields[ $form_fields[ $f['field_key'] ] ] ); //unset old field id
451 - unset( $form_fields[ $f['field_key'] ] ); //unset old field key
456 + // Unset old field id.
457 + unset( $form_fields[ $form_fields[ $f['field_key'] ] ] );
458 +
459 + // Unset old field key.
460 + unset( $form_fields[ $f['field_key'] ] );
452 461 } else {
453 - // if no matching field id or key in this form, create the field
462 + // If no matching field id or key in this form, create the field.
454 463 self::create_imported_field( $f, $imported );
455 - }
464 + }//end if
456 465 } else {
457 466
458 467 self::create_imported_field( $f, $imported );
459 - }
460 - }
468 + }//end if
469 + }//end foreach
461 470
462 471 if ( $keys_by_original_field_id ) {
463 472 self::maybe_update_field_ids( $form_id, $keys_by_original_field_id );
464 473 }
@@ -520,9 +529,9 @@
520 529 /**
521 530 * Update the current in_section value at the beginning of the field loop
522 531 *
523 532 * @since 2.0.25
524 - * @param int $in_section
533 + * @param int $in_section
525 534 * @param array $f
526 535 */
527 536 private static function maybe_update_in_section_variable( &$in_section, &$f ) {
528 537 // If we're at the end of a section, switch $in_section is 0
@@ -696,13 +705,15 @@
696 705 if ( ! is_array( $option ) || empty( $option['src'] ) ) {
697 706 continue;
698 707 }
699 708
700 - $field_object = (object) $field;
701 - $field_object->type = 'file'; // Fake the file type as FrmProImport::import_attachment checks for file type.
709 + $field_object = (object) $field;
710 + // Fake the file type as FrmProImport::import_attachment checks for file type.
711 + $field_object->type = 'file';
702 712
703 713 $image_id = FrmProFileImport::import_attachment( $option['src'], $field_object );
704 - unset( $field['options'][ $key ]['src'] ); // Remove the src from options as it isn't required after import.
714 + // Remove the src from options as it isn't required after import.
715 + unset( $field['options'][ $key ]['src'] );
705 716
706 717 if ( is_numeric( $image_id ) ) {
707 718 $field['options'][ $key ]['image'] = $image_id;
708 719 }
@@ -714,9 +725,9 @@
714 725 /**
715 726 * Fix field ids for fields that already exist prior to import.
716 727 *
717 728 * @since 4.07
718 - * @param int $form_id
729 + * @param int $form_id
719 730 * @param array $keys_by_original_field_id
720 731 */
721 732 protected static function maybe_update_field_ids( $form_id, $keys_by_original_field_id ) {
722 733 global $frm_duplicate_ids;
@@ -786,9 +797,9 @@
786 797
787 798 // Set to default
788 799 $form['options']['custom_style'] = 1;
789 800 }
790 - }
801 + }//end if
791 802 }
792 803
793 804 /**
794 805 * After styles are imported, check for any forms that were linked
@@ -876,9 +887,9 @@
876 887 $post['post_parent'] = $imported['posts'][ $post['post_parent'] ];
877 888 }
878 889 // Create/update post now
879 890 $post_id = wp_insert_post( $post );
880 - }
891 + }//end if
881 892
882 893 if ( ! is_numeric( $post_id ) ) {
883 894 continue;
884 895 }
@@ -909,9 +920,9 @@
909 920
910 921 do_action( 'frm_after_import_view', $post_id, $post );
911 922
912 923 unset( $post );
913 - }
924 + }//end foreach
914 925
915 926 if ( $posts_with_shortcodes && $view_ids ) {
916 927 self::maybe_switch_view_ids_after_importing_posts( $posts_with_shortcodes, $view_ids );
917 928 }
@@ -1102,9 +1113,9 @@
1102 1113 'key' => (string) $meta->meta_key,
1103 1114 'value' => (string) $meta->meta_value,
1104 1115 );
1105 1116
1106 - //switch old form and field ids to new ones
1117 + // Switch old form and field ids to new ones.
1107 1118 if ( 'frm_form_id' === $m['key'] && isset( $imported['forms'][ (int) $m['value'] ] ) ) {
1108 1119 $m['value'] = $imported['forms'][ (int) $m['value'] ];
1109 1120 } else {
1110 1121 $m['value'] = FrmAppHelper::maybe_json_decode( $m['value'] );
@@ -1141,11 +1152,11 @@
1141 1152 }
1142 1153 unset( $mk, $mv );
1143 1154 }
1144 1155 }
1145 - }
1146 - }
1147 - }
1156 + }//end if
1157 + }//end if
1158 + }//end if
1148 1159
1149 1160 if ( ! is_array( $m['value'] ) ) {
1150 1161 $m['value'] = FrmAppHelper::maybe_json_decode( $m['value'] );
1151 1162 }
@@ -1159,10 +1170,10 @@
1159 1170
1160 1171 /**
1161 1172 * Add terms to post
1162 1173 *
1163 - * @param array $post by reference
1164 - * @param object $item The XML object data
1174 + * @param array $post By reference.
1175 + * @param object $item The XML object data.
1165 1176 */
1166 1177 private static function populate_taxonomies( &$post, $item ) {
1167 1178 foreach ( $item->category as $c ) {
1168 1179 $att = $c->attributes();
@@ -1187,9 +1198,9 @@
1187 1198 }
1188 1199
1189 1200 $post['tax_input'][ $taxonomy ][] = $name;
1190 1201 unset( $name );
1191 - }
1202 + }//end foreach
1192 1203 }
1193 1204
1194 1205 /**
1195 1206 * Edit post if the key and created time match
@@ -1243,13 +1254,13 @@
1243 1254
1244 1255 case 'frm_param':
1245 1256 add_rewrite_endpoint( $v, EP_PERMALINK | EP_PAGES );
1246 1257 break;
1247 - }
1258 + }//end switch
1248 1259
1249 1260 update_post_meta( $post_id, $k, $v );
1250 1261 unset( $k, $v );
1251 - }
1262 + }//end foreach
1252 1263 }
1253 1264
1254 1265 /**
1255 1266 * @param array $post
@@ -1279,9 +1290,11 @@
1279 1290 }
1280 1291 }
1281 1292
1282 1293 /**
1294 + * @param mixed $result
1283 1295 * @param string $message
1296 + * @param array $errors
1284 1297 */
1285 1298 public static function parse_message( $result, &$message, &$errors ) {
1286 1299 if ( is_wp_error( $result ) ) {
1287 1300 $errors[] = $result->get_error_message();
@@ -1307,9 +1320,9 @@
1307 1320
1308 1321 return;
1309 1322 } elseif ( ! $result ) {
1310 1323 return;
1311 - }
1324 + }//end if
1312 1325
1313 1326 if ( ! is_array( $result ) ) {
1314 1327 $message = is_string( $result ) ? $result : htmlentities( print_r( $result, 1 ) );
1315 1328
@@ -1646,9 +1659,13 @@
1646 1659
1647 1660 /**
1648 1661 * Migrate post settings to form action
1649 1662 *
1663 + * @param array $form_options
1664 + * @param int $form_id
1650 1665 * @param string $post_type
1666 + * @param array $imported
1667 + * @param bool $switch
1651 1668 */
1652 1669 private static function migrate_post_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
1653 1670 if ( ! isset( $form_options['create_post'] ) || ! $form_options['create_post'] ) {
1654 1671 return;
@@ -1726,11 +1743,11 @@
1726 1743 * Switch old field IDs for new field IDs in emails and post
1727 1744 *
1728 1745 * @since 2.0
1729 1746 *
1730 - * @param array $post_content - check for old field IDs
1731 - * @param array $basic_fields - fields with string or int saved
1732 - * @param array $array_fields - fields with arrays saved
1747 + * @param array $post_content Check for old field IDs.
1748 + * @param array $basic_fields Fields with string or int saved.
1749 + * @param array $array_fields Fields with arrays saved.
1733 1750 *
1734 1751 * @return string $post_content - new field IDs
1735 1752 */
1736 1753 private static function switch_action_field_ids( $post_content, $basic_fields, $array_fields = array() ) {
@@ -1814,9 +1831,9 @@
1814 1831 FrmDb::save_json_post( $new_notification );
1815 1832 $imported['imported']['actions'] ++;
1816 1833 }
1817 1834 unset( $new_notification );
1818 - }
1835 + }//end foreach
1819 1836
1820 1837 self::remove_deprecated_notification_settings( $form_id, $form_options );
1821 1838 }
1822 1839
@@ -1825,9 +1842,9 @@
1825 1842 *
1826 1843 * @since 2.05
1827 1844 *
1828 1845 * @param int|string $form_id
1829 - * @param array $form_options
1846 + * @param array $form_options
1830 1847 */
1831 1848 private static function remove_deprecated_notification_settings( $form_id, $form_options ) {
1832 1849 $delete_settings = array( 'notification', 'autoresponder', 'email_to' );
1833 1850 foreach ( $delete_settings as $index ) {
@@ -1870,10 +1887,10 @@
1870 1887 $new_notification = array();
1871 1888 self::setup_new_notification( $new_notification, $notification, $atts );
1872 1889
1873 1890 $notifications[] = $new_notification;
1874 - }
1875 - }
1891 + }//end foreach
1892 + }//end if
1876 1893 }
1877 1894
1878 1895 private static function format_email_data( &$atts, $notification ) {
1879 1896 // Format email_to
@@ -1969,9 +1986,9 @@
1969 1986
1970 1987 /**
1971 1988 * Switch field IDs in pre-2.0 email conditional logic
1972 1989 *
1973 - * @param $post_content array, pass by reference
1990 + * @param array $post_content Pass by reference.
1974 1991 */
1975 1992 private static function switch_email_condition_field_ids( &$post_content ) {
1976 1993 // Switch field IDs in conditional logic
1977 1994 if ( isset( $post_content['conditions'] ) && is_array( $post_content['conditions'] ) ) {
@@ -2024,15 +2041,15 @@
2024 2041 }
2025 2042
2026 2043 $notifications[] = $new_notification2;
2027 2044 unset( $new_notification2 );
2028 - }
2045 + }//end if
2029 2046 }
2030 2047
2031 2048 /**
2032 2049 * PHP 8 backward compatibility for the libxml_disable_entity_loader function
2033 2050 *
2034 - * @param boolean $disable
2051 + * @param boolean $loader
2035 2052 *
2036 2053 * @return boolean
2037 2054 */
2038 2055 public static function maybe_libxml_disable_entity_loader( $loader ) {