PluginProbe ʕ •ᴥ•ʔ
Paid Membership Plugin, Ecommerce, User Registration Form, Login Form, User Profile & Restrict Content – ProfilePress / trunk
Paid Membership Plugin, Ecommerce, User Registration Form, Login Form, User Profile & Restrict Content – ProfilePress vtrunk
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 / DBUpdates.php
wp-user-avatar / src Last commit date
Admin 4 weeks ago AdminBarDashboardAccess 3 years ago Classes 1 week ago ContentProtection 1 month ago Functions 4 months ago Integrations 1 year ago Membership 1 week ago NavigationMenuLinks 2 years ago RegisterActivation 9 months ago ShortcodeParser 3 weeks ago Themes 2 months ago Widgets 10 months ago lib 3 years ago templates 1 month ago Base.php 2 months ago Cron.php 2 years ago DBTables.php 3 years ago DBUpdates.php 1 month ago LoginRedirect.php 9 months ago RegisterScripts.php 4 months ago eu-vat-rates.json 10 months ago
DBUpdates.php
222 lines
1 <?php
2
3 namespace ProfilePress\Core;
4
5 use ProfilePress\Core\Classes\ExtensionManager;
6 use ProfilePress\Core\Membership\DigitalProducts\UploadHandler;
7 use ProfilePress\Libsodium\Licensing\Licensing;
8
9 class DBUpdates
10 {
11 public static $instance;
12
13 const DB_VER = 14;
14
15 public function init_options()
16 {
17 add_option('ppress_db_ver', 0);
18 }
19
20 public function maybe_update()
21 {
22 $this->init_options();
23
24 if (get_option('ppress_db_ver', 0) >= self::DB_VER) {
25 return;
26 }
27
28 // update plugin
29 $this->update();
30 }
31
32 public function update()
33 {
34 // no PHP timeout for running updates
35 set_time_limit(0);
36
37 // this is the current database schema version number
38 $current_db_ver = get_option('ppress_db_ver', 0);
39
40 // this is the target version that we need to reach
41 $target_db_ver = self::DB_VER;
42
43 // run update routines one by one until the current version number
44 // reaches the target version number
45 while ($current_db_ver < $target_db_ver) {
46 // increment the current db_ver by one
47 $current_db_ver++;
48
49 // each db version will require a separate update function
50 $update_method = "update_routine_{$current_db_ver}";
51
52 if (method_exists($this, $update_method)) {
53 call_user_func(array($this, $update_method));
54 }
55 }
56
57 // update the option in the database, so that this process can always
58 // pick up where it left off
59 update_option('ppress_db_ver', $current_db_ver);
60 }
61
62 public function update_routine_1()
63 {
64 $a = get_option(ExtensionManager::DB_OPTION_NAME, []);
65 $a[ExtensionManager::PAYPAL] = 'true';
66 update_option(ExtensionManager::DB_OPTION_NAME, $a);
67 }
68
69 public function update_routine_2()
70 {
71 global $wpdb;
72
73 $table1 = DBTables::orders_db_table();
74 $table2 = DBTables::subscriptions_db_table();
75 $table3 = DBTables::customers_db_table();
76
77 $wpdb->query("ALTER TABLE $table1 CHANGE date_created date_created datetime NOT NULL;");
78 $wpdb->query("ALTER TABLE $table2 CHANGE created_date created_date datetime NOT NULL;");
79 $wpdb->query("ALTER TABLE $table3 CHANGE date_created date_created datetime NOT NULL;");
80 }
81
82 public function update_routine_3()
83 {
84 global $wpdb;
85
86 $table = DBTables::coupons_db_table();
87 $table2 = DBTables::subscription_plans_db_table();
88
89 $wpdb->query("ALTER TABLE $table CHANGE type coupon_type varchar(50) NULL;");
90 $wpdb->query("ALTER TABLE $table2 ADD COLUMN order_note text NULL AFTER description;");
91 }
92
93 public function update_routine_4()
94 {
95 global $wpdb;
96
97 $table = DBTables::subscription_plans_db_table();
98
99 $wpdb->query("ALTER TABLE $table ADD COLUMN user_role varchar(50) NULL AFTER description;");
100 }
101
102 public function update_routine_5()
103 {
104 UploadHandler::get_instance()->create_protection_files(true);
105
106 flush_rewrite_rules();
107
108 if (class_exists('\ProfilePress\Libsodium\Licensing\Licensing')) {
109
110 $response = Licensing::get_instance()->license_control_instance()->check_license();
111
112 if (is_wp_error($response)) return false;
113
114 if ( ! empty($response->license)) {
115 if ($response->license == 'valid') {
116 update_option('ppress_license_status', 'valid');
117 update_option('ppress_license_expired_status', 'false');
118 } else {
119 if (in_array($response->license, ['expired', 'disabled'])) {
120 update_option('ppress_license_expired_status', 'true');
121 }
122 update_option('ppress_license_status', 'invalid');
123 }
124 }
125 }
126 }
127
128 public function update_routine_6()
129 {
130 $a = get_option(ExtensionManager::DB_OPTION_NAME);
131 $a[ExtensionManager::MOLLIE] = 'true';
132 update_option(ExtensionManager::DB_OPTION_NAME, $a);
133 }
134
135 public function update_routine_7()
136 {
137 ppress_update_settings('wordpresscom_button_label', esc_html__('Sign in with WordPress.com', 'wp-user-avatar'));
138 ppress_update_settings('yahoo_button_label', esc_html__('Sign in with Yahoo', 'wp-user-avatar'));
139 ppress_update_settings('microsoft_button_label', esc_html__('Sign in with Microsoft', 'wp-user-avatar'));
140 ppress_update_settings('amazon_button_label', esc_html__('Sign in with Amazon', 'wp-user-avatar'));
141 }
142
143 public function update_routine_8()
144 {
145 $a = get_option(ExtensionManager::DB_OPTION_NAME);
146 $a[ExtensionManager::RECEIPT] = 'true';
147 update_option(ExtensionManager::DB_OPTION_NAME, $a);
148 }
149
150 public function update_routine_9()
151 {
152 global $wpdb;
153
154 $table = DBTables::coupons_db_table();
155
156 $wpdb->query("ALTER TABLE $table ADD COLUMN is_onetime_use enum('true','false') NOT NULL DEFAULT 'false' AFTER coupon_type;");
157 }
158
159 public function update_routine_10()
160 {
161 global $wpdb;
162
163 $table = DBTables::profile_fields_db_table();
164
165 if ($wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE %s", $table))) {
166 // Table exists, proceed with altering the table
167 $wpdb->query("ALTER TABLE $table CHANGE options options longtext NULL;");
168 }
169 }
170
171 public function update_routine_11()
172 {
173 $linkedin_api_version = ppress_get_setting('linkedin_api_version', '');
174
175 if (empty($linkedin_api_version)) {
176 ppress_update_settings('linkedin_api_version', 'deprecated');
177 }
178 }
179
180 public function update_routine_12()
181 {
182 global $wpdb;
183
184 $table = DBTables::passwordless_login_db_table();
185
186 // because this db updated might trigger if pro plugin isn't active, i had to also ensure the schema change below
187 // was added to the CREATE table definition in the pro plugin folder/archive to ensure the update is always present
188 // this will take care of for when a site already has pro and lite plugins active
189 if ($wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE %s", $table))) {
190 $wpdb->query("ALTER TABLE $table CHANGE id id bigint(20) unsigned NOT NULL AUTO_INCREMENT;");
191 $wpdb->query("ALTER TABLE $table CHANGE user_id user_id bigint(20) unsigned NOT NULL;");
192 }
193 }
194
195 public function update_routine_13()
196 {
197 $db = get_option(ExtensionManager::DB_OPTION_NAME, []);
198
199 if (in_array('true', [ppress_var($db, 'join_buddypress_groups'), ppress_var($db, 'buddypress_sync')])) {
200 $db['buddypress'] = 'true';
201 update_option(ExtensionManager::DB_OPTION_NAME, $db);
202 }
203 }
204
205 public function update_routine_14()
206 {
207 $recaptcha_site_key = ppress_settings_by_key('recaptcha_site_key');
208
209 if ( ! empty($recaptcha_site_key)) {
210 ppress_update_settings('recaptcha_api_platform', 'classic');
211 }
212 }
213
214 public static function get_instance()
215 {
216 if ( ! isset(self::$instance)) {
217 self::$instance = new self();
218 }
219
220 return self::$instance;
221 }
222 }