diff --git a/src/wp-includes/class-wp-customize-manager.php b/src/wp-includes/class-wp-customize-manager.php index 206d9641bd..5a9770a676 100644 --- a/src/wp-includes/class-wp-customize-manager.php +++ b/src/wp-includes/class-wp-customize-manager.php @@ -3599,6 +3599,7 @@ final class WP_Customize_Manager { $custom_css_setting = new WP_Customize_Custom_CSS_Setting( $this, sprintf( 'custom_css[%s]', get_stylesheet() ), array( 'capability' => 'unfiltered_css', + 'default' => sprintf( "/*\n%s\n*/", __( "You can add your own CSS here.\n\nClick the help icon above to learn more." ) ), ) ); $this->add_setting( $custom_css_setting ); @@ -3606,9 +3607,6 @@ final class WP_Customize_Manager { 'type' => 'textarea', 'section' => 'custom_css', 'settings' => array( 'default' => $custom_css_setting->id ), - 'input_attrs' => array( - 'placeholder' => __( "/*\nYou can add your own CSS here.\n\nClick the help icon above to learn more.\n*/" ), - ) ) ); } diff --git a/src/wp-includes/customize/class-wp-customize-custom-css-setting.php b/src/wp-includes/customize/class-wp-customize-custom-css-setting.php index 2015458119..17e01fc6a5 100644 --- a/src/wp-includes/customize/class-wp-customize-custom-css-setting.php +++ b/src/wp-includes/customize/class-wp-customize-custom-css-setting.php @@ -128,7 +128,11 @@ final class WP_Customize_Custom_CSS_Setting extends WP_Customize_Setting { * @return string */ public function value() { - return wp_get_custom_css( $this->stylesheet ); + $value = wp_get_custom_css( $this->stylesheet ); + if ( empty( $value ) ) { + $value = $this->default; + } + return $value; } /** diff --git a/tests/phpunit/tests/customize/custom-css-setting.php b/tests/phpunit/tests/customize/custom-css-setting.php index d1d2a18124..138f3a0f09 100644 --- a/tests/phpunit/tests/customize/custom-css-setting.php +++ b/tests/phpunit/tests/customize/custom-css-setting.php @@ -101,7 +101,7 @@ class Test_WP_Customize_Custom_CSS_Setting extends WP_UnitTestCase { } /** - * Test WP_Customize_Custom_CSS_Setting::update(). + * Test crud methods on WP_Customize_Custom_CSS_Setting. * * @covers wp_get_custom_css() * @covers WP_Customize_Custom_CSS_Setting::value() @@ -109,6 +109,10 @@ class Test_WP_Customize_Custom_CSS_Setting extends WP_UnitTestCase { * @covers WP_Customize_Custom_CSS_Setting::update() */ function test_crud() { + + $this->setting->default = '/* Hello World */'; + $this->assertEquals( $this->setting->default, $this->setting->value() ); + $original_css = 'body { color: black; }'; $this->factory()->post->create( array( 'post_title' => $this->setting->stylesheet,