TzOption.php
833 Bytes
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
<?php
namespace Tz\WordPress\Tools\TzOption;
use Tz\WordPress\Tools;
call_user_func(function() {
Tools\add_actions(__NAMESPACE__ . '\Actions');
Tools\add_shortcodes(__NAMESPACE__ . '\ShortCodes');
});
function GetOption($key) {
if ( isset( Vars::$options[$key] ) ) {
return Vars::$options[$key];
} else {
return '-';
}
}
class Actions {
public static function init() {
global $wpdb;
$results = $wpdb->get_results("SELECT * FROM wp_cbv_options", ARRAY_A);
foreach($results as $key => $val) {
Vars::$options[$key] = $val;
}
}
}
class ShortCodes {
public static function TzOption($args, $content, $tag) {
return TzOption\GetOption($args['key']);
}
}
class Vars {
public static $options = array();
}
?>