-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclass-activation.php
59 lines (50 loc) · 1.56 KB
/
class-activation.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
<?php
namespace FooPlugins\Generator;
/**
* FooPlugins Generator Activation Class
* Contains the activate method that runs on register_activation_hook
*
* Date: 16/09/2019
*/
if ( !class_exists( 'FooPlugins\Generator\Activation' ) ) {
class Activation {
/**
* Fired when the plugin is activated.
*
* @since 2.0.2
*
* @param boolean $network_wide True if WPMU superadmin uses
* "Network Activate" action, false if
* WPMU is disabled or plugin is
* activated on an individual blog.
*/
public static function activate( $network_wide ) {
$plugin_data = get_site_option( FOOGEN_OPTION_DATA );
$save_data = false;
if ( false === $plugin_data ) {
$plugin_data = array(
'version' => FOOGEN_VERSION,
'first_version' => FOOGEN_VERSION,
'first_install' => time()
);
$save_data = true;
} else {
$version = $plugin_data['version'];
if ( $version !== FOOGEN_VERSION ) {
//the version has been updated
$plugin_data['version'] = FOOGEN_VERSION;
$save_data = true;
//store a transient for 1 min with the update info
set_site_transient( FOOGEN_TRANSIENT_UPDATED, $plugin_data, 60 );
}
}
if ( $save_data ) {
update_site_option( FOOGEN_OPTION_DATA, $plugin_data );
}
if ( false === $network_wide ) {
//make sure we redirect to the welcome wizard
set_transient( FOOGEN_TRANSIENT_ACTIVATION_REDIRECT, true, 30 );
}
}
}
}