PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.16
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.16
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 +40 -253 6.326.16 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;
@@ -51,11 +32,9 @@
51 32 )
52 33 );
53 34
54 35 if ( $needs_upgrade ) {
55 - $this->maybe_delete_htaccess_file();
56 -
57 - // Update rewrite rules for views and other custom post types
36 + // update rewrite rules for views and other custom post types
58 37 flush_rewrite_rules();
59 38
60 39 require_once ABSPATH . 'wp-admin/includes/upgrade.php';
61 40
@@ -62,9 +41,8 @@
62 41 $old_db_version = get_option( 'frm_db_version' );
63 42
64 43 $this->create_tables();
65 44 $this->migrate_data( $old_db_version );
66 - $this->check_that_tables_exist();
67 45
68 46 // SAVE DB VERSION.
69 47 update_option( 'frm_db_version', FrmAppHelper::plugin_version() . '-' . FrmAppHelper::$db_version );
70 48
@@ -73,10 +51,8 @@
73 51
74 52 if ( false === get_option( 'frm_first_activation' ) ) {
75 53 update_option( 'frm_first_activation', time(), false );
76 54 }
77 -
78 - $this->update_settings_for_new_install();
79 55 }
80 56 }//end if
81 57
82 58 do_action( 'frm_after_install' );
@@ -84,97 +60,24 @@
84 60 $frm_vars['doing_upgrade'] = false;
85 61
86 62 FrmAppHelper::save_combined_js();
87 63
88 - // Update the styling settings
89 - if ( ! function_exists( 'get_filesystem_method' ) ) {
90 - return;
64 + // update the styling settings
65 + if ( function_exists( 'get_filesystem_method' ) ) {
66 + $frm_style = new FrmStyle();
67 + $frm_style->update( 'default' );
91 68 }
92 -
93 - $frm_style = new FrmStyle();
94 - $frm_style->update( 'default' );
95 69 }
96 70
97 - /**
98 - * Check if the .htaccess file should be deleted based on server response.
99 - * If a server has AllowOverride FileInfo but not AllowOverride AuthConfig, JS and CSS files
100 - * will result in a 500 error.
101 - *
102 - * @since 6.27
103 - *
104 - * @return void
105 - */
106 - private function maybe_delete_htaccess_file() {
107 - $css_file_request = wp_remote_get( FrmAppHelper::plugin_url() . '/css/frm_fonts.css' );
108 -
109 - if ( 200 === wp_remote_retrieve_response_code( $css_file_request ) ) {
110 - return;
111 - }
112 -
113 - $htaccess_path = FrmAppHelper::plugin_path() . '/.htaccess';
114 -
115 - if ( file_exists( $htaccess_path ) ) {
116 - wp_delete_file( $htaccess_path );
117 - }
118 - }
119 -
120 - /**
121 - * Updates some settings for new installs.
122 - *
123 - * @since 6.23
124 - *
125 - * @return void
126 - */
127 - private function update_settings_for_new_install() {
128 - $settings = FrmAppHelper::get_settings();
129 -
130 - $settings->denylist_check = 1;
131 - $settings->installed_after_welcome_tour_update = 1;
132 - $settings->store();
133 - }
134 -
135 - /**
136 - * If we fail to create the database tables, add an inbox notice.
137 - * This informs the user that they need to correct the issue and try again.
138 - *
139 - * @since 6.19
140 - *
141 - * @return void
142 - */
143 - private function check_that_tables_exist() {
144 - // Check the DB that the table $this->forms exists.
71 + public function collation() {
145 72 global $wpdb;
146 - $exists = $wpdb->get_results( $wpdb->prepare( 'SHOW TABLES LIKE %s', $this->forms ) );
147 -
148 - if ( $exists ) {
149 - $inbox = new FrmInbox();
150 - $inbox->dismiss( 'failed-to-create-tables' );
151 - return;
73 + if ( ! $wpdb->has_cap( 'collation' ) ) {
74 + return '';
152 75 }
153 76
154 - $message = array(
155 - 'key' => 'failed-to-create-tables',
156 - 'subject' => 'Something went wrong setting up the database',
157 - '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.', // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
158 - 'cta' => '<a href="https://formidableforms.com/knowledgebase/install-formidable-forms/#kb-missing-database-tables">Learn More</a>',
159 - 'type' => 'error',
160 - );
161 -
162 - $inbox = new FrmInbox();
163 - $inbox->add_message( $message );
77 + return $wpdb->get_charset_collate();
164 78 }
165 79
166 - /**
167 - * @return string
168 - */
169 - public function collation() {
170 - global $wpdb;
171 - return $wpdb->has_cap( 'collation' ) ? $wpdb->get_charset_collate() : '';
172 - }
173 -
174 - /**
175 - * @return void
176 - */
177 80 private function create_tables() {
178 81 $charset_collate = $this->collation();
179 82 $sql = array();
180 83
@@ -266,10 +169,8 @@
266 169 /**
267 170 * These indexes help optimize database queries for entries.
268 171 *
269 172 * @since 6.6
270 - * @since 6.16.3 idx_form_id_is_draft was also added to frm_items.
271 - * @since 6.17 idx_form_id_type was also added to frm_fields.
272 173 *
273 174 * @return void
274 175 */
275 176 private function add_composite_indexes_for_entries() {
@@ -287,22 +188,8 @@
287 188
288 189 if ( ! self::index_exists( $table_name, $index_name ) ) {
289 190 $wpdb->query( "CREATE INDEX idx_field_id_item_id ON `{$wpdb->prefix}frm_item_metas` (field_id, item_id)" );
290 191 }
291 -
292 - $table_name = "{$wpdb->prefix}frm_items";
293 - $index_name = 'idx_form_id_is_draft';
294 -
295 - if ( ! self::index_exists( $table_name, $index_name ) ) {
296 - $wpdb->query( "CREATE INDEX idx_form_id_is_draft ON `{$wpdb->prefix}frm_items` (form_id, is_draft)" );
297 - }
298 -
299 - $table_name = "{$wpdb->prefix}frm_fields";
300 - $index_name = 'idx_form_id_type';
301 -
302 - if ( ! self::index_exists( $table_name, $index_name ) ) {
303 - $wpdb->query( "CREATE INDEX idx_form_id_type ON `{$wpdb->prefix}frm_fields` (form_id, type(30))" );
304 - }
305 192 }
306 193
307 194 /**
308 195 * Check that an index exists in a database table before trying to add it (which results in an error).
@@ -310,9 +197,8 @@
310 197 * @since 6.6
311 198 *
312 199 * @param string $table_name
313 200 * @param string $index_name
314 - *
315 201 * @return bool
316 202 */
317 203 private static function index_exists( $table_name, $index_name ) {
318 204 global $wpdb;
@@ -328,14 +214,10 @@
328 214 );
329 215 return (bool) $row;
330 216 }
331 217
332 - /**
333 - * @return void
334 - */
335 218 private function maybe_create_contact_form() {
336 219 $form_exists = FrmForm::get_id_by_key( 'contact-form' );
337 -
338 220 if ( ! $form_exists ) {
339 221 $this->add_default_template();
340 222 }
341 223 }
@@ -343,10 +225,8 @@
343 225 /**
344 226 * Create the default contact form
345 227 *
346 228 * @since 3.06
347 - *
348 - * @return void
349 229 */
350 230 private function add_default_template() {
351 231 if ( FrmXMLHelper::check_if_libxml_disable_entity_loader_exists() ) {
352 232 // XML import is not enabled on your server.
@@ -354,9 +234,10 @@
354 234 }
355 235
356 236 $set_err = libxml_use_internal_errors( true );
357 237 $loader = FrmXMLHelper::maybe_libxml_disable_entity_loader( true );
358 - $file = FrmAppHelper::plugin_path() . '/classes/views/xml/default-templates.xml';
238 +
239 + $file = FrmAppHelper::plugin_path() . '/classes/views/xml/default-templates.xml';
359 240 FrmXMLHelper::import_xml( $file );
360 241
361 242 libxml_use_internal_errors( $set_err );
362 243 FrmXMLHelper::maybe_libxml_disable_entity_loader( $loader );
@@ -363,41 +244,32 @@
363 244 }
364 245
365 246 /**
366 247 * @param int|string $old_db_version
367 - *
368 - * @return void
369 248 */
370 249 private function migrate_data( $old_db_version ) {
371 250 if ( ! $old_db_version ) {
372 251 $old_db_version = get_option( 'frm_db_version' );
373 252 }
374 -
375 - if ( str_contains( $old_db_version, '-' ) ) {
253 + if ( strpos( $old_db_version, '-' ) ) {
376 254 $last_upgrade = explode( '-', $old_db_version );
377 - $old_db_version = intval( end( $last_upgrade ) );
255 + $old_db_version = (int) $last_upgrade[1];
378 256 }
379 257
380 258 if ( ! is_numeric( $old_db_version ) ) {
381 - // Bail if we don't know the previous version
259 + // bail if we don't know the previous version
382 260 return;
383 261 }
384 262
385 - $migrations = array( 16, 11, 16, 17, 23, 25, 86, 90, 97, 98, 101, 104, 105 );
386 -
263 + $migrations = array( 16, 11, 16, 17, 23, 25, 86, 90, 97, 98, 101 );
387 264 foreach ( $migrations as $migration ) {
388 - if ( FrmAppHelper::$db_version < $migration || $old_db_version >= $migration ) {
389 - continue;
265 + if ( FrmAppHelper::$db_version >= $migration && $old_db_version < $migration ) {
266 + $function_name = 'migrate_to_' . $migration;
267 + $this->$function_name();
390 268 }
391 -
392 - $function_name = 'migrate_to_' . $migration;
393 - $this->$function_name();
394 269 }
395 270 }
396 271
397 - /**
398 - * @return bool
399 - */
400 272 public function uninstall() {
401 273 if ( ! current_user_can( 'administrator' ) ) {
402 274 $frm_settings = FrmAppHelper::get_settings();
403 275 wp_die( esc_html( $frm_settings->admin_permission ) );
@@ -422,9 +294,8 @@
422 294
423 295 // Delete roles.
424 296 $frm_roles = FrmAppHelper::frm_capabilities();
425 297 $roles = get_editable_roles();
426 -
427 298 foreach ( $frm_roles as $frm_role => $frm_role_description ) {
428 299 foreach ( $roles as $role => $details ) {
429 300 $wp_roles->remove_cap( $role, $frm_role );
430 301 unset( $role, $details );
@@ -432,16 +303,15 @@
432 303 unset( $frm_role, $frm_role_description );
433 304 }
434 305 unset( $roles, $frm_roles );
435 306
436 - // Delete actions, views, and styles
307 + // delete actions, views, and styles
437 308
438 - // Prevent the post deletion from triggering entries to be deleted
309 + // prevent the post deletion from triggering entries to be deleted
439 310 remove_action( 'before_delete_post', 'FrmProDisplaysController::before_delete_post' );
440 311 remove_action( 'deleted_post', 'FrmProEntriesController::delete_entry' );
441 312
442 - $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
443 -
313 + $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' ) );
444 314 foreach ( $post_ids as $post_id ) {
445 315 // Delete's each post.
446 316 wp_delete_post( $post_id, true );
447 317 }
@@ -446,15 +316,15 @@
446 316 wp_delete_post( $post_id, true );
447 317 }
448 318 unset( $post_ids );
449 319
450 - // Delete transients
320 + // delete transients
451 321 delete_transient( 'frmpro_css' );
452 322 delete_transient( 'frm_options' );
453 323 delete_transient( 'frmpro_options' );
454 324 delete_transient( FrmOnboardingWizardController::TRANSIENT_NAME );
455 325
456 - $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
326 + $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_%' ) );
457 327
458 328 do_action( 'frm_after_uninstall' );
459 329
460 330 return true;
@@ -460,44 +330,11 @@
460 330 return true;
461 331 }
462 332
463 333 /**
464 - * In older versions of Lite, it's possible we've saved the wrong location ID.
465 - * So force it to get valid values again.
466 - *
467 - * @since 6.25
468 - *
469 - * @return void
470 - */
471 - private function migrate_to_104() {
472 - if ( FrmSquareLiteConnectHelper::get_merchant_id( 'test' ) ) {
473 - FrmSquareLiteConnectHelper::get_location_id( true, 'test' );
474 - }
475 -
476 - if ( FrmSquareLiteConnectHelper::get_merchant_id( 'live' ) ) {
477 - FrmSquareLiteConnectHelper::get_location_id( true, 'live' );
478 - }
479 - }
480 -
481 - /**
482 - * Add new wp_options row for custom setting.
483 - *
484 - * @since 6.26
485 - *
486 - * @return void
487 - */
488 - private function migrate_to_105() {
489 - if ( ! FrmAppHelper::pro_is_installed() ) {
490 - update_option( 'frm_show_pricing_fields_modal', 1, false );
491 - }
492 - }
493 -
494 - /**
495 334 * Disables summary email for multisite (not the main site) if recipient setting isn't changed.
496 335 *
497 336 * @since 6.8
498 - *
499 - * @return void
500 337 */
501 338 private function migrate_to_101() {
502 339 if ( ! is_multisite() || get_main_site_id() === get_current_blog_id() ) {
503 340 return;
@@ -503,9 +340,8 @@
503 340 return;
504 341 }
505 342
506 343 $frm_settings = FrmAppHelper::get_settings();
507 -
508 344 if ( empty( $frm_settings->summary_emails ) || '[admin_email]' !== $frm_settings->summary_emails_recipients ) {
509 345 // User changed it.
510 346 return;
511 347 }
@@ -517,10 +353,8 @@
517 353 /**
518 354 * Clear frmpro_css transient.
519 355 *
520 356 * @since 4.10.02
521 - *
522 - * @return void
523 357 */
524 358 private function migrate_to_98() {
525 359 delete_transient( 'frmpro_css' );
526 360 }
@@ -528,10 +362,8 @@
528 362 /**
529 363 * Move default_blank and clear_on_focus to placeholder.
530 364 *
531 365 * @since 4.0
532 - *
533 - * @return void
534 366 */
535 367 private function migrate_to_97() {
536 368 $this->migrate_to_placeholder( 'clear_on_focus' );
537 369 $this->migrate_to_placeholder( 'default_blank' );
@@ -540,12 +372,8 @@
540 372 /**
541 373 * Move clear_on_focus or default_blank to placeholder.
542 374 *
543 375 * @since 4.0
544 - *
545 - * @param string $type Field option key to migrate.
546 - *
547 - * @return void
548 376 */
549 377 private function migrate_to_placeholder( $type = 'clear_on_focus' ) {
550 378 $query = array(
551 379 'field_options like' => '"' . $type . '";s:1:"1";',
@@ -556,10 +384,9 @@
556 384 foreach ( $fields as $field ) {
557 385 FrmAppHelper::unserialize_or_decode( $field->field_options );
558 386 FrmAppHelper::unserialize_or_decode( $field->options );
559 387 $update_values = FrmXMLHelper::migrate_field_placeholder( $field, $type );
560 -
561 - if ( ! $update_values ) {
388 + if ( empty( $update_values ) ) {
562 389 continue;
563 390 }
564 391
565 392 FrmField::update( $field->id, $update_values );
@@ -570,15 +397,11 @@
570 397 /**
571 398 * Delete unneeded default templates
572 399 *
573 400 * @since 3.06
574 - *
575 - * @return void
576 401 */
577 402 private function migrate_to_90() {
578 403 $form = FrmForm::getOne( 'contact' );
579 -
580 - // phpcs:ignore Universal.Operators.StrictComparisons
581 404 if ( $form && $form->default_template == 1 ) {
582 405 FrmForm::destroy( 'contact' );
583 406 }
584 407 }
@@ -586,15 +409,14 @@
586 409 /**
587 410 * Reverse migration 17 -- Divide by 9
588 411 *
589 412 * @since 3.0.05
590 - *
591 - * @return void
592 413 */
593 414 private function migrate_to_86() {
415 +
594 416 $fields = $this->get_fields_with_size();
595 417
596 - foreach ( $fields as $f ) {
418 + foreach ( (array) $fields as $f ) {
597 419 FrmAppHelper::unserialize_or_decode( $f->field_options );
598 420 $size = $f->field_options['size'];
599 421 $this->maybe_convert_migrated_size( $size );
600 422
@@ -606,12 +428,11 @@
606 428 FrmField::update( $f->id, array( 'field_options' => $f->field_options ) );
607 429 unset( $f );
608 430 }
609 431
610 - // Reverse the extra size changes in widgets
432 + // reverse the extra size changes in widgets
611 433 $widgets = get_option( 'widget_frm_show_form' );
612 -
613 - if ( ! $widgets ) {
434 + if ( empty( $widgets ) ) {
614 435 return;
615 436 }
616 437
617 438 $this->revert_widget_field_size();
@@ -616,11 +437,8 @@
616 437
617 438 $this->revert_widget_field_size();
618 439 }
619 440
620 - /**
621 - * @return array
622 - */
623 441 private function get_fields_with_size() {
624 442 $field_types = array(
625 443 'textarea',
626 444 'text',
@@ -648,20 +466,16 @@
648 466 /**
649 467 * Reverse the extra size changes in widgets
650 468 *
651 469 * @since 3.0.05
652 - *
653 - * @return void
654 470 */
655 471 private function revert_widget_field_size() {
656 472 $widgets = get_option( 'widget_frm_show_form' );
657 -
658 - if ( ! $widgets ) {
473 + if ( empty( $widgets ) ) {
659 474 return;
660 475 }
661 476
662 477 FrmAppHelper::unserialize_or_decode( $widgets );
663 -
664 478 foreach ( $widgets as $k => $widget ) {
665 479 if ( ! is_array( $widget ) || ! isset( $widget['size'] ) ) {
666 480 continue;
667 481 }
@@ -667,9 +481,8 @@
667 481 }
668 482
669 483 $this->maybe_convert_migrated_size( $widgets[ $k ]['size'] );
670 484 }
671 -
672 485 update_option( 'widget_frm_show_form', $widgets );
673 486 }
674 487
675 488 /**
@@ -675,28 +488,23 @@
675 488 /**
676 489 * Divide by 9 to reverse the multiplication
677 490 *
678 491 * @since 3.0.05
679 - *
680 - * @param string $size Size string to maybe convert, passed by reference.
681 - *
682 - * @return void
683 492 */
684 493 private function maybe_convert_migrated_size( &$size ) {
685 - $has_px_size = $size && str_contains( $size, 'px' );
686 -
494 + $has_px_size = ! empty( $size ) && strpos( $size, 'px' );
687 495 if ( ! $has_px_size ) {
688 496 return;
689 497 }
690 498
691 499 $int_size = str_replace( 'px', '', $size );
692 -
693 500 if ( ! is_numeric( $int_size ) || (int) $int_size < 900 ) {
694 501 return;
695 502 }
696 503
697 504 $pixel_conversion = 9;
698 - $size = round( (int) $int_size / $pixel_conversion );
505 +
506 + $size = round( (int) $int_size / $pixel_conversion );
699 507 }
700 508
701 509 /**
702 510 * Migrate old styling settings. If sites are using the old
@@ -702,17 +510,14 @@
702 510 * Migrate old styling settings. If sites are using the old
703 511 * default 400px field width, switch it to 100%
704 512 *
705 513 * @since 2.0.4
706 - *
707 - * @return void
708 514 */
709 515 private function migrate_to_25() {
710 - // Get the style that was created with the style migration
516 + // get the style that was created with the style migration
711 517 $frm_style = new FrmStyle();
712 518 $styles = $frm_style->get_all( 'post_date', 'ASC', 1 );
713 -
714 - if ( ! $styles ) {
519 + if ( empty( $styles ) ) {
715 520 return;
716 521 }
717 522
718 523 foreach ( $styles as $style ) {
@@ -729,16 +534,13 @@
729 534 * Check if the parent_form_id columns exists.
730 535 * If not, try and add it again
731 536 *
732 537 * @since 2.0.2
733 - *
734 - * @return void
735 538 */
736 539 private function migrate_to_23() {
737 540 global $wpdb;
738 541 $exists = $wpdb->get_row( 'SHOW COLUMNS FROM ' . $this->forms . ' LIKE "parent_form_id"' ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
739 -
740 - if ( ! $exists ) {
542 + if ( empty( $exists ) ) {
741 543 $wpdb->query( 'ALTER TABLE ' . $this->forms . ' ADD parent_form_id int(11) default 0' ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
742 544 }
743 545 }
744 546
@@ -743,10 +545,8 @@
743 545 }
744 546
745 547 /**
746 548 * Change field size from character to pixel -- Multiply by 9
747 - *
748 - * @return void
749 549 */
750 550 private function migrate_to_17() {
751 551 $fields = $this->get_fields_with_size();
752 552
@@ -751,9 +551,8 @@
751 551 $fields = $this->get_fields_with_size();
752 552
753 553 foreach ( $fields as $f ) {
754 554 FrmAppHelper::unserialize_or_decode( $f->field_options );
755 -
756 555 if ( empty( $f->field_options['size'] ) || ! is_numeric( $f->field_options['size'] ) ) {
757 556 continue;
758 557 }
759 558
@@ -767,20 +566,16 @@
767 566 }
768 567
769 568 /**
770 569 * Change the characters in widgets to pixels
771 - *
772 - * @return void
773 570 */
774 571 private function adjust_widget_size() {
775 572 $widgets = get_option( 'widget_frm_show_form' );
776 -
777 - if ( ! $widgets ) {
573 + if ( empty( $widgets ) ) {
778 574 return;
779 575 }
780 576
781 577 FrmAppHelper::unserialize_or_decode( $widgets );
782 -
783 578 foreach ( $widgets as $k => $widget ) {
784 579 if ( ! is_array( $widget ) || ! isset( $widget['size'] ) ) {
785 580 continue;
786 581 }
@@ -785,17 +580,11 @@
785 580 continue;
786 581 }
787 582 $this->convert_character_to_px( $widgets[ $k ]['size'] );
788 583 }
789 -
790 584 update_option( 'widget_frm_show_form', $widgets );
791 585 }
792 586
793 - /**
794 - * @param string $size
795 - *
796 - * @return void
797 - */
798 587 private function convert_character_to_px( &$size ) {
799 588 $pixel_conversion = 9;
800 589
801 590 $size = round( $pixel_conversion * (int) $size );
@@ -838,9 +627,9 @@
838 627 * post_excerpt: message
839 628 */
840 629 foreach ( $forms as $form ) {
841 630 if ( $form->is_template && $form->default_template ) {
842 - // Don't migrate the default templates since the email will be added anyway
631 + // don't migrate the default templates since the email will be added anyway
843 632 continue;
844 633 }
845 634
846 635 // Format form options
@@ -854,9 +643,10 @@
854 643
855 644 private function migrate_to_11() {
856 645 global $wpdb;
857 646
858 - $forms = FrmDb::get_results( $this->forms, array(), 'id, options' );
647 + $forms = FrmDb::get_results( $this->forms, array(), 'id, options' );
648 +
859 649 $sending = __( 'Sending', 'formidable' );
860 650 $img = FrmAppHelper::plugin_url() . '/images/ajax_loader.gif';
861 651 $old_default_html = <<<DEFAULT_HTML
862 652 <div class="frm_submit">
@@ -868,21 +658,18 @@
868 658 unset( $sending, $img );
869 659
870 660 $new_default_html = FrmFormsHelper::get_default_html( 'submit' );
871 661 $draft_link = FrmFormsHelper::get_draft_link();
872 -
873 662 foreach ( $forms as $form ) {
874 663 FrmAppHelper::unserialize_or_decode( $form->options );
875 -
876 664 if ( empty( $form->options['submit_html'] ) ) {
877 665 continue;
878 666 }
879 667
880 - // phpcs:ignore Universal.Operators.StrictComparisons
881 668 if ( $form->options['submit_html'] != $new_default_html && $form->options['submit_html'] == $old_default_html ) {
882 669 $form->options['submit_html'] = $new_default_html;
883 670 $wpdb->update( $this->forms, array( 'options' => serialize( $form->options ) ), array( 'id' => $form->id ) );
884 - } elseif ( ! str_contains( $form->options['submit_html'], 'save_draft' ) ) {
671 + } elseif ( ! strpos( $form->options['submit_html'], 'save_draft' ) ) {
885 672 $form->options['submit_html'] = preg_replace( '~\<\/div\>(?!.*\<\/div\>)~', $draft_link . "\r\n</div>", $form->options['submit_html'] );
886 673 $wpdb->update( $this->forms, array( 'options' => serialize( $form->options ) ), array( 'id' => $form->id ) );
887 674 }
888 675 unset( $form );