WP_Customize_Color_Control

Customize Color Control class.

Defined (1)

The class is defined in the following location(s).

/wp-includes/customize/class-wp-customize-color-control.php  
  1. class WP_Customize_Color_Control extends WP_Customize_Control { 
  2. /** 
  3. * @access public 
  4. * @var string 
  5. */ 
  6. public $type = 'color'; 
  7.  
  8. /** 
  9. * @access public 
  10. * @var array 
  11. */ 
  12. public $statuses; 
  13.  
  14. /** 
  15. * Constructor. 
  16. * @since 3.4.0 
  17. * @uses WP_Customize_Control::__construct() 
  18. * @param WP_Customize_Manager $manager Customizer bootstrap instance. 
  19. * @param string $id Control ID. 
  20. * @param array $args Optional. Arguments to override class property defaults. 
  21. */ 
  22. public function __construct( $manager, $id, $args = array() ) { 
  23. $this->statuses = array( '' => __('Default') ); 
  24. parent::__construct( $manager, $id, $args ); 
  25.  
  26. /** 
  27. * Enqueue scripts/styles for the color picker. 
  28. * @since 3.4.0 
  29. */ 
  30. public function enqueue() { 
  31. wp_enqueue_script( 'wp-color-picker' ); 
  32. wp_enqueue_style( 'wp-color-picker' ); 
  33.  
  34. /** 
  35. * Refresh the parameters passed to the JavaScript via JSON. 
  36. * @since 3.4.0 
  37. * @uses WP_Customize_Control::to_json() 
  38. */ 
  39. public function to_json() { 
  40. parent::to_json(); 
  41. $this->json['statuses'] = $this->statuses; 
  42. $this->json['defaultValue'] = $this->setting->default; 
  43.  
  44. /** 
  45. * Don't render the control content from PHP, as it's rendered via JS on load. 
  46. * @since 3.4.0 
  47. */ 
  48. public function render_content() {} 
  49.  
  50. /** 
  51. * Render a JS template for the content of the color picker control. 
  52. * @since 4.1.0 
  53. */ 
  54. public function content_template() { 
  55. ?> 
  56. <# var defaultValue = ''; 
  57. if ( data.defaultValue ) { 
  58. if ( '#' !== data.defaultValue.substring( 0, 1 ) ) { 
  59. defaultValue = '#' + data.defaultValue; 
  60. } else { 
  61. defaultValue = data.defaultValue; 
  62. defaultValue = ' data-default-color=' + defaultValue; // Quotes added automatically. 
  63. } #> 
  64. <label> 
  65. <# if ( data.label ) { #> 
  66. <span class="customize-control-title">{{{ data.label }}}</span> 
  67. <# } #> 
  68. <# if ( data.description ) { #> 
  69. <span class="description customize-control-description">{{{ data.description }}}</span> 
  70. <# } #> 
  71. <div class="customize-control-content"> 
  72. <input class="color-picker-hex" type="text" maxlength="7" placeholder="<?php esc_attr_e( 'Hex Value' ); ?>" {{ defaultValue }} /> 
  73. </div> 
  74. </label> 
  75. <?php