PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 3.8.3
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v3.8.3
4.0.2 4.0.1 4.0.0 3.16.6 3.16.5 3.16.4 3.16.3 3.16.2 3.16.1 3.16.0 3.15.9 3.9.9 3.9.5 3.9.6 3.9.7 3.9.8 1.1.7 1.1.8 1.1.9 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 All 340 releases
profile-builder / features / upgrades / upgrades.php

upgrades.php in User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor 3.8.3, at features/upgrades/upgrades.php

322 lines 13.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3
4 include_once ( WPPB_PLUGIN_DIR.'/features/upgrades/upgrades-functions.php' );
5
6 /**
7 * Function that assures backwards compatibility for all future versions, where this is needed
8 *
9 * @since v.1.3.13
10 *
11 * @return void
12 */
13 function wppb_update_patch(){
14 if ( !get_option( 'wppb_version' ) ) {
15 add_option( 'wppb_version', '1.3.13' );
16
17 do_action( 'wppb_set_initial_version_number', PROFILE_BUILDER_VERSION );
18 }
19
20 $wppb_version = get_option( 'wppb_version' );
21
22 do_action( 'wppb_before_default_changes', PROFILE_BUILDER_VERSION, $wppb_version );
23
24 if ( version_compare( PROFILE_BUILDER_VERSION, $wppb_version, '>' ) ) {
25 $paid_versions = array( 'Profile Builder Pro', 'Profile Builder Hobbyist', 'Profile Builder Elite', 'Profile Builder Unlimited', 'Profile Builder Basic' );
26
27 if ( in_array( PROFILE_BUILDER, $paid_versions ) ){
28
29 /* stopped creating them on 01.02.2016 */
30 /*$upload_dir = wp_upload_dir();
31 wp_mkdir_p( $upload_dir['basedir'].'/profile_builder' );
32 wp_mkdir_p( $upload_dir['basedir'].'/profile_builder/attachments/' );
33 wp_mkdir_p( $upload_dir['basedir'].'/profile_builder/avatars/' );*/
34
35 // Flush the rewrite rules and add them, if need be, the proper way.
36 if ( function_exists( 'wppb_flush_rewrite_rules' ) )
37 wppb_flush_rewrite_rules();
38
39 wppb_pro_hobbyist_v1_3_13();
40 }
41
42 $pro_versions = array( 'Profile Builder Pro', 'Profile Builder Elite', 'Profile Builder Unlimited' );
43
44 if ( in_array( PROFILE_BUILDER, $pro_versions ) ){
45 wppb_pro_v1_3_15();
46 }
47
48 update_option( 'wppb_version', PROFILE_BUILDER_VERSION );
49 }
50
51 //this should run only once, mainly if the old version is < 2.0 (can be anything)
52 if ( version_compare( $wppb_version, 2.0, '<' ) ) {
53 $all_versions = array( 'Profile Builder Pro', 'Profile Builder Hobbyist', 'Profile Builder Elite', 'Profile Builder Unlimited', 'Profile Builder Basic', 'Profile Builder Free' );
54
55 if ( in_array( PROFILE_BUILDER, $all_versions ) ){
56 wppb_pro_hobbyist_free_v2_0();
57 }
58
59 $pro_versions = array( 'Profile Builder Pro', 'Profile Builder Elite', 'Profile Builder Unlimited' );
60
61 if ( in_array( PROFILE_BUILDER, $pro_versions ) ){
62 wppb_pro_userlisting_compatibility_upgrade();
63 wppb_pro_email_customizer_compatibility_upgrade();
64 }
65 }
66
67 // this should run only once, mainly if the old version is < 2.2.5 (can be anything)
68 if ( version_compare( $wppb_version, '2.2.5', '<' ) ) {
69 $pro_versions = array( 'Profile Builder Pro', 'Profile Builder Elite', 'Profile Builder Unlimited' );
70
71 if ( in_array( PROFILE_BUILDER, $pro_versions ) ){
72 wppb_new_custom_redirects_compatibility();
73 }
74 }
75
76 if ( version_compare( $wppb_version, '2.2.5', '<=' ) ) {
77 if( is_multisite() ){
78 $wppb_general_settings = get_option( 'wppb_general_settings', 'not_set' );
79 if ( $wppb_general_settings != 'not_set' ) {
80 $wppb_general_settings['emailConfirmation'] = 'yes';
81 update_option('wppb_general_settings', $wppb_general_settings);
82 }
83 }
84
85 }
86
87 do_action ( 'wppb_after_default_changes', PROFILE_BUILDER_VERSION, $wppb_version );
88 }
89 add_action ( 'init', 'wppb_update_patch' );
90
91
92 /**
93 * before disabling the old plugin addons save their status in the db
94 */
95 add_action( 'plugins_loaded', 'wppb_save_old_add_ons_status', 11 );
96 function wppb_save_old_add_ons_status(){
97 $old_addon_list = wppb_get_old_addons_slug_list();
98 $old_addons_status = get_option( 'wppb_old_add_ons_status', array() );
99
100 //if it's triggered in the frontend we need this include
101 if( !function_exists('is_plugin_active') )
102 include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
103
104 foreach( $old_addon_list as $addon_slug ){
105 if( !isset( $old_addons_status[$addon_slug] ) ) {//don't change the status, just take the first run through
106 if ( is_plugin_active($addon_slug) )
107 $old_addons_status[$addon_slug] = true;
108 else
109 $old_addons_status[$addon_slug] = false;
110 }
111 }
112
113 update_option( 'wppb_old_add_ons_status', $old_addons_status );
114 }
115
116
117 /**
118 * Deactivate the old addons as plugins
119 */
120 add_action( 'plugins_loaded', 'wppb_disable_old_add_ons', 12 );
121 function wppb_disable_old_add_ons(){
122
123 //if it's triggered in the frontend we need this include
124 if( !function_exists('is_plugin_active') )
125 include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
126
127 $old_addons_list = wppb_get_old_addons_slug_list();
128 $deactivated_addons = 0;
129 foreach( $old_addons_list as $addon_slug ){
130 if( is_plugin_active($addon_slug) ){
131 if( is_multisite() ){
132 if( is_plugin_active_for_network($addon_slug) )
133 deactivate_plugins($addon_slug, true);
134 else
135 deactivate_plugins($addon_slug, true, false);
136 }
137 else {
138 deactivate_plugins($addon_slug, true);
139 }
140 $deactivated_addons++;
141 }
142 }
143 if ( isset( $_GET['activate'] ) && $deactivated_addons === 1 ){
144 add_action( 'load-plugins.php',
145 function(){
146 add_action( 'in_admin_header',
147 function(){
148 add_filter( 'gettext', 'wppb_disable_old_add_ons_notice', 99, 3 );
149 }
150 );
151 }
152 );
153 } elseif ( isset( $_GET['activate-multi'] ) && $deactivated_addons !== 0 ){
154 add_action( 'admin_notices', 'wppb_disable_old_add_ons_notice_multi' );
155 }
156 }
157
158 function wppb_disable_old_add_ons_notice( $translated_text, $untranslated_text, $domain )
159 {
160 $old = array(
161 "Plugin activated."
162 );
163
164 $new = "This Profile Builder add-on has been migrated to the main plugin and is no longer used. You can delete it.";
165
166 if ( in_array( $untranslated_text, $old, true ) )
167 {
168 $translated_text = $new;
169 remove_filter( current_filter(), __FUNCTION__, 99 );
170 }
171 return $translated_text;
172 }
173
174 function wppb_disable_old_add_ons_notice_multi() {
175 ?>
176 <div id="message" class="updated notice is-dismissible">
177 <p><?php esc_html_e( 'This Profile Builder add-on has been migrated to the main plugin and is no longer used. You can delete it.', 'profile-builder' ); ?></p>
178 </div>
179 <?php
180 }
181
182 add_action( 'plugins_loaded', 'wppb_generate_new_free_add_ons_setting', 13 );
183 function wppb_generate_new_free_add_ons_setting(){
184 $wppb_free_add_ons_settings = get_option( 'wppb_free_add_ons_settings', array() );
185 if( empty( $wppb_free_add_ons_settings ) ){
186
187 $old_addons_list = wppb_get_old_addons_slug_list();
188 foreach( $old_addons_list as $addon_slug ){
189
190 switch ($addon_slug) {
191 case 'pb-add-on-customization-toolbox/index.php':
192 if( !wppb_was_addon_active_as_plugin( $addon_slug ) ){
193 //it might have been active at some point and we need to remove the settings so they don't get activated in Advance Settings
194 $toolbox_settings = array( 'wppb_toolbox_forms_settings', 'wppb_toolbox_fields_settings', 'wppb_toolbox_userlisting_settings', 'wppb_toolbox_shortcodes_settings', 'wppb_toolbox_admin_settings' );
195 foreach( $toolbox_settings as $toolbox_setting ){
196 delete_option( $toolbox_setting );
197 }
198 }
199 break;
200 case 'pb-add-on-gdpr-communication-preferences/pb-gdpr-communication-preferences.php':
201 if( wppb_was_addon_active_as_plugin( $addon_slug ) )
202 $wppb_free_add_ons_settings['gdpr-communication-preferences'] = true;
203 else
204 $wppb_free_add_ons_settings['gdpr-communication-preferences'] = false;
205 break;
206 case 'pb-add-on-labels-edit/pble.php':
207 if( wppb_was_addon_active_as_plugin( $addon_slug ) )
208 $wppb_free_add_ons_settings['labels-edit'] = true;
209 else
210 $wppb_free_add_ons_settings['labels-edit'] = false;
211 break;
212 case 'pb-add-on-maximum-character-length/index.php':
213 if( wppb_was_addon_active_as_plugin( $addon_slug ) )
214 $wppb_free_add_ons_settings['maximum-character-length'] = true;
215 else
216 $wppb_free_add_ons_settings['maximum-character-length'] = false;
217 break;
218 case 'pb-add-on-custom-css-classes-on-fields/index.php':
219 if( wppb_was_addon_active_as_plugin( $addon_slug ) )
220 $wppb_free_add_ons_settings['custom-css-classes-on-fields'] = true;
221 else
222 $wppb_free_add_ons_settings['custom-css-classes-on-fields'] = false;
223 break;
224 case 'pb-add-on-import-export/pbie.php':
225 if( wppb_was_addon_active_as_plugin( $addon_slug ) )
226 $wppb_free_add_ons_settings['import-export'] = true;
227 else
228 $wppb_free_add_ons_settings['import-export'] = false;
229 break;
230 }
231
232
233 }
234
235 add_option( 'wppb_free_add_ons_settings', $wppb_free_add_ons_settings );
236 }
237 }
238
239
240 add_action( 'plugins_loaded', 'wppb_generate_new_advanced_add_ons_setting', 13 );
241 function wppb_generate_new_advanced_add_ons_setting(){
242 $wppb_advanced_add_ons_settings = get_option( 'wppb_advanced_add_ons_settings', array() );
243 if( empty( $wppb_advanced_add_ons_settings ) ){
244
245 $old_addons_list = wppb_get_old_addons_slug_list();
246 foreach( $old_addons_list as $addon_slug ){
247
248 switch ($addon_slug) {
249 case 'pb-add-on-buddypress/index.php':
250 if( wppb_was_addon_active_as_plugin( $addon_slug ) )
251 $wppb_advanced_add_ons_settings['buddypress'] = true;
252 else
253 $wppb_advanced_add_ons_settings['buddypress'] = false;
254 break;
255 case 'pb-add-on-social-connect/index.php':
256 if( wppb_was_addon_active_as_plugin( $addon_slug ) )
257 $wppb_advanced_add_ons_settings['social-connect'] = true;
258 else
259 $wppb_advanced_add_ons_settings['social-connect'] = false;
260 break;
261 case 'pb-add-on-woocommerce/index.php':
262 if( wppb_was_addon_active_as_plugin( $addon_slug ) )
263 $wppb_advanced_add_ons_settings['woocommerce'] = true;
264 else
265 $wppb_advanced_add_ons_settings['woocommerce'] = false;
266 break;
267 case 'pb-add-on-multi-step-forms/index.php':
268 if( wppb_was_addon_active_as_plugin( $addon_slug ) )
269 $wppb_advanced_add_ons_settings['multi-step-forms'] = true;
270 else
271 $wppb_advanced_add_ons_settings['multi-step-forms'] = false;
272 break;
273 case 'pb-add-on-mailchimp-integration/index.php':
274 if( wppb_was_addon_active_as_plugin( $addon_slug ) )
275 $wppb_advanced_add_ons_settings['mailchimp-integration'] = true;
276 else
277 $wppb_advanced_add_ons_settings['mailchimp-integration'] = false;
278 break;
279 case 'pb-add-on-bbpress/index.php':
280 if( wppb_was_addon_active_as_plugin( $addon_slug ) )
281 $wppb_advanced_add_ons_settings['bbpress'] = true;
282 else
283 $wppb_advanced_add_ons_settings['bbpress'] = false;
284 break;
285 case 'pb-add-on-campaign-monitor/index.php':
286 if( wppb_was_addon_active_as_plugin( $addon_slug ) )
287 $wppb_advanced_add_ons_settings['campaign-monitor'] = true;
288 else
289 $wppb_advanced_add_ons_settings['campaign-monitor'] = false;
290 break;
291 case 'pb-add-on-field-visibility/index.php':
292 if( wppb_was_addon_active_as_plugin( $addon_slug ) )
293 $wppb_advanced_add_ons_settings['field-visibility'] = true;
294 else
295 $wppb_advanced_add_ons_settings['field-visibility'] = false;
296 break;
297 case 'pb-add-on-edit-profile-approved-by-admin/index.php':
298 if( wppb_was_addon_active_as_plugin( $addon_slug ) )
299 $wppb_advanced_add_ons_settings['edit-profile-approved-by-admin'] = true;
300 else
301 $wppb_advanced_add_ons_settings['edit-profile-approved-by-admin'] = false;
302 break;
303 case 'pb-add-on-custom-profile-menus/index.php':
304 if( wppb_was_addon_active_as_plugin( $addon_slug ) )
305 $wppb_advanced_add_ons_settings['custom-profile-menus'] = true;
306 else
307 $wppb_advanced_add_ons_settings['custom-profile-menus'] = false;
308 break;
309 case 'pb-add-on-mailpoet-integration/index.php':
310 if( wppb_was_addon_active_as_plugin( $addon_slug ) )
311 $wppb_advanced_add_ons_settings['mailpoet-integration'] = true;
312 else
313 $wppb_advanced_add_ons_settings['mailpoet-integration'] = false;
314 break;
315 }
316
317
318 }
319
320 add_option( 'wppb_advanced_add_ons_settings', $wppb_advanced_add_ons_settings );
321 }
322 }