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 -439 1.0.181.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,186 +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);
310 - uwp_update_usermeta($user_id, 'uwp_account_display_name', $user_data->display_name);
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
311 296 }
312 297 }
313 298
314 299 /**
@@ -317,18 +302,17 @@
317 302 * @since 1.0.0
318 303 * @package userswp
319 304 * @return void
320 305 */
321 - public static function uwp_create_default_fields()
322 - {
306 + public static function create_default_fields() {
323 307 $form_builder = new UsersWP_Form_Builder();
324 308
325 309 $fields = self::uwp_default_custom_fields();
326 310
327 - $fields = apply_filters('uwp_before_default_custom_fields_saved', $fields);
311 + $fields = apply_filters( 'uwp_before_default_custom_fields_saved', $fields );
328 312
329 - foreach ($fields as $field_index => $field) {
330 - $form_builder->uwp_admin_form_field_save($field);
313 + foreach ( $fields as $field_index => $field ) {
314 + $form_builder->admin_form_field_save( $field );
331 315 }
332 316 }
333 317
334 318 /**
@@ -337,9 +321,9 @@
337 321 * @since 1.0.0
338 322 * @package userswp
339 323 * @return array Merged custom fields.
340 324 */
341 - public static function uwp_default_custom_fields(){
325 + public static function uwp_default_custom_fields() {
342 326
343 327 $login = self::uwp_default_custom_fields_login();
344 328 $forgot = self::uwp_default_custom_fields_forgot();
345 329 $avatar = self::uwp_default_custom_fields_avatar();
@@ -347,14 +331,13 @@
347 331 $change = self::uwp_default_custom_fields_change();
348 332 $reset = self::uwp_default_custom_fields_reset();
349 333 $account = self::uwp_default_custom_fields_account();
350 334
351 - $fields = array_merge($login, $forgot, $account, $avatar, $banner, $change, $reset);
335 + $fields = array_merge( $login, $forgot, $account, $avatar, $banner, $change, $reset );
352 336
353 - $fields = apply_filters('uwp_default_custom_fields', $fields);
337 + $fields = apply_filters( 'uwp_default_custom_fields', $fields );
354 338
355 339 return $fields;
356 -
357 340 }
358 341
359 342 /**
360 343 * Returns Login form default custom fields.
@@ -362,39 +345,39 @@
362 345 * @since 1.0.0
363 346 * @package userswp
364 347 * @return array Login form default custom fields.
365 348 */
366 - public static function uwp_default_custom_fields_login(){
349 + public static function uwp_default_custom_fields_login() {
367 350
368 351 $fields = array();
369 352
370 353 $fields[] = array(
371 - 'form_type' => 'login',
372 - 'field_type' => 'text',
373 - 'data_type' => 'XVARCHAR',
374 - 'site_title' => __('Username', 'userswp'),
375 - 'htmlvar_name' => 'username',
354 + 'form_type' => 'login',
355 + 'field_type' => 'text',
356 + 'data_type' => 'XVARCHAR',
357 + 'site_title' => __( 'Username', 'userswp' ),
358 + 'htmlvar_name' => 'username',
376 359 'default_value' => '',
377 360 'option_values' => '',
378 - 'is_default' => '1',
379 - 'is_active' => '1',
380 - 'is_required' => '1'
361 + 'is_default' => '1',
362 + 'is_active' => '1',
363 + 'is_required' => '1',
381 364 );
382 365
383 366 $fields[] = array(
384 - 'form_type' => 'login',
385 - 'field_type' => 'password',
386 - 'data_type' => 'XVARCHAR',
387 - 'site_title' => __('Password', 'userswp'),
388 - 'htmlvar_name' => 'password',
367 + 'form_type' => 'login',
368 + 'field_type' => 'password',
369 + 'data_type' => 'XVARCHAR',
370 + 'site_title' => __( 'Password', 'userswp' ),
371 + 'htmlvar_name' => 'password',
389 372 'default_value' => '',
390 373 'option_values' => '',
391 - 'is_default' => '1',
392 - 'is_active' => '1',
393 - 'is_required' => '1'
374 + 'is_default' => '1',
375 + 'is_active' => '1',
376 + 'is_required' => '1',
394 377 );
395 378
396 - $fields = apply_filters('uwp_default_custom_fields_login', $fields);
379 + $fields = apply_filters( 'uwp_default_custom_fields_login', $fields );
397 380
398 381 return $fields;
399 382 }
400 383
@@ -404,26 +387,26 @@
404 387 * @since 1.0.0
405 388 * @package userswp
406 389 * @return array Forgot form default custom fields.
407 390 */
408 - public static function uwp_default_custom_fields_forgot(){
391 + public static function uwp_default_custom_fields_forgot() {
409 392
410 393 $fields = array();
411 394
412 395 $fields[] = array(
413 - 'form_type' => 'forgot',
414 - 'field_type' => 'email',
415 - 'data_type' => 'XVARCHAR',
416 - 'site_title' => __('Email', 'userswp'),
417 - 'htmlvar_name' => 'email',
396 + 'form_type' => 'forgot',
397 + 'field_type' => 'email',
398 + 'data_type' => 'XVARCHAR',
399 + 'site_title' => __( 'Email', 'userswp' ),
400 + 'htmlvar_name' => 'email',
418 401 'default_value' => '',
419 402 'option_values' => '',
420 - 'is_default' => '1',
421 - 'is_active' => '1',
422 - 'is_required' => '1'
403 + 'is_default' => '1',
404 + 'is_active' => '1',
405 + 'is_required' => '1',
423 406 );
424 407
425 - $fields = apply_filters('uwp_default_custom_fields_forgot', $fields);
408 + $fields = apply_filters( 'uwp_default_custom_fields_forgot', $fields );
426 409
427 410 return $fields;
428 411 }
429 412
@@ -433,35 +416,35 @@
433 416 * @since 1.0.0
434 417 * @package userswp
435 418 * @return array Avatar form default custom fields.
436 419 */
437 - public static function uwp_default_custom_fields_avatar(){
420 + public static function uwp_default_custom_fields_avatar() {
438 421
439 422 $fields = array();
440 423
441 424 $fields[] = array(
442 - 'form_type' => 'avatar',
443 - 'field_type' => 'file',
444 - 'data_type' => 'TEXT',
445 - 'site_title' => __('Avatar', 'userswp'),
446 - 'htmlvar_name' => 'file',
425 + 'form_type' => 'avatar',
426 + 'field_type' => 'file',
427 + 'data_type' => 'TEXT',
428 + 'site_title' => __( 'Avatar', 'userswp' ),
429 + 'htmlvar_name' => 'avatar',
447 430 'default_value' => '',
448 431 'option_values' => '',
449 - 'is_default' => '1',
450 - 'is_active' => '1',
451 - 'is_required' => '1',
452 - 'extra_fields' => array(
453 - '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(
454 437 'jpg',
455 438 'jpe',
456 439 'jpeg',
457 440 'gif',
458 - 'png'
441 + 'png',
459 442 ),
460 - )
443 + ),
461 444 );
462 445
463 - $fields = apply_filters('uwp_default_custom_fields_avatar', $fields);
446 + $fields = apply_filters( 'uwp_default_custom_fields_avatar', $fields );
464 447
465 448 return $fields;
466 449 }
467 450
@@ -471,35 +454,35 @@
471 454 * @since 1.0.0
472 455 * @package userswp
473 456 * @return array Banner form default custom fields.
474 457 */
475 - public static function uwp_default_custom_fields_banner(){
458 + public static function uwp_default_custom_fields_banner() {
476 459
477 460 $fields = array();
478 461
479 462 $fields[] = array(
480 - 'form_type' => 'banner',
481 - 'field_type' => 'file',
482 - 'data_type' => 'TEXT',
483 - 'site_title' => __('Banner', 'userswp'),
484 - 'htmlvar_name' => 'file',
463 + 'form_type' => 'banner',
464 + 'field_type' => 'file',
465 + 'data_type' => 'TEXT',
466 + 'site_title' => __( 'Banner', 'userswp' ),
467 + 'htmlvar_name' => 'banner',
485 468 'default_value' => '',
486 469 'option_values' => '',
487 - 'is_default' => '1',
488 - 'is_active' => '1',
489 - 'is_required' => '1',
490 - 'extra_fields' => array(
491 - '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(
492 475 'jpg',
493 476 'jpe',
494 477 'jpeg',
495 478 'gif',
496 - 'png'
479 + 'png',
497 480 ),
498 - )
481 + ),
499 482 );
500 483
501 - $fields = apply_filters('uwp_default_custom_fields_banner', $fields);
484 + $fields = apply_filters( 'uwp_default_custom_fields_banner', $fields );
502 485
503 486 return $fields;
504 487 }
505 488
@@ -509,52 +492,52 @@
509 492 * @since 1.0.0
510 493 * @package userswp
511 494 * @return array Change Password form default custom fields.
512 495 */
513 - public static function uwp_default_custom_fields_change(){
496 + public static function uwp_default_custom_fields_change() {
514 497
515 498 $fields = array();
516 499
517 500 $fields[] = array(
518 - 'form_type' => 'change',
519 - 'field_type' => 'password',
520 - 'data_type' => 'XVARCHAR',
521 - 'site_title' => __('Old Password', 'userswp'),
522 - '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',
523 506 'default_value' => '',
524 507 'option_values' => '',
525 - 'is_default' => '1',
526 - 'is_active' => '1',
527 - 'is_required' => '1'
508 + 'is_default' => '1',
509 + 'is_active' => '1',
510 + 'is_required' => '1',
528 511 );
529 512
530 513 $fields[] = array(
531 - 'form_type' => 'change',
532 - 'field_type' => 'password',
533 - 'data_type' => 'XVARCHAR',
534 - 'site_title' => __('New Password', 'userswp'),
535 - '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',
536 519 'default_value' => '',
537 520 'option_values' => '',
538 - 'is_default' => '1',
539 - 'is_active' => '1',
540 - 'is_required' => '1'
521 + 'is_default' => '1',
522 + 'is_active' => '1',
523 + 'is_required' => '1',
541 524 );
542 525
543 526 $fields[] = array(
544 - 'form_type' => 'change',
545 - 'field_type' => 'password',
546 - 'data_type' => 'XVARCHAR',
547 - 'site_title' => __('Confirm Password', 'userswp'),
548 - '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',
549 532 'default_value' => '',
550 533 'option_values' => '',
551 - 'is_default' => '1',
552 - 'is_active' => '1',
553 - 'is_required' => '1'
534 + 'is_default' => '1',
535 + 'is_active' => '1',
536 + 'is_required' => '1',
554 537 );
555 538
556 - $fields = apply_filters('uwp_default_custom_fields_change', $fields);
539 + $fields = apply_filters( 'uwp_default_custom_fields_change', $fields );
557 540
558 541 return $fields;
559 542 }
560 543
@@ -564,39 +547,39 @@
564 547 * @since 1.0.0
565 548 * @package userswp
566 549 * @return array Reset Password form default custom fields.
567 550 */
568 - public static function uwp_default_custom_fields_reset(){
551 + public static function uwp_default_custom_fields_reset() {
569 552
570 553 $fields = array();
571 554
572 555 $fields[] = array(
573 - 'form_type' => 'reset',
574 - 'field_type' => 'password',
575 - 'data_type' => 'XVARCHAR',
576 - 'site_title' => __('Password', 'userswp'),
577 - 'htmlvar_name' => 'password',
556 + 'form_type' => 'reset',
557 + 'field_type' => 'password',
558 + 'data_type' => 'XVARCHAR',
559 + 'site_title' => __( 'Password', 'userswp' ),
560 + 'htmlvar_name' => 'password',
578 561 'default_value' => '',
579 562 'option_values' => '',
580 - 'is_default' => '1',
581 - 'is_active' => '1',
582 - 'is_required' => '1'
563 + 'is_default' => '1',
564 + 'is_active' => '1',
565 + 'is_required' => '1',
583 566 );
584 567
585 568 $fields[] = array(
586 - 'form_type' => 'reset',
587 - 'field_type' => 'password',
588 - 'data_type' => 'XVARCHAR',
589 - 'site_title' => __('Confirm Password', 'userswp'),
590 - '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',
591 574 'default_value' => '',
592 575 'option_values' => '',
593 - 'is_default' => '1',
594 - 'is_active' => '1',
595 - 'is_required' => '1'
576 + 'is_default' => '1',
577 + 'is_active' => '1',
578 + 'is_required' => '1',
596 579 );
597 580
598 - $fields = apply_filters('uwp_default_custom_fields_reset', $fields);
581 + $fields = apply_filters( 'uwp_default_custom_fields_reset', $fields );
599 582
600 583 return $fields;
601 584 }
602 585
@@ -606,132 +589,128 @@
606 589 * @since 1.0.0
607 590 * @package userswp
608 591 * @return array Account form default custom fields.
609 592 */
610 - public static function uwp_default_custom_fields_account(){
593 + public static function uwp_default_custom_fields_account() {
611 594
612 595 $fields = array();
613 596
614 597 $fields[] = array(
615 - 'form_type' => 'account',
616 - 'field_type' => 'text',
617 - 'data_type' => 'XVARCHAR',
618 - 'site_title' => __('First Name', 'userswp'),
619 - 'htmlvar_name' => 'first_name',
620 - 'default_value' => '',
621 - 'option_values' => '',
622 - 'is_default' => '1',
623 - 'is_public' => '1',
624 - 'is_active' => '1',
625 - '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',
626 609 'is_register_field' => '1',
627 - 'is_search_field' => '1',
628 - 'css_class' => 'uwp-half uwp-half-left',
610 + 'is_search_field' => '1',
629 611 );
630 612
631 613 $fields[] = array(
632 - 'form_type' => 'account',
633 - 'field_type' => 'text',
634 - 'data_type' => 'XVARCHAR',
635 - 'site_title' => __('Last Name', 'userswp'),
636 - 'htmlvar_name' => 'last_name',
637 - 'default_value' => '',
638 - 'option_values' => '',
639 - 'is_default' => '1',
640 - 'is_public' => '1',
641 - 'is_active' => '1',
642 - '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',
643 625 'is_register_field' => '1',
644 - 'is_search_field' => '1',
645 - 'css_class' => 'uwp-half uwp-half-right',
626 + 'is_search_field' => '1',
646 627 );
647 628
648 629 $fields[] = array(
649 - 'form_type' => 'account',
650 - 'field_type' => 'text',
651 - 'data_type' => 'XVARCHAR',
652 - 'site_title' => __('Username', 'userswp'),
653 - 'htmlvar_name' => 'username',
654 - 'default_value' => '',
655 - 'option_values' => '',
656 - 'is_default' => '1',
657 - 'is_public' => '1',
658 - 'is_active' => '1',
659 - 'is_required' => '1',
660 - 'is_register_field' => '1',
661 - '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',
662 643 'is_register_only_field' => '1',
663 644 );
664 645
665 646 $fields[] = array(
666 - 'form_type' => 'account',
667 - 'field_type' => 'text',
668 - 'data_type' => 'XVARCHAR',
669 - 'site_title' => __('Display Name', 'userswp'),
670 - 'htmlvar_name' => 'display_name',
671 - 'default_value' => '',
672 - 'option_values' => '',
673 - 'is_default' => '1',
674 - 'is_public' => '1',
675 - 'is_active' => '1',
676 - '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',
677 658 'is_register_field' => '0',
678 - 'is_search_field' => '1',
659 + 'is_search_field' => '1',
679 660 );
680 661
681 662 $fields[] = array(
682 - 'form_type' => 'account',
683 - 'field_type' => 'email',
684 - 'data_type' => 'XVARCHAR',
685 - 'site_title' => __('Email', 'userswp'),
686 - 'htmlvar_name' => 'email',
687 - 'default_value' => '',
688 - 'option_values' => '',
689 - 'is_default' => '1',
690 - 'is_active' => '1',
691 - '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',
692 673 'is_register_field' => '1',
693 - 'is_search_field' => '1',
674 + 'is_search_field' => '1',
694 675 );
695 676
696 -
697 677 $fields[] = array(
698 - 'form_type' => 'account',
699 - 'field_type' => 'textarea',
700 - 'data_type' => 'TEXT',
701 - 'site_title' => __('Bio', 'userswp'),
702 - 'htmlvar_name' => 'bio',
703 - 'default_value' => '',
704 - 'option_values' => '',
705 - 'is_default' => '1',
706 - 'is_active' => '1',
707 - 'is_public' => '1',
708 - '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',
709 689 'is_search_field' => '1',
710 - 'show_in' => array('[profile_side]', '[users]')
690 + 'show_in' => array( '[users]' ),
711 691 );
712 692
713 693 $fields[] = array(
714 - 'form_type' => 'account',
715 - 'field_type' => 'password',
716 - 'data_type' => 'XVARCHAR',
717 - 'site_title' => __('Password', 'userswp'),
718 - 'htmlvar_name' => 'password',
719 - 'default_value' => '',
720 - 'option_values' => '',
721 - 'is_default' => '1',
722 - 'is_active' => '1',
723 - 'is_required' => '1',
724 - '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',
725 705 'is_register_only_field' => '1',
726 - 'extra' => array(
727 - 'confirm_password' => '1'
728 - )
706 + 'extra' => array(
707 + 'confirm_password' => '1',
708 + ),
729 709 );
730 710
711 + $fields = apply_filters( 'uwp_default_custom_fields_account', $fields );
731 712
732 - $fields = apply_filters('uwp_default_custom_fields_account', $fields);
733 -
734 713 return $fields;
735 714 }
736 715
737 716 /**
@@ -740,9 +719,9 @@
740 719 * @since 1.0.0
741 720 * @package userswp
742 721 * @return void
743 722 */
744 - public static function uwp_flush_rewrite_rules() {
723 + public static function flush_rewrite_rules() {
745 724 flush_rewrite_rules();
746 725 }
747 726
748 727 /**
@@ -751,9 +730,9 @@
751 730 * @since 1.0.0
752 731 * @package userswp
753 732 * @return void
754 733 */
755 - public static function uwp_insert_form_extras() {
734 + public static function insert_form_extras( $form_id = 1 ) {
756 735 global $wpdb;
757 736 $extras_table_name = uwp_get_table_prefix() . 'uwp_form_extras';
758 737
759 738 $fields = array();
@@ -758,61 +737,61 @@
758 737
759 738 $fields = array();
760 739
761 740 $fields[] = array(
762 - 'form_type' => 'register',
763 - 'field_type' => 'text',
764 - 'is_default' => '1',
765 - 'htmlvar_name' => 'uwp_account_first_name'
741 + 'form_type' => 'register',
742 + 'field_type' => 'text',
743 + 'is_default' => '0',
744 + 'htmlvar_name' => 'first_name',
766 745 );
767 746
768 747 $fields[] = array(
769 - 'form_type' => 'register',
770 - 'field_type' => 'text',
771 - 'is_default' => '1',
772 - 'htmlvar_name' => 'uwp_account_last_name'
748 + 'form_type' => 'register',
749 + 'field_type' => 'text',
750 + 'is_default' => '0',
751 + 'htmlvar_name' => 'last_name',
773 752 );
774 753
775 754 $fields[] = array(
776 - 'form_type' => 'register',
777 - 'field_type' => 'text',
778 - 'is_default' => '1',
779 - 'htmlvar_name' => 'uwp_account_username'
755 + 'form_type' => 'register',
756 + 'field_type' => 'text',
757 + 'is_default' => '1',
758 + 'htmlvar_name' => 'username',
780 759 );
781 760
782 761 $fields[] = array(
783 - 'form_type' => 'register',
784 - 'field_type' => 'email',
785 - 'is_default' => '1',
786 - 'htmlvar_name' => 'uwp_account_email'
762 + 'form_type' => 'register',
763 + 'field_type' => 'email',
764 + 'is_default' => '1',
765 + 'htmlvar_name' => 'email',
787 766 );
788 767
789 768 $fields[] = array(
790 - 'form_type' => 'register',
791 - 'field_type' => 'password',
792 - 'is_default' => '1',
793 - 'htmlvar_name' => 'uwp_account_password'
769 + 'form_type' => 'register',
770 + 'field_type' => 'password',
771 + 'is_default' => '0',
772 + 'htmlvar_name' => 'password',
794 773 );
795 774
796 -
797 - foreach ($fields as $field) {
798 - $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 );
799 777 $sort_order = (int)$last_order + 1;
800 778 $wpdb->query(
801 779 $wpdb->prepare(
802 -
803 - "insert into " . $extras_table_name . " set
780 + 'insert into ' . $extras_table_name . ' set
804 781 form_type = %s,
805 782 field_type = %s,
806 783 is_default = %s,
807 784 site_htmlvar_name = %s,
808 - sort_order = %s",
785 + sort_order = %s,
786 + form_id = %s',
809 787 array(
810 788 $field['form_type'],
811 789 $field['field_type'],
812 790 $field['is_default'],
813 791 $field['htmlvar_name'],
814 - $sort_order
792 + $sort_order,
793 + $form_id,
815 794 )
816 795 )
817 796 );
818 797 }
@@ -817,5 +796,66 @@
817 796 );
818 797 }
819 798 }
820 799
821 -}
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 +}