-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathheadstart_functions.php
51 lines (34 loc) · 1.13 KB
/
headstart_functions.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
<?php
/*
* Headstart plugin functions
*/
add_action( 'plugins_loaded', 'headstart_functions_setup' );
function headstart_functions_setup() {
$old_version = headstart_get_option( 'version' );
if ( false === get_option( 'headstart_settings' ) ) {
add_option( 'headstart_settings', headstart_get_default_settings( ) );
} elseif ( $old_version !== HEADSTART_VERSION ) {
headstart_update_settings( );
}
}
function headstart_get_option($option) {
$settings = get_option( 'headstart_settings' );
if ( ! is_array( $settings ) || ! array_key_exists( $option, $settings ) )
return false;
return $settings[$option];
}
function headstart_update_settings() {
$settings = get_option( 'headstart_settings' );
$default_settings = headstart_get_default_settings( );
$settings['version'] = HEADSTART_VERSION;
foreach ( $default_settings as $setting_key => $setting_value ) {
if ( ! isset( $settings[$setting_key] ) )
$settings[$setting_key] = $setting_value;
}
update_option( 'headstart_settings', $settings );
}
function headstart_get_default_settings() {
$settings = array( 'version' => HEADSTART_VERSION );
return $settings;
}
?>