PluginProbe
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP / 1.2.3.4
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP v1.2.3.4
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 1.0.22 1.0.23 All 172 releases
userswp / includes / class-activator.php

class-activator.php in UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP 1.2.3.4, at includes/class-activator.php

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