| 1 |
<?php |
| 2 |
/** |
| 3 |
* |
| 4 |
*/ |
| 5 |
|
| 6 |
/** |
| 7 |
* |
| 8 |
*/ |
| 9 |
class CJTServicesStorage { |
| 10 |
|
| 11 |
/** |
| 12 |
* put your comment there... |
| 13 |
* |
| 14 |
* @var mixed |
| 15 |
*/ |
| 16 |
private $storageVarName; |
| 17 |
|
| 18 |
/** |
| 19 |
* put your comment there... |
| 20 |
* |
| 21 |
* @var mixed |
| 22 |
*/ |
| 23 |
private $value; |
| 24 |
|
| 25 |
/** |
| 26 |
* put your comment there... |
| 27 |
* |
| 28 |
* @param mixed $name |
| 29 |
* @param mixed $default |
| 30 |
*/ |
| 31 |
public function __construct($name, $default = null) { |
| 32 |
# Storage Wordpress option name |
| 33 |
$this->storageVarName = strtolower( $name ); |
| 34 |
# Read |
| 35 |
$this->value = get_option( $this->storageVarName, $default ); |
| 36 |
} |
| 37 |
|
| 38 |
/** |
| 39 |
* put your comment there... |
| 40 |
* |
| 41 |
*/ |
| 42 |
public function & getValue() { |
| 43 |
return $this->value; |
| 44 |
} |
| 45 |
|
| 46 |
/** |
| 47 |
* put your comment there... |
| 48 |
* |
| 49 |
* @param mixed $value |
| 50 |
*/ |
| 51 |
public function & setValue($value) { |
| 52 |
# Set value |
| 53 |
$this->value =& $value; |
| 54 |
# chain |
| 55 |
return $this; |
| 56 |
} |
| 57 |
|
| 58 |
/** |
| 59 |
* put your comment there... |
| 60 |
* |
| 61 |
*/ |
| 62 |
public function & update() { |
| 63 |
# Update DB Value |
| 64 |
update_option( $this->storageVarName, $this->value ); |
| 65 |
# Chain |
| 66 |
return $this; |
| 67 |
} |
| 68 |
|
| 69 |
} |