PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.2
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.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/controllers/FrmXMLController.php +38 -62 6.25.16.2 View file →
@@ -16,9 +16,9 @@
16 16 * @return void
17 17 */
18 18 public static function add_default_templates() {
19 19 if ( FrmXMLHelper::check_if_libxml_disable_entity_loader_exists() ) {
20 - // XML import is not enabled on your server.
20 + // XML import is not enabled on your server
21 21 return;
22 22 }
23 23
24 24 $set_err = libxml_use_internal_errors( true );
@@ -87,9 +87,9 @@
87 87 end( $imported['form_status'] );
88 88 $form_id = key( $imported['form_status'] );
89 89 $response = array(
90 90 'id' => $form_id,
91 - 'redirect' => FrmForm::get_edit_link( $form_id ) . '&new_template=true',
91 + 'redirect' => FrmForm::get_edit_link( $form_id ),
92 92 'success' => 1,
93 93 );
94 94 if ( ! empty( $imported['imported']['posts'] ) ) {
95 95 // Return the link to the last page created.
@@ -100,10 +100,10 @@
100 100 // Create selected pages with the correct shortcodes.
101 101 $pages = self::create_pages_for_import( $form );
102 102 }
103 103
104 - if ( ! empty( $pages ) ) {
105 - $post_id = end( $pages );
104 + if ( isset( $pages ) && ! empty( $pages ) ) {
105 + $post_id = end( $pages );
106 106 $response['redirect'] = get_permalink( $post_id );
107 107 }
108 108 } else {
109 109 if ( isset( $imported['error'] ) ) {
@@ -114,14 +114,11 @@
114 114 $response = array(
115 115 'message' => $message,
116 116 );
117 117
118 - }//end if
118 + }
119 119
120 - /**
121 - * @since 6.18 Added `url` to the $args.
122 - */
123 - $response = apply_filters( 'frm_xml_response', $response, compact( 'form', 'imported', 'url' ) );
120 + $response = apply_filters( 'frm_xml_response', $response, compact( 'form', 'imported' ) );
124 121
125 122 echo wp_json_encode( $response );
126 123 wp_die();
127 124 }
@@ -165,9 +162,9 @@
165 162 if ( empty( $selected_form ) ) {
166 163 return;
167 164 }
168 165
169 - $selected_xml = isset( $form['xml'] ) && isset( $form['xml'][ $selected_form ] ) ? $form['xml'][ $selected_form ] : '';
166 + $selected_xml = isset( $form['xml'] ) && isset( $form['xml'][ $selected_form ] ) ? $form['xml'][ $selected_form ] : '';
170 167 if ( empty( $selected_xml ) || strpos( $selected_xml, 'http' ) !== 0 ) {
171 168 return;
172 169 }
173 170
@@ -176,13 +173,13 @@
176 173
177 174 /**
178 175 * @since 4.06.02
179 176 *
180 - * @param array $form
181 177 * @param string $value
178 + * @param array $form
182 179 */
183 180 private static function get_selected_in_form( $form, $value = 'form' ) {
184 - if ( ! empty( $form ) && ! empty( $form[ $value ] ) ) {
181 + if ( ! empty( $form ) && isset( $form[ $value ] ) && ! empty( $form[ $value ] ) ) {
185 182 return $form[ $value ];
186 183 }
187 184
188 185 return '';
@@ -191,16 +188,17 @@
191 188 /**
192 189 * @since 4.06.02
193 190 *
194 191 * @param array $form The posted form values.
195 - * @return array|null The array of created pages.
192 + *
193 + * @return array The array of created pages.
196 194 */
197 195 private static function create_pages_for_import( $form ) {
198 - if ( empty( $form['pages'] ) ) {
199 - return null;
196 + if ( ! isset( $form['pages'] ) || empty( $form['pages'] ) ) {
197 + return;
200 198 }
201 199
202 - $form_key = self::get_selected_in_form( $form, 'form' );
200 + $form_key = self::get_selected_in_form( $form, 'form' );
203 201 $view_keys = self::get_selected_in_form( $form, 'view' );
204 202
205 203 $page_ids = array();
206 204 foreach ( (array) $form['pages'] as $for => $name ) {
@@ -212,9 +210,9 @@
212 210 if ( $for === 'view' ) {
213 211 $item_key = is_array( $view_keys ) ? $view_keys[ $form_key ] : $view_keys;
214 212 $shortcode = '[display-frm-data id=%1$s filter=limited]';
215 213 } elseif ( $for === 'form' ) {
216 - $item_key = $form_key;
214 + $item_key = $form_key;
217 215 $shortcode = '[formidable id=%1$s]';
218 216 } else {
219 217 $item_key = self::get_selected_in_form( $form, 'form' );
220 218 $shortcode = '[' . esc_html( $for ) . ' id=%1$s]';
@@ -231,9 +229,9 @@
231 229 'post_type' => 'page',
232 230 'post_content' => sprintf( $shortcode, $item_key ),
233 231 )
234 232 );
235 - }//end foreach
233 + }
236 234
237 235 return $page_ids;
238 236 }
239 237
@@ -297,15 +295,15 @@
297 295 }
298 296
299 297 /**
300 298 * @param string[] $errors
301 - * @param string $message
299 + * @param string $message
302 300 *
303 301 * @return void
304 302 */
305 303 public static function form( $errors = array(), $message = '' ) {
306 304 $where = array(
307 - 'status' => array( null, '', 'published' ),
305 + 'status' => array( null, '', 'published' ),
308 306 );
309 307 $forms = FrmForm::getAll( $where, 'name' );
310 308
311 309 $export_types = array(
@@ -345,10 +343,9 @@
345 343
346 344 return;
347 345 }
348 346
349 - // phpcs:ignore WordPress.Security.NonceVerification.Missing
350 - $has_file = ! empty( $_FILES['frm_import_file'] ) && ! empty( $_FILES['frm_import_file']['name'] ) && ! empty( $_FILES['frm_import_file']['size'] ) && (int) $_FILES['frm_import_file']['size'] > 0;
347 + $has_file = isset( $_FILES ) && isset( $_FILES['frm_import_file'] ) && ! empty( $_FILES['frm_import_file']['name'] ) && ! empty( $_FILES['frm_import_file']['size'] ) && (int) $_FILES['frm_import_file']['size'] > 0;
351 348 if ( ! $has_file ) {
352 349 $errors[] = __( 'Oops, you didn\'t select a file.', 'formidable' );
353 350 self::form( $errors );
354 351
@@ -354,9 +351,9 @@
354 351
355 352 return;
356 353 }
357 354
358 - // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.NonceVerification.Missing
355 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash
359 356 $file = isset( $_FILES['frm_import_file']['tmp_name'] ) ? sanitize_option( 'upload_path', $_FILES['frm_import_file']['tmp_name'] ) : '';
360 357
361 358 if ( ! is_uploaded_file( $file ) ) {
362 359 unset( $file );
@@ -365,8 +362,10 @@
365 362
366 363 return;
367 364 }
368 365
366 + //add_filter('upload_mimes', 'FrmXMLController::allow_mime');
367 +
369 368 $export_format = array(
370 369 'xml' => array(
371 370 'name' => 'XML',
372 371 'support' => 'forms',
@@ -374,9 +373,9 @@
374 373 ),
375 374 );
376 375 $export_format = apply_filters( 'frm_export_formats', $export_format );
377 376
378 - // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.NonceVerification.Missing
377 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash
379 378 $file_type = sanitize_option( 'upload_path', $_FILES['frm_import_file']['name'] );
380 379 $file_type = strtolower( pathinfo( $file_type, PATHINFO_EXTENSION ) );
381 380 if ( 'xml' !== $file_type && isset( $export_format[ $file_type ] ) ) {
382 381 // allow other file types to be imported
@@ -436,10 +435,9 @@
436 435 wp_die();
437 436 }
438 437
439 438 /**
440 - * @param string[] $type
441 - * @param array $args
439 + * @param array $args
442 440 *
443 441 * @psalm-param array{ids?: mixed} $args
444 442 *
445 443 * @return void
@@ -478,9 +476,9 @@
478 476 $query_vars = array();
479 477
480 478 switch ( $tb_type ) {
481 479 case 'forms':
482 - // Add forms.
480 + //add forms
483 481 if ( $args['ids'] ) {
484 482 $where[] = array(
485 483 'or' => 1,
486 484 $table . '.id' => $args['ids'],
@@ -538,15 +536,15 @@
538 536 $where['pm.meta_value >'] = 1;
539 537 } else {
540 538 $where['pm.meta_value'] = $args['ids'];
541 539 }
542 - }//end switch
540 + }
543 541
544 542 $records[ $tb_type ] = FrmDb::get_col( $table . $join, $where, $select );
545 543 unset( $tb_type );
546 - }//end foreach
544 + }
547 545
548 - $filename = self::get_file_name( $args, $records );
546 + $filename = self::get_file_name( $args, $type, $records );
549 547
550 548 header( 'Content-Description: File Transfer' );
551 549 header( 'Content-Disposition: attachment; filename=' . $filename );
552 550 header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), true );
@@ -555,39 +553,18 @@
555 553 include FrmAppHelper::plugin_path() . '/classes/views/xml/xml.php';
556 554 }
557 555
558 556 /**
559 - * Returns an array that has parent term slugs for the terms provided.
560 - *
561 - * @since 6.8.3
562 - * @param array $terms
563 - * @return array
564 - */
565 - public static function get_parent_terms_slugs( $terms ) {
566 - $parent_term_ids = array_filter( array_unique( wp_list_pluck( $terms, 'parent' ) ) );
567 - $parent_slugs = array();
568 -
569 - if ( ! $parent_term_ids ) {
570 - return $parent_slugs;
571 - }
572 -
573 - $results = FrmDb::get_results( 'terms', array( 'term_id' => $parent_term_ids ), 'term_id, slug' );
574 - $parent_slugs = wp_list_pluck( $results, 'slug', 'term_id' );
575 -
576 - return $parent_slugs;
577 - }
578 -
579 - /**
580 557 * @return void
581 558 */
582 559 private static function prepare_types_array( &$type ) {
583 560 $type = (array) $type;
584 - if ( ! in_array( 'forms', $type, true ) && ( in_array( 'items', $type, true ) || in_array( 'posts', $type, true ) ) ) {
561 + if ( ! in_array( 'forms', $type ) && ( in_array( 'items', $type ) || in_array( 'posts', $type ) ) ) {
585 562 // make sure the form is included if there are entries
586 563 $type[] = 'forms';
587 564 }
588 565
589 - if ( in_array( 'forms', $type, true ) ) {
566 + if ( in_array( 'forms', $type ) ) {
590 567 // include actions with forms
591 568 $type[] = 'actions';
592 569 }
593 570 }
@@ -597,14 +574,16 @@
597 574 * Use the nme of the form if only one form is exported.
598 575 *
599 576 * @since 3.06
600 577 *
578 + * @param array $type
579 + * @param array $records
601 580 * @param array $args
602 - * @param array $records
581 + *
603 582 * @return string
604 583 */
605 - private static function get_file_name( $args, $records ) {
606 - $has_one_form = ! empty( $records['forms'] ) && count( $args['ids'] ) === 1;
584 + private static function get_file_name( $args, $type, $records ) {
585 + $has_one_form = isset( $records['forms'] ) && ! empty( $records['forms'] ) && count( $args['ids'] ) === 1;
607 586 if ( $has_one_form ) {
608 587 // one form is being exported
609 588 $selected_form_id = reset( $args['ids'] );
610 589 $filename = 'form-' . $selected_form_id . '.xml';
@@ -624,9 +603,9 @@
624 603 if ( ! empty( $sitename ) ) {
625 604 $sitename .= '.';
626 605 }
627 606 $filename = $sitename . 'formidable.' . gmdate( 'Y-m-d' ) . '.xml';
628 - }//end if
607 + }
629 608
630 609 /**
631 610 * @since 5.3
632 611 *
@@ -663,12 +642,9 @@
663 642 $search = FrmAppHelper::get_param( ( isset( $_REQUEST['s'] ) ? 's' : 'search' ), '', 'get', 'sanitize_text_field' );
664 643 $fid = FrmAppHelper::get_param( 'fid', '', 'get', 'sanitize_text_field' );
665 644 }
666 645
667 - // Remove time limit to execute this function.
668 - if ( function_exists( 'set_time_limit' ) ) {
669 - set_time_limit( 0 );
670 - }
646 + set_time_limit( 0 ); //Remove time limit to execute this function
671 647 $mem_limit = str_replace( 'M', '', ini_get( 'memory_limit' ) );
672 648 if ( (int) $mem_limit < 256 ) {
673 649 wp_raise_memory_limit();
674 650 }
@@ -723,9 +699,9 @@
723 699 *
724 700 * @since 2.0.19
725 701 * @since 5.0.16 function went from private to public.
726 702 *
727 - * @param int $form_id
703 + * @param int $form_id
728 704 * @param object $form
729 705 *
730 706 * @return array $csv_fields
731 707 */