[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

title

Body

[close]

/wp-includes/customize/ -> class-wp-customize-color-control.php (source)

   1  <?php
   2  /**
   3   * Customize API: WP_Customize_Color_Control class
   4   *
   5   * @package WordPress
   6   * @subpackage Customize
   7   * @since 4.4.0
   8   */
   9  
  10  /**
  11   * Customize Color Control class.
  12   *
  13   * @since 3.4.0
  14   *
  15   * @see WP_Customize_Control
  16   */
  17  class WP_Customize_Color_Control extends WP_Customize_Control {
  18      /**
  19       * Type.
  20       *
  21       * @var string
  22       */
  23      public $type = 'color';
  24  
  25      /**
  26       * Statuses.
  27       *
  28       * @var array
  29       */
  30      public $statuses;
  31  
  32      /**
  33       * Mode.
  34       *
  35       * @since 4.7.0
  36       * @var string
  37       */
  38      public $mode = 'full';
  39  
  40      /**
  41       * Constructor.
  42       *
  43       * @since 3.4.0
  44       * @uses WP_Customize_Control::__construct()
  45       *
  46       * @param WP_Customize_Manager $manager Customizer bootstrap instance.
  47       * @param string               $id      Control ID.
  48       * @param array                $args    Optional. Arguments to override class property defaults.
  49       */
  50  	public function __construct( $manager, $id, $args = array() ) {
  51          $this->statuses = array( '' => __( 'Default' ) );
  52          parent::__construct( $manager, $id, $args );
  53      }
  54  
  55      /**
  56       * Enqueue scripts/styles for the color picker.
  57       *
  58       * @since 3.4.0
  59       */
  60  	public function enqueue() {
  61          wp_enqueue_script( 'wp-color-picker' );
  62          wp_enqueue_style( 'wp-color-picker' );
  63      }
  64  
  65      /**
  66       * Refresh the parameters passed to the JavaScript via JSON.
  67       *
  68       * @since 3.4.0
  69       * @uses WP_Customize_Control::to_json()
  70       */
  71  	public function to_json() {
  72          parent::to_json();
  73          $this->json['statuses']     = $this->statuses;
  74          $this->json['defaultValue'] = $this->setting->default;
  75          $this->json['mode']         = $this->mode;
  76      }
  77  
  78      /**
  79       * Don't render the control content from PHP, as it's rendered via JS on load.
  80       *
  81       * @since 3.4.0
  82       */
  83  	public function render_content() {}
  84  
  85      /**
  86       * Render a JS template for the content of the color picker control.
  87       *
  88       * @since 4.1.0
  89       */
  90  	public function content_template() {
  91          ?>
  92          <# var defaultValue = '#RRGGBB', defaultValueAttr = '',
  93              isHueSlider = data.mode === 'hue';
  94          if ( data.defaultValue && _.isString( data.defaultValue ) && ! isHueSlider ) {
  95              if ( '#' !== data.defaultValue.substring( 0, 1 ) ) {
  96                  defaultValue = '#' + data.defaultValue;
  97              } else {
  98                  defaultValue = data.defaultValue;
  99              }
 100              defaultValueAttr = ' data-default-color=' + defaultValue; // Quotes added automatically.
 101          } #>
 102          <# if ( data.label ) { #>
 103              <span class="customize-control-title">{{{ data.label }}}</span>
 104          <# } #>
 105          <# if ( data.description ) { #>
 106              <span class="description customize-control-description">{{{ data.description }}}</span>
 107          <# } #>
 108          <div class="customize-control-content">
 109              <label><span class="screen-reader-text">{{{ data.label }}}</span>
 110              <# if ( isHueSlider ) { #>
 111                  <input class="color-picker-hue" type="text" data-type="hue" />
 112              <# } else { #>
 113                  <input class="color-picker-hex" type="text" maxlength="7" placeholder="{{ defaultValue }}" {{ defaultValueAttr }} />
 114              <# } #>
 115              </label>
 116          </div>
 117          <?php
 118      }
 119  }


Generated: Wed Oct 23 08:20:01 2019 Cross-referenced by PHPXref 0.7