Fixed bug in WP_Option
Showing
1 changed file
with
8 additions
and
5 deletions
| ... | @@ -11,17 +11,20 @@ class WP_Option implements ArrayAccess, Countable { | ... | @@ -11,17 +11,20 @@ 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 | } | ||
| 21 | } | ||
| 17 | } | 22 | } |
| 18 | 23 | ||
| 19 | if ($this->_data != $defaults) { | 24 | if ($changed) { |
| 20 | $this->_data = $defaults; | ||
| 21 | $this->save(); | 25 | $this->save(); |
| 22 | } | 26 | } |
| 23 | } | 27 | } |
| 24 | } | ||
| 25 | 28 | ||
| 26 | public function offsetExists($var) { | 29 | public function offsetExists($var) { |
| 27 | return (isset($this->_data[$var]) ? true : false); | 30 | return (isset($this->_data[$var]) ? true : false); | ... | ... |
-
Please register or sign in to post a comment