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