added TzOption Library in com
Showing
1 changed file
with
39 additions
and
0 deletions
com/TzOption/TzOption.php
0 → 100644
| 1 | <?php | ||
| 2 | namespace Tz\WordPress\Tools\TzOption; | ||
| 3 | use Tz\WordPress\Tools; | ||
| 4 | |||
| 5 | call_user_func(function() { | ||
| 6 | Tools\add_actions(__NAMESPACE__ . '\Actions'); | ||
| 7 | Tools\add_shortcodes(__NAMESPACE__ . '\ShortCodes'); | ||
| 8 | }); | ||
| 9 | |||
| 10 | function GetOption($key) { | ||
| 11 | if ( isset( Vars::$options[$key] ) ) { | ||
| 12 | return Vars::$options[$key]; | ||
| 13 | } else { | ||
| 14 | return '-'; | ||
| 15 | } | ||
| 16 | } | ||
| 17 | |||
| 18 | class Actions { | ||
| 19 | public static function init() { | ||
| 20 | global $wpdb; | ||
| 21 | $results = $wpdb->get_results("SELECT * FROM wp_cbv_options", ARRAY_A); | ||
| 22 | foreach($results as $key => $val) { | ||
| 23 | Vars::$options[$key] = $val; | ||
| 24 | } | ||
| 25 | } | ||
| 26 | } | ||
| 27 | |||
| 28 | class ShortCodes { | ||
| 29 | |||
| 30 | public static function TzOption($args, $content, $tag) { | ||
| 31 | return TzOption\GetOption($args['key']); | ||
| 32 | } | ||
| 33 | |||
| 34 | } | ||
| 35 | |||
| 36 | class Vars { | ||
| 37 | public static $options = array(); | ||
| 38 | } | ||
| 39 | ?> | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
-
Please register or sign in to post a comment