PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.22.1
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.22.1
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/models/FrmMigrate.php +2 -124 6.26 → 6.22.1 View file →
@@ -3,27 +3,11 @@
3 3 die( 'You are not allowed to call this page directly.' );
4 4 }
5 5
6 6 class FrmMigrate {
7 -
8 - /**
9 - * @var string
10 - */
11 7 public $fields;
12 -
13 - /**
14 - * @var string
15 - */
16 8 public $forms;
17 -
18 - /**
19 - * @var string
20 - */
21 9 public $entries;
22 -
23 - /**
24 - * @var string
25 - */
26 10 public $entry_metas;
27 11
28 12 public function __construct() {
29 13 global $wpdb;
@@ -32,11 +16,8 @@
32 16 $this->entries = $wpdb->prefix . 'frm_items';
33 17 $this->entry_metas = $wpdb->prefix . 'frm_item_metas';
34 18 }
35 19
36 - /**
37 - * @return void
38 - */
39 20 public function upgrade() {
40 21 do_action( 'frm_before_install' );
41 22
42 23 global $wpdb, $frm_vars;
@@ -71,10 +52,8 @@
71 52
72 53 if ( false === get_option( 'frm_first_activation' ) ) {
73 54 update_option( 'frm_first_activation', time(), false );
74 55 }
75 -
76 - $this->update_settings_for_new_install();
77 56 }
78 57 }//end if
79 58
80 59 do_action( 'frm_after_install' );
@@ -90,23 +69,8 @@
90 69 }
91 70 }
92 71
93 72 /**
94 - * Updates some settings for new installs.
95 - *
96 - * @since 6.23
97 - *
98 - * @return void
99 - */
100 - private function update_settings_for_new_install() {
101 - $settings = FrmAppHelper::get_settings();
102 -
103 - $settings->denylist_check = 1;
104 - $settings->installed_after_welcome_tour_update = 1;
105 - $settings->store();
106 - }
107 -
108 - /**
109 73 * If we fail to create the database tables, add an inbox notice.
110 74 * This informs the user that they need to correct the issue and try again.
111 75 *
112 76 * @since 6.19
@@ -140,9 +104,8 @@
140 104 * @return string
141 105 */
142 106 public function collation() {
143 107 global $wpdb;
144 -
145 108 if ( ! $wpdb->has_cap( 'collation' ) ) {
146 109 return '';
147 110 }
148 111
@@ -148,11 +111,8 @@
148 111
149 112 return $wpdb->get_charset_collate();
150 113 }
151 114
152 - /**
153 - * @return void
154 - */
155 115 private function create_tables() {
156 116 $charset_collate = $this->collation();
157 117 $sql = array();
158 118
@@ -288,9 +248,8 @@
288 248 * @since 6.6
289 249 *
290 250 * @param string $table_name
291 251 * @param string $index_name
292 - *
293 252 * @return bool
294 253 */
295 254 private static function index_exists( $table_name, $index_name ) {
296 255 global $wpdb;
@@ -306,14 +265,10 @@
306 265 );
307 266 return (bool) $row;
308 267 }
309 268
310 - /**
311 - * @return void
312 - */
313 269 private function maybe_create_contact_form() {
314 270 $form_exists = FrmForm::get_id_by_key( 'contact-form' );
315 -
316 271 if ( ! $form_exists ) {
317 272 $this->add_default_template();
318 273 }
319 274 }
@@ -321,10 +276,8 @@
321 276 /**
322 277 * Create the default contact form
323 278 *
324 279 * @since 3.06
325 - *
326 - * @return void
327 280 */
328 281 private function add_default_template() {
329 282 if ( FrmXMLHelper::check_if_libxml_disable_entity_loader_exists() ) {
330 283 // XML import is not enabled on your server.
@@ -342,16 +295,13 @@
342 295 }
343 296
344 297 /**
345 298 * @param int|string $old_db_version
346 - *
347 - * @return void
348 299 */
349 300 private function migrate_data( $old_db_version ) {
350 301 if ( ! $old_db_version ) {
351 302 $old_db_version = get_option( 'frm_db_version' );
352 303 }
353 -
354 304 if ( strpos( $old_db_version, '-' ) ) {
355 305 $last_upgrade = explode( '-', $old_db_version );
356 306 $old_db_version = (int) $last_upgrade[1];
357 307 }
@@ -360,10 +310,9 @@
360 310 // bail if we don't know the previous version
361 311 return;
362 312 }
363 313
364 - $migrations = array( 16, 11, 16, 17, 23, 25, 86, 90, 97, 98, 101, 104 );
365 -
314 + $migrations = array( 16, 11, 16, 17, 23, 25, 86, 90, 97, 98, 101 );
366 315 foreach ( $migrations as $migration ) {
367 316 if ( FrmAppHelper::$db_version >= $migration && $old_db_version < $migration ) {
368 317 $function_name = 'migrate_to_' . $migration;
369 318 $this->$function_name();
@@ -396,9 +345,8 @@
396 345
397 346 // Delete roles.
398 347 $frm_roles = FrmAppHelper::frm_capabilities();
399 348 $roles = get_editable_roles();
400 -
401 349 foreach ( $frm_roles as $frm_role => $frm_role_description ) {
402 350 foreach ( $roles as $role => $details ) {
403 351 $wp_roles->remove_cap( $role, $frm_role );
404 352 unset( $role, $details );
@@ -413,9 +361,8 @@
413 361 remove_action( 'before_delete_post', 'FrmProDisplaysController::before_delete_post' );
414 362 remove_action( 'deleted_post', 'FrmProEntriesController::delete_entry' );
415 363
416 364 $post_ids = $wpdb->get_col( $wpdb->prepare( 'SELECT ID FROM ' . $wpdb->posts . ' WHERE post_type in (%s, %s, %s)', FrmFormActionsController::$action_post_type, FrmStylesController::$post_type, 'frm_display' ) );
417 -
418 365 foreach ( $post_ids as $post_id ) {
419 366 // Delete's each post.
420 367 wp_delete_post( $post_id, true );
421 368 }
@@ -434,31 +381,11 @@
434 381 return true;
435 382 }
436 383
437 384 /**
438 - * In older versions of Lite, it's possible we've saved the wrong location ID.
439 - * So force it to get valid values again.
440 - *
441 - * @since 6.25
442 - *
443 - * @return void
444 - */
445 - private function migrate_to_104() {
446 - if ( FrmSquareLiteConnectHelper::get_merchant_id( 'test' ) ) {
447 - FrmSquareLiteConnectHelper::get_location_id( true, 'test' );
448 - }
449 -
450 - if ( FrmSquareLiteConnectHelper::get_merchant_id( 'live' ) ) {
451 - FrmSquareLiteConnectHelper::get_location_id( true, 'live' );
452 - }
453 - }
454 -
455 - /**
456 385 * Disables summary email for multisite (not the main site) if recipient setting isn't changed.
457 386 *
458 387 * @since 6.8
459 - *
460 - * @return void
461 388 */
462 389 private function migrate_to_101() {
463 390 if ( ! is_multisite() || get_main_site_id() === get_current_blog_id() ) {
464 391 return;
@@ -464,9 +391,8 @@
464 391 return;
465 392 }
466 393
467 394 $frm_settings = FrmAppHelper::get_settings();
468 -
469 395 if ( empty( $frm_settings->summary_emails ) || '[admin_email]' !== $frm_settings->summary_emails_recipients ) {
470 396 // User changed it.
471 397 return;
472 398 }
@@ -478,10 +404,8 @@
478 404 /**
479 405 * Clear frmpro_css transient.
480 406 *
481 407 * @since 4.10.02
482 - *
483 - * @return void
484 408 */
485 409 private function migrate_to_98() {
486 410 delete_transient( 'frmpro_css' );
487 411 }
@@ -489,10 +413,8 @@
489 413 /**
490 414 * Move default_blank and clear_on_focus to placeholder.
491 415 *
492 416 * @since 4.0
493 - *
494 - * @return void
495 417 */
496 418 private function migrate_to_97() {
497 419 $this->migrate_to_placeholder( 'clear_on_focus' );
498 420 $this->migrate_to_placeholder( 'default_blank' );
@@ -501,12 +423,8 @@
501 423 /**
502 424 * Move clear_on_focus or default_blank to placeholder.
503 425 *
504 426 * @since 4.0
505 - *
506 - * @param string $type Field option key to migrate.
507 - *
508 - * @return void
509 427 */
510 428 private function migrate_to_placeholder( $type = 'clear_on_focus' ) {
511 429 $query = array(
512 430 'field_options like' => '"' . $type . '";s:1:"1";',
@@ -517,9 +435,8 @@
517 435 foreach ( $fields as $field ) {
518 436 FrmAppHelper::unserialize_or_decode( $field->field_options );
519 437 FrmAppHelper::unserialize_or_decode( $field->options );
520 438 $update_values = FrmXMLHelper::migrate_field_placeholder( $field, $type );
521 -
522 439 if ( empty( $update_values ) ) {
523 440 continue;
524 441 }
525 442
@@ -531,14 +448,11 @@
531 448 /**
532 449 * Delete unneeded default templates
533 450 *
534 451 * @since 3.06
535 - *
536 - * @return void
537 452 */
538 453 private function migrate_to_90() {
539 454 $form = FrmForm::getOne( 'contact' );
540 -
541 455 if ( $form && $form->default_template == 1 ) {
542 456 FrmForm::destroy( 'contact' );
543 457 }
544 458 }
@@ -546,16 +460,14 @@
546 460 /**
547 461 * Reverse migration 17 -- Divide by 9
548 462 *
549 463 * @since 3.0.05
550 - *
551 - * @return void
552 464 */
553 465 private function migrate_to_86() {
554 466
555 467 $fields = $this->get_fields_with_size();
556 468
557 - foreach ( $fields as $f ) {
469 + foreach ( (array) $fields as $f ) {
558 470 FrmAppHelper::unserialize_or_decode( $f->field_options );
559 471 $size = $f->field_options['size'];
560 472 $this->maybe_convert_migrated_size( $size );
561 473
@@ -569,9 +481,8 @@
569 481 }
570 482
571 483 // reverse the extra size changes in widgets
572 484 $widgets = get_option( 'widget_frm_show_form' );
573 -
574 485 if ( empty( $widgets ) ) {
575 486 return;
576 487 }
577 488
@@ -577,11 +488,8 @@
577 488
578 489 $this->revert_widget_field_size();
579 490 }
580 491
581 - /**
582 - * @return array
583 - */
584 492 private function get_fields_with_size() {
585 493 $field_types = array(
586 494 'textarea',
587 495 'text',
@@ -609,20 +517,16 @@
609 517 /**
610 518 * Reverse the extra size changes in widgets
611 519 *
612 520 * @since 3.0.05
613 - *
614 - * @return void
615 521 */
616 522 private function revert_widget_field_size() {
617 523 $widgets = get_option( 'widget_frm_show_form' );
618 -
619 524 if ( empty( $widgets ) ) {
620 525 return;
621 526 }
622 527
623 528 FrmAppHelper::unserialize_or_decode( $widgets );
624 -
625 529 foreach ( $widgets as $k => $widget ) {
626 530 if ( ! is_array( $widget ) || ! isset( $widget['size'] ) ) {
627 531 continue;
628 532 }
@@ -635,22 +539,16 @@
635 539 /**
636 540 * Divide by 9 to reverse the multiplication
637 541 *
638 542 * @since 3.0.05
639 - *
640 - * @param string $size Size string to maybe convert, passed by reference.
641 - *
642 - * @return void
643 543 */
644 544 private function maybe_convert_migrated_size( &$size ) {
645 545 $has_px_size = ! empty( $size ) && strpos( $size, 'px' );
646 -
647 546 if ( ! $has_px_size ) {
648 547 return;
649 548 }
650 549
651 550 $int_size = str_replace( 'px', '', $size );
652 -
653 551 if ( ! is_numeric( $int_size ) || (int) $int_size < 900 ) {
654 552 return;
655 553 }
656 554
@@ -663,16 +561,13 @@
663 561 * Migrate old styling settings. If sites are using the old
664 562 * default 400px field width, switch it to 100%
665 563 *
666 564 * @since 2.0.4
667 - *
668 - * @return void
669 565 */
670 566 private function migrate_to_25() {
671 567 // get the style that was created with the style migration
672 568 $frm_style = new FrmStyle();
673 569 $styles = $frm_style->get_all( 'post_date', 'ASC', 1 );
674 -
675 570 if ( empty( $styles ) ) {
676 571 return;
677 572 }
678 573
@@ -690,15 +585,12 @@
690 585 * Check if the parent_form_id columns exists.
691 586 * If not, try and add it again
692 587 *
693 588 * @since 2.0.2
694 - *
695 - * @return void
696 589 */
697 590 private function migrate_to_23() {
698 591 global $wpdb;
699 592 $exists = $wpdb->get_row( 'SHOW COLUMNS FROM ' . $this->forms . ' LIKE "parent_form_id"' ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
700 -
701 593 if ( empty( $exists ) ) {
702 594 $wpdb->query( 'ALTER TABLE ' . $this->forms . ' ADD parent_form_id int(11) default 0' ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
703 595 }
704 596 }
@@ -704,10 +596,8 @@
704 596 }
705 597
706 598 /**
707 599 * Change field size from character to pixel -- Multiply by 9
708 - *
709 - * @return void
710 600 */
711 601 private function migrate_to_17() {
712 602 $fields = $this->get_fields_with_size();
713 603
@@ -712,9 +602,8 @@
712 602 $fields = $this->get_fields_with_size();
713 603
714 604 foreach ( $fields as $f ) {
715 605 FrmAppHelper::unserialize_or_decode( $f->field_options );
716 -
717 606 if ( empty( $f->field_options['size'] ) || ! is_numeric( $f->field_options['size'] ) ) {
718 607 continue;
719 608 }
720 609
@@ -728,20 +617,16 @@
728 617 }
729 618
730 619 /**
731 620 * Change the characters in widgets to pixels
732 - *
733 - * @return void
734 621 */
735 622 private function adjust_widget_size() {
736 623 $widgets = get_option( 'widget_frm_show_form' );
737 -
738 624 if ( empty( $widgets ) ) {
739 625 return;
740 626 }
741 627
742 628 FrmAppHelper::unserialize_or_decode( $widgets );
743 -
744 629 foreach ( $widgets as $k => $widget ) {
745 630 if ( ! is_array( $widget ) || ! isset( $widget['size'] ) ) {
746 631 continue;
747 632 }
@@ -749,13 +634,8 @@
749 634 }
750 635 update_option( 'widget_frm_show_form', $widgets );
751 636 }
752 637
753 - /**
754 - * @param string $size
755 - *
756 - * @return void
757 - */
758 638 private function convert_character_to_px( &$size ) {
759 639 $pixel_conversion = 9;
760 640
761 641 $size = round( $pixel_conversion * (int) $size );
@@ -829,12 +709,10 @@
829 709 unset( $sending, $img );
830 710
831 711 $new_default_html = FrmFormsHelper::get_default_html( 'submit' );
832 712 $draft_link = FrmFormsHelper::get_draft_link();
833 -
834 713 foreach ( $forms as $form ) {
835 714 FrmAppHelper::unserialize_or_decode( $form->options );
836 -
837 715 if ( empty( $form->options['submit_html'] ) ) {
838 716 continue;
839 717 }
840 718