PluginProbe ʕ •ᴥ•ʔ
Paid Membership Plugin, Ecommerce, User Registration Form, Login Form, User Profile & Restrict Content – ProfilePress / 4.16.19
Paid Membership Plugin, Ecommerce, User Registration Form, Login Form, User Profile & Restrict Content – ProfilePress v4.16.19
4.16.19 4.16.18 4.16.17 4.16.16 trunk 1.0 1.0.1 1.0.2 1.1 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.5a 1.1.6 1.1.7 1.2 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.3 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.4 1.4.1 1.4.2 1.5 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.6 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.7 1.7.1 1.7.2 1.8 1.8.1 1.8.10 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 1.9 1.9.1 1.9.10 1.9.11 1.9.12 1.9.13 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.1.9 2.2.10 2.2.11 2.2.12 2.2.13 2.2.14 2.2.15 2.2.16 2.2.2 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 3.0 3.1 3.1.1 3.1.10 3.1.11 3.1.12 3.1.13 3.1.14 3.1.15 3.1.16 3.1.17 3.1.18 3.1.19 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.10 3.2.11 3.2.12 3.2.13 3.2.14 3.2.15 3.2.16 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 4.0.0 4.0.1 4.0.2 4.0.3 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4 4.10.0 4.10.1 4.10.2 4.10.3 4.11.0 4.12.0 4.13.0 4.13.1 4.13.2 4.13.3 4.13.4 4.14.0 4.14.1 4.14.2 4.14.3 4.14.4 4.15.0 4.15.1 4.15.10 4.15.11 4.15.12 4.15.13 4.15.14 4.15.15 4.15.16 4.15.17 4.15.18 4.15.19 4.15.2 4.15.20 4.15.20.1 4.15.21 4.15.22 4.15.23 4.15.24 4.15.25 4.15.3 4.15.4 4.15.5 4.15.6 4.15.7 4.15.8 4.15.9 4.16.0 4.16.1 4.16.10 4.16.11 4.16.12 4.16.13 4.16.14 4.16.15 4.16.2 4.16.3 4.16.4 4.16.5 4.16.6 4.16.7 4.16.8 4.16.9 4.2.0 4.3.0 4.3.1 4.3.2 4.4.0 4.4.1 4.5.0 4.5.1 4.5.2 4.5.3 4.5.4 4.5.5 4.6.0 4.7.0 4.8.0 4.9.0
wp-user-avatar / src / RegisterActivation / CreateDBTables.php
wp-user-avatar / src / RegisterActivation Last commit date
Base.php 9 months ago CreateDBTables.php 1 year ago index.php 5 years ago
CreateDBTables.php
226 lines
1 <?php
2
3 namespace ProfilePress\Core\RegisterActivation;
4
5 use ProfilePress\Core\Base as CoreBase;
6
7 class CreateDBTables
8 {
9 public static function make()
10 {
11 global $wpdb;
12
13 $collate = '';
14 if ($wpdb->has_cap('collation')) {
15 $collate = $wpdb->get_charset_collate();
16 }
17
18 $forms_table = CoreBase::form_db_table();
19 $forms_meta_table = CoreBase::form_meta_db_table();
20 $meta_data_table = CoreBase::meta_data_db_table();
21
22 $sqls[] = "CREATE TABLE IF NOT EXISTS $forms_table (
23 id bigint(20) NOT NULL AUTO_INCREMENT,
24 name varchar(100) NOT NULL,
25 form_id bigint(20) NOT NULL,
26 form_type varchar(20) NOT NULL DEFAULT '',
27 builder_type varchar(20) NOT NULL DEFAULT '',
28 date datetime NOT NULL DEFAULT '1000-01-01 00:00:00',
29 PRIMARY KEY (id),
30 UNIQUE KEY name (name),
31 KEY form_id (form_id)
32 ) $collate;
33 ";
34 // max index length is 191 to avoid this error "Index column size too large. The maximum column size is 767 bytes."
35 // @see wp_get_db_schema()
36 $sqls[] = "CREATE TABLE IF NOT EXISTS $forms_meta_table (
37 meta_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
38 form_id bigint(20) unsigned NOT NULL,
39 form_type varchar(20) DEFAULT NULL,
40 meta_key varchar(255) DEFAULT NULL,
41 meta_value longtext,
42 PRIMARY KEY (meta_id),
43 KEY form_id (form_id),
44 KEY form_type (form_type),
45 KEY meta_key (meta_key(191))
46 ) $collate;
47 ";
48 $sqls[] = "CREATE TABLE IF NOT EXISTS $meta_data_table (
49 id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
50 meta_key varchar(50) DEFAULT NULL,
51 meta_value longtext,
52 flag varchar(20) DEFAULT NULL,
53 PRIMARY KEY (id),
54 KEY meta_key (meta_key),
55 KEY flag (flag)
56 ) $collate;
57 ";
58
59 $sqls = apply_filters('ppress_create_database_tables', $sqls, $collate);
60
61 require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
62
63 foreach ($sqls as $sql) {
64 dbDelta($sql);
65 }
66
67 self::membership_db_make();
68 }
69
70 public static function membership_db_make()
71 {
72 global $wpdb;
73
74 $collate = '';
75 if ($wpdb->has_cap('collation')) {
76 $collate = $wpdb->get_charset_collate();
77 }
78
79 $subscriptions_table = CoreBase::subscriptions_db_table();
80 $plans_table = CoreBase::subscription_plans_db_table();
81 $orders_table = CoreBase::orders_db_table();
82 $order_meta_table = CoreBase::order_meta_db_table();
83 $coupons_table = CoreBase::coupons_db_table();
84 $customers_table = CoreBase::customers_db_table();
85
86 //Not using CURRENT_TIMESTAMP because it uses mysql session/server timezone which always isn’t UTC
87
88 $sqls[] = "CREATE TABLE IF NOT EXISTS $subscriptions_table (
89 id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
90 parent_order_id bigint(20) unsigned NOT NULL,
91 plan_id bigint(20) unsigned NOT NULL,
92 customer_id bigint(20) unsigned NOT NULL,
93 billing_frequency varchar(50) NOT NULL,
94 initial_amount decimal(26,8) NOT NULL,
95 initial_tax_rate mediumtext NOT NULL,
96 initial_tax mediumtext NOT NULL,
97 recurring_amount decimal(26,8) NOT NULL,
98 recurring_tax_rate mediumtext NOT NULL,
99 recurring_tax mediumtext NOT NULL,
100 total_payments bigint(20) unsigned NOT NULL DEFAULT '0',
101 trial_period varchar(50) DEFAULT NULL,
102 profile_id varchar(255) NOT NULL,
103 status varchar(20) NOT NULL,
104 notes longtext,
105 created_date datetime NOT NULL,
106 expiration_date datetime DEFAULT NULL,
107 PRIMARY KEY (id),
108 KEY plan_id (plan_id),
109 KEY customer_id (customer_id),
110 KEY status (status),
111 KEY parent_order_id (parent_order_id),
112 KEY customer_and_status (customer_id,status),
113 KEY profile_id (profile_id(191))
114 ) $collate;
115 ";
116
117 $sqls[] = "CREATE TABLE IF NOT EXISTS $plans_table (
118 id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
119 name varchar(255) NOT NULL,
120 description text,
121 price decimal(26,8) NOT NULL DEFAULT '0.00000000',
122 billing_frequency varchar(50) NOT NULL,
123 subscription_length varchar(50) NOT NULL,
124 total_payments int(11) DEFAULT NULL,
125 signup_fee decimal(26,8) DEFAULT '0.00000000',
126 free_trial varchar(50) DEFAULT NULL,
127 status enum('true','false') NOT NULL DEFAULT 'true',
128 meta_data longtext,
129 PRIMARY KEY (id)
130 ) $collate;
131 ";
132 $sqls[] = "CREATE TABLE IF NOT EXISTS $orders_table (
133 id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
134 order_key varchar(64) NOT NULL,
135 plan_id bigint(20) unsigned NOT NULL,
136 customer_id bigint(20) unsigned NOT NULL,
137 subscription_id bigint(20) unsigned NOT NULL DEFAULT '0',
138 order_type varchar(20) NOT NULL DEFAULT '',
139 transaction_id varchar(100) DEFAULT '',
140 payment_method varchar(100) NOT NULL DEFAULT '',
141 status varchar(20) NOT NULL,
142 coupon_code varchar(20) DEFAULT NULL,
143 subtotal decimal(26,8) NOT NULL DEFAULT '0.00000000',
144 tax decimal(26,8) NOT NULL DEFAULT '0.00000000',
145 tax_rate mediumtext NOT NULL,
146 discount decimal(26,8) NOT NULL DEFAULT '0.00000000',
147 total decimal(26,8) NOT NULL DEFAULT '0.00000000',
148 billing_address varchar(200) NOT NULL,
149 billing_city varchar(100) NOT NULL,
150 billing_state varchar(100) NOT NULL,
151 billing_postcode varchar(100) NOT NULL,
152 billing_country varchar(100) NOT NULL,
153 billing_phone varchar(100) NOT NULL,
154 mode enum('live','test') NOT NULL,
155 currency varchar(10) NOT NULL,
156 ip_address varchar(100) NOT NULL DEFAULT '',
157 date_created datetime NOT NULL,
158 date_completed datetime DEFAULT NULL,
159 PRIMARY KEY (id),
160 UNIQUE KEY order_key (order_key),
161 KEY status (status),
162 KEY mode (mode),
163 KEY plan_id (plan_id),
164 KEY transaction_id (transaction_id),
165 KEY date (date_created),
166 KEY coupon_code (coupon_code),
167 KEY customer_id (customer_id)
168 ) $collate;
169 ";
170 $sqls[] = "CREATE TABLE IF NOT EXISTS $order_meta_table (
171 meta_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
172 ppress_order_id bigint(20) unsigned NOT NULL,
173 meta_key varchar(255) COLLATE utf8mb4_unicode_520_ci DEFAULT NULL,
174 meta_value longtext COLLATE utf8mb4_unicode_520_ci,
175 PRIMARY KEY (meta_id)
176 ) $collate;
177 ";
178 $sqls[] = "CREATE TABLE IF NOT EXISTS $coupons_table (
179 id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
180 code varchar(50) NOT NULL,
181 description mediumtext,
182 coupon_application varchar(50) NOT NULL,
183 type varchar(50) NOT NULL,
184 amount mediumtext NOT NULL,
185 unit varchar(50) NOT NULL,
186 plan_ids mediumtext,
187 usage_limit mediumint(8) unsigned DEFAULT NULL,
188 status enum('true','false') NOT NULL DEFAULT 'true',
189 start_date date DEFAULT NULL,
190 end_date date DEFAULT NULL,
191 PRIMARY KEY (id),
192 UNIQUE KEY code (code),
193 KEY type (type),
194 KEY status (status)
195 ) $collate;
196 ";
197 $sqls[] = "CREATE TABLE IF NOT EXISTS $customers_table (
198 id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
199 user_id bigint(20) unsigned DEFAULT NULL,
200 private_note longtext,
201 total_spend decimal(18,9) NOT NULL DEFAULT '0.000000000',
202 purchase_count bigint(20) unsigned NOT NULL DEFAULT '0',
203 last_login datetime DEFAULT NULL,
204 date_created datetime NOT NULL,
205 PRIMARY KEY (id),
206 UNIQUE KEY user_id (user_id),
207 KEY date_created (date_created)
208 ) $collate;
209 ";
210
211 $sqls[] = "CREATE TABLE {$wpdb->prefix}ppress_sessions (
212 session_id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
213 session_key char(32) NOT NULL,
214 session_value LONGTEXT NOT NULL,
215 session_expiry BIGINT(20) UNSIGNED NOT NULL,
216 PRIMARY KEY (session_key),
217 UNIQUE KEY session_id (session_id)
218 ) $collate;";
219
220 require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
221
222 foreach ($sqls as $sql) {
223 dbDelta($sql);
224 }
225 }
226 }