3b5668b0 by Chris Boden

Added defaults option

1 parent 53f8033a
<?php
/*
* I made a boo boo
* This only works with Array variables
*/
class WP_Option implements ArrayAccess, Countable {
private $_ns;
private $_data = Array();
public function __construct($ns) {
public function __construct($ns, $defaults = null) {
$this->_ns = $ns;
$this->_data = get_option($ns);
if (!is_null($defaults) && is_array($defaults)) {
foreach ($this->_data as $key => $val) {
$defaults[$key] = $val;
}
if ($this->_data != $defaults) {
$this->_data = $defaults;
$this->save();
}
}
}
public function offsetExists($var) {
......