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 +200 -47 6.25.1 → 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,19 +90,46 @@
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
@@ -105,10 +159,10 @@
105 159
106 160 $message = array(
107 161 'key' => 'failed-to-create-tables',
108 162 'subject' => 'Something went wrong setting up the database',
109 - '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.',
110 - '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
111 165 'type' => 'error',
112 166 );
113 167
114 168 $inbox = new FrmInbox();
@@ -119,15 +173,14 @@
119 173 * @return string
120 174 */
121 175 public function collation() {
122 176 global $wpdb;
123 - if ( ! $wpdb->has_cap( 'collation' ) ) {
124 - return '';
125 - }
126 -
127 - return $wpdb->get_charset_collate();
177 + return $wpdb->has_cap( 'collation' ) ? $wpdb->get_charset_collate() : '';
128 178 }
129 179
180 + /**
181 + * @return void
182 + */
130 183 private function create_tables() {
131 184 $charset_collate = $this->collation();
132 185 $sql = array();
133 186
@@ -202,8 +255,25 @@
202 255 KEY field_id (field_id),
203 256 KEY item_id (item_id)
204 257 )';
205 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 +
206 276 foreach ( $sql as $q ) {
207 277 if ( function_exists( 'dbDelta' ) ) {
208 278 dbDelta( $q . $charset_collate . ';' );
209 279 } else {
@@ -263,8 +333,9 @@
263 333 * @since 6.6
264 334 *
265 335 * @param string $table_name
266 336 * @param string $index_name
337 + *
267 338 * @return bool
268 339 */
269 340 private static function index_exists( $table_name, $index_name ) {
270 341 global $wpdb;
@@ -280,10 +351,14 @@
280 351 );
281 352 return (bool) $row;
282 353 }
283 354
355 + /**
356 + * @return void
357 + */
284 358 private function maybe_create_contact_form() {
285 359 $form_exists = FrmForm::get_id_by_key( 'contact-form' );
360 +
286 361 if ( ! $form_exists ) {
287 362 $this->add_default_template();
288 363 }
289 364 }
@@ -291,8 +366,10 @@
291 366 /**
292 367 * Create the default contact form
293 368 *
294 369 * @since 3.06
370 + *
371 + * @return void
295 372 */
296 373 private function add_default_template() {
297 374 if ( FrmXMLHelper::check_if_libxml_disable_entity_loader_exists() ) {
298 375 // XML import is not enabled on your server.
@@ -300,10 +377,9 @@
300 377 }
301 378
302 379 $set_err = libxml_use_internal_errors( true );
303 380 $loader = FrmXMLHelper::maybe_libxml_disable_entity_loader( true );
304 -
305 - $file = FrmAppHelper::plugin_path() . '/classes/views/xml/default-templates.xml';
381 + $file = FrmAppHelper::plugin_path() . '/classes/views/xml/default-templates.xml';
306 382 FrmXMLHelper::import_xml( $file );
307 383
308 384 libxml_use_internal_errors( $set_err );
309 385 FrmXMLHelper::maybe_libxml_disable_entity_loader( $loader );
@@ -310,32 +386,41 @@
310 386 }
311 387
312 388 /**
313 389 * @param int|string $old_db_version
390 + *
391 + * @return void
314 392 */
315 393 private function migrate_data( $old_db_version ) {
316 394 if ( ! $old_db_version ) {
317 395 $old_db_version = get_option( 'frm_db_version' );
318 396 }
319 - if ( strpos( $old_db_version, '-' ) ) {
397 +
398 + if ( str_contains( $old_db_version, '-' ) ) {
320 399 $last_upgrade = explode( '-', $old_db_version );
321 - $old_db_version = (int) $last_upgrade[1];
400 + $old_db_version = intval( end( $last_upgrade ) );
322 401 }
323 402
324 403 if ( ! is_numeric( $old_db_version ) ) {
325 - // bail if we don't know the previous version
404 + // Bail if we don't know the previous version
326 405 return;
327 406 }
328 407
329 - $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 +
330 410 foreach ( $migrations as $migration ) {
331 - if ( FrmAppHelper::$db_version >= $migration && $old_db_version < $migration ) {
332 - $function_name = 'migrate_to_' . $migration;
333 - $this->$function_name();
411 + if ( FrmAppHelper::$db_version < $migration || $old_db_version >= $migration ) {
412 + continue;
334 413 }
414 +
415 + $function_name = 'migrate_to_' . $migration;
416 + $this->$function_name();
335 417 }
336 418 }
337 419
420 + /**
421 + * @return bool
422 + */
338 423 public function uninstall() {
339 424 if ( ! current_user_can( 'administrator' ) ) {
340 425 $frm_settings = FrmAppHelper::get_settings();
341 426 wp_die( esc_html( $frm_settings->admin_permission ) );
@@ -346,8 +431,9 @@
346 431 $wpdb->query( 'DROP TABLE IF EXISTS ' . $this->fields ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
347 432 $wpdb->query( 'DROP TABLE IF EXISTS ' . $this->forms ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
348 433 $wpdb->query( 'DROP TABLE IF EXISTS ' . $this->entries ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
349 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
350 436
351 437 delete_option( 'frm_options' );
352 438 delete_option( 'frm_db_version' );
353 439 delete_option( 'frm_install_running' );
@@ -360,8 +446,9 @@
360 446
361 447 // Delete roles.
362 448 $frm_roles = FrmAppHelper::frm_capabilities();
363 449 $roles = get_editable_roles();
450 +
364 451 foreach ( $frm_roles as $frm_role => $frm_role_description ) {
365 452 foreach ( $roles as $role => $details ) {
366 453 $wp_roles->remove_cap( $role, $frm_role );
367 454 unset( $role, $details );
@@ -369,15 +456,16 @@
369 456 unset( $frm_role, $frm_role_description );
370 457 }
371 458 unset( $roles, $frm_roles );
372 459
373 - // delete actions, views, and styles
460 + // Delete actions, views, and styles
374 461
375 - // prevent the post deletion from triggering entries to be deleted
462 + // Prevent the post deletion from triggering entries to be deleted
376 463 remove_action( 'before_delete_post', 'FrmProDisplaysController::before_delete_post' );
377 464 remove_action( 'deleted_post', 'FrmProEntriesController::delete_entry' );
378 465
379 - $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 +
380 468 foreach ( $post_ids as $post_id ) {
381 469 // Delete's each post.
382 470 wp_delete_post( $post_id, true );
383 471 }
@@ -382,15 +470,15 @@
382 470 wp_delete_post( $post_id, true );
383 471 }
384 472 unset( $post_ids );
385 473
386 - // delete transients
474 + // Delete transients
387 475 delete_transient( 'frmpro_css' );
388 476 delete_transient( 'frm_options' );
389 477 delete_transient( 'frmpro_options' );
390 478 delete_transient( FrmOnboardingWizardController::TRANSIENT_NAME );
391 479
392 - $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
393 481
394 482 do_action( 'frm_after_uninstall' );
395 483
396 484 return true;
@@ -414,11 +502,26 @@
414 502 }
415 503 }
416 504
417 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 + /**
418 519 * Disables summary email for multisite (not the main site) if recipient setting isn't changed.
419 520 *
420 521 * @since 6.8
522 + *
523 + * @return void
421 524 */
422 525 private function migrate_to_101() {
423 526 if ( ! is_multisite() || get_main_site_id() === get_current_blog_id() ) {
424 527 return;
@@ -424,8 +527,9 @@
424 527 return;
425 528 }
426 529
427 530 $frm_settings = FrmAppHelper::get_settings();
531 +
428 532 if ( empty( $frm_settings->summary_emails ) || '[admin_email]' !== $frm_settings->summary_emails_recipients ) {
429 533 // User changed it.
430 534 return;
431 535 }
@@ -437,8 +541,10 @@
437 541 /**
438 542 * Clear frmpro_css transient.
439 543 *
440 544 * @since 4.10.02
545 + *
546 + * @return void
441 547 */
442 548 private function migrate_to_98() {
443 549 delete_transient( 'frmpro_css' );
444 550 }
@@ -446,8 +552,10 @@
446 552 /**
447 553 * Move default_blank and clear_on_focus to placeholder.
448 554 *
449 555 * @since 4.0
556 + *
557 + * @return void
450 558 */
451 559 private function migrate_to_97() {
452 560 $this->migrate_to_placeholder( 'clear_on_focus' );
453 561 $this->migrate_to_placeholder( 'default_blank' );
@@ -456,8 +564,12 @@
456 564 /**
457 565 * Move clear_on_focus or default_blank to placeholder.
458 566 *
459 567 * @since 4.0
568 + *
569 + * @param string $type Field option key to migrate.
570 + *
571 + * @return void
460 572 */
461 573 private function migrate_to_placeholder( $type = 'clear_on_focus' ) {
462 574 $query = array(
463 575 'field_options like' => '"' . $type . '";s:1:"1";',
@@ -468,9 +580,10 @@
468 580 foreach ( $fields as $field ) {
469 581 FrmAppHelper::unserialize_or_decode( $field->field_options );
470 582 FrmAppHelper::unserialize_or_decode( $field->options );
471 583 $update_values = FrmXMLHelper::migrate_field_placeholder( $field, $type );
472 - if ( empty( $update_values ) ) {
584 +
585 + if ( ! $update_values ) {
473 586 continue;
474 587 }
475 588
476 589 FrmField::update( $field->id, $update_values );
@@ -481,11 +594,15 @@
481 594 /**
482 595 * Delete unneeded default templates
483 596 *
484 597 * @since 3.06
598 + *
599 + * @return void
485 600 */
486 601 private function migrate_to_90() {
487 602 $form = FrmForm::getOne( 'contact' );
603 +
604 + // phpcs:ignore Universal.Operators.StrictComparisons
488 605 if ( $form && $form->default_template == 1 ) {
489 606 FrmForm::destroy( 'contact' );
490 607 }
491 608 }
@@ -493,14 +610,15 @@
493 610 /**
494 611 * Reverse migration 17 -- Divide by 9
495 612 *
496 613 * @since 3.0.05
614 + *
615 + * @return void
497 616 */
498 617 private function migrate_to_86() {
499 -
500 618 $fields = $this->get_fields_with_size();
501 619
502 - foreach ( (array) $fields as $f ) {
620 + foreach ( $fields as $f ) {
503 621 FrmAppHelper::unserialize_or_decode( $f->field_options );
504 622 $size = $f->field_options['size'];
505 623 $this->maybe_convert_migrated_size( $size );
506 624
@@ -512,11 +630,12 @@
512 630 FrmField::update( $f->id, array( 'field_options' => $f->field_options ) );
513 631 unset( $f );
514 632 }
515 633
516 - // reverse the extra size changes in widgets
634 + // Reverse the extra size changes in widgets
517 635 $widgets = get_option( 'widget_frm_show_form' );
518 - if ( empty( $widgets ) ) {
636 +
637 + if ( ! $widgets ) {
519 638 return;
520 639 }
521 640
522 641 $this->revert_widget_field_size();
@@ -521,8 +640,11 @@
521 640
522 641 $this->revert_widget_field_size();
523 642 }
524 643
644 + /**
645 + * @return array
646 + */
525 647 private function get_fields_with_size() {
526 648 $field_types = array(
527 649 'textarea',
528 650 'text',
@@ -550,16 +672,20 @@
550 672 /**
551 673 * Reverse the extra size changes in widgets
552 674 *
553 675 * @since 3.0.05
676 + *
677 + * @return void
554 678 */
555 679 private function revert_widget_field_size() {
556 680 $widgets = get_option( 'widget_frm_show_form' );
557 - if ( empty( $widgets ) ) {
681 +
682 + if ( ! $widgets ) {
558 683 return;
559 684 }
560 685
561 686 FrmAppHelper::unserialize_or_decode( $widgets );
687 +
562 688 foreach ( $widgets as $k => $widget ) {
563 689 if ( ! is_array( $widget ) || ! isset( $widget['size'] ) ) {
564 690 continue;
565 691 }
@@ -565,8 +691,9 @@
565 691 }
566 692
567 693 $this->maybe_convert_migrated_size( $widgets[ $k ]['size'] );
568 694 }
695 +
569 696 update_option( 'widget_frm_show_form', $widgets );
570 697 }
571 698
572 699 /**
@@ -572,23 +699,28 @@
572 699 /**
573 700 * Divide by 9 to reverse the multiplication
574 701 *
575 702 * @since 3.0.05
703 + *
704 + * @param string $size Size string to maybe convert, passed by reference.
705 + *
706 + * @return void
576 707 */
577 708 private function maybe_convert_migrated_size( &$size ) {
578 - $has_px_size = ! empty( $size ) && strpos( $size, 'px' );
709 + $has_px_size = $size && str_contains( $size, 'px' );
710 +
579 711 if ( ! $has_px_size ) {
580 712 return;
581 713 }
582 714
583 715 $int_size = str_replace( 'px', '', $size );
716 +
584 717 if ( ! is_numeric( $int_size ) || (int) $int_size < 900 ) {
585 718 return;
586 719 }
587 720
588 721 $pixel_conversion = 9;
589 -
590 - $size = round( (int) $int_size / $pixel_conversion );
722 + $size = round( (int) $int_size / $pixel_conversion );
591 723 }
592 724
593 725 /**
594 726 * Migrate old styling settings. If sites are using the old
@@ -594,14 +726,17 @@
594 726 * Migrate old styling settings. If sites are using the old
595 727 * default 400px field width, switch it to 100%
596 728 *
597 729 * @since 2.0.4
730 + *
731 + * @return void
598 732 */
599 733 private function migrate_to_25() {
600 - // get the style that was created with the style migration
734 + // Get the style that was created with the style migration
601 735 $frm_style = new FrmStyle();
602 736 $styles = $frm_style->get_all( 'post_date', 'ASC', 1 );
603 - if ( empty( $styles ) ) {
737 +
738 + if ( ! $styles ) {
604 739 return;
605 740 }
606 741
607 742 foreach ( $styles as $style ) {
@@ -618,13 +753,16 @@
618 753 * Check if the parent_form_id columns exists.
619 754 * If not, try and add it again
620 755 *
621 756 * @since 2.0.2
757 + *
758 + * @return void
622 759 */
623 760 private function migrate_to_23() {
624 761 global $wpdb;
625 762 $exists = $wpdb->get_row( 'SHOW COLUMNS FROM ' . $this->forms . ' LIKE "parent_form_id"' ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
626 - if ( empty( $exists ) ) {
763 +
764 + if ( ! $exists ) {
627 765 $wpdb->query( 'ALTER TABLE ' . $this->forms . ' ADD parent_form_id int(11) default 0' ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
628 766 }
629 767 }
630 768
@@ -629,8 +767,10 @@
629 767 }
630 768
631 769 /**
632 770 * Change field size from character to pixel -- Multiply by 9
771 + *
772 + * @return void
633 773 */
634 774 private function migrate_to_17() {
635 775 $fields = $this->get_fields_with_size();
636 776
@@ -635,8 +775,9 @@
635 775 $fields = $this->get_fields_with_size();
636 776
637 777 foreach ( $fields as $f ) {
638 778 FrmAppHelper::unserialize_or_decode( $f->field_options );
779 +
639 780 if ( empty( $f->field_options['size'] ) || ! is_numeric( $f->field_options['size'] ) ) {
640 781 continue;
641 782 }
642 783
@@ -650,16 +791,20 @@
650 791 }
651 792
652 793 /**
653 794 * Change the characters in widgets to pixels
795 + *
796 + * @return void
654 797 */
655 798 private function adjust_widget_size() {
656 799 $widgets = get_option( 'widget_frm_show_form' );
657 - if ( empty( $widgets ) ) {
800 +
801 + if ( ! $widgets ) {
658 802 return;
659 803 }
660 804
661 805 FrmAppHelper::unserialize_or_decode( $widgets );
806 +
662 807 foreach ( $widgets as $k => $widget ) {
663 808 if ( ! is_array( $widget ) || ! isset( $widget['size'] ) ) {
664 809 continue;
665 810 }
@@ -664,11 +809,17 @@
664 809 continue;
665 810 }
666 811 $this->convert_character_to_px( $widgets[ $k ]['size'] );
667 812 }
813 +
668 814 update_option( 'widget_frm_show_form', $widgets );
669 815 }
670 816
817 + /**
818 + * @param string $size
819 + *
820 + * @return void
821 + */
671 822 private function convert_character_to_px( &$size ) {
672 823 $pixel_conversion = 9;
673 824
674 825 $size = round( $pixel_conversion * (int) $size );
@@ -711,9 +862,9 @@
711 862 * post_excerpt: message
712 863 */
713 864 foreach ( $forms as $form ) {
714 865 if ( $form->is_template && $form->default_template ) {
715 - // 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
716 867 continue;
717 868 }
718 869
719 870 // Format form options
@@ -727,10 +878,9 @@
727 878
728 879 private function migrate_to_11() {
729 880 global $wpdb;
730 881
731 - $forms = FrmDb::get_results( $this->forms, array(), 'id, options' );
732 -
882 + $forms = FrmDb::get_results( $this->forms, array(), 'id, options' );
733 883 $sending = __( 'Sending', 'formidable' );
734 884 $img = FrmAppHelper::plugin_url() . '/images/ajax_loader.gif';
735 885 $old_default_html = <<<DEFAULT_HTML
736 886 <div class="frm_submit">
@@ -742,18 +892,21 @@
742 892 unset( $sending, $img );
743 893
744 894 $new_default_html = FrmFormsHelper::get_default_html( 'submit' );
745 895 $draft_link = FrmFormsHelper::get_draft_link();
896 +
746 897 foreach ( $forms as $form ) {
747 898 FrmAppHelper::unserialize_or_decode( $form->options );
899 +
748 900 if ( empty( $form->options['submit_html'] ) ) {
749 901 continue;
750 902 }
751 903
904 + // phpcs:ignore Universal.Operators.StrictComparisons
752 905 if ( $form->options['submit_html'] != $new_default_html && $form->options['submit_html'] == $old_default_html ) {
753 906 $form->options['submit_html'] = $new_default_html;
754 907 $wpdb->update( $this->forms, array( 'options' => serialize( $form->options ) ), array( 'id' => $form->id ) );
755 - } elseif ( ! strpos( $form->options['submit_html'], 'save_draft' ) ) {
908 + } elseif ( ! str_contains( $form->options['submit_html'], 'save_draft' ) ) {
756 909 $form->options['submit_html'] = preg_replace( '~\<\/div\>(?!.*\<\/div\>)~', $draft_link . "\r\n</div>", $form->options['submit_html'] );
757 910 $wpdb->update( $this->forms, array( 'options' => serialize( $form->options ) ), array( 'id' => $form->id ) );
758 911 }
759 912 unset( $form );