WordPress.org

Make WordPress Core

Ticket #38685: 38685.0.diff

File 38685.0.diff, 2.6 KB (added by westonruter, 3 years ago)
  • src/wp-includes/class-wp-customize-manager.php

    diff --git src/wp-includes/class-wp-customize-manager.php src/wp-includes/class-wp-customize-manager.php
    index 206d964..f96a4b7 100644
    final class WP_Customize_Manager { 
    35993599
    36003600                $custom_css_setting = new WP_Customize_Custom_CSS_Setting( $this, sprintf( 'custom_css[%s]', get_stylesheet() ), array(
    36013601                        'capability' => 'unfiltered_css',
     3602                        'default' => __( "/*\nYou can add your own CSS here.\n\nClick the help icon above to learn more.\n*/" ),
    36023603                ) );
    36033604                $this->add_setting( $custom_css_setting );
    36043605
    final class WP_Customize_Manager { 
    36063607                        'type'     => 'textarea',
    36073608                        'section'  => 'custom_css',
    36083609                        'settings' => array( 'default' => $custom_css_setting->id ),
    3609                         'input_attrs' => array(
    3610                                 'placeholder' => __( "/*\nYou can add your own CSS here.\n\nClick the help icon above to learn more.\n*/" ),
    3611                         )
    36123610                ) );
    36133611        }
    36143612
  • src/wp-includes/customize/class-wp-customize-custom-css-setting.php

    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 2015458..17e01fc 100644
    final class WP_Customize_Custom_CSS_Setting extends WP_Customize_Setting { 
    128128         * @return string
    129129         */
    130130        public function value() {
    131                 return wp_get_custom_css( $this->stylesheet );
     131                $value = wp_get_custom_css( $this->stylesheet );
     132                if ( empty( $value ) ) {
     133                        $value = $this->default;
     134                }
     135                return $value;
    132136        }
    133137
    134138        /**
  • tests/phpunit/tests/customize/custom-css-setting.php

    diff --git tests/phpunit/tests/customize/custom-css-setting.php tests/phpunit/tests/customize/custom-css-setting.php
    index d1d2a18..138f3a0 100644
    class Test_WP_Customize_Custom_CSS_Setting extends WP_UnitTestCase { 
    101101        }
    102102
    103103        /**
    104          * Test WP_Customize_Custom_CSS_Setting::update().
     104         * Test crud methods on WP_Customize_Custom_CSS_Setting.
    105105         *
    106106         * @covers wp_get_custom_css()
    107107         * @covers WP_Customize_Custom_CSS_Setting::value()
    class Test_WP_Customize_Custom_CSS_Setting extends WP_UnitTestCase { 
    109109         * @covers WP_Customize_Custom_CSS_Setting::update()
    110110         */
    111111        function test_crud() {
     112
     113                $this->setting->default = '/* Hello World */';
     114                $this->assertEquals( $this->setting->default, $this->setting->value() );
     115
    112116                $original_css = 'body { color: black; }';
    113117                $this->factory()->post->create( array(
    114118                        'post_title' => $this->setting->stylesheet,