Make WordPress Core

Changeset 39151


Ignore:
Timestamp:
11/07/2016 06:12:28 PM (10 years ago)
Author:
westonruter
Message:

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.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-customize-manager.php

    r39149 r39151  
    36003600                $custom_css_setting = new WP_Customize_Custom_CSS_Setting( $this, sprintf( 'custom_css[%s]', get_stylesheet() ), array(
    36013601                        'capability' => 'unfiltered_css',
     3602                        'default' => sprintf( "/*\n%s\n*/", __( "You can add your own CSS here.\n\nClick the help icon above to learn more." ) ),
    36023603                ) );
    36033604                $this->add_setting( $custom_css_setting );
    … …  
    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        }
  • trunk/src/wp-includes/customize/class-wp-customize-custom-css-setting.php

    r39009 r39151  
    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
  • trunk/tests/phpunit/tests/customize/custom-css-setting.php

    r39020 r39151  
    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()
    … …  
    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(
Note: See TracChangeset for help on using the changeset viewer.