PluginProbe
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP / 1.2.74
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP v1.2.74
1.2.74 1.2.73 1.2.72 1.2.71 1.2.70 1.2.69 1.2.68 1.2.67 1.2.66 1.2.65 1.2.64 1.2.63 trunk 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.20 1.0.21 All 174 releases
← All changes | includes/class-activator.php +479 -438 1.0.171.2.74 View file →
@@ -8,9 +8,33 @@
8 8 * @author GeoDirectory Team <info@wpgeodirectory.com>
9 9 */
10 10 class UsersWP_Activator {
11 11
12 + /** @var array DB updates and callbacks that need to be run per version */
13 + private static $db_updates = array(
14 + '1.2.0.0' => array(
15 + 'uwp_upgrade_1200',
16 + ),
17 + '1.2.0.13' => array(
18 + 'uwp_upgrade_12013',
19 + ),
20 + '1.2.2.5' => array(
21 + 'uwp_upgrade_1225',
22 + ),
23 + '1.2.3' => array(
24 + 'uwp_upgrade_1230',
25 + ),
26 + );
27 +
28 +
12 29 /**
30 + * Background update class.
31 + *
32 + * @var object
33 + */
34 + private static $background_updater;
35 +
36 + /**
13 37 * This method gets fired during plugin activation.
14 38 *
15 39 * @since 1.0.0
16 40 * @package userswp
@@ -15,19 +39,22 @@
15 39 * @since 1.0.0
16 40 * @package userswp
17 41 * @return void
18 42 */
19 - public static function activate($network_wide = false) {
43 + public static function activate( $network_wide = false ) {
20 44
21 - self::load_dependencies();
45 + if ( is_multisite() ) {
46 + $main_site = get_network()->site_id;
47 + if ( $network_wide ) {
22 48
23 - if (is_multisite()) {
24 - $main_site = get_network()->site_id;
25 - if($network_wide){
26 - if (defined('UWP_ROOT_PAGES')) {
27 - if (UWP_ROOT_PAGES == 'all') {
28 - $blog_ids = self::uwp_get_blog_ids();
49 + update_network_option( '', 'uwp_is_network_active', 1 );
50 + switch_to_blog( $main_site );
51 + restore_current_blog();
29 52
53 + if ( defined( 'UWP_ROOT_PAGES' ) ) {
54 + if ( UWP_ROOT_PAGES == 'all' ) {
55 + $blog_ids = self::get_blog_ids();
56 +
30 57 foreach ( $blog_ids as $blog_id ) {
31 58 switch_to_blog( $blog_id );
32 59 self::install();
33 60 }
@@ -42,42 +69,53 @@
42 69 switch_to_blog( $main_site );
43 70 self::install();
44 71 restore_current_blog();
45 72 }
46 -
47 - switch_to_blog( $main_site );
48 - self::uwp101_create_tables();
49 - self::uwp_insert_usermeta();
50 - restore_current_blog();
51 - } else {
73 +} else {
52 74 self::install();
53 - self::uwp101_create_tables();
54 - self::uwp_insert_usermeta();
55 75 }
56 76 } else {
57 77 self::install();
58 - self::uwp101_create_tables();
59 - self::uwp_insert_usermeta();
60 78 }
79 + }
61 80
62 - }
81 + public static function install() {
63 82
64 - public static function install(){
83 + uwp_generate_default_pages();
84 + self::add_default_options();
85 + uwp_create_tables();
65 86
66 - self::generate_pages();
67 - self::uwp_create_tables();
87 + // run update functions if needed
88 + if ( self::needs_db_update() ) {
89 + self::update();
90 + }
68 91
69 - if (!get_option('uwp_default_data_installed')) {
70 - self::add_default_options();
71 - self::uwp_create_default_fields();
72 - self::uwp_insert_form_extras();
73 - update_option('uwp_default_data_installed', 1);
74 - update_option('uwp_activation_redirect', 1);
92 + if ( ! get_option( 'uwp_default_data_installed' ) ) {
93 + // new install
94 + self::create_default_fields();
95 + self::insert_form_extras();
96 + update_option( 'uwp_default_data_installed', 1 );
97 + update_option( 'uwp_activation_redirect', 1 );
98 + } else {
99 + // upgrade
100 + // if updating from < 1.2.0 then add the try bootstrap notice
101 + if ( version_compare( get_option( 'uwp_db_version', null ), '1.2.0', '<' ) ) {
102 + update_option( 'uwp_notice_try_bootstrap', true );
103 + uwp_update_option( 'design_style', '' );
104 + }
75 105 }
76 106
77 - self::uwp_flush_rewrite_rules();
78 - update_option('uwp_flush_rewrite', 1);
107 + self::flush_rewrite_rules();
108 + update_option( 'uwp_flush_rewrite', 1 );
79 109
110 + // update the version
111 + update_option( 'uwp_db_version', USERSWP_VERSION );
112 +
113 + $installed = get_option( 'uwp_installed_on' );
114 +
115 + if ( empty( $installed ) ) {
116 + update_option( 'uwp_installed_on', time() );
117 + }
80 118 }
81 119
82 120 /**
83 121 * Get all IDs of blogs that are not activated, not spam, and not deleted
@@ -84,9 +122,9 @@
84 122 *
85 123 * @global object $wpdb
86 124 * @return array|false Array of IDs or false if none are found
87 125 */
88 - public static function uwp_get_blog_ids() {
126 + public static function get_blog_ids() {
89 127 global $wpdb;
90 128
91 129 // Get an array of IDs
92 130 $sql = "SELECT blog_id FROM $wpdb->blogs
@@ -96,33 +134,8 @@
96 134 return $wpdb->get_col( $sql );
97 135 }
98 136
99 137 /**
100 - * Loads all dependencies during plugin activation.
101 - *
102 - * @since 1.0.0
103 - * @package userswp
104 - * @return void
105 - */
106 - public static function load_dependencies() {
107 - require_once dirname( __FILE__ ) . '/class-tables.php';
108 - require_once dirname( __FILE__ ) . '/class-meta.php';
109 - require_once dirname( __FILE__ ) . '/class-pages.php';
110 - require_once dirname(dirname( __FILE__ )) . '/admin/settings/class-formbuilder.php';
111 - }
112 -
113 - /**
114 - * Generates the default pages during plugin activation.
115 - *
116 - * @since 1.0.0
117 - * @package userswp
118 - * @return void
119 - */
120 - public static function generate_pages() {
121 - uwp_generate_default_pages();
122 - }
123 -
124 - /**
125 138 * Adds default settings during plugin activation.
126 139 *
127 140 * @since 1.0.0
128 141 * @package userswp
@@ -129,185 +142,158 @@
129 142 * @return void
130 143 */
131 144 public static function add_default_options() {
132 145
133 - $settings = get_option( 'uwp_settings', array());
146 + $settings = get_option( 'uwp_settings', array() );
134 147
135 - //general
136 - if (!isset($settings['profile_no_of_items'])) {
137 - $settings['profile_no_of_items'] = '10';
138 - }
148 + $options = array(
149 + 'register_modal' => 1,
150 + 'uwp_registration_action' => 'auto_approve',
151 + 'wp_register_redirect' => 1,
152 + 'login_modal' => 1,
153 + 'login_redirect_to' => -1,
154 + 'block_wp_login' => 0,
155 + 'disable_wp_2fa' => 0,
156 + 'forgot_modal' => 1,
157 + 'change_enable_old_password' => 1,
158 + 'change_disable_password_nag' => 0,
159 + 'enable_profile_header' => 1,
160 + 'enable_profile_body' => 1,
161 + 'profile_avatar_size' => '',
162 + 'profile_banner_size' => '',
163 + 'profile_banner_width' => 1000,
164 + 'profile_no_of_items' => 10,
165 + 'users_no_of_items' => 10,
166 + 'uwp_disable_author_link' => 0,
167 + 'users_default_layout' => '3col',
168 + 'author_box_enable_disable' => 1,
169 + 'author_box_display_content' => 'below_content',
170 + 'author_box_display_post_types' => array( 'post' ),
171 + 'author_box_content' => '',
172 + 'author_box_bio_limit' => 200,
173 + 'registration_success_email_admin' => 1,
174 + 'registration_success_email_subject_admin' => UsersWP_Defaults::registration_success_email_subject_admin(),
175 + 'registration_success_email_content_admin' => UsersWP_Defaults::registration_success_email_content_admin(),
176 + 'registration_activate_email' => 1,
177 + 'registration_activate_email_subject' => UsersWP_Defaults::registration_activate_email_subject(),
178 + 'registration_activate_email_content' => UsersWP_Defaults::registration_activate_email_content(),
179 + 'registration_success_email' => 1,
180 + 'registration_success_email_subject' => UsersWP_Defaults::registration_success_email_subject(),
181 + 'registration_success_email_content' => UsersWP_Defaults::registration_success_email_content(),
182 + 'forgot_password_email' => 1,
183 + 'forgot_password_email_subject' => UsersWP_Defaults::forgot_password_email_subject(),
184 + 'forgot_password_email_content' => UsersWP_Defaults::forgot_password_email_content(),
185 + 'change_password_email' => 1,
186 + 'change_password_email_subject' => UsersWP_Defaults::change_password_email_subject(),
187 + 'change_password_email_content' => UsersWP_Defaults::change_password_email_content(),
188 + 'reset_password_email' => 1,
189 + 'reset_password_email_subject' => UsersWP_Defaults::reset_password_email_subject(),
190 + 'reset_password_email_content' => UsersWP_Defaults::reset_password_email_content(),
191 + 'account_update_email' => 1,
192 + 'account_update_email_subject' => UsersWP_Defaults::account_update_email_subject(),
193 + 'account_update_email_content' => UsersWP_Defaults::account_update_email_content(),
194 + 'account_delete_email' => 1,
195 + 'account_delete_email_subject' => UsersWP_Defaults::account_delete_email_subject(),
196 + 'account_delete_email_content' => UsersWP_Defaults::account_delete_email_content(),
197 + 'account_delete_email_admin' => 1,
198 + 'account_delete_email_subject_admin' => UsersWP_Defaults::account_delete_email_subject_admin(),
199 + 'account_delete_email_content_admin' => UsersWP_Defaults::account_delete_email_content_admin(),
200 + 'wp_new_user_notification_email' => 1,
201 + 'wp_new_user_notification_email_subject' => UsersWP_Defaults::wp_new_user_notification_email_subject(),
202 + 'wp_new_user_notification_email_content' => UsersWP_Defaults::wp_new_user_notification_email_content(),
203 + 'account_new_email_activation_email' => 1,
204 + 'account_new_email_activation_email_subject' => UsersWP_Defaults::account_new_email_activation_email_subject(),
205 + 'account_new_email_activation_email_content' => UsersWP_Defaults::account_new_email_activation_email_content(),
206 + 'wp_new_user_notification_email_admin' => 1,
207 + 'wp_new_user_notification_email_subject_admin' => UsersWP_Defaults::wp_new_user_notification_email_subject_admin(),
208 + 'wp_new_user_notification_email_content_admin' => UsersWP_Defaults::wp_new_user_notification_email_content_admin(),
209 + 'user_post_counts_cpts' => array( 'post' ),
210 + 'login_user_post_counts_cpts' => array( 'post' ),
211 + 'multiple_registration_forms' => uwp_get_default_form_data(),
212 + 'profile_seo_meta_description_length' => 150,
213 + );
139 214
140 - //login
141 - if (!isset($settings['login_redirect_to'])) {
142 - $settings['login_redirect_to'] = -1;
143 - }
144 -
145 - //profile
146 - if (!isset($settings['enable_profile_header'])) {
147 - $settings['enable_profile_header'] = '1';
148 - }
149 - if (!isset($settings['enable_profile_body'])) {
150 - $settings['enable_profile_body'] = '1';
151 - }
152 - if (!isset($settings['enable_profile_posts_tab'])) {
153 - $settings['enable_profile_posts_tab'] = '1';
154 - }
155 - if (!isset($settings['enable_profile_comments_tab'])) {
156 - $settings['enable_profile_comments_tab'] = '1';
157 - }
158 -
159 - if (isset($settings['enable_profile_tabs']) && is_array($settings['enable_profile_tabs'])) {
160 - if (!isset($settings['enable_profile_tabs']['more_info'])) {
161 - $settings['enable_profile_tabs'][] = 'more_info';
215 + foreach ( $options as $option => $value ) {
216 + if ( ! isset( $settings[ $option ] ) ) {
217 + $settings[ $option ] = $value;
162 218 }
163 - if (!isset($settings['enable_profile_tabs']['posts'])) {
164 - $settings['enable_profile_tabs'][] = 'posts';
165 - }
166 - if (!isset($settings['enable_profile_tabs']['comments'])) {
167 - $settings['enable_profile_tabs'][] = 'comments';
168 - }
169 - } else {
170 - $settings['enable_profile_tabs'] = array('more_info', 'posts', 'comments');
171 219 }
172 220
221 + update_option( 'uwp_settings', $settings );
222 + }
173 223
174 - //notifications
175 -
176 - // admin
177 - $registration_success_email_subject_admin = __( 'New account registration', 'userswp' );
178 - $registration_success_email_content_admin = __("A user has been registered recently on your website. [#extras#]", "userswp");
179 -
180 - if (!isset($settings['registration_success_email_subject_admin'])) {
181 - $settings['registration_success_email_subject_admin'] = $registration_success_email_subject_admin;
224 + public static function init_background_updater() {
225 + if ( empty( self::$background_updater ) ) {
226 + include_once __DIR__ . '/class-uwp-background-updater.php';
227 + self::$background_updater = new UsersWP_Background_Updater();
182 228 }
183 - if (!isset($settings['registration_success_email_content_admin'])) {
184 - $settings['registration_success_email_content_admin'] = $registration_success_email_content_admin;
185 - }
229 + }
186 230
231 + /**
232 + * Syncs WP usermeta with UsersWP usermeta during plugin activation.
233 + *
234 + * @since 1.0.0
235 + * @package userswp
236 + * @return void
237 + */
238 + public static function uwp_update_usermeta( $dispatch = false ) {
239 + $update_callback = 'uwp_insert_usermeta';
240 + self::init_background_updater();
187 241
188 - // User
189 -
190 - // Register
191 - $registration_success_email_subject = __('Your Log In Details', 'userswp');
192 - $registration_success_email_content = __("<p>Dear [#user_name#],</p><p>You can log in with the following information:</p>[#login_details#]<p>You can login here: [#login_url#]</p><p>Thank you,<br /><br />[#site_name_url#].</p>" ,'userswp');
193 -
194 - if (!isset($settings['registration_success_email_subject'])) {
195 - $settings['registration_success_email_subject'] = $registration_success_email_subject;
242 + uwp_error_log( sprintf( 'Queuing %s - %s', USERSWP_VERSION, $update_callback ) );
243 + self::$background_updater->push_to_queue( $update_callback );
244 + if ( $dispatch ) {
245 + self::$background_updater->save()->dispatch();
196 246 }
197 - if (!isset($settings['registration_success_email_content'])) {
198 - $settings['registration_success_email_content'] = $registration_success_email_content;
199 - }
200 -
201 - // Activate
202 - $registration_activate_email_subject = __('Please activate your account', 'userswp');
203 - $registration_activate_email_content = __("<p>Dear [#user_name#],</p><p>Thank you for signing up with [#site_name#]</p>[#login_details#]<p>Thank you,<br /><br />[#site_name_url#].</p>" ,'userswp');
204 -
205 - if (!isset($settings['registration_activate_email_subject'])) {
206 - $settings['registration_activate_email_subject'] = $registration_activate_email_subject;
207 - }
208 - if (!isset($settings['registration_activate_email_content'])) {
209 - $settings['registration_activate_email_content'] = $registration_activate_email_content;
210 - }
211 -
212 - // Forgot
213 - $forgot_password_email_subject = __('[#site_name#] - Your new password', 'userswp');
214 - $forgot_password_email_content = __("<p>Dear [#user_name#],</p>[#login_details#]<p>You can login here: [#login_url#]</p><p>Thank you,<br /><br />[#site_name_url#].</p>" ,'userswp');
215 -
216 - if (!isset($settings['forgot_password_email_subject'])) {
217 - $settings['forgot_password_email_subject'] = $forgot_password_email_subject;
218 - }
219 - if (!isset($settings['forgot_password_email_content'])) {
220 - $settings['forgot_password_email_content'] = $forgot_password_email_content;
221 - }
222 -
223 - // Change
224 - $change_password_email_subject = __('[#site_name#] - Password has been changed', 'userswp');
225 - $change_password_email_content = __("<p>Dear [#user_name#],</p><p>Your password has been changed successfully.</p><p>You can login here: [#login_url#]</p><p>Thank you,<br /><br />[#site_name_url#].</p>" ,'userswp');
226 -
227 - if (!isset($settings['change_password_email_subject'])) {
228 - $settings['change_password_email_subject'] = $change_password_email_subject;
229 - }
230 - if (!isset($settings['change_password_email_content'])) {
231 - $settings['change_password_email_content'] = $change_password_email_content;
232 - }
233 -
234 - // Reset
235 - $reset_password_email_subject = __('[#site_name#] - Password has been reset', 'userswp');
236 - $reset_password_email_content = __("<p>Dear [#user_name#],</p><p>Your password has been reset</p><p>You can login here: [#login_url#]</p><p>Thank you,<br /><br />[#site_name_url#].</p>" ,'userswp');
237 -
238 - if (!isset($settings['reset_password_email_subject'])) {
239 - $settings['reset_password_email_subject'] = $reset_password_email_subject;
240 - }
241 - if (!isset($settings['reset_password_email_content'])) {
242 - $settings['reset_password_email_content'] = $reset_password_email_content;
243 - }
244 -
245 - // Update
246 - $account_update_email_subject = __('[#site_name#] - Account has been updated', 'userswp');
247 - $account_update_email_content = __("<p>Dear [#user_name#],</p><p>Your account has been updated successfully</p><p>Thank you,<br /><br />[#site_name_url#].</p>" ,'userswp');
248 -
249 - if (!isset($settings['account_update_email_subject'])) {
250 - $settings['account_update_email_subject'] = $account_update_email_subject;
251 - }
252 - if (!isset($settings['account_update_email_content'])) {
253 - $settings['account_update_email_content'] = $account_update_email_content;
254 - }
255 -
256 - update_option( 'uwp_settings', $settings );
257 -
258 247 }
259 248
260 249 /**
261 - * Creates tables during plugin activation.
250 + * Get list of DB update callbacks.
262 251 *
263 - * @since 1.0.0
264 - * @package userswp
265 - * @return void
252 + * @since 3.0.0
253 + * @return array
266 254 */
267 - public static function uwp_create_tables()
268 - {
269 - uwp_create_tables();
255 + public static function get_db_update_callbacks() {
256 + return self::$db_updates;
270 257 }
271 258
272 259 /**
273 - * Creates the new tables added in version 1.0.1 during plugin activation.
260 + * Is a DB update needed?
274 261 *
275 - * @since 1.0.0
276 - * @package userswp
277 - * @return void
262 + * @since 2.0.0
263 + * @return boolean
278 264 */
279 - public static function uwp101_create_tables() {
280 - uwp101_create_tables();
265 + private static function needs_db_update() {
266 + $current_db_version = get_option( 'uwp_db_version', null );
267 + $updates = self::get_db_update_callbacks();
268 +
269 + return ! is_null( $current_db_version ) && ! empty( $updates ) && version_compare( $current_db_version, max( array_keys( $updates ) ), '<' );
281 270 }
282 271
283 272 /**
284 - * Syncs WP usermeta with UsersWP usermeta during plugin activation.
273 + * Push all needed DB updates to the queue for processing.
285 274 *
286 - * @since 1.0.0
287 - * @package userswp
288 - * @return void
275 + * @since 2.0.0
289 276 */
290 - public static function uwp_insert_usermeta()
291 - {
292 - global $wpdb;
293 - $sort= "user_registered";
294 - $all_users_id = $wpdb->get_col( $wpdb->prepare(
295 - "SELECT $wpdb->users.ID FROM $wpdb->users ORDER BY %s ASC"
296 - , $sort ));
277 + private static function update() {
278 + $current_db_version = get_option( 'uwp_db_version' );
279 + $update_queued = false;
280 + self::init_background_updater();
281 + foreach ( self::get_db_update_callbacks() as $version => $update_callbacks ) {
282 + if ( version_compare( $current_db_version, $version, '<' ) ) {
283 + foreach ( $update_callbacks as $update_callback ) {
284 + uwp_error_log( sprintf( 'Queuing %s - %s', $version, $update_callback ) );
285 + self::$background_updater->push_to_queue( $update_callback );
286 + $update_queued = true;
287 + }
288 + }
289 + }
297 290
298 - //we got all the IDs, now loop through them to get individual IDs
299 - foreach ( $all_users_id as $user_id ) {
300 - // get user info by calling get_userdata() on each id
301 - $user_data = get_userdata($user_id);
302 - $first_name = get_user_meta( $user_id, 'first_name', true );
303 - $last_name = get_user_meta( $user_id, 'last_name', true );
304 - $bio = get_user_meta( $user_id, 'description', true );
305 - uwp_update_usermeta($user_id, 'uwp_account_username', $user_data->user_login);
306 - uwp_update_usermeta($user_id, 'uwp_account_email', $user_data->user_email);
307 - uwp_update_usermeta($user_id, 'uwp_account_first_name', $first_name);
308 - uwp_update_usermeta($user_id, 'uwp_account_last_name', $last_name);
309 - uwp_update_usermeta($user_id, 'uwp_account_bio', $bio);
291 + if ( $update_queued ) {
292 + self::uwp_update_usermeta();// make sure to sync user meta
293 + self::$background_updater->save()->dispatch();
294 + } else {
295 + self::uwp_update_usermeta( true );// make sure to sync user meta
310 296 }
311 297 }
312 298
313 299 /**
@@ -316,18 +302,17 @@
316 302 * @since 1.0.0
317 303 * @package userswp
318 304 * @return void
319 305 */
320 - public static function uwp_create_default_fields()
321 - {
306 + public static function create_default_fields() {
322 307 $form_builder = new UsersWP_Form_Builder();
323 308
324 309 $fields = self::uwp_default_custom_fields();
325 310
326 - $fields = apply_filters('uwp_before_default_custom_fields_saved', $fields);
311 + $fields = apply_filters( 'uwp_before_default_custom_fields_saved', $fields );
327 312
328 - foreach ($fields as $field_index => $field) {
329 - $form_builder->uwp_admin_form_field_save($field);
313 + foreach ( $fields as $field_index => $field ) {
314 + $form_builder->admin_form_field_save( $field );
330 315 }
331 316 }
332 317
333 318 /**
@@ -336,9 +321,9 @@
336 321 * @since 1.0.0
337 322 * @package userswp
338 323 * @return array Merged custom fields.
339 324 */
340 - public static function uwp_default_custom_fields(){
325 + public static function uwp_default_custom_fields() {
341 326
342 327 $login = self::uwp_default_custom_fields_login();
343 328 $forgot = self::uwp_default_custom_fields_forgot();
344 329 $avatar = self::uwp_default_custom_fields_avatar();
@@ -346,14 +331,13 @@
346 331 $change = self::uwp_default_custom_fields_change();
347 332 $reset = self::uwp_default_custom_fields_reset();
348 333 $account = self::uwp_default_custom_fields_account();
349 334
350 - $fields = array_merge($login, $forgot, $account, $avatar, $banner, $change, $reset);
335 + $fields = array_merge( $login, $forgot, $account, $avatar, $banner, $change, $reset );
351 336
352 - $fields = apply_filters('uwp_default_custom_fields', $fields);
337 + $fields = apply_filters( 'uwp_default_custom_fields', $fields );
353 338
354 339 return $fields;
355 -
356 340 }
357 341
358 342 /**
359 343 * Returns Login form default custom fields.
@@ -361,39 +345,39 @@
361 345 * @since 1.0.0
362 346 * @package userswp
363 347 * @return array Login form default custom fields.
364 348 */
365 - public static function uwp_default_custom_fields_login(){
349 + public static function uwp_default_custom_fields_login() {
366 350
367 351 $fields = array();
368 352
369 353 $fields[] = array(
370 - 'form_type' => 'login',
371 - 'field_type' => 'text',
372 - 'data_type' => 'XVARCHAR',
373 - 'site_title' => __('Username', 'userswp'),
374 - 'htmlvar_name' => 'username',
354 + 'form_type' => 'login',
355 + 'field_type' => 'text',
356 + 'data_type' => 'XVARCHAR',
357 + 'site_title' => __( 'Username', 'userswp' ),
358 + 'htmlvar_name' => 'username',
375 359 'default_value' => '',
376 360 'option_values' => '',
377 - 'is_default' => '1',
378 - 'is_active' => '1',
379 - 'is_required' => '1'
361 + 'is_default' => '1',
362 + 'is_active' => '1',
363 + 'is_required' => '1',
380 364 );
381 365
382 366 $fields[] = array(
383 - 'form_type' => 'login',
384 - 'field_type' => 'password',
385 - 'data_type' => 'XVARCHAR',
386 - 'site_title' => __('Password', 'userswp'),
387 - 'htmlvar_name' => 'password',
367 + 'form_type' => 'login',
368 + 'field_type' => 'password',
369 + 'data_type' => 'XVARCHAR',
370 + 'site_title' => __( 'Password', 'userswp' ),
371 + 'htmlvar_name' => 'password',
388 372 'default_value' => '',
389 373 'option_values' => '',
390 - 'is_default' => '1',
391 - 'is_active' => '1',
392 - 'is_required' => '1'
374 + 'is_default' => '1',
375 + 'is_active' => '1',
376 + 'is_required' => '1',
393 377 );
394 378
395 - $fields = apply_filters('uwp_default_custom_fields_login', $fields);
379 + $fields = apply_filters( 'uwp_default_custom_fields_login', $fields );
396 380
397 381 return $fields;
398 382 }
399 383
@@ -403,26 +387,26 @@
403 387 * @since 1.0.0
404 388 * @package userswp
405 389 * @return array Forgot form default custom fields.
406 390 */
407 - public static function uwp_default_custom_fields_forgot(){
391 + public static function uwp_default_custom_fields_forgot() {
408 392
409 393 $fields = array();
410 394
411 395 $fields[] = array(
412 - 'form_type' => 'forgot',
413 - 'field_type' => 'email',
414 - 'data_type' => 'XVARCHAR',
415 - 'site_title' => __('Email', 'userswp'),
416 - 'htmlvar_name' => 'email',
396 + 'form_type' => 'forgot',
397 + 'field_type' => 'email',
398 + 'data_type' => 'XVARCHAR',
399 + 'site_title' => __( 'Email', 'userswp' ),
400 + 'htmlvar_name' => 'email',
417 401 'default_value' => '',
418 402 'option_values' => '',
419 - 'is_default' => '1',
420 - 'is_active' => '1',
421 - 'is_required' => '1'
403 + 'is_default' => '1',
404 + 'is_active' => '1',
405 + 'is_required' => '1',
422 406 );
423 407
424 - $fields = apply_filters('uwp_default_custom_fields_forgot', $fields);
408 + $fields = apply_filters( 'uwp_default_custom_fields_forgot', $fields );
425 409
426 410 return $fields;
427 411 }
428 412
@@ -432,35 +416,35 @@
432 416 * @since 1.0.0
433 417 * @package userswp
434 418 * @return array Avatar form default custom fields.
435 419 */
436 - public static function uwp_default_custom_fields_avatar(){
420 + public static function uwp_default_custom_fields_avatar() {
437 421
438 422 $fields = array();
439 423
440 424 $fields[] = array(
441 - 'form_type' => 'avatar',
442 - 'field_type' => 'file',
443 - 'data_type' => 'TEXT',
444 - 'site_title' => __('Avatar', 'userswp'),
445 - 'htmlvar_name' => 'file',
425 + 'form_type' => 'avatar',
426 + 'field_type' => 'file',
427 + 'data_type' => 'TEXT',
428 + 'site_title' => __( 'Avatar', 'userswp' ),
429 + 'htmlvar_name' => 'avatar',
446 430 'default_value' => '',
447 431 'option_values' => '',
448 - 'is_default' => '1',
449 - 'is_active' => '1',
450 - 'is_required' => '1',
451 - 'extra_fields' => array(
452 - 'uwp_file_types' => array(
432 + 'is_default' => '1',
433 + 'is_active' => '1',
434 + 'is_required' => '1',
435 + 'extra_fields' => array(
436 + 'uwp_file_types' => array(
453 437 'jpg',
454 438 'jpe',
455 439 'jpeg',
456 440 'gif',
457 - 'png'
441 + 'png',
458 442 ),
459 - )
443 + ),
460 444 );
461 445
462 - $fields = apply_filters('uwp_default_custom_fields_avatar', $fields);
446 + $fields = apply_filters( 'uwp_default_custom_fields_avatar', $fields );
463 447
464 448 return $fields;
465 449 }
466 450
@@ -470,35 +454,35 @@
470 454 * @since 1.0.0
471 455 * @package userswp
472 456 * @return array Banner form default custom fields.
473 457 */
474 - public static function uwp_default_custom_fields_banner(){
458 + public static function uwp_default_custom_fields_banner() {
475 459
476 460 $fields = array();
477 461
478 462 $fields[] = array(
479 - 'form_type' => 'banner',
480 - 'field_type' => 'file',
481 - 'data_type' => 'TEXT',
482 - 'site_title' => __('Banner', 'userswp'),
483 - 'htmlvar_name' => 'file',
463 + 'form_type' => 'banner',
464 + 'field_type' => 'file',
465 + 'data_type' => 'TEXT',
466 + 'site_title' => __( 'Banner', 'userswp' ),
467 + 'htmlvar_name' => 'banner',
484 468 'default_value' => '',
485 469 'option_values' => '',
486 - 'is_default' => '1',
487 - 'is_active' => '1',
488 - 'is_required' => '1',
489 - 'extra_fields' => array(
490 - 'uwp_file_types' => array(
470 + 'is_default' => '1',
471 + 'is_active' => '1',
472 + 'is_required' => '1',
473 + 'extra_fields' => array(
474 + 'uwp_file_types' => array(
491 475 'jpg',
492 476 'jpe',
493 477 'jpeg',
494 478 'gif',
495 - 'png'
479 + 'png',
496 480 ),
497 - )
481 + ),
498 482 );
499 483
500 - $fields = apply_filters('uwp_default_custom_fields_banner', $fields);
484 + $fields = apply_filters( 'uwp_default_custom_fields_banner', $fields );
501 485
502 486 return $fields;
503 487 }
504 488
@@ -508,52 +492,52 @@
508 492 * @since 1.0.0
509 493 * @package userswp
510 494 * @return array Change Password form default custom fields.
511 495 */
512 - public static function uwp_default_custom_fields_change(){
496 + public static function uwp_default_custom_fields_change() {
513 497
514 498 $fields = array();
515 499
516 500 $fields[] = array(
517 - 'form_type' => 'change',
518 - 'field_type' => 'password',
519 - 'data_type' => 'XVARCHAR',
520 - 'site_title' => __('Old Password', 'userswp'),
521 - 'htmlvar_name' => 'old_password',
501 + 'form_type' => 'change',
502 + 'field_type' => 'password',
503 + 'data_type' => 'XVARCHAR',
504 + 'site_title' => __( 'Old Password', 'userswp' ),
505 + 'htmlvar_name' => 'old_password',
522 506 'default_value' => '',
523 507 'option_values' => '',
524 - 'is_default' => '1',
525 - 'is_active' => '1',
526 - 'is_required' => '1'
508 + 'is_default' => '1',
509 + 'is_active' => '1',
510 + 'is_required' => '1',
527 511 );
528 512
529 513 $fields[] = array(
530 - 'form_type' => 'change',
531 - 'field_type' => 'password',
532 - 'data_type' => 'XVARCHAR',
533 - 'site_title' => __('New Password', 'userswp'),
534 - 'htmlvar_name' => 'password',
514 + 'form_type' => 'change',
515 + 'field_type' => 'password',
516 + 'data_type' => 'XVARCHAR',
517 + 'site_title' => __( 'New Password', 'userswp' ),
518 + 'htmlvar_name' => 'password',
535 519 'default_value' => '',
536 520 'option_values' => '',
537 - 'is_default' => '1',
538 - 'is_active' => '1',
539 - 'is_required' => '1'
521 + 'is_default' => '1',
522 + 'is_active' => '1',
523 + 'is_required' => '1',
540 524 );
541 525
542 526 $fields[] = array(
543 - 'form_type' => 'change',
544 - 'field_type' => 'password',
545 - 'data_type' => 'XVARCHAR',
546 - 'site_title' => __('Confirm Password', 'userswp'),
547 - 'htmlvar_name' => 'confirm_password',
527 + 'form_type' => 'change',
528 + 'field_type' => 'password',
529 + 'data_type' => 'XVARCHAR',
530 + 'site_title' => __( 'Confirm Password', 'userswp' ),
531 + 'htmlvar_name' => 'confirm_password',
548 532 'default_value' => '',
549 533 'option_values' => '',
550 - 'is_default' => '1',
551 - 'is_active' => '1',
552 - 'is_required' => '1'
534 + 'is_default' => '1',
535 + 'is_active' => '1',
536 + 'is_required' => '1',
553 537 );
554 538
555 - $fields = apply_filters('uwp_default_custom_fields_change', $fields);
539 + $fields = apply_filters( 'uwp_default_custom_fields_change', $fields );
556 540
557 541 return $fields;
558 542 }
559 543
@@ -563,39 +547,39 @@
563 547 * @since 1.0.0
564 548 * @package userswp
565 549 * @return array Reset Password form default custom fields.
566 550 */
567 - public static function uwp_default_custom_fields_reset(){
551 + public static function uwp_default_custom_fields_reset() {
568 552
569 553 $fields = array();
570 554
571 555 $fields[] = array(
572 - 'form_type' => 'reset',
573 - 'field_type' => 'password',
574 - 'data_type' => 'XVARCHAR',
575 - 'site_title' => __('Password', 'userswp'),
576 - 'htmlvar_name' => 'password',
556 + 'form_type' => 'reset',
557 + 'field_type' => 'password',
558 + 'data_type' => 'XVARCHAR',
559 + 'site_title' => __( 'Password', 'userswp' ),
560 + 'htmlvar_name' => 'password',
577 561 'default_value' => '',
578 562 'option_values' => '',
579 - 'is_default' => '1',
580 - 'is_active' => '1',
581 - 'is_required' => '1'
563 + 'is_default' => '1',
564 + 'is_active' => '1',
565 + 'is_required' => '1',
582 566 );
583 567
584 568 $fields[] = array(
585 - 'form_type' => 'reset',
586 - 'field_type' => 'password',
587 - 'data_type' => 'XVARCHAR',
588 - 'site_title' => __('Confirm Password', 'userswp'),
589 - 'htmlvar_name' => 'confirm_password',
569 + 'form_type' => 'reset',
570 + 'field_type' => 'password',
571 + 'data_type' => 'XVARCHAR',
572 + 'site_title' => __( 'Confirm Password', 'userswp' ),
573 + 'htmlvar_name' => 'confirm_password',
590 574 'default_value' => '',
591 575 'option_values' => '',
592 - 'is_default' => '1',
593 - 'is_active' => '1',
594 - 'is_required' => '1'
576 + 'is_default' => '1',
577 + 'is_active' => '1',
578 + 'is_required' => '1',
595 579 );
596 580
597 - $fields = apply_filters('uwp_default_custom_fields_reset', $fields);
581 + $fields = apply_filters( 'uwp_default_custom_fields_reset', $fields );
598 582
599 583 return $fields;
600 584 }
601 585
@@ -605,132 +589,128 @@
605 589 * @since 1.0.0
606 590 * @package userswp
607 591 * @return array Account form default custom fields.
608 592 */
609 - public static function uwp_default_custom_fields_account(){
593 + public static function uwp_default_custom_fields_account() {
610 594
611 595 $fields = array();
612 596
613 597 $fields[] = array(
614 - 'form_type' => 'account',
615 - 'field_type' => 'text',
616 - 'data_type' => 'XVARCHAR',
617 - 'site_title' => __('First Name', 'userswp'),
618 - 'htmlvar_name' => 'first_name',
619 - 'default_value' => '',
620 - 'option_values' => '',
621 - 'is_default' => '1',
622 - 'is_public' => '1',
623 - 'is_active' => '1',
624 - 'is_required' => '1',
598 + 'form_type' => 'account',
599 + 'field_type' => 'text',
600 + 'data_type' => 'XVARCHAR',
601 + 'site_title' => __( 'First Name', 'userswp' ),
602 + 'htmlvar_name' => 'first_name',
603 + 'default_value' => '',
604 + 'option_values' => '',
605 + 'is_default' => '1',
606 + 'is_public' => '1',
607 + 'is_active' => '1',
608 + 'is_required' => '1',
625 609 'is_register_field' => '1',
626 - 'is_search_field' => '1',
627 - 'css_class' => 'uwp-half uwp-half-left',
610 + 'is_search_field' => '1',
628 611 );
629 612
630 613 $fields[] = array(
631 - 'form_type' => 'account',
632 - 'field_type' => 'text',
633 - 'data_type' => 'XVARCHAR',
634 - 'site_title' => __('Last Name', 'userswp'),
635 - 'htmlvar_name' => 'last_name',
636 - 'default_value' => '',
637 - 'option_values' => '',
638 - 'is_default' => '1',
639 - 'is_public' => '1',
640 - 'is_active' => '1',
641 - 'is_required' => '1',
614 + 'form_type' => 'account',
615 + 'field_type' => 'text',
616 + 'data_type' => 'XVARCHAR',
617 + 'site_title' => __( 'Last Name', 'userswp' ),
618 + 'htmlvar_name' => 'last_name',
619 + 'default_value' => '',
620 + 'option_values' => '',
621 + 'is_default' => '1',
622 + 'is_public' => '1',
623 + 'is_active' => '1',
624 + 'is_required' => '1',
642 625 'is_register_field' => '1',
643 - 'is_search_field' => '1',
644 - 'css_class' => 'uwp-half uwp-half-right',
626 + 'is_search_field' => '1',
645 627 );
646 628
647 629 $fields[] = array(
648 - 'form_type' => 'account',
649 - 'field_type' => 'text',
650 - 'data_type' => 'XVARCHAR',
651 - 'site_title' => __('Username', 'userswp'),
652 - 'htmlvar_name' => 'username',
653 - 'default_value' => '',
654 - 'option_values' => '',
655 - 'is_default' => '1',
656 - 'is_public' => '1',
657 - 'is_active' => '1',
658 - 'is_required' => '1',
659 - 'is_register_field' => '1',
660 - 'is_search_field' => '1',
630 + 'form_type' => 'account',
631 + 'field_type' => 'text',
632 + 'data_type' => 'XVARCHAR',
633 + 'site_title' => __( 'Username', 'userswp' ),
634 + 'htmlvar_name' => 'username',
635 + 'default_value' => '',
636 + 'option_values' => '',
637 + 'is_default' => '1',
638 + 'is_public' => '1',
639 + 'is_active' => '1',
640 + 'is_required' => '1',
641 + 'is_register_field' => '1',
642 + 'is_search_field' => '1',
661 643 'is_register_only_field' => '1',
662 644 );
663 645
664 646 $fields[] = array(
665 - 'form_type' => 'account',
666 - 'field_type' => 'text',
667 - 'data_type' => 'XVARCHAR',
668 - 'site_title' => __('Display Name', 'userswp'),
669 - 'htmlvar_name' => 'display_name',
670 - 'default_value' => '',
671 - 'option_values' => '',
672 - 'is_default' => '1',
673 - 'is_public' => '1',
674 - 'is_active' => '1',
675 - 'is_required' => '0',
647 + 'form_type' => 'account',
648 + 'field_type' => 'text',
649 + 'data_type' => 'XVARCHAR',
650 + 'site_title' => __( 'Display Name', 'userswp' ),
651 + 'htmlvar_name' => 'display_name',
652 + 'default_value' => '',
653 + 'option_values' => '',
654 + 'is_default' => '1',
655 + 'is_public' => '1',
656 + 'is_active' => '1',
657 + 'is_required' => '0',
676 658 'is_register_field' => '0',
677 - 'is_search_field' => '1',
659 + 'is_search_field' => '1',
678 660 );
679 661
680 662 $fields[] = array(
681 - 'form_type' => 'account',
682 - 'field_type' => 'email',
683 - 'data_type' => 'XVARCHAR',
684 - 'site_title' => __('Email', 'userswp'),
685 - 'htmlvar_name' => 'email',
686 - 'default_value' => '',
687 - 'option_values' => '',
688 - 'is_default' => '1',
689 - 'is_active' => '1',
690 - 'is_required' => '1',
663 + 'form_type' => 'account',
664 + 'field_type' => 'email',
665 + 'data_type' => 'XVARCHAR',
666 + 'site_title' => __( 'Email', 'userswp' ),
667 + 'htmlvar_name' => 'email',
668 + 'default_value' => '',
669 + 'option_values' => '',
670 + 'is_default' => '1',
671 + 'is_active' => '1',
672 + 'is_required' => '1',
691 673 'is_register_field' => '1',
692 - 'is_search_field' => '1',
674 + 'is_search_field' => '1',
693 675 );
694 676
695 -
696 677 $fields[] = array(
697 - 'form_type' => 'account',
698 - 'field_type' => 'textarea',
699 - 'data_type' => 'TEXT',
700 - 'site_title' => __('Bio', 'userswp'),
701 - 'htmlvar_name' => 'bio',
702 - 'default_value' => '',
703 - 'option_values' => '',
704 - 'is_default' => '1',
705 - 'is_active' => '1',
706 - 'is_public' => '1',
707 - 'is_required' => '1',
678 + 'form_type' => 'account',
679 + 'field_type' => 'textarea',
680 + 'data_type' => 'TEXT',
681 + 'site_title' => __( 'Bio', 'userswp' ),
682 + 'htmlvar_name' => 'bio',
683 + 'default_value' => '',
684 + 'option_values' => '',
685 + 'is_default' => '0',
686 + 'is_active' => '1',
687 + 'is_public' => '1',
688 + 'is_required' => '1',
708 689 'is_search_field' => '1',
709 - 'show_in' => array('[profile_side]', '[users]')
690 + 'show_in' => array( '[users]' ),
710 691 );
711 692
712 693 $fields[] = array(
713 - 'form_type' => 'account',
714 - 'field_type' => 'password',
715 - 'data_type' => 'XVARCHAR',
716 - 'site_title' => __('Password', 'userswp'),
717 - 'htmlvar_name' => 'password',
718 - 'default_value' => '',
719 - 'option_values' => '',
720 - 'is_default' => '1',
721 - 'is_active' => '1',
722 - 'is_required' => '1',
723 - 'is_register_field' => '1',
694 + 'form_type' => 'account',
695 + 'field_type' => 'password',
696 + 'data_type' => 'XVARCHAR',
697 + 'site_title' => __( 'Password', 'userswp' ),
698 + 'htmlvar_name' => 'password',
699 + 'default_value' => '',
700 + 'option_values' => '',
701 + 'is_default' => '1',
702 + 'is_active' => '1',
703 + 'is_required' => '1',
704 + 'is_register_field' => '1',
724 705 'is_register_only_field' => '1',
725 - 'extra' => array(
726 - 'confirm_password' => '1'
727 - )
706 + 'extra' => array(
707 + 'confirm_password' => '1',
708 + ),
728 709 );
729 710
711 + $fields = apply_filters( 'uwp_default_custom_fields_account', $fields );
730 712
731 - $fields = apply_filters('uwp_default_custom_fields_account', $fields);
732 -
733 713 return $fields;
734 714 }
735 715
736 716 /**
@@ -739,9 +719,9 @@
739 719 * @since 1.0.0
740 720 * @package userswp
741 721 * @return void
742 722 */
743 - public static function uwp_flush_rewrite_rules() {
723 + public static function flush_rewrite_rules() {
744 724 flush_rewrite_rules();
745 725 }
746 726
747 727 /**
@@ -750,9 +730,9 @@
750 730 * @since 1.0.0
751 731 * @package userswp
752 732 * @return void
753 733 */
754 - public static function uwp_insert_form_extras() {
734 + public static function insert_form_extras( $form_id = 1 ) {
755 735 global $wpdb;
756 736 $extras_table_name = uwp_get_table_prefix() . 'uwp_form_extras';
757 737
758 738 $fields = array();
@@ -757,61 +737,61 @@
757 737
758 738 $fields = array();
759 739
760 740 $fields[] = array(
761 - 'form_type' => 'register',
762 - 'field_type' => 'text',
763 - 'is_default' => '1',
764 - 'htmlvar_name' => 'uwp_account_first_name'
741 + 'form_type' => 'register',
742 + 'field_type' => 'text',
743 + 'is_default' => '0',
744 + 'htmlvar_name' => 'first_name',
765 745 );
766 746
767 747 $fields[] = array(
768 - 'form_type' => 'register',
769 - 'field_type' => 'text',
770 - 'is_default' => '1',
771 - 'htmlvar_name' => 'uwp_account_last_name'
748 + 'form_type' => 'register',
749 + 'field_type' => 'text',
750 + 'is_default' => '0',
751 + 'htmlvar_name' => 'last_name',
772 752 );
773 753
774 754 $fields[] = array(
775 - 'form_type' => 'register',
776 - 'field_type' => 'text',
777 - 'is_default' => '1',
778 - 'htmlvar_name' => 'uwp_account_username'
755 + 'form_type' => 'register',
756 + 'field_type' => 'text',
757 + 'is_default' => '1',
758 + 'htmlvar_name' => 'username',
779 759 );
780 760
781 761 $fields[] = array(
782 - 'form_type' => 'register',
783 - 'field_type' => 'email',
784 - 'is_default' => '1',
785 - 'htmlvar_name' => 'uwp_account_email'
762 + 'form_type' => 'register',
763 + 'field_type' => 'email',
764 + 'is_default' => '1',
765 + 'htmlvar_name' => 'email',
786 766 );
787 767
788 768 $fields[] = array(
789 - 'form_type' => 'register',
790 - 'field_type' => 'password',
791 - 'is_default' => '1',
792 - 'htmlvar_name' => 'uwp_account_password'
769 + 'form_type' => 'register',
770 + 'field_type' => 'password',
771 + 'is_default' => '0',
772 + 'htmlvar_name' => 'password',
793 773 );
794 774
795 -
796 - foreach ($fields as $field) {
797 - $last_order = $wpdb->get_var("SELECT MAX(sort_order) as last_order FROM " . $extras_table_name);
775 + foreach ( $fields as $field ) {
776 + $last_order = $wpdb->get_var( 'SELECT MAX(sort_order) as last_order FROM ' . $extras_table_name . ' where form_id = ' . $form_id );
798 777 $sort_order = (int)$last_order + 1;
799 778 $wpdb->query(
800 779 $wpdb->prepare(
801 -
802 - "insert into " . $extras_table_name . " set
780 + 'insert into ' . $extras_table_name . ' set
803 781 form_type = %s,
804 782 field_type = %s,
805 783 is_default = %s,
806 784 site_htmlvar_name = %s,
807 - sort_order = %s",
785 + sort_order = %s,
786 + form_id = %s',
808 787 array(
809 788 $field['form_type'],
810 789 $field['field_type'],
811 790 $field['is_default'],
812 791 $field['htmlvar_name'],
813 - $sort_order
792 + $sort_order,
793 + $form_id,
814 794 )
815 795 )
816 796 );
817 797 }
@@ -816,5 +796,66 @@
816 796 );
817 797 }
818 798 }
819 799
820 -}
800 + /**
801 + * Performs automatic upgrade
802 + *
803 + * @since 2.0.0
804 + * @package userswp
805 + * @return void
806 + */
807 + public static function automatic_upgrade() {
808 + $uwp_db_version = get_option( 'uwp_db_version' );
809 +
810 + if ( $uwp_db_version != USERSWP_VERSION ) {
811 + self::activate( is_plugin_active_for_network( 'userswp/userswp.php' ) );
812 + $settings = get_option( 'uwp_settings', array() );
813 + $needs_update = false;
814 + if ( isset( $settings['design_style'] ) && 'bootstrap' == $settings['design_style'] ) {
815 + $settings['users_default_layout'] = '3col';
816 + $needs_update = true;
817 + }
818 +
819 + if ( isset( $settings['uwp_registration_action'] ) && $settings['uwp_registration_action'] == 'force_redirect' ) {
820 + $settings['uwp_registration_action'] = 'auto_approve_login';
821 + $needs_update = true;
822 + }
823 +
824 + $get_register_form = isset( $settings['multiple_registration_forms'] ) ? $settings['multiple_registration_forms'] : false;
825 +
826 + if ( ! empty( $get_register_form ) && is_array( $get_register_form ) ) {
827 +
828 + foreach ( $get_register_form as $key => $register_form ) {
829 +
830 + if ( ! empty( $register_form['id'] ) ) {
831 +
832 + $reg_action = isset( $register_form['reg_action'] ) ? $register_form['reg_action'] : '';
833 +
834 + if ( isset( $reg_action ) && $reg_action == 'force_redirect' ) {
835 + $settings['multiple_registration_forms'][ $key ]['reg_action'] = 'auto_approve_login';
836 + $needs_update = true;
837 + }
838 +
839 + $reg_title = isset( $register_form['title'] ) ? $register_form['title'] : '';
840 +
841 + if ( isset( $reg_title ) && ! empty( $reg_title ) ) {
842 + $clean_title = sanitize_text_field( $reg_title );
843 + if ( $clean_title !== $reg_title ) {
844 + $settings['multiple_registration_forms'][ $key ]['title'] = $clean_title;
845 + $needs_update = true;
846 + }
847 + }
848 + }
849 + }
850 + }
851 +
852 + if ( $needs_update ) {
853 + update_option( 'uwp_settings', $settings );
854 + }
855 +
856 + // Run this function once.
857 + update_option( 'uwp_db_version', USERSWP_VERSION );
858 +
859 + }
860 + }
861 +}