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/models/FrmMigrate.php +202 -48 6.25 → trunk View file →
@@ -3,21 +3,46 @@
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 + */
7 11 public $fields;
12 +
13 + /**
14 + * @var string
15 + */
8 16 public $forms;
17 +
18 + /**
19 + * @var string
20 + */
9 21 public $entries;
22 +
23 + /**
24 + * @var string
25 + */
10 26 public $entry_metas;
11 27
28 + /**
29 + * @var string
30 + */
31 + public $gated_tokens;
32 +
12 33 public function __construct() {
13 34 global $wpdb;
14 - $this->fields = $wpdb->prefix . 'frm_fields';
15 - $this->forms = $wpdb->prefix . 'frm_forms';
16 - $this->entries = $wpdb->prefix . 'frm_items';
17 - $this->entry_metas = $wpdb->prefix . 'frm_item_metas';
35 + $this->fields = $wpdb->prefix . 'frm_fields';
36 + $this->forms = $wpdb->prefix . 'frm_forms';
37 + $this->entries = $wpdb->prefix . 'frm_items';
38 + $this->entry_metas = $wpdb->prefix . 'frm_item_metas';
39 + $this->gated_tokens = $wpdb->prefix . 'frm_gated_tokens';
18 40 }
19 41
42 + /**
43 + * @return void
44 + */
20 45 public function upgrade() {
21 46 do_action( 'frm_before_install' );
22 47
23 48 global $wpdb, $frm_vars;
@@ -32,9 +57,11 @@
32 57 )
33 58 );
34 59
35 60 if ( $needs_upgrade ) {
36 - // update rewrite rules for views and other custom post types
61 + $this->maybe_delete_htaccess_file();
62 +
63 + // Update rewrite rules for views and other custom post types
37 64 flush_rewrite_rules();
38 65
39 66 require_once ABSPATH . 'wp-admin/includes/upgrade.php';
40 67
@@ -63,24 +90,52 @@
63 90 $frm_vars['doing_upgrade'] = false;
64 91
65 92 FrmAppHelper::save_combined_js();
66 93
67 - // update the styling settings
68 - if ( function_exists( 'get_filesystem_method' ) ) {
69 - $frm_style = new FrmStyle();
70 - $frm_style->update( 'default' );
94 + // Update the styling settings
95 + if ( ! function_exists( 'get_filesystem_method' ) ) {
96 + return;
71 97 }
98 +
99 + $frm_style = new FrmStyle();
100 + $frm_style->update( 'default' );
72 101 }
73 102
74 103 /**
104 + * Check if the .htaccess file should be deleted based on server response.
105 + * If a server has AllowOverride FileInfo but not AllowOverride AuthConfig, JS and CSS files
106 + * will result in a 500 error.
107 + *
108 + * @since 6.27
109 + *
110 + * @return void
111 + */
112 + private function maybe_delete_htaccess_file() {
113 + $css_file_request = wp_remote_get( FrmAppHelper::plugin_url() . '/css/frm_fonts.css' );
114 +
115 + if ( 200 === wp_remote_retrieve_response_code( $css_file_request ) ) {
116 + return;
117 + }
118 +
119 + $htaccess_path = FrmAppHelper::plugin_path() . '/.htaccess';
120 +
121 + if ( file_exists( $htaccess_path ) ) {
122 + wp_delete_file( $htaccess_path );
123 + }
124 + }
125 +
126 + /**
75 127 * Updates some settings for new installs.
76 128 *
77 129 * @since 6.23
130 + *
131 + * @return void
78 132 */
79 133 private function update_settings_for_new_install() {
80 134 $settings = FrmAppHelper::get_settings();
81 135
82 - $settings->denylist_check = 1;
136 + $settings->denylist_check = 1;
137 + $settings->installed_after_welcome_tour_update = 1;
83 138 $settings->store();
84 139 }
85 140
86 141 /**
@@ -104,10 +159,10 @@
104 159
105 160 $message = array(
106 161 'key' => 'failed-to-create-tables',
107 162 'subject' => 'Something went wrong setting up the database',
108 - 'message' => 'For steps to continue, see our <a href="https://formidableforms.com/knowledgebase/install-formidable-forms/#kb-missing-database-tables">documentation</a>. If you need assistance, we recommend that you reach out to your hosting provider. Then <a href="' . esc_url( admin_url( 'admin.php?page=formidable&frm_add_tables=1' ) ) . '">click here</a> to try again.',
109 - 'cta' => '<a href="https://formidableforms.com/knowledgebase/install-formidable-forms/#kb-missing-database-tables">Learn More</a>',
163 + 'message' => 'For steps to continue, see our <a href="https://formidableforms.com/knowledgebase/install-formidable-forms/#kb-missing-database-tables" target="_blank" rel="noopener">documentation</a>. If you need assistance, we recommend that you reach out to your hosting provider. Then <a href="' . esc_url( admin_url( 'admin.php?page=formidable&frm_add_tables=1' ) ) . '">click here</a> to try again.', // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
164 + 'cta' => '<a href="https://formidableforms.com/knowledgebase/install-formidable-forms/#kb-missing-database-tables" target="_blank" rel="noopener">Learn More</a>', // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
110 165 'type' => 'error',
111 166 );
112 167
113 168 $inbox = new FrmInbox();
@@ -118,15 +173,14 @@
118 173 * @return string
119 174 */
120 175 public function collation() {
121 176 global $wpdb;
122 - if ( ! $wpdb->has_cap( 'collation' ) ) {
123 - return '';
124 - }
125 -
126 - return $wpdb->get_charset_collate();
177 + return $wpdb->has_cap( 'collation' ) ? $wpdb->get_charset_collate() : '';
127 178 }
128 179
180 + /**
181 + * @return void
182 + */
129 183 private function create_tables() {
130 184 $charset_collate = $this->collation();
131 185 $sql = array();
132 186
@@ -201,8 +255,25 @@
201 255 KEY field_id (field_id),
202 256 KEY item_id (item_id)
203 257 )';
204 258
259 + /* Create/Upgrade Gated Tokens Table */
260 + $sql[] = 'CREATE TABLE ' . $this->gated_tokens . ' (
261 + id BIGINT UNSIGNED NOT NULL auto_increment,
262 + token_hash varchar(64) NOT NULL,
263 + action_id BIGINT UNSIGNED NOT NULL,
264 + entry_id BIGINT UNSIGNED NOT NULL,
265 + user_id BIGINT UNSIGNED default NULL,
266 + ip_address varchar(255) default NULL,
267 + created_at int UNSIGNED NOT NULL,
268 + expired_at int UNSIGNED default NULL,
269 + PRIMARY KEY (id),
270 + UNIQUE KEY token_hash (token_hash),
271 + KEY action_id (action_id),
272 + KEY user_id (user_id),
273 + KEY expired_at (expired_at)
274 + )';
275 +
205 276 foreach ( $sql as $q ) {
206 277 if ( function_exists( 'dbDelta' ) ) {
207 278 dbDelta( $q . $charset_collate . ';' );
208 279 } else {
@@ -262,8 +333,9 @@
262 333 * @since 6.6
263 334 *
264 335 * @param string $table_name
265 336 * @param string $index_name
337 + *
266 338 * @return bool
267 339 */
268 340 private static function index_exists( $table_name, $index_name ) {
269 341 global $wpdb;
@@ -279,10 +351,14 @@
279 351 );
280 352 return (bool) $row;
281 353 }
282 354
355 + /**
356 + * @return void
357 + */
283 358 private function maybe_create_contact_form() {
284 359 $form_exists = FrmForm::get_id_by_key( 'contact-form' );
360 +
285 361 if ( ! $form_exists ) {
286 362 $this->add_default_template();
287 363 }
288 364 }
@@ -290,8 +366,10 @@
290 366 /**
291 367 * Create the default contact form
292 368 *
293 369 * @since 3.06
370 + *
371 + * @return void
294 372 */
295 373 private function add_default_template() {
296 374 if ( FrmXMLHelper::check_if_libxml_disable_entity_loader_exists() ) {
297 375 // XML import is not enabled on your server.
@@ -299,10 +377,9 @@
299 377 }
300 378
301 379 $set_err = libxml_use_internal_errors( true );
302 380 $loader = FrmXMLHelper::maybe_libxml_disable_entity_loader( true );
303 -
304 - $file = FrmAppHelper::plugin_path() . '/classes/views/xml/default-templates.xml';
381 + $file = FrmAppHelper::plugin_path() . '/classes/views/xml/default-templates.xml';
305 382 FrmXMLHelper::import_xml( $file );
306 383
307 384 libxml_use_internal_errors( $set_err );
308 385 FrmXMLHelper::maybe_libxml_disable_entity_loader( $loader );
@@ -309,32 +386,41 @@
309 386 }
310 387
311 388 /**
312 389 * @param int|string $old_db_version
390 + *
391 + * @return void
313 392 */
314 393 private function migrate_data( $old_db_version ) {
315 394 if ( ! $old_db_version ) {
316 395 $old_db_version = get_option( 'frm_db_version' );
317 396 }
318 - if ( strpos( $old_db_version, '-' ) ) {
397 +
398 + if ( str_contains( $old_db_version, '-' ) ) {
319 399 $last_upgrade = explode( '-', $old_db_version );
320 - $old_db_version = (int) $last_upgrade[1];
400 + $old_db_version = intval( end( $last_upgrade ) );
321 401 }
322 402
323 403 if ( ! is_numeric( $old_db_version ) ) {
324 - // bail if we don't know the previous version
404 + // Bail if we don't know the previous version
325 405 return;
326 406 }
327 407
328 - $migrations = array( 16, 11, 16, 17, 23, 25, 86, 90, 97, 98, 101, 104 );
408 + $migrations = array( 16, 11, 16, 17, 23, 25, 86, 90, 97, 98, 101, 104, 105 );
409 +
329 410 foreach ( $migrations as $migration ) {
330 - if ( FrmAppHelper::$db_version >= $migration && $old_db_version < $migration ) {
331 - $function_name = 'migrate_to_' . $migration;
332 - $this->$function_name();
411 + if ( FrmAppHelper::$db_version < $migration || $old_db_version >= $migration ) {
412 + continue;
333 413 }
414 +
415 + $function_name = 'migrate_to_' . $migration;
416 + $this->$function_name();
334 417 }
335 418 }
336 419
420 + /**
421 + * @return bool
422 + */
337 423 public function uninstall() {
338 424 if ( ! current_user_can( 'administrator' ) ) {
339 425 $frm_settings = FrmAppHelper::get_settings();
340 426 wp_die( esc_html( $frm_settings->admin_permission ) );
@@ -345,8 +431,9 @@
345 431 $wpdb->query( 'DROP TABLE IF EXISTS ' . $this->fields ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
346 432 $wpdb->query( 'DROP TABLE IF EXISTS ' . $this->forms ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
347 433 $wpdb->query( 'DROP TABLE IF EXISTS ' . $this->entries ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
348 434 $wpdb->query( 'DROP TABLE IF EXISTS ' . $this->entry_metas ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
435 + $wpdb->query( 'DROP TABLE IF EXISTS ' . $this->gated_tokens ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
349 436
350 437 delete_option( 'frm_options' );
351 438 delete_option( 'frm_db_version' );
352 439 delete_option( 'frm_install_running' );
@@ -359,8 +446,9 @@
359 446
360 447 // Delete roles.
361 448 $frm_roles = FrmAppHelper::frm_capabilities();
362 449 $roles = get_editable_roles();
450 +
363 451 foreach ( $frm_roles as $frm_role => $frm_role_description ) {
364 452 foreach ( $roles as $role => $details ) {
365 453 $wp_roles->remove_cap( $role, $frm_role );
366 454 unset( $role, $details );
@@ -368,15 +456,16 @@
368 456 unset( $frm_role, $frm_role_description );
369 457 }
370 458 unset( $roles, $frm_roles );
371 459
372 - // delete actions, views, and styles
460 + // Delete actions, views, and styles
373 461
374 - // prevent the post deletion from triggering entries to be deleted
462 + // Prevent the post deletion from triggering entries to be deleted
375 463 remove_action( 'before_delete_post', 'FrmProDisplaysController::before_delete_post' );
376 464 remove_action( 'deleted_post', 'FrmProEntriesController::delete_entry' );
377 465
378 - $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' ) );
466 + $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' ) ); // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
467 +
379 468 foreach ( $post_ids as $post_id ) {
380 469 // Delete's each post.
381 470 wp_delete_post( $post_id, true );
382 471 }
@@ -381,15 +470,15 @@
381 470 wp_delete_post( $post_id, true );
382 471 }
383 472 unset( $post_ids );
384 473
385 - // delete transients
474 + // Delete transients
386 475 delete_transient( 'frmpro_css' );
387 476 delete_transient( 'frm_options' );
388 477 delete_transient( 'frmpro_options' );
389 478 delete_transient( FrmOnboardingWizardController::TRANSIENT_NAME );
390 479
391 - $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->options . ' WHERE option_name LIKE %s OR option_name LIKE %s', '_transient_timeout_frm_form_fields_%', '_transient_frm_form_fields_%' ) );
480 + $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->options . ' WHERE option_name LIKE %s OR option_name LIKE %s', '_transient_timeout_frm_form_fields_%', '_transient_frm_form_fields_%' ) ); // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
392 481
393 482 do_action( 'frm_after_uninstall' );
394 483
395 484 return true;
@@ -413,11 +502,26 @@
413 502 }
414 503 }
415 504
416 505 /**
506 + * Add new wp_options row for custom setting.
507 + *
508 + * @since 6.26
509 + *
510 + * @return void
511 + */
512 + private function migrate_to_105() {
513 + if ( ! FrmAppHelper::pro_is_installed() ) {
514 + update_option( 'frm_show_pricing_fields_modal', 1, false );
515 + }
516 + }
517 +
518 + /**
417 519 * Disables summary email for multisite (not the main site) if recipient setting isn't changed.
418 520 *
419 521 * @since 6.8
522 + *
523 + * @return void
420 524 */
421 525 private function migrate_to_101() {
422 526 if ( ! is_multisite() || get_main_site_id() === get_current_blog_id() ) {
423 527 return;
@@ -423,8 +527,9 @@
423 527 return;
424 528 }
425 529
426 530 $frm_settings = FrmAppHelper::get_settings();
531 +
427 532 if ( empty( $frm_settings->summary_emails ) || '[admin_email]' !== $frm_settings->summary_emails_recipients ) {
428 533 // User changed it.
429 534 return;
430 535 }
@@ -436,8 +541,10 @@
436 541 /**
437 542 * Clear frmpro_css transient.
438 543 *
439 544 * @since 4.10.02
545 + *
546 + * @return void
440 547 */
441 548 private function migrate_to_98() {
442 549 delete_transient( 'frmpro_css' );
443 550 }
@@ -445,8 +552,10 @@
445 552 /**
446 553 * Move default_blank and clear_on_focus to placeholder.
447 554 *
448 555 * @since 4.0
556 + *
557 + * @return void
449 558 */
450 559 private function migrate_to_97() {
451 560 $this->migrate_to_placeholder( 'clear_on_focus' );
452 561 $this->migrate_to_placeholder( 'default_blank' );
@@ -455,8 +564,12 @@
455 564 /**
456 565 * Move clear_on_focus or default_blank to placeholder.
457 566 *
458 567 * @since 4.0
568 + *
569 + * @param string $type Field option key to migrate.
570 + *
571 + * @return void
459 572 */
460 573 private function migrate_to_placeholder( $type = 'clear_on_focus' ) {
461 574 $query = array(
462 575 'field_options like' => '"' . $type . '";s:1:"1";',
@@ -467,9 +580,10 @@
467 580 foreach ( $fields as $field ) {
468 581 FrmAppHelper::unserialize_or_decode( $field->field_options );
469 582 FrmAppHelper::unserialize_or_decode( $field->options );
470 583 $update_values = FrmXMLHelper::migrate_field_placeholder( $field, $type );
471 - if ( empty( $update_values ) ) {
584 +
585 + if ( ! $update_values ) {
472 586 continue;
473 587 }
474 588
475 589 FrmField::update( $field->id, $update_values );
@@ -480,11 +594,15 @@
480 594 /**
481 595 * Delete unneeded default templates
482 596 *
483 597 * @since 3.06
598 + *
599 + * @return void
484 600 */
485 601 private function migrate_to_90() {
486 602 $form = FrmForm::getOne( 'contact' );
603 +
604 + // phpcs:ignore Universal.Operators.StrictComparisons
487 605 if ( $form && $form->default_template == 1 ) {
488 606 FrmForm::destroy( 'contact' );
489 607 }
490 608 }
@@ -492,14 +610,15 @@
492 610 /**
493 611 * Reverse migration 17 -- Divide by 9
494 612 *
495 613 * @since 3.0.05
614 + *
615 + * @return void
496 616 */
497 617 private function migrate_to_86() {
498 -
499 618 $fields = $this->get_fields_with_size();
500 619
501 - foreach ( (array) $fields as $f ) {
620 + foreach ( $fields as $f ) {
502 621 FrmAppHelper::unserialize_or_decode( $f->field_options );
503 622 $size = $f->field_options['size'];
504 623 $this->maybe_convert_migrated_size( $size );
505 624
@@ -511,11 +630,12 @@
511 630 FrmField::update( $f->id, array( 'field_options' => $f->field_options ) );
512 631 unset( $f );
513 632 }
514 633
515 - // reverse the extra size changes in widgets
634 + // Reverse the extra size changes in widgets
516 635 $widgets = get_option( 'widget_frm_show_form' );
517 - if ( empty( $widgets ) ) {
636 +
637 + if ( ! $widgets ) {
518 638 return;
519 639 }
520 640
521 641 $this->revert_widget_field_size();
@@ -520,8 +640,11 @@
520 640
521 641 $this->revert_widget_field_size();
522 642 }
523 643
644 + /**
645 + * @return array
646 + */
524 647 private function get_fields_with_size() {
525 648 $field_types = array(
526 649 'textarea',
527 650 'text',
@@ -549,16 +672,20 @@
549 672 /**
550 673 * Reverse the extra size changes in widgets
551 674 *
552 675 * @since 3.0.05
676 + *
677 + * @return void
553 678 */
554 679 private function revert_widget_field_size() {
555 680 $widgets = get_option( 'widget_frm_show_form' );
556 - if ( empty( $widgets ) ) {
681 +
682 + if ( ! $widgets ) {
557 683 return;
558 684 }
559 685
560 686 FrmAppHelper::unserialize_or_decode( $widgets );
687 +
561 688 foreach ( $widgets as $k => $widget ) {
562 689 if ( ! is_array( $widget ) || ! isset( $widget['size'] ) ) {
563 690 continue;
564 691 }
@@ -564,8 +691,9 @@
564 691 }
565 692
566 693 $this->maybe_convert_migrated_size( $widgets[ $k ]['size'] );
567 694 }
695 +
568 696 update_option( 'widget_frm_show_form', $widgets );
569 697 }
570 698
571 699 /**
@@ -571,23 +699,28 @@
571 699 /**
572 700 * Divide by 9 to reverse the multiplication
573 701 *
574 702 * @since 3.0.05
703 + *
704 + * @param string $size Size string to maybe convert, passed by reference.
705 + *
706 + * @return void
575 707 */
576 708 private function maybe_convert_migrated_size( &$size ) {
577 - $has_px_size = ! empty( $size ) && strpos( $size, 'px' );
709 + $has_px_size = $size && str_contains( $size, 'px' );
710 +
578 711 if ( ! $has_px_size ) {
579 712 return;
580 713 }
581 714
582 715 $int_size = str_replace( 'px', '', $size );
716 +
583 717 if ( ! is_numeric( $int_size ) || (int) $int_size < 900 ) {
584 718 return;
585 719 }
586 720
587 721 $pixel_conversion = 9;
588 -
589 - $size = round( (int) $int_size / $pixel_conversion );
722 + $size = round( (int) $int_size / $pixel_conversion );
590 723 }
591 724
592 725 /**
593 726 * Migrate old styling settings. If sites are using the old
@@ -593,14 +726,17 @@
593 726 * Migrate old styling settings. If sites are using the old
594 727 * default 400px field width, switch it to 100%
595 728 *
596 729 * @since 2.0.4
730 + *
731 + * @return void
597 732 */
598 733 private function migrate_to_25() {
599 - // get the style that was created with the style migration
734 + // Get the style that was created with the style migration
600 735 $frm_style = new FrmStyle();
601 736 $styles = $frm_style->get_all( 'post_date', 'ASC', 1 );
602 - if ( empty( $styles ) ) {
737 +
738 + if ( ! $styles ) {
603 739 return;
604 740 }
605 741
606 742 foreach ( $styles as $style ) {
@@ -617,13 +753,16 @@
617 753 * Check if the parent_form_id columns exists.
618 754 * If not, try and add it again
619 755 *
620 756 * @since 2.0.2
757 + *
758 + * @return void
621 759 */
622 760 private function migrate_to_23() {
623 761 global $wpdb;
624 762 $exists = $wpdb->get_row( 'SHOW COLUMNS FROM ' . $this->forms . ' LIKE "parent_form_id"' ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
625 - if ( empty( $exists ) ) {
763 +
764 + if ( ! $exists ) {
626 765 $wpdb->query( 'ALTER TABLE ' . $this->forms . ' ADD parent_form_id int(11) default 0' ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
627 766 }
628 767 }
629 768
@@ -628,8 +767,10 @@
628 767 }
629 768
630 769 /**
631 770 * Change field size from character to pixel -- Multiply by 9
771 + *
772 + * @return void
632 773 */
633 774 private function migrate_to_17() {
634 775 $fields = $this->get_fields_with_size();
635 776
@@ -634,8 +775,9 @@
634 775 $fields = $this->get_fields_with_size();
635 776
636 777 foreach ( $fields as $f ) {
637 778 FrmAppHelper::unserialize_or_decode( $f->field_options );
779 +
638 780 if ( empty( $f->field_options['size'] ) || ! is_numeric( $f->field_options['size'] ) ) {
639 781 continue;
640 782 }
641 783
@@ -649,16 +791,20 @@
649 791 }
650 792
651 793 /**
652 794 * Change the characters in widgets to pixels
795 + *
796 + * @return void
653 797 */
654 798 private function adjust_widget_size() {
655 799 $widgets = get_option( 'widget_frm_show_form' );
656 - if ( empty( $widgets ) ) {
800 +
801 + if ( ! $widgets ) {
657 802 return;
658 803 }
659 804
660 805 FrmAppHelper::unserialize_or_decode( $widgets );
806 +
661 807 foreach ( $widgets as $k => $widget ) {
662 808 if ( ! is_array( $widget ) || ! isset( $widget['size'] ) ) {
663 809 continue;
664 810 }
@@ -663,11 +809,17 @@
663 809 continue;
664 810 }
665 811 $this->convert_character_to_px( $widgets[ $k ]['size'] );
666 812 }
813 +
667 814 update_option( 'widget_frm_show_form', $widgets );
668 815 }
669 816
817 + /**
818 + * @param string $size
819 + *
820 + * @return void
821 + */
670 822 private function convert_character_to_px( &$size ) {
671 823 $pixel_conversion = 9;
672 824
673 825 $size = round( $pixel_conversion * (int) $size );
@@ -710,9 +862,9 @@
710 862 * post_excerpt: message
711 863 */
712 864 foreach ( $forms as $form ) {
713 865 if ( $form->is_template && $form->default_template ) {
714 - // don't migrate the default templates since the email will be added anyway
866 + // Don't migrate the default templates since the email will be added anyway
715 867 continue;
716 868 }
717 869
718 870 // Format form options
@@ -726,10 +878,9 @@
726 878
727 879 private function migrate_to_11() {
728 880 global $wpdb;
729 881
730 - $forms = FrmDb::get_results( $this->forms, array(), 'id, options' );
731 -
882 + $forms = FrmDb::get_results( $this->forms, array(), 'id, options' );
732 883 $sending = __( 'Sending', 'formidable' );
733 884 $img = FrmAppHelper::plugin_url() . '/images/ajax_loader.gif';
734 885 $old_default_html = <<<DEFAULT_HTML
735 886 <div class="frm_submit">
@@ -741,18 +892,21 @@
741 892 unset( $sending, $img );
742 893
743 894 $new_default_html = FrmFormsHelper::get_default_html( 'submit' );
744 895 $draft_link = FrmFormsHelper::get_draft_link();
896 +
745 897 foreach ( $forms as $form ) {
746 898 FrmAppHelper::unserialize_or_decode( $form->options );
899 +
747 900 if ( empty( $form->options['submit_html'] ) ) {
748 901 continue;
749 902 }
750 903
904 + // phpcs:ignore Universal.Operators.StrictComparisons
751 905 if ( $form->options['submit_html'] != $new_default_html && $form->options['submit_html'] == $old_default_html ) {
752 906 $form->options['submit_html'] = $new_default_html;
753 907 $wpdb->update( $this->forms, array( 'options' => serialize( $form->options ) ), array( 'id' => $form->id ) );
754 - } elseif ( ! strpos( $form->options['submit_html'], 'save_draft' ) ) {
908 + } elseif ( ! str_contains( $form->options['submit_html'], 'save_draft' ) ) {
755 909 $form->options['submit_html'] = preg_replace( '~\<\/div\>(?!.*\<\/div\>)~', $draft_link . "\r\n</div>", $form->options['submit_html'] );
756 910 $wpdb->update( $this->forms, array( 'options' => serialize( $form->options ) ), array( 'id' => $form->id ) );
757 911 }
758 912 unset( $form );