PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / 5.2.8
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder v5.2.8
6.2.13 6.2.12 6.2.10 6.2.11 6.2.9 6.2.8 6.2.7 6.2.6 6.2.5 6.2.4 6.2.3 6.2.2 3.6.22 3.6.31 3.6.40 3.6.41 3.6.42 3.6.50 3.6.51 3.6.60 3.6.61 3.6.62 3.6.64 3.6.65 3.6.66 All 195 releases
fluentform / database / Migrations / FormAnalytics.php

FormAnalytics.php in Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder 5.2.8, at database/Migrations/FormAnalytics.php

51 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentForm\Database\Migrations;
4
5 class FormAnalytics
6 {
7 /**
8 * Migrate the table.
9 *
10 * @return void
11 */
12 public static function migrate()
13 {
14 global $wpdb;
15
16 $charsetCollate = $wpdb->get_charset_collate();
17
18 $table = $wpdb->prefix . 'fluentform_form_analytics';
19
20 if ($wpdb->get_var("SHOW TABLES LIKE '$table'") != $table) {
21 $sql = "CREATE TABLE $table (
22 `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
23 `form_id` INT UNSIGNED NULL,
24 `user_id` INT UNSIGNED NULL,
25 `source_url` TEXT NOT NULL,
26 `platform` CHAR(30) NULL,
27 `browser` CHAR(30) NULL,
28 `city` VARCHAR (100) NULL,
29 `country` VARCHAR (100) NULL,
30 `ip` CHAR(15) NULL,
31 `count` INT DEFAULT 1,
32 `created_at` TIMESTAMP NULL,
33 PRIMARY KEY (`id`) ) $charsetCollate;";
34
35 require_once ABSPATH . 'wp-admin/includes/upgrade.php';
36
37 dbDelta($sql);
38 }else{
39 // increase column type of source_url from varchar to text - for already installed sites
40 $column_name = 'source_url';
41 $dataType = $wpdb->get_col_length($table, $column_name);
42 $type = $dataType['type'] ?? false;
43 if ($type == 'char') {
44 $sql = "ALTER TABLE {$table} MODIFY {$column_name} TEXT NOT NULL";
45 $wpdb->query($sql);
46 }
47 }
48
49 }
50 }
51