PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 3.6.2
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v3.6.2
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.6.2, at features/upgrades/upgrades.php

227 lines 8.7 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 if ( ( PROFILE_BUILDER == 'Profile Builder Pro' ) || ( PROFILE_BUILDER == 'Profile Builder Hobbyist' ) ){
26
27 /* stopped creating them on 01.02.2016 */
28 /*$upload_dir = wp_upload_dir();
29 wp_mkdir_p( $upload_dir['basedir'].'/profile_builder' );
30 wp_mkdir_p( $upload_dir['basedir'].'/profile_builder/attachments/' );
31 wp_mkdir_p( $upload_dir['basedir'].'/profile_builder/avatars/' );*/
32
33 // Flush the rewrite rules and add them, if need be, the proper way.
34 if ( function_exists( 'wppb_flush_rewrite_rules' ) )
35 wppb_flush_rewrite_rules();
36
37 wppb_pro_hobbyist_v1_3_13();
38 }
39
40 if ( PROFILE_BUILDER == 'Profile Builder Pro' ){
41 wppb_pro_v1_3_15();
42 }
43
44 update_option( 'wppb_version', PROFILE_BUILDER_VERSION );
45 }
46
47 //this should run only once, mainly if the old version is < 2.0 (can be anything)
48 if ( version_compare( $wppb_version, 2.0, '<' ) ) {
49 if ( ( PROFILE_BUILDER == 'Profile Builder Pro' ) || ( PROFILE_BUILDER == 'Profile Builder Hobbyist' ) || ( PROFILE_BUILDER == 'Profile Builder Free' ) ){
50 wppb_pro_hobbyist_free_v2_0();
51 }
52
53 if ( PROFILE_BUILDER == 'Profile Builder Pro' ){
54 wppb_pro_userlisting_compatibility_upgrade();
55 wppb_pro_email_customizer_compatibility_upgrade();
56 }
57 }
58
59 // this should run only once, mainly if the old version is < 2.2.5 (can be anything)
60 if ( version_compare( $wppb_version, '2.2.5', '<' ) ) {
61 if ( PROFILE_BUILDER == 'Profile Builder Pro' ) {
62 wppb_new_custom_redirects_compatibility();
63 }
64 }
65
66 if ( version_compare( $wppb_version, '2.2.5', '<=' ) ) {
67 if( is_multisite() ){
68 $wppb_general_settings = get_option( 'wppb_general_settings', 'not_set' );
69 if ( $wppb_general_settings != 'not_set' ) {
70 $wppb_general_settings['emailConfirmation'] = 'yes';
71 update_option('wppb_general_settings', $wppb_general_settings);
72 }
73 }
74
75 }
76
77 do_action ( 'wppb_after_default_changes', PROFILE_BUILDER_VERSION, $wppb_version );
78 }
79 add_action ( 'init', 'wppb_update_patch' );
80
81
82 /**
83 * before disabling the old plugin addons save their status in the db
84 */
85 add_action( 'plugins_loaded', 'wppb_save_old_add_ons_status', 11 );
86 function wppb_save_old_add_ons_status(){
87 $old_addon_list = wppb_get_old_addons_slug_list();
88 $old_addons_status = get_option( 'wppb_old_add_ons_status', array() );
89
90 //if it's triggered in the frontend we need this include
91 if( !function_exists('is_plugin_active') )
92 include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
93
94 foreach( $old_addon_list as $addon_slug ){
95 if( !isset( $old_addons_status[$addon_slug] ) ) {//don't change the status, just take the first run through
96 if ( is_plugin_active($addon_slug) )
97 $old_addons_status[$addon_slug] = true;
98 else
99 $old_addons_status[$addon_slug] = false;
100 }
101 }
102
103 update_option( 'wppb_old_add_ons_status', $old_addons_status );
104 }
105
106
107 /**
108 * Deactivate the old addons as plugins
109 */
110 add_action( 'plugins_loaded', 'wppb_disable_old_add_ons', 12 );
111 function wppb_disable_old_add_ons(){
112
113 //if it's triggered in the frontend we need this include
114 if( !function_exists('is_plugin_active') )
115 include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
116
117 $old_addons_list = wppb_get_old_addons_slug_list();
118 $deactivated_addons = 0;
119 foreach( $old_addons_list as $addon_slug ){
120 if( is_plugin_active($addon_slug) ){
121 if( is_multisite() ){
122 if( is_plugin_active_for_network($addon_slug) )
123 deactivate_plugins($addon_slug, true);
124 else
125 deactivate_plugins($addon_slug, true, false);
126 }
127 else {
128 deactivate_plugins($addon_slug, true);
129 }
130 $deactivated_addons++;
131 }
132 }
133 if ( isset( $_GET['activate'] ) && $deactivated_addons === 1 ){
134 add_action( 'load-plugins.php',
135 function(){
136 add_action( 'in_admin_header',
137 function(){
138 add_filter( 'gettext', 'wppb_disable_old_add_ons_notice', 99, 3 );
139 }
140 );
141 }
142 );
143 } elseif ( isset( $_GET['activate-multi'] ) && $deactivated_addons !== 0 ){
144 add_action( 'admin_notices', 'wppb_disable_old_add_ons_notice_multi' );
145 }
146 }
147
148 function wppb_disable_old_add_ons_notice( $translated_text, $untranslated_text, $domain )
149 {
150 $old = array(
151 "Plugin activated."
152 );
153
154 $new = "This Profile Builder add-on has been migrated to the main plugin and is no longer used. You can delete it.";
155
156 if ( in_array( $untranslated_text, $old, true ) )
157 {
158 $translated_text = $new;
159 remove_filter( current_filter(), __FUNCTION__, 99 );
160 }
161 return $translated_text;
162 }
163
164 function wppb_disable_old_add_ons_notice_multi() {
165 ?>
166 <div id="message" class="updated notice is-dismissible">
167 <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>
168 </div>
169 <?php
170 }
171
172 add_action( 'plugins_loaded', 'wppb_generate_new_free_add_ons_setting', 13 );
173 function wppb_generate_new_free_add_ons_setting(){
174 $wppb_free_add_ons_settings = get_option( 'wppb_free_add_ons_settings', array() );
175 if( empty( $wppb_free_add_ons_settings ) ){
176
177 $old_addons_list = wppb_get_old_addons_slug_list();
178 foreach( $old_addons_list as $addon_slug ){
179
180 switch ($addon_slug) {
181 case 'pb-add-on-customization-toolbox/index.php':
182 if( !wppb_was_addon_active_as_plugin( $addon_slug ) ){
183 //it might have been active at some point and we need to remove the settings so they don't get activated in Advance Settings
184 $toolbox_settings = array( 'wppb_toolbox_forms_settings', 'wppb_toolbox_fields_settings', 'wppb_toolbox_userlisting_settings', 'wppb_toolbox_shortcodes_settings', 'wppb_toolbox_admin_settings' );
185 foreach( $toolbox_settings as $toolbox_setting ){
186 delete_option( $toolbox_setting );
187 }
188 }
189 break;
190 case 'pb-add-on-gdpr-communication-preferences/pb-gdpr-communication-preferences.php':
191 if( wppb_was_addon_active_as_plugin( $addon_slug ) )
192 $wppb_free_add_ons_settings['gdpr-communication-preferences'] = true;
193 else
194 $wppb_free_add_ons_settings['gdpr-communication-preferences'] = false;
195 break;
196 case 'pb-add-on-labels-edit/pble.php':
197 if( wppb_was_addon_active_as_plugin( $addon_slug ) )
198 $wppb_free_add_ons_settings['labels-edit'] = true;
199 else
200 $wppb_free_add_ons_settings['labels-edit'] = false;
201 break;
202 case 'pb-add-on-maximum-character-length/index.php':
203 if( wppb_was_addon_active_as_plugin( $addon_slug ) )
204 $wppb_free_add_ons_settings['maximum-character-length'] = true;
205 else
206 $wppb_free_add_ons_settings['maximum-character-length'] = false;
207 break;
208 case 'pb-add-on-custom-css-classes-on-fields/index.php':
209 if( wppb_was_addon_active_as_plugin( $addon_slug ) )
210 $wppb_free_add_ons_settings['custom-css-classes-on-fields'] = true;
211 else
212 $wppb_free_add_ons_settings['custom-css-classes-on-fields'] = false;
213 break;
214 case 'pb-add-on-import-export/pbie.php':
215 if( wppb_was_addon_active_as_plugin( $addon_slug ) )
216 $wppb_free_add_ons_settings['import-export'] = true;
217 else
218 $wppb_free_add_ons_settings['import-export'] = false;
219 break;
220 }
221
222
223 }
224
225 add_option( 'wppb_free_add_ons_settings', $wppb_free_add_ons_settings );
226 }
227 }