ru-se.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

GradientControl.php (2014B)


      1 <?php
      2 
      3 namespace Materialis;
      4 
      5 class GradientControl extends \Kirki_Customize_Control
      6 {
      7     public $type = 'gradient-control';
      8     public $button_label = '';
      9 
     10 
     11     public function __construct($manager, $id, $args = array())
     12     {
     13         parent::__construct($manager, $id, $args);
     14 
     15         $this->button_label = esc_html__('Select Gradient', 'materialis');
     16     }
     17 
     18 
     19     public function enqueue()
     20     {
     21         $jsRoot = get_template_directory_uri() . "/customizer/js";
     22         wp_enqueue_script(materialis_get_text_domain() . '-gradient-control', $jsRoot . "/gradient-control.js", array('materialis-customizer-spectrum'));
     23     }
     24 
     25 
     26     public function to_json()
     27     {
     28         parent::to_json();
     29 
     30         $gradient = $this->json['value'];
     31         if (is_string($this->json['value'])) {
     32             $gradient = json_decode($this->json['value'], true);
     33         }
     34 
     35         $this->json['button_label'] = $this->button_label;
     36         $this->json['gradient']     = materialis_get_gradient_value($gradient['colors'], $gradient['angle']);
     37         $this->json['angle']        = intval($gradient['angle']);
     38     }
     39 
     40 
     41     protected function content_template()
     42     {
     43         ?>
     44         <label for="{{ data.settings['default'] }}-button">
     45             <# if ( data.label ) { #>
     46             <span class="customize-control-title">{{ data.label }}</span>
     47             <# } #>
     48             <# if ( data.description ) { #>
     49             <span class="description customize-control-description">{{{ data.description }}}</span>
     50             <# } #>
     51         </label>
     52 
     53         <div class="webgradient-icon-container">
     54             <div class="webgradient-icon-preview">
     55                 <div class="webgradient" style="background: {{data.gradient}}"></i>
     56                 </div>
     57                 <div class="webgradient-controls">
     58                     <button type="button" class="button upload-button control-focus" id="_customize-button-{{ data.id }}">{{{ data.button_label }}}</button>
     59                 </div>
     60             </div>
     61 
     62         <?php
     63     }
     64 }