/**
  * get field setting
  * @return array
  */
 public function get_field_definition()
 {
     //select widgets setting data
     $widgets_settings = array();
     if (is_array($this->saved_widgets_settings)) {
         foreach ($this->saved_widgets_settings as $item) {
             $widgets_settings[$item->id] = $item->id . '-' . $item->name;
         }
     }
     //$sidebars =  hwawc_get_all_active_sidebars();   //get all registered sidebars
     if (function_exists('hwawc_get_active_sidebars_select')) {
         $sidebars_field_data = hwawc_get_active_sidebars_select();
     } else {
         global $wp_registered_sidebars;
         $sidebars_field_data = array();
         foreach ($wp_registered_sidebars as $sidebar) {
             $sidebars_field_data[$sidebar['id']] = $sidebar['name'];
         }
     }
     //get sidebar wiget skins
     $sidebar_skins_data = array();
     if (class_exists('HW_AWC_Sidebar_Settings')) {
         $sidebar_skins = HW_AWC_Sidebar_Settings::available_widget_skins();
         //other way: just call HW_AWC_Sidebar_Settings::available_widget_skins(true)
         foreach ($sidebar_skins as $theme_name => $opt) {
             $sidebar_skins_data[$theme_name] = $opt['title'];
         }
     } else {
         $tip = 'Không tìm thấy HW Any Widget class plugin.';
     }
     return array('field_id' => 'main_loop_content_style', 'type' => 'hw_table_fields', 'title' => 'Lặp nội dung chính', 'description' => 'Áp dụng cho template sử dụng lặp nội dung.' . (!empty($tip) ? 'Chú ý: ' . $tip : ''), 'repeatable' => true, 'show_root_field' => false, 'attributes' => array('hw_table_fields' => array()), 'fields' => array('col1' => array('name' => 'layout', 'type' => 'select', 'options' => $this->layouts, 'description' => ''), 'col2' => array('name' => 'widget_config', 'type' => 'select', 'options' => $widgets_settings, 'description' => ''), 'col3' => array('name' => 'sidebar', 'type' => 'select', 'options' => $sidebars_field_data), 'col4' => array('name' => 'sidebar_widget_skin', 'type' => "select", 'options' => $sidebar_skins_data)), 'table_header' => array('col1' => 'Layout', 'col2' => 'Cấu hình nội dung + hiển thị', 'col3' => 'Box', 'col4' => 'Chọn một giao diện'));
 }
 /**
  * load option grid posts
  * @param WP_Widget $t: widget object
  * @param array $instance: widget data
  */
 function do_widget_feature($t, $instance = array())
 {
     $this->widget_instance = $instance;
     //maybe update widget instance
     //$wf_name = $this->get_widget_feature_name('');
     //list registered sidebars
     $sidebars = hwawc_get_active_sidebars_select();
     $sidebar_skins = HW_AWC_Sidebar_Settings::available_widget_skins(true);
     //sidebar skins
     //saved widget configs by specifying group
     $widgetconfig_groups = AWC_WidgetFeature_saveconfig::get_widgets_settings_select(' WHERE _group="' . self::WIDGET_CONFIG_GROUP . '"');
     //HW_UI_Component::build_select_tag($sidebars, '', '');
     echo '<div class="form-wf-shortcode-params" id="' . $this->get_field_id('wfshortcode_container') . '"><fieldset><legend>Tạo shortcode widget</legend>';
     echo '<input type="hidden" class="widget_class" name="' . $this->get_field_name('widget_class') . '" id="' . $this->get_field_id('widget_class') . '" value="' . get_class($t) . '"/>';
     echo '<input type="hidden" class="widget_instance" name="' . $this->get_field_name('widget_instance') . '" id=" ' . $this->get_field_id('widget_instance') . ' " value="' . base64_encode(serialize($instance)) . '"/>';
     //apply widget to sidebar
     echo '<p><label for="' . $this->get_field_id('sidebar') . '">Chọn Sidebar</label><br/>';
     echo '<select class="hw-select sidebar" name="' . $this->get_field_name('sidebar') . '" id="' . $this->get_field_id('sidebar') . '">';
     foreach ($sidebars as $id => $name) {
         $selected = selected($this->get_field_value('sidebar'), $id, false);
         printf('<option value="%s" %s>%s</option>', $id, $selected, $name);
     }
     echo '</select></p>';
     //choose sidebar skin
     echo '<p><label for="' . $this->get_field_id('sidebar_skin') . '">Chọn giao diện Sidebar</label><br/>';
     echo HW_UI_Component::build_select_tag($sidebar_skins, null, array('name' => $this->get_field_name('sidebar_skin'), 'id' => $this->get_field_id('sidebar_skin'), 'class' => 'sidebar_skin'));
     echo '</select></p>';
     //widget config group
     echo '<p><label for="' . $this->get_field_id('config_group') . '">Chọn widget config</label><br/>';
     echo '<select class="config_group" name=" ' . $this->get_field_name('config_group') . ' " id="' . $this->get_field_id('config_group') . '">';
     foreach ($widgetconfig_groups as $id => $text) {
         $selected = selected($this->get_field_value('config_group'), $id, false);
         printf('<option value="%s" %s>%s</option>', $id, $selected, $text);
     }
     echo '</select>';
     echo '<a href="javascript:void(0)" onclick="__awc_feature_shortcode_params.refresh_saved_widgetsconfig(this,\'' . $this->get_field_id('config_group') . '\')">Refresh</a>';
     //you also should be active saveconfig feature
     if (!HW_AWC_WidgetFeatures::check_widget_feature($t, 'saveconfig')) {
         echo '<div>Bạn cũng cần kích hoạt feature "<a href="' . admin_url('options-general.php?page=' . HW_HOANGWEB_Settings::HW_SETTINGS_PAGE) . '" target="_blank">saveconfig</a>" cho widget này.</div>';
     }
     echo '</p>';
     echo '<a href="javascript:void(0)" onclick="__awc_feature_shortcode_params.generate_shortcode(this,jQuery(\'#' . $this->get_field_id('wfshortcode_container') . '\'))" class="button">Tạo shortcode</a>';
     echo '<div></div>';
     echo '<p><em>Hướng dẫn</em>: Sử dụng tính năng "Lưu cài đặt" ở tại widget này để lưu cấu hình của widget (chọn nhóm "Shortcode Widget")</p>';
     echo '</fieldset></div>';
 }
 //get post type object
 //skins
 $atts = array('name' => $aSkin_field_name . '[skin]', 'id' => "hwrp_skins_{$post_type}");
 $skins_list = $this->skin->get_skins_select_tag(null, $active_skin4pt, $atts, false);
 $skin_preview_holder = $this->skin->get_skins_preview_screen(null);
 //skin preview
 //get skin config
 if (1 || empty($skins[$post_type]['hwskin_config'])) {
     //ensure sure to keep update skin config
     $skins[$post_type]['hwskin_config'] = $this->skin->get_config(true);
 }
 //enable filter skin terms
 $enable_filter_term = isset($skins[$post_type]['filter_terms']) ? 1 : 0;
 $active = isset($skins[$post_type]['active']) ? 1 : 0;
 //get all active sidebars select
 $sidebars = hwawc_get_active_sidebars_select();
 $current_box = isset($skins[$post_type]['box_skin']) ? $skins[$post_type]['box_skin'] : '';
 //pick sidebar widget skin
 $current_box_skin = isset($skins[$post_type]['box_widget_skin']) ? $skins[$post_type]['box_widget_skin'] : '';
 //since we use hw-taxonomy-post-list-widget plugin to query all posts type in wp, and I also apply to this plugin
 $widgets_settings = AWC_WidgetFeature_saveconfig::get_widgets_settings_select(' where widget="hw_taxonomy_post_list_widget"');
 $current_widgetconfig = isset($skins[$post_type]['widget_config']) ? $skins[$post_type]['widget_config'] : '';
 echo '<tr>';
 echo '<td><input type="checkbox" name="' . $aSkin_field_name . '[active]" id="enable_' . $post_type . '" ' . ($active ? 'checked="checked"' : '') . '/></td>';
 //enable tog
 echo "<td>{$pt->labels->name}</td>";
 /**
  * skins chooser
  */
 echo '<td>' . $skins_list;
 //first develop, we use same hw_skin instance to manage all post types