PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.12
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.12
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 -244 6.296.12 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
@@ -69,16 +47,10 @@
69 47 update_option( 'frm_db_version', FrmAppHelper::plugin_version() . '-' . FrmAppHelper::$db_version );
70 48
71 49 if ( ! $old_db_version ) {
72 50 $this->maybe_create_contact_form();
73 -
74 - if ( false === get_option( 'frm_first_activation' ) ) {
75 - update_option( 'frm_first_activation', time(), false );
76 - }
77 -
78 - $this->update_settings_for_new_install();
79 51 }
80 - }//end if
52 + }
81 53
82 54 do_action( 'frm_after_install' );
83 55
84 56 $frm_vars['doing_upgrade'] = false;
@@ -84,97 +56,24 @@
84 56 $frm_vars['doing_upgrade'] = false;
85 57
86 58 FrmAppHelper::save_combined_js();
87 59
88 - // Update the styling settings
89 - if ( ! function_exists( 'get_filesystem_method' ) ) {
90 - return;
60 + // update the styling settings
61 + if ( function_exists( 'get_filesystem_method' ) ) {
62 + $frm_style = new FrmStyle();
63 + $frm_style->update( 'default' );
91 64 }
92 -
93 - $frm_style = new FrmStyle();
94 - $frm_style->update( 'default' );
95 65 }
96 66
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.
67 + public function collation() {
145 68 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;
69 + if ( ! $wpdb->has_cap( 'collation' ) ) {
70 + return '';
152 71 }
153 72
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 );
73 + return $wpdb->get_charset_collate();
164 74 }
165 75
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 76 private function create_tables() {
178 77 $charset_collate = $this->collation();
179 78 $sql = array();
180 79
@@ -266,10 +165,8 @@
266 165 /**
267 166 * These indexes help optimize database queries for entries.
268 167 *
269 168 * @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 169 *
273 170 * @return void
274 171 */
275 172 private function add_composite_indexes_for_entries() {
@@ -287,22 +184,8 @@
287 184
288 185 if ( ! self::index_exists( $table_name, $index_name ) ) {
289 186 $wpdb->query( "CREATE INDEX idx_field_id_item_id ON `{$wpdb->prefix}frm_item_metas` (field_id, item_id)" );
290 187 }
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 188 }
306 189
307 190 /**
308 191 * Check that an index exists in a database table before trying to add it (which results in an error).
@@ -310,9 +193,8 @@
310 193 * @since 6.6
311 194 *
312 195 * @param string $table_name
313 196 * @param string $index_name
314 - *
315 197 * @return bool
316 198 */
317 199 private static function index_exists( $table_name, $index_name ) {
318 200 global $wpdb;
@@ -328,14 +210,10 @@
328 210 );
329 211 return (bool) $row;
330 212 }
331 213
332 - /**
333 - * @return void
334 - */
335 214 private function maybe_create_contact_form() {
336 215 $form_exists = FrmForm::get_id_by_key( 'contact-form' );
337 -
338 216 if ( ! $form_exists ) {
339 217 $this->add_default_template();
340 218 }
341 219 }
@@ -343,10 +221,8 @@
343 221 /**
344 222 * Create the default contact form
345 223 *
346 224 * @since 3.06
347 - *
348 - * @return void
349 225 */
350 226 private function add_default_template() {
351 227 if ( FrmXMLHelper::check_if_libxml_disable_entity_loader_exists() ) {
352 228 // XML import is not enabled on your server.
@@ -354,9 +230,10 @@
354 230 }
355 231
356 232 $set_err = libxml_use_internal_errors( true );
357 233 $loader = FrmXMLHelper::maybe_libxml_disable_entity_loader( true );
358 - $file = FrmAppHelper::plugin_path() . '/classes/views/xml/default-templates.xml';
234 +
235 + $file = FrmAppHelper::plugin_path() . '/classes/views/xml/default-templates.xml';
359 236 FrmXMLHelper::import_xml( $file );
360 237
361 238 libxml_use_internal_errors( $set_err );
362 239 FrmXMLHelper::maybe_libxml_disable_entity_loader( $loader );
@@ -363,41 +240,32 @@
363 240 }
364 241
365 242 /**
366 243 * @param int|string $old_db_version
367 - *
368 - * @return void
369 244 */
370 245 private function migrate_data( $old_db_version ) {
371 246 if ( ! $old_db_version ) {
372 247 $old_db_version = get_option( 'frm_db_version' );
373 248 }
374 -
375 - if ( str_contains( $old_db_version, '-' ) ) {
249 + if ( strpos( $old_db_version, '-' ) ) {
376 250 $last_upgrade = explode( '-', $old_db_version );
377 251 $old_db_version = (int) $last_upgrade[1];
378 252 }
379 253
380 254 if ( ! is_numeric( $old_db_version ) ) {
381 - // Bail if we don't know the previous version
255 + // bail if we don't know the previous version
382 256 return;
383 257 }
384 258
385 - $migrations = array( 16, 11, 16, 17, 23, 25, 86, 90, 97, 98, 101, 104 );
386 -
259 + $migrations = array( 16, 11, 16, 17, 23, 25, 86, 90, 97, 98, 101 );
387 260 foreach ( $migrations as $migration ) {
388 - if ( FrmAppHelper::$db_version < $migration || $old_db_version >= $migration ) {
389 - continue;
261 + if ( FrmAppHelper::$db_version >= $migration && $old_db_version < $migration ) {
262 + $function_name = 'migrate_to_' . $migration;
263 + $this->$function_name();
390 264 }
391 -
392 - $function_name = 'migrate_to_' . $migration;
393 - $this->$function_name();
394 265 }
395 266 }
396 267
397 - /**
398 - * @return bool
399 - */
400 268 public function uninstall() {
401 269 if ( ! current_user_can( 'administrator' ) ) {
402 270 $frm_settings = FrmAppHelper::get_settings();
403 271 wp_die( esc_html( $frm_settings->admin_permission ) );
@@ -422,9 +290,8 @@
422 290
423 291 // Delete roles.
424 292 $frm_roles = FrmAppHelper::frm_capabilities();
425 293 $roles = get_editable_roles();
426 -
427 294 foreach ( $frm_roles as $frm_role => $frm_role_description ) {
428 295 foreach ( $roles as $role => $details ) {
429 296 $wp_roles->remove_cap( $role, $frm_role );
430 297 unset( $role, $details );
@@ -432,16 +299,15 @@
432 299 unset( $frm_role, $frm_role_description );
433 300 }
434 301 unset( $roles, $frm_roles );
435 302
436 - // Delete actions, views, and styles
303 + // delete actions, views, and styles
437 304
438 - // Prevent the post deletion from triggering entries to be deleted
305 + // prevent the post deletion from triggering entries to be deleted
439 306 remove_action( 'before_delete_post', 'FrmProDisplaysController::before_delete_post' );
440 307 remove_action( 'deleted_post', 'FrmProEntriesController::delete_entry' );
441 308
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 -
309 + $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 310 foreach ( $post_ids as $post_id ) {
445 311 // Delete's each post.
446 312 wp_delete_post( $post_id, true );
447 313 }
@@ -446,15 +312,15 @@
446 312 wp_delete_post( $post_id, true );
447 313 }
448 314 unset( $post_ids );
449 315
450 - // Delete transients
316 + // delete transients
451 317 delete_transient( 'frmpro_css' );
452 318 delete_transient( 'frm_options' );
453 319 delete_transient( 'frmpro_options' );
454 320 delete_transient( FrmOnboardingWizardController::TRANSIENT_NAME );
455 321
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
322 + $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 323
458 324 do_action( 'frm_after_uninstall' );
459 325
460 326 return true;
@@ -460,31 +326,11 @@
460 326 return true;
461 327 }
462 328
463 329 /**
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 330 * Disables summary email for multisite (not the main site) if recipient setting isn't changed.
483 331 *
484 332 * @since 6.8
485 - *
486 - * @return void
487 333 */
488 334 private function migrate_to_101() {
489 335 if ( ! is_multisite() || get_main_site_id() === get_current_blog_id() ) {
490 336 return;
@@ -490,9 +336,8 @@
490 336 return;
491 337 }
492 338
493 339 $frm_settings = FrmAppHelper::get_settings();
494 -
495 340 if ( empty( $frm_settings->summary_emails ) || '[admin_email]' !== $frm_settings->summary_emails_recipients ) {
496 341 // User changed it.
497 342 return;
498 343 }
@@ -504,10 +349,8 @@
504 349 /**
505 350 * Clear frmpro_css transient.
506 351 *
507 352 * @since 4.10.02
508 - *
509 - * @return void
510 353 */
511 354 private function migrate_to_98() {
512 355 delete_transient( 'frmpro_css' );
513 356 }
@@ -515,10 +358,8 @@
515 358 /**
516 359 * Move default_blank and clear_on_focus to placeholder.
517 360 *
518 361 * @since 4.0
519 - *
520 - * @return void
521 362 */
522 363 private function migrate_to_97() {
523 364 $this->migrate_to_placeholder( 'clear_on_focus' );
524 365 $this->migrate_to_placeholder( 'default_blank' );
@@ -527,12 +368,8 @@
527 368 /**
528 369 * Move clear_on_focus or default_blank to placeholder.
529 370 *
530 371 * @since 4.0
531 - *
532 - * @param string $type Field option key to migrate.
533 - *
534 - * @return void
535 372 */
536 373 private function migrate_to_placeholder( $type = 'clear_on_focus' ) {
537 374 $query = array(
538 375 'field_options like' => '"' . $type . '";s:1:"1";',
@@ -543,10 +380,9 @@
543 380 foreach ( $fields as $field ) {
544 381 FrmAppHelper::unserialize_or_decode( $field->field_options );
545 382 FrmAppHelper::unserialize_or_decode( $field->options );
546 383 $update_values = FrmXMLHelper::migrate_field_placeholder( $field, $type );
547 -
548 - if ( ! $update_values ) {
384 + if ( empty( $update_values ) ) {
549 385 continue;
550 386 }
551 387
552 388 FrmField::update( $field->id, $update_values );
@@ -557,15 +393,11 @@
557 393 /**
558 394 * Delete unneeded default templates
559 395 *
560 396 * @since 3.06
561 - *
562 - * @return void
563 397 */
564 398 private function migrate_to_90() {
565 399 $form = FrmForm::getOne( 'contact' );
566 -
567 - // phpcs:ignore Universal.Operators.StrictComparisons
568 400 if ( $form && $form->default_template == 1 ) {
569 401 FrmForm::destroy( 'contact' );
570 402 }
571 403 }
@@ -573,15 +405,14 @@
573 405 /**
574 406 * Reverse migration 17 -- Divide by 9
575 407 *
576 408 * @since 3.0.05
577 - *
578 - * @return void
579 409 */
580 410 private function migrate_to_86() {
411 +
581 412 $fields = $this->get_fields_with_size();
582 413
583 - foreach ( $fields as $f ) {
414 + foreach ( (array) $fields as $f ) {
584 415 FrmAppHelper::unserialize_or_decode( $f->field_options );
585 416 $size = $f->field_options['size'];
586 417 $this->maybe_convert_migrated_size( $size );
587 418
@@ -593,12 +424,11 @@
593 424 FrmField::update( $f->id, array( 'field_options' => $f->field_options ) );
594 425 unset( $f );
595 426 }
596 427
597 - // Reverse the extra size changes in widgets
428 + // reverse the extra size changes in widgets
598 429 $widgets = get_option( 'widget_frm_show_form' );
599 -
600 - if ( ! $widgets ) {
430 + if ( empty( $widgets ) ) {
601 431 return;
602 432 }
603 433
604 434 $this->revert_widget_field_size();
@@ -603,11 +433,8 @@
603 433
604 434 $this->revert_widget_field_size();
605 435 }
606 436
607 - /**
608 - * @return array
609 - */
610 437 private function get_fields_with_size() {
611 438 $field_types = array(
612 439 'textarea',
613 440 'text',
@@ -635,20 +462,16 @@
635 462 /**
636 463 * Reverse the extra size changes in widgets
637 464 *
638 465 * @since 3.0.05
639 - *
640 - * @return void
641 466 */
642 467 private function revert_widget_field_size() {
643 468 $widgets = get_option( 'widget_frm_show_form' );
644 -
645 - if ( ! $widgets ) {
469 + if ( empty( $widgets ) ) {
646 470 return;
647 471 }
648 472
649 473 FrmAppHelper::unserialize_or_decode( $widgets );
650 -
651 474 foreach ( $widgets as $k => $widget ) {
652 475 if ( ! is_array( $widget ) || ! isset( $widget['size'] ) ) {
653 476 continue;
654 477 }
@@ -654,9 +477,8 @@
654 477 }
655 478
656 479 $this->maybe_convert_migrated_size( $widgets[ $k ]['size'] );
657 480 }
658 -
659 481 update_option( 'widget_frm_show_form', $widgets );
660 482 }
661 483
662 484 /**
@@ -662,28 +484,23 @@
662 484 /**
663 485 * Divide by 9 to reverse the multiplication
664 486 *
665 487 * @since 3.0.05
666 - *
667 - * @param string $size Size string to maybe convert, passed by reference.
668 - *
669 - * @return void
670 488 */
671 489 private function maybe_convert_migrated_size( &$size ) {
672 - $has_px_size = $size && str_contains( $size, 'px' );
673 -
490 + $has_px_size = ! empty( $size ) && strpos( $size, 'px' );
674 491 if ( ! $has_px_size ) {
675 492 return;
676 493 }
677 494
678 495 $int_size = str_replace( 'px', '', $size );
679 -
680 496 if ( ! is_numeric( $int_size ) || (int) $int_size < 900 ) {
681 497 return;
682 498 }
683 499
684 500 $pixel_conversion = 9;
685 - $size = round( (int) $int_size / $pixel_conversion );
501 +
502 + $size = round( (int) $int_size / $pixel_conversion );
686 503 }
687 504
688 505 /**
689 506 * Migrate old styling settings. If sites are using the old
@@ -689,17 +506,14 @@
689 506 * Migrate old styling settings. If sites are using the old
690 507 * default 400px field width, switch it to 100%
691 508 *
692 509 * @since 2.0.4
693 - *
694 - * @return void
695 510 */
696 511 private function migrate_to_25() {
697 - // Get the style that was created with the style migration
512 + // get the style that was created with the style migration
698 513 $frm_style = new FrmStyle();
699 514 $styles = $frm_style->get_all( 'post_date', 'ASC', 1 );
700 -
701 - if ( ! $styles ) {
515 + if ( empty( $styles ) ) {
702 516 return;
703 517 }
704 518
705 519 foreach ( $styles as $style ) {
@@ -716,16 +530,13 @@
716 530 * Check if the parent_form_id columns exists.
717 531 * If not, try and add it again
718 532 *
719 533 * @since 2.0.2
720 - *
721 - * @return void
722 534 */
723 535 private function migrate_to_23() {
724 536 global $wpdb;
725 537 $exists = $wpdb->get_row( 'SHOW COLUMNS FROM ' . $this->forms . ' LIKE "parent_form_id"' ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
726 -
727 - if ( ! $exists ) {
538 + if ( empty( $exists ) ) {
728 539 $wpdb->query( 'ALTER TABLE ' . $this->forms . ' ADD parent_form_id int(11) default 0' ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
729 540 }
730 541 }
731 542
@@ -730,10 +541,8 @@
730 541 }
731 542
732 543 /**
733 544 * Change field size from character to pixel -- Multiply by 9
734 - *
735 - * @return void
736 545 */
737 546 private function migrate_to_17() {
738 547 $fields = $this->get_fields_with_size();
739 548
@@ -738,9 +547,8 @@
738 547 $fields = $this->get_fields_with_size();
739 548
740 549 foreach ( $fields as $f ) {
741 550 FrmAppHelper::unserialize_or_decode( $f->field_options );
742 -
743 551 if ( empty( $f->field_options['size'] ) || ! is_numeric( $f->field_options['size'] ) ) {
744 552 continue;
745 553 }
746 554
@@ -754,20 +562,16 @@
754 562 }
755 563
756 564 /**
757 565 * Change the characters in widgets to pixels
758 - *
759 - * @return void
760 566 */
761 567 private function adjust_widget_size() {
762 568 $widgets = get_option( 'widget_frm_show_form' );
763 -
764 - if ( ! $widgets ) {
569 + if ( empty( $widgets ) ) {
765 570 return;
766 571 }
767 572
768 573 FrmAppHelper::unserialize_or_decode( $widgets );
769 -
770 574 foreach ( $widgets as $k => $widget ) {
771 575 if ( ! is_array( $widget ) || ! isset( $widget['size'] ) ) {
772 576 continue;
773 577 }
@@ -772,17 +576,11 @@
772 576 continue;
773 577 }
774 578 $this->convert_character_to_px( $widgets[ $k ]['size'] );
775 579 }
776 -
777 580 update_option( 'widget_frm_show_form', $widgets );
778 581 }
779 582
780 - /**
781 - * @param string $size
782 - *
783 - * @return void
784 - */
785 583 private function convert_character_to_px( &$size ) {
786 584 $pixel_conversion = 9;
787 585
788 586 $size = round( $pixel_conversion * (int) $size );
@@ -825,9 +623,9 @@
825 623 * post_excerpt: message
826 624 */
827 625 foreach ( $forms as $form ) {
828 626 if ( $form->is_template && $form->default_template ) {
829 - // Don't migrate the default templates since the email will be added anyway
627 + // don't migrate the default templates since the email will be added anyway
830 628 continue;
831 629 }
832 630
833 631 // Format form options
@@ -841,9 +639,10 @@
841 639
842 640 private function migrate_to_11() {
843 641 global $wpdb;
844 642
845 - $forms = FrmDb::get_results( $this->forms, array(), 'id, options' );
643 + $forms = FrmDb::get_results( $this->forms, array(), 'id, options' );
644 +
846 645 $sending = __( 'Sending', 'formidable' );
847 646 $img = FrmAppHelper::plugin_url() . '/images/ajax_loader.gif';
848 647 $old_default_html = <<<DEFAULT_HTML
849 648 <div class="frm_submit">
@@ -855,21 +654,18 @@
855 654 unset( $sending, $img );
856 655
857 656 $new_default_html = FrmFormsHelper::get_default_html( 'submit' );
858 657 $draft_link = FrmFormsHelper::get_draft_link();
859 -
860 658 foreach ( $forms as $form ) {
861 659 FrmAppHelper::unserialize_or_decode( $form->options );
862 -
863 660 if ( empty( $form->options['submit_html'] ) ) {
864 661 continue;
865 662 }
866 663
867 - // phpcs:ignore Universal.Operators.StrictComparisons
868 664 if ( $form->options['submit_html'] != $new_default_html && $form->options['submit_html'] == $old_default_html ) {
869 665 $form->options['submit_html'] = $new_default_html;
870 666 $wpdb->update( $this->forms, array( 'options' => serialize( $form->options ) ), array( 'id' => $form->id ) );
871 - } elseif ( ! str_contains( $form->options['submit_html'], 'save_draft' ) ) {
667 + } elseif ( ! strpos( $form->options['submit_html'], 'save_draft' ) ) {
872 668 $form->options['submit_html'] = preg_replace( '~\<\/div\>(?!.*\<\/div\>)~', $draft_link . "\r\n</div>", $form->options['submit_html'] );
873 669 $wpdb->update( $this->forms, array( 'options' => serialize( $form->options ) ), array( 'id' => $form->id ) );
874 670 }
875 671 unset( $form );