File tree Expand file tree Collapse file tree 2 files changed +48
-0
lines changed Expand file tree Collapse file tree 2 files changed +48
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Upgrade routines.
4
+ *
5
+ * @package WP Approve User
6
+ */
7
+
8
+ /**
9
+ * Upgrade routine.
10
+ */
11
+ function wpau_upgrade_all () {
12
+ global $ wpau_db_version ;
13
+
14
+ $ wpau_current_db_version = get_site_option ( 'wpau_db_version ' , 0 );
15
+
16
+ if ( $ wpau_current_db_version === $ wpau_db_version ) {
17
+ return ;
18
+ }
19
+
20
+ if ( $ wpau_current_db_version < 12 ) {
21
+ wpau_upgrade_to_12 ();
22
+ }
23
+
24
+ update_site_option ( 'wpau_db_version ' , $ wpau_db_version );
25
+ }
26
+ add_action ( 'admin_init ' , 'wpau_upgrade_all ' );
27
+
28
+ /**
29
+ * Updates all user meta values from true to 'approved'.
30
+ */
31
+ function wpau_upgrade_to_12 () {
32
+ global $ wpdb ;
33
+
34
+ // phpcs:disable WordPress.DB
35
+ $ wpdb ->update (
36
+ $ wpdb ->usermeta ,
37
+ array ( 'meta_value ' => 'approved ' ),
38
+ array (
39
+ 'meta_key ' => 'wp-approve-user ' ,
40
+ 'meta_value ' => true ,
41
+ )
42
+ );
43
+ // phpcs:enable WordPress.DB
44
+ }
Original file line number Diff line number Diff line change 18
18
return ;
19
19
}
20
20
21
+ // Define the current version for upgrades.
22
+ $ wpau_db_version = 12 ;
23
+
21
24
if ( ! class_exists ( 'Obenland_Wp_Plugins_V5 ' ) ) {
22
25
require_once __DIR__ . '/class-obenland-wp-plugins-v5.php ' ;
23
26
}
24
27
25
28
require_once __DIR__ . '/class-obenland-wp-approve-user.php ' ;
26
29
require_once __DIR__ . '/cron-events.php ' ;
30
+ require_once __DIR__ . '/upgrade.php ' ;
27
31
28
32
/**
29
33
* Instantiates Obenland_Wp_Approve_User.
You can’t perform that action at this time.
0 commit comments