Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds alpha option to multicolor control #1449

Merged
merged 1 commit into from
Jul 4, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion controls/multicolor/class-kirki-control-multicolor.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ class Kirki_Control_Multicolor extends WP_Customize_Control {
*/
public $option_type = 'theme_mod';

/**
* Enable/Disable Alpha channel on color pickers
*
* @access public
* @var boolean
*/
public $alpha = true;

/**
* Constructor.
*
Expand Down Expand Up @@ -72,6 +80,7 @@ class Kirki_Control_Multicolor extends WP_Customize_Control {
* @type array $choices List of choices for 'radio' or 'select' type controls, where
* values are the keys, and labels are the values.
* Default empty array.
* @type boolean $alpha Enables/Disables alpha channel on color pickers
* @type array $input_attrs List of custom input attributes for control output, where
* attribute names are the keys and values are the values. Not
* used for 'checkbox', 'radio', 'select', 'textarea', or
Expand Down Expand Up @@ -129,6 +138,7 @@ public function to_json() {
$this->json['choices'] = $this->choices;
$this->json['link'] = $this->get_link();
$this->json['id'] = $this->id;
$this->json['alpha'] = $this->alpha;

$this->json['inputAttrs'] = '';
foreach ( $this->input_attrs as $attr => $value ) {
Expand Down Expand Up @@ -162,7 +172,7 @@ protected function content_template() {
<# if ( data.choices[ key ] ) { #>
<label for="{{ data.id }}-{{ key }}">{{ data.choices[ key ] }}</label>
<# } #>
<input {{{ data.inputAttrs }}} id="{{ data.id }}-{{ key }}" type="text" data-palette="{{ data.palette }}" data-default-color="{{ data.default[ key ] }}" data-alpha="true" value="{{ data.value[ key ] }}" class="kirki-color-control color-picker multicolor-index-{{ key }}" />
<input {{{ data.inputAttrs }}} id="{{ data.id }}-{{ key }}" type="text" data-palette="{{ data.palette }}" data-default-color="{{ data.default[ key ] }}" data-alpha="{{ data.alpha }}" value="{{ data.value[ key ] }}" class="kirki-color-control color-picker multicolor-index-{{ key }}" />
</div>
<# } #>
<# } #>
Expand Down