ColorBoxesControl.php (1652B)
1 <?php 2 3 namespace Materialis\Customizer\Controls; 4 5 class ColorBoxesControl extends \Materialis\Customizer\BaseControl 6 { 7 public function init() 8 { 9 $this->type = 'radio'; 10 } 11 12 13 public function render() 14 { 15 $id = 'customize-control-' . str_replace(array('[', ']'), array('-', ''), $this->id); 16 $class = 'customize-control customize-control-' . $this->type; ?> 17 18 <li id="<?php echo esc_attr($id); ?>" class="<?php echo esc_attr($class); ?> cp-color-boxes"> 19 <?php $this->render_content(); ?> 20 </li> 21 <?php 22 } 23 24 public function render_content() 25 { 26 if (empty($this->choices)) { 27 return; 28 } 29 30 $name = '_customize-radio-' . $this->id; 31 32 if ( ! empty($this->label)) : ?> 33 <span class="customize-control-title"><?php echo esc_html($this->label); ?></span> 34 <?php endif; 35 if ( ! empty($this->description)) : ?> 36 <span class="description customize-control-description"><?php echo $this->description; ?></span> 37 <?php endif; 38 39 foreach ($this->choices as $value) : ?> 40 <label> 41 <div class="color-container" style="background:<?php echo $value; ?>;"> 42 <input type="radio" value="<?php echo esc_attr($value); ?>" 43 name="<?php echo esc_attr($name); ?>" <?php $this->link(); 44 checked($this->value(), $value); ?> /> 45 <span class="check-icon"></span> 46 </div> 47 </label> 48 <?php 49 endforeach; 50 } 51 }