diff -r 490d5cc509ed -r cf61fcea0001 wp/wp-includes/customize/class-wp-customize-color-control.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wp/wp-includes/customize/class-wp-customize-color-control.php Mon Oct 14 17:39:30 2019 +0200 @@ -0,0 +1,119 @@ +statuses = array( '' => __('Default') ); + parent::__construct( $manager, $id, $args ); + } + + /** + * Enqueue scripts/styles for the color picker. + * + * @since 3.4.0 + */ + public function enqueue() { + wp_enqueue_script( 'wp-color-picker' ); + wp_enqueue_style( 'wp-color-picker' ); + } + + /** + * Refresh the parameters passed to the JavaScript via JSON. + * + * @since 3.4.0 + * @uses WP_Customize_Control::to_json() + */ + public function to_json() { + parent::to_json(); + $this->json['statuses'] = $this->statuses; + $this->json['defaultValue'] = $this->setting->default; + $this->json['mode'] = $this->mode; + } + + /** + * Don't render the control content from PHP, as it's rendered via JS on load. + * + * @since 3.4.0 + */ + public function render_content() {} + + /** + * Render a JS template for the content of the color picker control. + * + * @since 4.1.0 + */ + public function content_template() { + ?> + <# var defaultValue = '#RRGGBB', defaultValueAttr = '', + isHueSlider = data.mode === 'hue'; + if ( data.defaultValue && _.isString( data.defaultValue ) && ! isHueSlider ) { + if ( '#' !== data.defaultValue.substring( 0, 1 ) ) { + defaultValue = '#' + data.defaultValue; + } else { + defaultValue = data.defaultValue; + } + defaultValueAttr = ' data-default-color=' + defaultValue; // Quotes added automatically. + } #> + <# if ( data.label ) { #> + {{{ data.label }}} + <# } #> + <# if ( data.description ) { #> + {{{ data.description }}} + <# } #> +