Customize: Move Custom CSS control placeholder help text to setting default value.

The `WP_Customize_Custom_CSS_Setting::value()` method now returns the `default` if `wp_get_custom_css()` returns empty.

Props westonruter, afercia, helen.
See #35395.
Fixes #38685.

Built from https://develop.svn.wordpress.org/trunk@39151


git-svn-id: http://core.svn.wordpress.org/trunk@39091 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Weston Ruter 2016-11-07 18:13:34 +00:00
parent c1ff206bac
commit 1363813c6b
3 changed files with 7 additions and 5 deletions

View File

@ -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( $custom_css_setting = new WP_Customize_Custom_CSS_Setting( $this, sprintf( 'custom_css[%s]', get_stylesheet() ), array(
'capability' => 'unfiltered_css', '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 ); $this->add_setting( $custom_css_setting );
@ -3606,9 +3607,6 @@ final class WP_Customize_Manager {
'type' => 'textarea', 'type' => 'textarea',
'section' => 'custom_css', 'section' => 'custom_css',
'settings' => array( 'default' => $custom_css_setting->id ), '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*/" ),
)
) ); ) );
} }

View File

@ -128,7 +128,11 @@ final class WP_Customize_Custom_CSS_Setting extends WP_Customize_Setting {
* @return string * @return string
*/ */
public function value() { 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;
} }
/** /**

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '4.7-beta2-39150'; $wp_version = '4.7-beta2-39151';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.