| @@ -24,14 +24,20 @@ | ||
| 24 | 24 | * @var string |
| 25 | 25 | */ |
| 26 | 26 | public $entry_metas; |
| 27 | 27 | |
| 28 | + /** | |
| 29 | + * @var string | |
| 30 | + */ | |
| 31 | + public $gated_tokens; | |
| 32 | + | |
| 28 | 33 | public function __construct() { |
| 29 | 34 | global $wpdb; |
| 30 | - $this->fields = $wpdb->prefix . 'frm_fields'; | |
| 31 | - $this->forms = $wpdb->prefix . 'frm_forms'; | |
| 32 | - $this->entries = $wpdb->prefix . 'frm_items'; | |
| 33 | - $this->entry_metas = $wpdb->prefix . 'frm_item_metas'; | |
| 35 | + $this->fields = $wpdb->prefix . 'frm_fields'; | |
| 36 | + $this->forms = $wpdb->prefix . 'frm_forms'; | |
| 37 | + $this->entries = $wpdb->prefix . 'frm_items'; | |
| 38 | + $this->entry_metas = $wpdb->prefix . 'frm_item_metas'; | |
| 39 | + $this->gated_tokens = $wpdb->prefix . 'frm_gated_tokens'; | |
| 34 | 40 | } |
| 35 | 41 | |
| 36 | 42 | /** |
| 37 | 43 | * @return void |
| @@ -153,10 +159,10 @@ | ||
| 153 | 159 | |
| 154 | 160 | $message = array( |
| 155 | 161 | 'key' => 'failed-to-create-tables', |
| 156 | 162 | '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>', | |
| 163 | + 'message' => 'For steps to continue, see our <a href="https://formidableforms.com/knowledgebase/install-formidable-forms/#kb-missing-database-tables" target="_blank" rel="noopener">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 | |
| 164 | + 'cta' => '<a href="https://formidableforms.com/knowledgebase/install-formidable-forms/#kb-missing-database-tables" target="_blank" rel="noopener">Learn More</a>', // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong | |
| 159 | 165 | 'type' => 'error', |
| 160 | 166 | ); |
| 161 | 167 | |
| 162 | 168 | $inbox = new FrmInbox(); |
| @@ -249,8 +255,25 @@ | ||
| 249 | 255 | KEY field_id (field_id), |
| 250 | 256 | KEY item_id (item_id) |
| 251 | 257 | )'; |
| 252 | 258 | |
| 259 | + /* Create/Upgrade Gated Tokens Table */ | |
| 260 | + $sql[] = 'CREATE TABLE ' . $this->gated_tokens . ' ( | |
| 261 | + id BIGINT UNSIGNED NOT NULL auto_increment, | |
| 262 | + token_hash varchar(64) NOT NULL, | |
| 263 | + action_id BIGINT UNSIGNED NOT NULL, | |
| 264 | + entry_id BIGINT UNSIGNED NOT NULL, | |
| 265 | + user_id BIGINT UNSIGNED default NULL, | |
| 266 | + ip_address varchar(255) default NULL, | |
| 267 | + created_at int UNSIGNED NOT NULL, | |
| 268 | + expired_at int UNSIGNED default NULL, | |
| 269 | + PRIMARY KEY (id), | |
| 270 | + UNIQUE KEY token_hash (token_hash), | |
| 271 | + KEY action_id (action_id), | |
| 272 | + KEY user_id (user_id), | |
| 273 | + KEY expired_at (expired_at) | |
| 274 | + )'; | |
| 275 | + | |
| 253 | 276 | foreach ( $sql as $q ) { |
| 254 | 277 | if ( function_exists( 'dbDelta' ) ) { |
| 255 | 278 | dbDelta( $q . $charset_collate . ';' ); |
| 256 | 279 | } else { |
| @@ -373,9 +396,9 @@ | ||
| 373 | 396 | } |
| 374 | 397 | |
| 375 | 398 | if ( str_contains( $old_db_version, '-' ) ) { |
| 376 | 399 | $last_upgrade = explode( '-', $old_db_version ); |
| 377 | - $old_db_version = (int) $last_upgrade[1]; | |
| 400 | + $old_db_version = intval( end( $last_upgrade ) ); | |
| 378 | 401 | } |
| 379 | 402 | |
| 380 | 403 | if ( ! is_numeric( $old_db_version ) ) { |
| 381 | 404 | // Bail if we don't know the previous version |
| @@ -381,15 +404,17 @@ | ||
| 381 | 404 | // Bail if we don't know the previous version |
| 382 | 405 | return; |
| 383 | 406 | } |
| 384 | 407 | |
| 385 | - $migrations = array( 16, 11, 16, 17, 23, 25, 86, 90, 97, 98, 101, 104 ); | |
| 408 | + $migrations = array( 16, 11, 16, 17, 23, 25, 86, 90, 97, 98, 101, 104, 105 ); | |
| 386 | 409 | |
| 387 | 410 | foreach ( $migrations as $migration ) { |
| 388 | - if ( FrmAppHelper::$db_version >= $migration && $old_db_version < $migration ) { | |
| 389 | - $function_name = 'migrate_to_' . $migration; | |
| 390 | - $this->$function_name(); | |
| 411 | + if ( FrmAppHelper::$db_version < $migration || $old_db_version >= $migration ) { | |
| 412 | + continue; | |
| 391 | 413 | } |
| 414 | + | |
| 415 | + $function_name = 'migrate_to_' . $migration; | |
| 416 | + $this->$function_name(); | |
| 392 | 417 | } |
| 393 | 418 | } |
| 394 | 419 | |
| 395 | 420 | /** |
| @@ -406,8 +431,9 @@ | ||
| 406 | 431 | $wpdb->query( 'DROP TABLE IF EXISTS ' . $this->fields ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared |
| 407 | 432 | $wpdb->query( 'DROP TABLE IF EXISTS ' . $this->forms ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared |
| 408 | 433 | $wpdb->query( 'DROP TABLE IF EXISTS ' . $this->entries ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared |
| 409 | 434 | $wpdb->query( 'DROP TABLE IF EXISTS ' . $this->entry_metas ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared |
| 435 | + $wpdb->query( 'DROP TABLE IF EXISTS ' . $this->gated_tokens ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared | |
| 410 | 436 | |
| 411 | 437 | delete_option( 'frm_options' ); |
| 412 | 438 | delete_option( 'frm_db_version' ); |
| 413 | 439 | delete_option( 'frm_install_running' ); |
| @@ -472,8 +498,21 @@ | ||
| 472 | 498 | } |
| 473 | 499 | |
| 474 | 500 | if ( FrmSquareLiteConnectHelper::get_merchant_id( 'live' ) ) { |
| 475 | 501 | FrmSquareLiteConnectHelper::get_location_id( true, 'live' ); |
| 502 | + } | |
| 503 | + } | |
| 504 | + | |
| 505 | + /** | |
| 506 | + * Add new wp_options row for custom setting. | |
| 507 | + * | |
| 508 | + * @since 6.26 | |
| 509 | + * | |
| 510 | + * @return void | |
| 511 | + */ | |
| 512 | + private function migrate_to_105() { | |
| 513 | + if ( ! FrmAppHelper::pro_is_installed() ) { | |
| 514 | + update_option( 'frm_show_pricing_fields_modal', 1, false ); | |
| 476 | 515 | } |
| 477 | 516 | } |
| 478 | 517 | |
| 479 | 518 | /** |