wp_settings.php
1.8 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
if (!defined('ABSPATH')) exit;
if (!class_exists('PTNWPSettings')) :
class PTNWPSettings {
public function getOption($key) {
$res = false;
if (function_exists('get_site_option')) {
$res = get_site_option($key, false);
}
if ($res === false) {
$res = get_option($key, false);
}
return $res;
}
public function deleteOption($key) {
if (function_exists('delete_site_option')) {
return delete_site_option($key);
} else {
return delete_option($key);
}
}
public function updateOption($key, $value) {
if (function_exists('update_site_option')) {
return update_site_option($key, $value);
} else {
return update_option($key, $value);
}
}
public function getOptions($options = array()) {
$result = array();
foreach ($options as $option)
$result[$option] = $this->getOption($option);
return $result;
}
public function updateOptions($args) {
$result = array();
foreach ($args as $option => $value) {
$this->updateOption($option, $value);
$result[$option] = $this->getOption($option);
}
return $result;
}
public function deleteOptions($options) {
$result = array();
foreach ($options as $option) {
$this->deleteOption($option);
$result[$option] = !$this->getOption($option);
}
return $result;
}
public function setTransient($name, $value, $time) {
if (function_exists('set_site_transient')) {
return set_site_transient($name, $value, $time);
}
return false;
}
public function deleteTransient($name) {
if (function_exists('delete_site_transient')) {
return delete_site_transient($name);
}
return false;
}
public function getTransient($name) {
if (function_exists('get_site_transient')) {
return get_site_transient($name);
}
return false;
}
}
endif;