X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/af50974463450c98503e763a7836a50e260461a9..a7cd4c052013b423c6301153f68c7fdbaa2a447b:/wp-includes/class-wp-customize-setting.php diff --git a/wp-includes/class-wp-customize-setting.php b/wp-includes/class-wp-customize-setting.php index 0207b709..d8bf1e23 100644 --- a/wp-includes/class-wp-customize-setting.php +++ b/wp-includes/class-wp-customize-setting.php @@ -103,12 +103,18 @@ class WP_Customize_Setting { return $this; } + protected $_original_value; + /** * Handle previewing the setting. * * @since 3.4.0 */ public function preview() { + if ( ! isset( $this->_original_value ) ) { + $this->_original_value = $this->value(); + } + switch( $this->type ) { case 'theme_mod' : add_filter( 'theme_mod_' . $this->id_data[ 'base' ], array( $this, '_preview_filter' ) ); @@ -159,7 +165,15 @@ class WP_Customize_Setting { * @return mixed New or old value. */ public function _preview_filter( $original ) { - return $this->multidimensional_replace( $original, $this->id_data[ 'keys' ], $this->post_value() ); + $undefined = new stdClass(); // symbol hack + $post_value = $this->manager->post_value( $this, $undefined ); + if ( $undefined === $post_value ) { + $value = $this->_original_value; + } else { + $value = $post_value; + } + + return $this->multidimensional_replace( $original, $this->id_data['keys'], $value ); } /** @@ -425,8 +439,15 @@ class WP_Customize_Setting { $node = &$node[ $key ]; } - if ( $create && ! isset( $node[ $last ] ) ) - $node[ $last ] = array(); + if ( $create ) { + if ( ! is_array( $node ) ) { + // account for an array overriding a string or object value + $node = array(); + } + if ( ! isset( $node[ $last ] ) ) { + $node[ $last ] = array(); + } + } if ( ! isset( $node[ $last ] ) ) return;