5efbe65d by Chris Boden

Fixed bug in WP_Option

1 parent db6017bc
...@@ -11,15 +11,18 @@ class WP_Option implements ArrayAccess, Countable { ...@@ -11,15 +11,18 @@ class WP_Option implements ArrayAccess, Countable {
11 $this->_ns = $ns; 11 $this->_ns = $ns;
12 $this->_data = get_option($ns); 12 $this->_data = get_option($ns);
13 13
14 $changed = false;
14 if (is_array($defaults)) { 15 if (is_array($defaults)) {
15 foreach ($this->_data as $key => $val) { 16 foreach ($defaults as $key => $val) {
16 $defaults[$key] = $val; 17 if (!isset($this->_data[$key])) {
18 $this->_data[$key] = $val;
19 $changed = true;
20 }
17 } 21 }
22 }
18 23
19 if ($this->_data != $defaults) { 24 if ($changed) {
20 $this->_data = $defaults; 25 $this->save();
21 $this->save();
22 }
23 } 26 }
24 } 27 }
25 28
......