forked from castlegateit/cgit-wp-acf-events
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathactivation.php
More file actions
67 lines (59 loc) · 1.38 KB
/
activation.php
File metadata and controls
67 lines (59 loc) · 1.38 KB
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
<?php
/**
* Plugin activation hook to check that required plugins are installed and to
* flush rewrite rules so custom rules will take effect.
*
* @author Castlgate IT <info@castlegateit.co.uk>
* @author Andy Reading
*
* @return void
*/
function cgit_wp_events_activate()
{
// Set default options
cgit_wp_events_default_options();
// Flush rewrite rules
add_filter('wp_loaded', 'cgit_wp_events_flush_rules');
}
/**
* Assign the default option values
*
* @author Castlgate IT <info@castlegateit.co.uk>
* @author Andy Reading
*
* @return void
*/
function cgit_wp_events_default_options()
{
// Set default options
foreach (cgit_wp_events::$options as $option => $value) {
if (empty(get_option($option))) {
if (is_array($value)) {
foreach ($value as $k => $v) {
update_option($option, $v);
break;
}
} else {
update_option($option, $value);
}
}
}
}
/**
* Remove all options
*
* @author Castlgate IT <info@castlegateit.co.uk>
* @author Andy Reading
*
* @return void
*/
function cgit_wp_events_uninstall()
{
global $default_options;
// Delete saved options
foreach ($default_options as $option => $value) {
delete_option($option);
}
// Flush rewrite rules
cgit_wp_events_flush_rules();
}