diff --git src/wp-includes/class-wp-customize-setting.php src/wp-includes/class-wp-customize-setting.php
index a16b100..7f1f98a 100644
|
|
class WP_Customize_Setting { |
696 | 696 | $is_core_type = ( 'option' === $this->type || 'theme_mod' === $this->type ); |
697 | 697 | |
698 | 698 | if ( ! $is_core_type && ! $this->is_multidimensional_aggregated ) { |
| 699 | |
| 700 | // Use post value if previewed and a post value is present. |
| 701 | if ( $this->is_previewed ) { |
| 702 | $value = $this->post_value( null ); |
| 703 | if ( null !== $value ) { |
| 704 | return $value; |
| 705 | } |
| 706 | } |
| 707 | |
699 | 708 | $value = $this->get_root_value( $this->default ); |
700 | 709 | |
701 | 710 | /** |
diff --git src/wp-includes/customize/class-wp-customize-custom-css-setting.php src/wp-includes/customize/class-wp-customize-custom-css-setting.php
index eb9379e..eadd47c 100644
|
|
final class WP_Customize_Custom_CSS_Setting extends WP_Customize_Setting { |
132 | 132 | * @return string |
133 | 133 | */ |
134 | 134 | public function value() { |
135 | | $id_base = $this->id_data['base']; |
136 | | if ( $this->is_previewed && null !== $this->post_value( null ) ) { |
137 | | return $this->post_value(); |
| 135 | if ( $this->is_previewed ) { |
| 136 | $post_value = $this->post_value( null ); |
| 137 | if ( null !== $post_value ) { |
| 138 | return $post_value; |
| 139 | } |
138 | 140 | } |
| 141 | $id_base = $this->id_data['base']; |
139 | 142 | $value = ''; |
140 | 143 | $post = wp_get_custom_css_post( $this->stylesheet ); |
141 | 144 | if ( $post ) { |
diff --git tests/phpunit/tests/customize/setting.php tests/phpunit/tests/customize/setting.php
index 89b0720..03fd0c2 100644
|
|
class Tests_WP_Customize_Setting extends WP_UnitTestCase { |
395 | 395 | $this->assertEquals( $post_data_overrides[ $name ], $this->custom_type_getter( $name, $this->undefined ) ); |
396 | 396 | $this->assertEquals( $post_data_overrides[ $name ], $setting->value() ); |
397 | 397 | |
| 398 | // Custom type that does not handle supplying the post value from the customize_value_{$id_base} filter. |
| 399 | $setting_id = 'custom_without_previewing_value_filter'; |
| 400 | $setting = $this->manager->add_setting( $setting_id, array( |
| 401 | 'type' => 'custom_preview_test', |
| 402 | 'default' => 123, |
| 403 | 'sanitize_callback' => array( $this->manager->nav_menus, 'intval_base10' ), |
| 404 | ) ); |
| 405 | $this->assertSame( 123, $setting->value() ); |
| 406 | $this->manager->set_post_value( $setting_id, '456' ); |
| 407 | $setting->preview(); |
| 408 | $this->assertSame( 456, $setting->value() ); |
| 409 | |
398 | 410 | unset( $this->custom_type_data_previewed, $this->custom_type_data_saved ); |
399 | 411 | } |
400 | 412 | |