forked from hunk/Magic-Fields
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RCCWP_Options.php
executable file
·51 lines (48 loc) · 1.25 KB
/
RCCWP_Options.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
/**
* This class is used for Manages all the options related With Magic Fields
*
*/
class RCCWP_Options {
/**
* Update the options of Magic Fields
*
* @params array $options is a array with the options of Magic Fields
*/
public static function Update($options) {
$options = serialize($options);
update_option(RC_CWP_OPTION_KEY, $options);
}
/**
* Get the options of magic fields
*
* if is not specified a key is return a array with all the options of magic fields
*
* @param string $key is the name of the option.
*
*/
public static function Get($key = null) {
if (get_option(RC_CWP_OPTION_KEY) == "") return "";
if (is_array(get_option(RC_CWP_OPTION_KEY)))
$options = get_option(RC_CWP_OPTION_KEY);
else
$options = unserialize(get_option(RC_CWP_OPTION_KEY));
if (!empty($key)){
if( isset($options[$key]) ) return $options[$key];
return false;
}else{
return $options;
}
}
/**
* Save a new value in the options
*
* @param string $key is the name of the option to will be updated
* @param string $val is the new value of the option
*/
public static function Set($key, $val) {
$options = RCCWP_Options::Get();
$options[$key] = $val;
RCCWP_Options::Update($options);
}
}