PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.1
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.1
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 +46 -320 6.286.1 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,34 +32,25 @@
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 - require_once ABSPATH . 'wp-admin/includes/upgrade.php';
39 + require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
61 40
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 - // SAVE DB VERSION.
46 + /***** SAVE DB VERSION *****/
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
@@ -258,84 +157,12 @@
258 157 $wpdb->query( $q . $charset_collate ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
259 158 }
260 159 unset( $q );
261 160 }
262 -
263 - $this->add_composite_indexes_for_entries();
264 161 }
265 162
266 - /**
267 - * These indexes help optimize database queries for entries.
268 - *
269 - * @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 - *
273 - * @return void
274 - */
275 - private function add_composite_indexes_for_entries() {
276 - global $wpdb;
277 -
278 - $table_name = "{$wpdb->prefix}frm_items";
279 - $index_name = 'idx_is_draft_created_at';
280 -
281 - if ( ! self::index_exists( $table_name, $index_name ) ) {
282 - $wpdb->query( "CREATE INDEX idx_is_draft_created_at ON `{$wpdb->prefix}frm_items` (is_draft, created_at)" );
283 - }
284 -
285 - $table_name = "{$wpdb->prefix}frm_item_metas";
286 - $index_name = 'idx_field_id_item_id';
287 -
288 - if ( ! self::index_exists( $table_name, $index_name ) ) {
289 - $wpdb->query( "CREATE INDEX idx_field_id_item_id ON `{$wpdb->prefix}frm_item_metas` (field_id, item_id)" );
290 - }
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 - }
306 -
307 - /**
308 - * Check that an index exists in a database table before trying to add it (which results in an error).
309 - *
310 - * @since 6.6
311 - *
312 - * @param string $table_name
313 - * @param string $index_name
314 - *
315 - * @return bool
316 - */
317 - private static function index_exists( $table_name, $index_name ) {
318 - global $wpdb;
319 - $row = $wpdb->get_row(
320 - $wpdb->prepare(
321 - 'SELECT 1 FROM information_schema.statistics
322 - WHERE table_schema = database()
323 - AND table_name = %s
324 - AND index_name = %s
325 - LIMIT 1',
326 - array( $table_name, $index_name )
327 - )
328 - );
329 - return (bool) $row;
330 - }
331 -
332 - /**
333 - * @return void
334 - */
335 163 private function maybe_create_contact_form() {
336 164 $form_exists = FrmForm::get_id_by_key( 'contact-form' );
337 -
338 165 if ( ! $form_exists ) {
339 166 $this->add_default_template();
340 167 }
341 168 }
@@ -343,10 +170,8 @@
343 170 /**
344 171 * Create the default contact form
345 172 *
346 173 * @since 3.06
347 - *
348 - * @return void
349 174 */
350 175 private function add_default_template() {
351 176 if ( FrmXMLHelper::check_if_libxml_disable_entity_loader_exists() ) {
352 177 // XML import is not enabled on your server.
@@ -354,9 +179,10 @@
354 179 }
355 180
356 181 $set_err = libxml_use_internal_errors( true );
357 182 $loader = FrmXMLHelper::maybe_libxml_disable_entity_loader( true );
358 - $file = FrmAppHelper::plugin_path() . '/classes/views/xml/default-templates.xml';
183 +
184 + $file = FrmAppHelper::plugin_path() . '/classes/views/xml/default-templates.xml';
359 185 FrmXMLHelper::import_xml( $file );
360 186
361 187 libxml_use_internal_errors( $set_err );
362 188 FrmXMLHelper::maybe_libxml_disable_entity_loader( $loader );
@@ -363,28 +189,24 @@
363 189 }
364 190
365 191 /**
366 192 * @param int|string $old_db_version
367 - *
368 - * @return void
369 193 */
370 194 private function migrate_data( $old_db_version ) {
371 195 if ( ! $old_db_version ) {
372 196 $old_db_version = get_option( 'frm_db_version' );
373 197 }
374 -
375 - if ( str_contains( $old_db_version, '-' ) ) {
198 + if ( strpos( $old_db_version, '-' ) ) {
376 199 $last_upgrade = explode( '-', $old_db_version );
377 200 $old_db_version = (int) $last_upgrade[1];
378 201 }
379 202
380 203 if ( ! is_numeric( $old_db_version ) ) {
381 - // Bail if we don't know the previous version
204 + // bail if we don't know the previous version
382 205 return;
383 206 }
384 207
385 - $migrations = array( 16, 11, 16, 17, 23, 25, 86, 90, 97, 98, 101, 104 );
386 -
208 + $migrations = array( 16, 11, 16, 17, 23, 25, 86, 90, 97, 98 );
387 209 foreach ( $migrations as $migration ) {
388 210 if ( FrmAppHelper::$db_version >= $migration && $old_db_version < $migration ) {
389 211 $function_name = 'migrate_to_' . $migration;
390 212 $this->$function_name();
@@ -391,11 +213,8 @@
391 213 }
392 214 }
393 215 }
394 216
395 - /**
396 - * @return bool
397 - */
398 217 public function uninstall() {
399 218 if ( ! current_user_can( 'administrator' ) ) {
400 219 $frm_settings = FrmAppHelper::get_settings();
401 220 wp_die( esc_html( $frm_settings->admin_permission ) );
@@ -414,15 +233,13 @@
414 233 delete_option( 'frm_lite_settings_upgrade' );
415 234 delete_option( 'frm-usage-uuid' );
416 235 delete_option( 'frm_inbox' );
417 236 delete_option( 'frmpro_css' );
418 - delete_option( FrmOnboardingWizardController::REDIRECT_STATUS_OPTION );
419 - delete_option( FrmEmailSummaryHelper::$option_name );
237 + delete_option( 'frm_welcome_redirect' );
420 238
421 239 // Delete roles.
422 240 $frm_roles = FrmAppHelper::frm_capabilities();
423 241 $roles = get_editable_roles();
424 -
425 242 foreach ( $frm_roles as $frm_role => $frm_role_description ) {
426 243 foreach ( $roles as $role => $details ) {
427 244 $wp_roles->remove_cap( $role, $frm_role );
428 245 unset( $role, $details );
@@ -430,16 +247,15 @@
430 247 unset( $frm_role, $frm_role_description );
431 248 }
432 249 unset( $roles, $frm_roles );
433 250
434 - // Delete actions, views, and styles
251 + // delete actions, views, and styles
435 252
436 - // Prevent the post deletion from triggering entries to be deleted
253 + // prevent the post deletion from triggering entries to be deleted
437 254 remove_action( 'before_delete_post', 'FrmProDisplaysController::before_delete_post' );
438 255 remove_action( 'deleted_post', 'FrmProEntriesController::delete_entry' );
439 256
440 - $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
441 -
257 + $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' ) );
442 258 foreach ( $post_ids as $post_id ) {
443 259 // Delete's each post.
444 260 wp_delete_post( $post_id, true );
445 261 }
@@ -444,15 +260,15 @@
444 260 wp_delete_post( $post_id, true );
445 261 }
446 262 unset( $post_ids );
447 263
448 - // Delete transients
264 + // delete transients
449 265 delete_transient( 'frmpro_css' );
450 266 delete_transient( 'frm_options' );
451 267 delete_transient( 'frmpro_options' );
452 - delete_transient( FrmOnboardingWizardController::TRANSIENT_NAME );
268 + delete_transient( 'frm_activation_redirect' );
453 269
454 - $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
270 + $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_%' ) );
455 271
456 272 do_action( 'frm_after_uninstall' );
457 273
458 274 return true;
@@ -458,54 +274,11 @@
458 274 return true;
459 275 }
460 276
461 277 /**
462 - * In older versions of Lite, it's possible we've saved the wrong location ID.
463 - * So force it to get valid values again.
464 - *
465 - * @since 6.25
466 - *
467 - * @return void
468 - */
469 - private function migrate_to_104() {
470 - if ( FrmSquareLiteConnectHelper::get_merchant_id( 'test' ) ) {
471 - FrmSquareLiteConnectHelper::get_location_id( true, 'test' );
472 - }
473 -
474 - if ( FrmSquareLiteConnectHelper::get_merchant_id( 'live' ) ) {
475 - FrmSquareLiteConnectHelper::get_location_id( true, 'live' );
476 - }
477 - }
478 -
479 - /**
480 - * Disables summary email for multisite (not the main site) if recipient setting isn't changed.
481 - *
482 - * @since 6.8
483 - *
484 - * @return void
485 - */
486 - private function migrate_to_101() {
487 - if ( ! is_multisite() || get_main_site_id() === get_current_blog_id() ) {
488 - return;
489 - }
490 -
491 - $frm_settings = FrmAppHelper::get_settings();
492 -
493 - if ( empty( $frm_settings->summary_emails ) || '[admin_email]' !== $frm_settings->summary_emails_recipients ) {
494 - // User changed it.
495 - return;
496 - }
497 -
498 - $frm_settings->summary_emails = 0;
499 - $frm_settings->store();
500 - }
501 -
502 - /**
503 278 * Clear frmpro_css transient.
504 279 *
505 280 * @since 4.10.02
506 - *
507 - * @return void
508 281 */
509 282 private function migrate_to_98() {
510 283 delete_transient( 'frmpro_css' );
511 284 }
@@ -513,10 +286,8 @@
513 286 /**
514 287 * Move default_blank and clear_on_focus to placeholder.
515 288 *
516 289 * @since 4.0
517 - *
518 - * @return void
519 290 */
520 291 private function migrate_to_97() {
521 292 $this->migrate_to_placeholder( 'clear_on_focus' );
522 293 $this->migrate_to_placeholder( 'default_blank' );
@@ -525,12 +296,8 @@
525 296 /**
526 297 * Move clear_on_focus or default_blank to placeholder.
527 298 *
528 299 * @since 4.0
529 - *
530 - * @param string $type Field option key to migrate.
531 - *
532 - * @return void
533 300 */
534 301 private function migrate_to_placeholder( $type = 'clear_on_focus' ) {
535 302 $query = array(
536 303 'field_options like' => '"' . $type . '";s:1:"1";',
@@ -541,10 +308,9 @@
541 308 foreach ( $fields as $field ) {
542 309 FrmAppHelper::unserialize_or_decode( $field->field_options );
543 310 FrmAppHelper::unserialize_or_decode( $field->options );
544 311 $update_values = FrmXMLHelper::migrate_field_placeholder( $field, $type );
545 -
546 - if ( ! $update_values ) {
312 + if ( empty( $update_values ) ) {
547 313 continue;
548 314 }
549 315
550 316 FrmField::update( $field->id, $update_values );
@@ -552,18 +318,14 @@
552 318 }
553 319 }
554 320
555 321 /**
556 - * Delete unneeded default templates
322 + * Delete uneeded default templates
557 323 *
558 324 * @since 3.06
559 - *
560 - * @return void
561 325 */
562 326 private function migrate_to_90() {
563 327 $form = FrmForm::getOne( 'contact' );
564 -
565 - // phpcs:ignore Universal.Operators.StrictComparisons
566 328 if ( $form && $form->default_template == 1 ) {
567 329 FrmForm::destroy( 'contact' );
568 330 }
569 331 }
@@ -571,17 +333,16 @@
571 333 /**
572 334 * Reverse migration 17 -- Divide by 9
573 335 *
574 336 * @since 3.0.05
575 - *
576 - * @return void
577 337 */
578 338 private function migrate_to_86() {
339 +
579 340 $fields = $this->get_fields_with_size();
580 341
581 - foreach ( $fields as $f ) {
342 + foreach ( (array) $fields as $f ) {
582 343 FrmAppHelper::unserialize_or_decode( $f->field_options );
583 - $size = $f->field_options['size'];
344 + $size = $f->field_options['size'];
584 345 $this->maybe_convert_migrated_size( $size );
585 346
586 347 if ( $size === $f->field_options['size'] ) {
587 348 continue;
@@ -591,12 +352,11 @@
591 352 FrmField::update( $f->id, array( 'field_options' => $f->field_options ) );
592 353 unset( $f );
593 354 }
594 355
595 - // Reverse the extra size changes in widgets
356 + // reverse the extra size changes in widgets
596 357 $widgets = get_option( 'widget_frm_show_form' );
597 -
598 - if ( ! $widgets ) {
358 + if ( empty( $widgets ) ) {
599 359 return;
600 360 }
601 361
602 362 $this->revert_widget_field_size();
@@ -601,11 +361,8 @@
601 361
602 362 $this->revert_widget_field_size();
603 363 }
604 364
605 - /**
606 - * @return array
607 - */
608 365 private function get_fields_with_size() {
609 366 $field_types = array(
610 367 'textarea',
611 368 'text',
@@ -633,20 +390,16 @@
633 390 /**
634 391 * Reverse the extra size changes in widgets
635 392 *
636 393 * @since 3.0.05
637 - *
638 - * @return void
639 394 */
640 395 private function revert_widget_field_size() {
641 396 $widgets = get_option( 'widget_frm_show_form' );
642 -
643 - if ( ! $widgets ) {
397 + if ( empty( $widgets ) ) {
644 398 return;
645 399 }
646 400
647 401 FrmAppHelper::unserialize_or_decode( $widgets );
648 -
649 402 foreach ( $widgets as $k => $widget ) {
650 403 if ( ! is_array( $widget ) || ! isset( $widget['size'] ) ) {
651 404 continue;
652 405 }
@@ -652,9 +405,8 @@
652 405 }
653 406
654 407 $this->maybe_convert_migrated_size( $widgets[ $k ]['size'] );
655 408 }
656 -
657 409 update_option( 'widget_frm_show_form', $widgets );
658 410 }
659 411
660 412 /**
@@ -660,28 +412,23 @@
660 412 /**
661 413 * Divide by 9 to reverse the multiplication
662 414 *
663 415 * @since 3.0.05
664 - *
665 - * @param string $size Size string to maybe convert, passed by reference.
666 - *
667 - * @return void
668 416 */
669 417 private function maybe_convert_migrated_size( &$size ) {
670 - $has_px_size = $size && str_contains( $size, 'px' );
671 -
418 + $has_px_size = ! empty( $size ) && strpos( $size, 'px' );
672 419 if ( ! $has_px_size ) {
673 420 return;
674 421 }
675 422
676 423 $int_size = str_replace( 'px', '', $size );
677 -
678 424 if ( ! is_numeric( $int_size ) || (int) $int_size < 900 ) {
679 425 return;
680 426 }
681 427
682 428 $pixel_conversion = 9;
683 - $size = round( (int) $int_size / $pixel_conversion );
429 +
430 + $size = round( (int) $int_size / $pixel_conversion );
684 431 }
685 432
686 433 /**
687 434 * Migrate old styling settings. If sites are using the old
@@ -687,22 +434,19 @@
687 434 * Migrate old styling settings. If sites are using the old
688 435 * default 400px field width, switch it to 100%
689 436 *
690 437 * @since 2.0.4
691 - *
692 - * @return void
693 438 */
694 439 private function migrate_to_25() {
695 - // Get the style that was created with the style migration
440 + // get the style that was created with the style migration
696 441 $frm_style = new FrmStyle();
697 442 $styles = $frm_style->get_all( 'post_date', 'ASC', 1 );
698 -
699 - if ( ! $styles ) {
443 + if ( empty( $styles ) ) {
700 444 return;
701 445 }
702 446
703 447 foreach ( $styles as $style ) {
704 - if ( $style->post_content['field_width'] === '400px' ) {
448 + if ( $style->post_content['field_width'] == '400px' ) {
705 449 $style->post_content['field_width'] = '100%';
706 450 $frm_style->save( (array) $style );
707 451
708 452 return;
@@ -714,16 +458,13 @@
714 458 * Check if the parent_form_id columns exists.
715 459 * If not, try and add it again
716 460 *
717 461 * @since 2.0.2
718 - *
719 - * @return void
720 462 */
721 463 private function migrate_to_23() {
722 464 global $wpdb;
723 465 $exists = $wpdb->get_row( 'SHOW COLUMNS FROM ' . $this->forms . ' LIKE "parent_form_id"' ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
724 -
725 - if ( ! $exists ) {
466 + if ( empty( $exists ) ) {
726 467 $wpdb->query( 'ALTER TABLE ' . $this->forms . ' ADD parent_form_id int(11) default 0' ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
727 468 }
728 469 }
729 470
@@ -728,10 +469,8 @@
728 469 }
729 470
730 471 /**
731 472 * Change field size from character to pixel -- Multiply by 9
732 - *
733 - * @return void
734 473 */
735 474 private function migrate_to_17() {
736 475 $fields = $this->get_fields_with_size();
737 476
@@ -736,9 +475,8 @@
736 475 $fields = $this->get_fields_with_size();
737 476
738 477 foreach ( $fields as $f ) {
739 478 FrmAppHelper::unserialize_or_decode( $f->field_options );
740 -
741 479 if ( empty( $f->field_options['size'] ) || ! is_numeric( $f->field_options['size'] ) ) {
742 480 continue;
743 481 }
744 482
@@ -752,20 +490,16 @@
752 490 }
753 491
754 492 /**
755 493 * Change the characters in widgets to pixels
756 - *
757 - * @return void
758 494 */
759 495 private function adjust_widget_size() {
760 496 $widgets = get_option( 'widget_frm_show_form' );
761 -
762 - if ( ! $widgets ) {
497 + if ( empty( $widgets ) ) {
763 498 return;
764 499 }
765 500
766 501 FrmAppHelper::unserialize_or_decode( $widgets );
767 -
768 502 foreach ( $widgets as $k => $widget ) {
769 503 if ( ! is_array( $widget ) || ! isset( $widget['size'] ) ) {
770 504 continue;
771 505 }
@@ -770,21 +504,15 @@
770 504 continue;
771 505 }
772 506 $this->convert_character_to_px( $widgets[ $k ]['size'] );
773 507 }
774 -
775 508 update_option( 'widget_frm_show_form', $widgets );
776 509 }
777 510
778 - /**
779 - * @param string $size
780 - *
781 - * @return void
782 - */
783 511 private function convert_character_to_px( &$size ) {
784 512 $pixel_conversion = 9;
785 513
786 - $size = round( $pixel_conversion * (int) $size );
514 + $size = round( $pixel_conversion * (int) $size );
787 515 $size .= 'px';
788 516 }
789 517
790 518 /**
@@ -823,9 +551,9 @@
823 551 * post_excerpt: message
824 552 */
825 553 foreach ( $forms as $form ) {
826 554 if ( $form->is_template && $form->default_template ) {
827 - // Don't migrate the default templates since the email will be added anyway
555 + // don't migrate the default templates since the email will be added anyway
828 556 continue;
829 557 }
830 558
831 559 // Format form options
@@ -839,9 +567,10 @@
839 567
840 568 private function migrate_to_11() {
841 569 global $wpdb;
842 570
843 - $forms = FrmDb::get_results( $this->forms, array(), 'id, options' );
571 + $forms = FrmDb::get_results( $this->forms, array(), 'id, options' );
572 +
844 573 $sending = __( 'Sending', 'formidable' );
845 574 $img = FrmAppHelper::plugin_url() . '/images/ajax_loader.gif';
846 575 $old_default_html = <<<DEFAULT_HTML
847 576 <div class="frm_submit">
@@ -853,21 +582,18 @@
853 582 unset( $sending, $img );
854 583
855 584 $new_default_html = FrmFormsHelper::get_default_html( 'submit' );
856 585 $draft_link = FrmFormsHelper::get_draft_link();
857 -
858 586 foreach ( $forms as $form ) {
859 587 FrmAppHelper::unserialize_or_decode( $form->options );
860 -
861 - if ( empty( $form->options['submit_html'] ) ) {
588 + if ( ! isset( $form->options['submit_html'] ) || empty( $form->options['submit_html'] ) ) {
862 589 continue;
863 590 }
864 591
865 - // phpcs:ignore Universal.Operators.StrictComparisons
866 592 if ( $form->options['submit_html'] != $new_default_html && $form->options['submit_html'] == $old_default_html ) {
867 593 $form->options['submit_html'] = $new_default_html;
868 594 $wpdb->update( $this->forms, array( 'options' => serialize( $form->options ) ), array( 'id' => $form->id ) );
869 - } elseif ( ! str_contains( $form->options['submit_html'], 'save_draft' ) ) {
595 + } elseif ( ! strpos( $form->options['submit_html'], 'save_draft' ) ) {
870 596 $form->options['submit_html'] = preg_replace( '~\<\/div\>(?!.*\<\/div\>)~', $draft_link . "\r\n</div>", $form->options['submit_html'] );
871 597 $wpdb->update( $this->forms, array( 'options' => serialize( $form->options ) ), array( 'id' => $form->id ) );
872 598 }
873 599 unset( $form );