| @@ -35,15 +35,14 @@ | ||
| 35 | 35 | if ( $needs_upgrade ) { |
| 36 | 36 | // update rewrite rules for views and other custom post types |
| 37 | 37 | flush_rewrite_rules(); |
| 38 | 38 | |
| 39 | - require_once ABSPATH . 'wp-admin/includes/upgrade.php'; | |
| 39 | + require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); | |
| 40 | 40 | |
| 41 | 41 | $old_db_version = get_option( 'frm_db_version' ); |
| 42 | 42 | |
| 43 | 43 | $this->create_tables(); |
| 44 | 44 | $this->migrate_data( $old_db_version ); |
| 45 | - $this->check_that_tables_exist(); | |
| 46 | 45 | |
| 47 | 46 | // SAVE DB VERSION. |
| 48 | 47 | update_option( 'frm_db_version', FrmAppHelper::plugin_version() . '-' . FrmAppHelper::$db_version ); |
| 49 | 48 | |
| @@ -48,16 +47,10 @@ | ||
| 48 | 47 | update_option( 'frm_db_version', FrmAppHelper::plugin_version() . '-' . FrmAppHelper::$db_version ); |
| 49 | 48 | |
| 50 | 49 | if ( ! $old_db_version ) { |
| 51 | 50 | $this->maybe_create_contact_form(); |
| 52 | - | |
| 53 | - if ( false === get_option( 'frm_first_activation' ) ) { | |
| 54 | - update_option( 'frm_first_activation', time(), false ); | |
| 55 | - } | |
| 56 | - | |
| 57 | - $this->update_settings_for_new_install(); | |
| 58 | 51 | } |
| 59 | - }//end if | |
| 52 | + } | |
| 60 | 53 | |
| 61 | 54 | do_action( 'frm_after_install' ); |
| 62 | 55 | |
| 63 | 56 | $frm_vars['doing_upgrade'] = false; |
| @@ -70,54 +63,8 @@ | ||
| 70 | 63 | $frm_style->update( 'default' ); |
| 71 | 64 | } |
| 72 | 65 | } |
| 73 | 66 | |
| 74 | - /** | |
| 75 | - * Updates some settings for new installs. | |
| 76 | - * | |
| 77 | - * @since 6.23 | |
| 78 | - */ | |
| 79 | - private function update_settings_for_new_install() { | |
| 80 | - $settings = FrmAppHelper::get_settings(); | |
| 81 | - | |
| 82 | - $settings->denylist_check = 1; | |
| 83 | - $settings->store(); | |
| 84 | - } | |
| 85 | - | |
| 86 | - /** | |
| 87 | - * If we fail to create the database tables, add an inbox notice. | |
| 88 | - * This informs the user that they need to correct the issue and try again. | |
| 89 | - * | |
| 90 | - * @since 6.19 | |
| 91 | - * | |
| 92 | - * @return void | |
| 93 | - */ | |
| 94 | - private function check_that_tables_exist() { | |
| 95 | - // Check the DB that the table $this->forms exists. | |
| 96 | - global $wpdb; | |
| 97 | - $exists = $wpdb->get_results( $wpdb->prepare( 'SHOW TABLES LIKE %s', $this->forms ) ); | |
| 98 | - | |
| 99 | - if ( $exists ) { | |
| 100 | - $inbox = new FrmInbox(); | |
| 101 | - $inbox->dismiss( 'failed-to-create-tables' ); | |
| 102 | - return; | |
| 103 | - } | |
| 104 | - | |
| 105 | - $message = array( | |
| 106 | - 'key' => 'failed-to-create-tables', | |
| 107 | - 'subject' => 'Something went wrong setting up the database', | |
| 108 | - '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.', | |
| 109 | - 'cta' => '<a href="https://formidableforms.com/knowledgebase/install-formidable-forms/#kb-missing-database-tables">Learn More</a>', | |
| 110 | - 'type' => 'error', | |
| 111 | - ); | |
| 112 | - | |
| 113 | - $inbox = new FrmInbox(); | |
| 114 | - $inbox->add_message( $message ); | |
| 115 | - } | |
| 116 | - | |
| 117 | - /** | |
| 118 | - * @return string | |
| 119 | - */ | |
| 120 | 67 | public function collation() { |
| 121 | 68 | global $wpdb; |
| 122 | 69 | if ( ! $wpdb->has_cap( 'collation' ) ) { |
| 123 | 70 | return ''; |
| @@ -218,10 +165,8 @@ | ||
| 218 | 165 | /** |
| 219 | 166 | * These indexes help optimize database queries for entries. |
| 220 | 167 | * |
| 221 | 168 | * @since 6.6 |
| 222 | - * @since 6.16.3 idx_form_id_is_draft was also added to frm_items. | |
| 223 | - * @since 6.17 idx_form_id_type was also added to frm_fields. | |
| 224 | 169 | * |
| 225 | 170 | * @return void |
| 226 | 171 | */ |
| 227 | 172 | private function add_composite_indexes_for_entries() { |
| @@ -239,22 +184,8 @@ | ||
| 239 | 184 | |
| 240 | 185 | if ( ! self::index_exists( $table_name, $index_name ) ) { |
| 241 | 186 | $wpdb->query( "CREATE INDEX idx_field_id_item_id ON `{$wpdb->prefix}frm_item_metas` (field_id, item_id)" ); |
| 242 | 187 | } |
| 243 | - | |
| 244 | - $table_name = "{$wpdb->prefix}frm_items"; | |
| 245 | - $index_name = 'idx_form_id_is_draft'; | |
| 246 | - | |
| 247 | - if ( ! self::index_exists( $table_name, $index_name ) ) { | |
| 248 | - $wpdb->query( "CREATE INDEX idx_form_id_is_draft ON `{$wpdb->prefix}frm_items` (form_id, is_draft)" ); | |
| 249 | - } | |
| 250 | - | |
| 251 | - $table_name = "{$wpdb->prefix}frm_fields"; | |
| 252 | - $index_name = 'idx_form_id_type'; | |
| 253 | - | |
| 254 | - if ( ! self::index_exists( $table_name, $index_name ) ) { | |
| 255 | - $wpdb->query( "CREATE INDEX idx_form_id_type ON `{$wpdb->prefix}frm_fields` (form_id, type(30))" ); | |
| 256 | - } | |
| 257 | 188 | } |
| 258 | 189 | |
| 259 | 190 | /** |
| 260 | 191 | * Check that an index exists in a database table before trying to add it (which results in an error). |
| @@ -324,9 +255,9 @@ | ||
| 324 | 255 | // bail if we don't know the previous version |
| 325 | 256 | return; |
| 326 | 257 | } |
| 327 | 258 | |
| 328 | - $migrations = array( 16, 11, 16, 17, 23, 25, 86, 90, 97, 98, 101, 104 ); | |
| 259 | + $migrations = array( 16, 11, 16, 17, 23, 25, 86, 90, 97, 98, 101 ); | |
| 329 | 260 | foreach ( $migrations as $migration ) { |
| 330 | 261 | if ( FrmAppHelper::$db_version >= $migration && $old_db_version < $migration ) { |
| 331 | 262 | $function_name = 'migrate_to_' . $migration; |
| 332 | 263 | $this->$function_name(); |
| @@ -353,9 +284,9 @@ | ||
| 353 | 284 | delete_option( 'frm_lite_settings_upgrade' ); |
| 354 | 285 | delete_option( 'frm-usage-uuid' ); |
| 355 | 286 | delete_option( 'frm_inbox' ); |
| 356 | 287 | delete_option( 'frmpro_css' ); |
| 357 | - delete_option( FrmOnboardingWizardController::REDIRECT_STATUS_OPTION ); | |
| 288 | + delete_option( 'frm_welcome_redirect' ); | |
| 358 | 289 | delete_option( FrmEmailSummaryHelper::$option_name ); |
| 359 | 290 | |
| 360 | 291 | // Delete roles. |
| 361 | 292 | $frm_roles = FrmAppHelper::frm_capabilities(); |
| @@ -385,9 +316,9 @@ | ||
| 385 | 316 | // delete transients |
| 386 | 317 | delete_transient( 'frmpro_css' ); |
| 387 | 318 | delete_transient( 'frm_options' ); |
| 388 | 319 | delete_transient( 'frmpro_options' ); |
| 389 | - delete_transient( FrmOnboardingWizardController::TRANSIENT_NAME ); | |
| 320 | + delete_transient( 'frm_activation_redirect' ); | |
| 390 | 321 | |
| 391 | 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_%' ) ); |
| 392 | 323 | |
| 393 | 324 | do_action( 'frm_after_uninstall' ); |
| @@ -395,26 +326,8 @@ | ||
| 395 | 326 | return true; |
| 396 | 327 | } |
| 397 | 328 | |
| 398 | 329 | /** |
| 399 | - * In older versions of Lite, it's possible we've saved the wrong location ID. | |
| 400 | - * So force it to get valid values again. | |
| 401 | - * | |
| 402 | - * @since 6.25 | |
| 403 | - * | |
| 404 | - * @return void | |
| 405 | - */ | |
| 406 | - private function migrate_to_104() { | |
| 407 | - if ( FrmSquareLiteConnectHelper::get_merchant_id( 'test' ) ) { | |
| 408 | - FrmSquareLiteConnectHelper::get_location_id( true, 'test' ); | |
| 409 | - } | |
| 410 | - | |
| 411 | - if ( FrmSquareLiteConnectHelper::get_merchant_id( 'live' ) ) { | |
| 412 | - FrmSquareLiteConnectHelper::get_location_id( true, 'live' ); | |
| 413 | - } | |
| 414 | - } | |
| 415 | - | |
| 416 | - /** | |
| 417 | 330 | * Disables summary email for multisite (not the main site) if recipient setting isn't changed. |
| 418 | 331 | * |
| 419 | 332 | * @since 6.8 |
| 420 | 333 | */ |
| @@ -477,9 +390,9 @@ | ||
| 477 | 390 | } |
| 478 | 391 | } |
| 479 | 392 | |
| 480 | 393 | /** |
| 481 | - * Delete unneeded default templates | |
| 394 | + * Delete uneeded default templates | |
| 482 | 395 | * |
| 483 | 396 | * @since 3.06 |
| 484 | 397 | */ |
| 485 | 398 | private function migrate_to_90() { |
| @@ -499,9 +412,9 @@ | ||
| 499 | 412 | $fields = $this->get_fields_with_size(); |
| 500 | 413 | |
| 501 | 414 | foreach ( (array) $fields as $f ) { |
| 502 | 415 | FrmAppHelper::unserialize_or_decode( $f->field_options ); |
| 503 | - $size = $f->field_options['size']; | |
| 416 | + $size = $f->field_options['size']; | |
| 504 | 417 | $this->maybe_convert_migrated_size( $size ); |
| 505 | 418 | |
| 506 | 419 | if ( $size === $f->field_options['size'] ) { |
| 507 | 420 | continue; |
| @@ -603,9 +516,9 @@ | ||
| 603 | 516 | return; |
| 604 | 517 | } |
| 605 | 518 | |
| 606 | 519 | foreach ( $styles as $style ) { |
| 607 | - if ( $style->post_content['field_width'] === '400px' ) { | |
| 520 | + if ( $style->post_content['field_width'] == '400px' ) { | |
| 608 | 521 | $style->post_content['field_width'] = '100%'; |
| 609 | 522 | $frm_style->save( (array) $style ); |
| 610 | 523 | |
| 611 | 524 | return; |
| @@ -669,9 +582,9 @@ | ||
| 669 | 582 | |
| 670 | 583 | private function convert_character_to_px( &$size ) { |
| 671 | 584 | $pixel_conversion = 9; |
| 672 | 585 | |
| 673 | - $size = round( $pixel_conversion * (int) $size ); | |
| 586 | + $size = round( $pixel_conversion * (int) $size ); | |
| 674 | 587 | $size .= 'px'; |
| 675 | 588 | } |
| 676 | 589 | |
| 677 | 590 | /** |
| @@ -743,9 +656,9 @@ | ||
| 743 | 656 | $new_default_html = FrmFormsHelper::get_default_html( 'submit' ); |
| 744 | 657 | $draft_link = FrmFormsHelper::get_draft_link(); |
| 745 | 658 | foreach ( $forms as $form ) { |
| 746 | 659 | FrmAppHelper::unserialize_or_decode( $form->options ); |
| 747 | - if ( empty( $form->options['submit_html'] ) ) { | |
| 660 | + if ( ! isset( $form->options['submit_html'] ) || empty( $form->options['submit_html'] ) ) { | |
| 748 | 661 | continue; |
| 749 | 662 | } |
| 750 | 663 | |
| 751 | 664 | if ( $form->options['submit_html'] != $new_default_html && $form->options['submit_html'] == $old_default_html ) { |