ru-se.com

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

HeaderPanel.php (3646B)


      1 <?php
      2 
      3 namespace Materialis\Customizer\Panels;
      4 
      5 class HeaderPanel extends \Materialis\Customizer\BasePanel
      6 {
      7 
      8     public function init()
      9     {
     10         $this->companion()->customizer()->registerScripts(array($this, 'addScripts'));
     11 
     12         $this->addSections(
     13             array(
     14                 "header_background_chooser"=>array(
     15                     "wp_data"=>array(
     16                         "title" => "Header Background",
     17                         "priority"=>10,
     18                         "panel"=> $this->id
     19                     )
     20                 ),
     21                 "header_layout"=>array(
     22                     "wp_data"=>array(
     23                         "priority"=>20,
     24                         "panel" => $this->id,
     25                         "title"=> "Header Templates"
     26                     ),
     27                 )
     28             )
     29         );
     30 
     31         $this->addSettings(
     32             array(
     33                 "header_background_type"=>array(
     34                     "section"=>"header_background_chooser",
     35                     "wp_data"=>array(
     36                          "transport"=> "refresh",
     37                          "default"=> apply_filters("cloudpress\customizer\header\default_bg_type", "image")
     38                     ),
     39                     "control"=>array(
     40                         "class"=> "Materialis\\Customizer\\Controls\\BackroundTypesControl",
     41                         "choices"=> apply_filters("cloudpress\customizer\header\bg_types", array()),
     42                         "wp_data"=>array(
     43                             "priority"=> -1 * PHP_INT_MAX, // put this first
     44                             "label"=> "Choose Header Background Type",
     45                         )
     46                     )
     47                 ),
     48 
     49                 "header_presets"=> array(
     50                     "class"=> false,
     51                     "section"=> "header_layout",
     52                     "wp_data"=> array(
     53                         "transport"=> "postMessage"
     54                     ),
     55                     "control"=> array(
     56                         "class"=> "\\Materialis\\Customizer\\Controls\\RowsListControl",
     57                         "insertText"=> "Apply Preset",
     58                         "wp_data"=> array(),
     59                         "type"=> "presets_changer",
     60                         "dataSource"=> "data:headers"
     61                     )
     62                 )
     63             )
     64         );
     65     }
     66 
     67     public function addScripts()
     68     {
     69         if ($this->isClassic()) {
     70             return;
     71         }
     72 
     73         $jsUrl = $this->companion()->assetsRootURL() . "/js/customizer/";
     74         wp_enqueue_script('cp-customizer-header', $jsUrl . "customizer-header.js", array(), false, true);
     75     }
     76 
     77     public function render_template()
     78     {
     79         if ($this->isClassic()) {
     80             parent::render_template();
     81         } else {
     82             $this->renderEnhanced();
     83         }
     84     }
     85 
     86     public function renderEnhanced()
     87     {
     88         ?>
     89 
     90         <li id="accordion-panel-{{ data.id }}" data-name="{{{ data.id }}}" class="accordion-section control-section control-panel control-panel-{{ data.type }}">
     91           <h3 class="accordion-section-title no-chevron" tabindex="0">
     92              {{ data.title }}
     93             <span title="<?php _e('Change Header', 'cloudpress-companion'); ?>" data-name="change" class="open-right section-icon"></span>
     94             <span title="<?php _e('Header Settings', 'cloudpress-companion'); ?>" data-name="edit" class="setting section-icon"></span>
     95           </h3>
     96           <ul class="accordion-sub-container control-panel-content"></ul>
     97         </li>
     98         <?php
     99 
    100     }
    101 }