| @@ -1,0 +1,42 @@ | ||
| 1 | +<?php | |
| 2 | + | |
| 3 | +namespace Templately; | |
| 4 | + | |
| 5 | +class DB { | |
| 6 | + /** | |
| 7 | + * Get an option | |
| 8 | + * | |
| 9 | + * @param string $key | |
| 10 | + * @param mixed $default | |
| 11 | + * @return void | |
| 12 | + */ | |
| 13 | + public static function get_option( $key, $default = false ){ | |
| 14 | + $trimmed_key = trim( $key ); | |
| 15 | + return empty( $trimmed_key ) ? false : \get_option( $trimmed_key, $default ); | |
| 16 | + } | |
| 17 | + /** | |
| 18 | + * Update an option | |
| 19 | + * | |
| 20 | + * @param string $key | |
| 21 | + * @param mixed $value | |
| 22 | + * @param string|boolean $autoload | |
| 23 | + * @return void | |
| 24 | + */ | |
| 25 | + public static function update_option( $key, $value, $autoload = null){ | |
| 26 | + $trimmed_key = trim( $key ); | |
| 27 | + return empty( $trimmed_key ) ? false : \update_option( $trimmed_key, $value, $autoload ); | |
| 28 | + } | |
| 29 | + /** | |
| 30 | + * Delete an option | |
| 31 | + * | |
| 32 | + * @param string $key | |
| 33 | + * @return void | |
| 34 | + */ | |
| 35 | + public static function delete_option( $key ){ | |
| 36 | + $trimmed_key = trim( $key ); | |
| 37 | + if( ! empty( $trimmed_key ) ) { | |
| 38 | + return \delete_option( $trimmed_key ); | |
| 39 | + } | |
| 40 | + return false; | |
| 41 | + } | |
| 42 | +} | |