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