PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / trunk
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More vtrunk
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 +45 -8 6.29 → trunk View file →
@@ -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,9 +404,9 @@
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 411 if ( FrmAppHelper::$db_version < $migration || $old_db_version >= $migration ) {
389 412 continue;
@@ -408,8 +431,9 @@
408 431 $wpdb->query( 'DROP TABLE IF EXISTS ' . $this->fields ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
409 432 $wpdb->query( 'DROP TABLE IF EXISTS ' . $this->forms ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
410 433 $wpdb->query( 'DROP TABLE IF EXISTS ' . $this->entries ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
411 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
412 436
413 437 delete_option( 'frm_options' );
414 438 delete_option( 'frm_db_version' );
415 439 delete_option( 'frm_install_running' );
@@ -474,8 +498,21 @@
474 498 }
475 499
476 500 if ( FrmSquareLiteConnectHelper::get_merchant_id( 'live' ) ) {
477 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 );
478 515 }
479 516 }
480 517
481 518 /**