/**
  * Adds a `Template` view.
  *
  * @since 1.0.0
  */
 public function add_template_view($shortcodes)
 {
     $shortcode = !empty($_REQUEST['shortcode']) ? sanitize_key($_REQUEST['shortcode']) : '';
     if (empty($shortcode)) {
         return $shortcodes;
     }
     if (!isset($shortcodes[$shortcode]['atts']['template'])) {
         return $shortcodes;
     }
     // Get templates.
     $templates = Cherry_Shortcode_Editor::dirlist($shortcode);
     if (!$templates || empty($templates)) {
         return $shortcodes;
     }
     // Add new atts - template.
     $shortcodes[$shortcode]['atts']['template'] = array('type' => 'select', 'values' => $templates, 'default' => 'default.tmpl', 'name' => __('Template', 'cherry-shortcodes-templater'), 'desc' => __('Shortcode template', 'cherry-shortcodes-templater'));
     return $shortcodes;
 }
 private function cherry_attributes_to_parameters($atts, $params = null, $shortcode = '')
 {
     if ($params == NULL) {
         $params = array();
     }
     if (is_array($atts) && count($atts)) {
         foreach ($atts as $att_id => $att) {
             $param = array();
             $type = isset($att['type']) ? $att['type'] : '';
             switch ($type) {
                 case 'select':
                     $param['type'] = isset($att['multiple']) && $att['multiple'] == TRUE ? 'select-multiple' : 'select';
                     $param['label'] = $att['name'];
                     $param['default'] = $att['default'];
                     $param['list'] = $att['values'];
                     $param['description'] = empty($att['desc']) ? '' : $att['desc'];
                     break;
                 case 'responsive':
                     $responsive_sizes = array('_xs', '_sm', '_md', '_lg');
                     foreach ($responsive_sizes as $size) {
                         // skip size_md while we set it visually
                         if ($att_id . $size == 'size_md') {
                             continue;
                         }
                         $params[$att_id . $size] = array('type' => 'text', 'label' => $att['name'] . $size, 'default' => 'none', 'description' => $this->responsive_size_to_label($size));
                     }
                     break;
                 case 'color':
                     $param['type'] = 'color-picker';
                     $param['label'] = $att['name'];
                     $param['description'] = empty($att['desc']) ? '' : $att['desc'];
                     //$param['default'] = $att['default'];
                     break;
                 case 'slider':
                     $param['type'] = 'slider';
                     $param['label'] = $att['name'];
                     $param['description'] = empty($att['desc']) ? '' : $att['desc'];
                     $param['default'] = $att['default'];
                     $param['min'] = $att['min'];
                     $param['max'] = $att['max'];
                     break;
                 case 'number':
                     $param['type'] = 'spinner';
                     $param['label'] = $att['name'];
                     $param['description'] = empty($att['desc']) ? '' : $att['desc'];
                     $param['default'] = $att['default'];
                     $param['min'] = $att['min'];
                     $param['max'] = $att['max'];
                     break;
                 case 'bool':
                     $param['type'] = 'radio-buttons';
                     $param['label'] = $att['name'];
                     $param['description'] = empty($att['desc']) ? '' : $att['desc'];
                     $param['default'] = $att['default'];
                     $param['list'] = array('yes' => __('Yes'), 'no' => __('No'));
                     break;
                 case 'upload':
                     $param['type'] = 'media';
                     $param['label'] = $att['name'];
                     $param['description'] = empty($att['desc']) ? '' : $att['desc'];
                     $param['default'] = $att['default'];
                     break;
                 case 'icon':
                     $param['type'] = 'icon-picker';
                     $param['label'] = $att['name'];
                     $param['description'] = empty($att['desc']) ? '' : $att['desc'];
                     $param['default'] = '';
                     //delete_transient('mpce-cherry-icons-list');
                     $icons_list = get_transient('mpce-cherry-icons-list');
                     if ($icons_list == FALSE) {
                         $icons = Cherry_Shortcodes_Data::icons();
                         $icons_list = array('none' => array('class' => 'fa', 'label' => ''));
                         foreach ($icons as $icon) {
                             $icons_list['icon:' . $icon] = array('label' => str_replace('fa fa-', '', $icon), 'class' => $icon);
                         }
                         //asort($icons_list);
                         $expiration = 60 * 60;
                         // one hour
                         set_transient('mpce-cherry-icons-list', $icons_list, $expiration);
                     }
                     $param['list'] = $icons_list;
                     /*echo "<pre>";
                       var_export($param); exit;*/
                     break;
                 default:
                     $param['type'] = 'text';
                     if ($att_id == 'url') {
                         $param['type'] = 'link';
                     }
                     $param['label'] = $att['name'];
                     $param['default'] = $att['default'];
                     $param['description'] = empty($att['desc']) ? '' : $att['desc'];
             }
             // Cherry Shortcodes Templater
             if ($att_id == 'template' && class_exists('Cherry_Shortcode_Editor') && strlen($shortcode)) {
                 $templates = Cherry_Shortcode_Editor::dirlist($shortcode);
                 if ($templates && !empty($templates)) {
                     $param['list'] = $templates;
                 }
             }
             if (count($param)) {
                 $params[$att_id] = $param;
             }
         }
     }
     return $params;
 }
 /**
  * chart content meta box
  *
  * @since  1.0.0
  */
 function _content_box($post)
 {
     // Get templates.
     if (class_exists('Cherry_Shortcode_Editor')) {
         $templates = Cherry_Shortcode_Editor::dirlist('charts');
     } else {
         $templates = array('default.tmpl' => 'default.tmpl');
     }
     $fields = array('template' => array('id' => 'template', 'save' => true, 'type' => 'select', 'label' => __('Progress bar template', 'cherry-charts'), 'description' => __('Select progress bar template (this option allowed only for progress bars)', 'cherry-charts'), 'value' => 'radial', 'options' => $templates, 'chart_group' => 'progress_bar-group depend-group'), 'chart_icon' => array('id' => 'chart_icon', 'type' => 'text', 'label' => __('Chart Icon', 'cherry-charts'), 'description' => __('Select chart icon', 'cherry-charts'), 'value' => '', 'chart_group' => 'progress_bar-group depend-group'), 'icon_size' => array('id' => 'icon_size', 'save' => true, 'type' => 'stepper', 'label' => __('Chart Icon size', 'cherry-charts'), 'description' => __('Set chart icon size', 'cherry-charts'), 'value' => 60, 'max_value' => 120, 'min_value' => 12, 'value_step' => 1, 'chart_group' => 'progress_bar-group depend-group'), 'icon_color' => array('id' => 'icon_color', 'type' => 'colorpicker', 'label' => __('Chart icon color', 'cherry-charts'), 'description' => '', 'value' => '#bdc3c7', 'chart_group' => 'progress_bar-group depend-group'), 'show_title' => array('id' => 'show_title', 'type' => 'switcher', 'label' => __('Show chart title', 'cherry-charts'), 'description' => '', 'value' => 'true', 'toggle' => array('true_toggle' => __('Yes', 'cherry-charts'), 'false_toggle' => __('No', 'cherry-charts')), 'chart_group' => 'multi_progress-group doughnut-group pie-group bar-group depend-group'), 'show_labels' => array('id' => 'show_labels', 'type' => 'switcher', 'label' => __('Show chart label', 'cherry-charts'), 'description' => '', 'value' => 'true', 'toggle' => array('true_toggle' => __('Yes', 'cherry-charts'), 'false_toggle' => __('No', 'cherry-charts')), 'chart_group' => 'doughnut-group pie-group bar-group depend-group'), 'show_legend' => array('id' => 'show_legend', 'type' => 'switcher', 'label' => __('Show chart legend', 'cherry-charts'), 'description' => '', 'value' => 'true', 'toggle' => array('true_toggle' => __('Yes', 'cherry-charts'), 'false_toggle' => __('No', 'cherry-charts')), 'chart_group' => 'doughnut-group pie-group bar-group depend-group'));
     $fields = apply_filters('cherry_charts_content_meta_fields', $fields);
     $this->meta_fields = array_merge($this->meta_fields, $fields);
     $result = '';
     foreach ($fields as $field) {
         $field['value'] = cherry_charts_get_meta($post->ID, $field['id'], $field['value']);
         $row_class = !empty($field['chart_group']) ? esc_attr($field['chart_group']) : '';
         $result .= '<div class="' . $row_class . '">' . $this->builder->add_form_item($field) . '</div>';
     }
     printf('<div class="cherry-ui-core">%1s</div>', $result);
 }
 /**
  * Returns the instance.
  *
  * @since  1.0.0
  * @return object
  */
 public static function get_instance()
 {
     // If the single instance hasn't been set, set it now.
     if (null == self::$instance) {
         self::$instance = new self();
     }
     return self::$instance;
 }