-
Notifications
You must be signed in to change notification settings - Fork 32
/
updater.php
100 lines (87 loc) · 2.67 KB
/
updater.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?php
/**
* Updater class.
*
* @since 3.7.0
*/
class GES_Updater {
/**
* Constructor.
*
* @param bool $skip_admin_check Run updater code without admin check. Default: false.
* When false, our updater only runs on certain admin pages only. This
* currently includes the "Dashboard", "Dashboard > Updates" and
* "Plugins" pages. You should only set to true if you need to run the
* updater manually.
*/
public function __construct( $skip_admin_check = false ) {
// Skip admin check and run updater code.
if ( true === $skip_admin_check ) {
$this->init();
// Use admin check.
} else {
add_action( 'load-index.php', array( $this, '_init' ) );
add_action( 'load-update-core.php', array( $this, '_init' ) );
add_action( 'load-plugins.php', array( $this, '_init' ) );
}
}
/**
* Stub initializer.
*
* This is designed to prevent access to the main, protected init method.
*/
public function _init() {
if ( ! did_action( 'admin_init' ) ) {
return;
}
$this->init();
}
/**
* Update routine.
*/
protected function init() {
// Bail if BuddyPress isn't available.
if ( ! function_exists( 'bp_get_option' ) ) {
return;
}
$installed_date = (int) self::get_installed_revision_date();
// Sept 28, 2016 - Install email post types.
if ( $installed_date < 1475020800 && function_exists( 'bp_send_email' ) ) {
ass_install_emails( true );
}
// 3.9.0 - Install subscription table and migrate data.
if ( $installed_date < 1523891599 ) {
bp_update_option( '_ges_installed_before_39', 1 );
bpges_install_subscription_table();
bpges_install_queued_items_table();
bpges_39_launch_legacy_subscription_migration();
}
// Bump revision date in DB.
self::bump_revision_date();
}
/** REVISION DATE *************************************************/
/**
* Returns the current revision date as set in our loader.
*
* @return string The current revision date string (eg. 2014-01-01 01:00 UTC).
*/
public static function get_current_revision_date() {
return constant( 'GES_REVISION_DATE' );
}
/**
* Returns the revision date for the GES install as saved in the DB.
*
* @return int|bool Integer of the installed unix timestamp on success. Boolean false on failure.
*/
public static function get_installed_revision_date() {
return strtotime( bp_get_option( '_ges_revision_date' ) );
}
/**
* Bumps the revision date in the DB
*
* @return void
*/
protected static function bump_revision_date() {
bp_update_option( '_ges_revision_date', self::get_current_revision_date() );
}
}