/**
  * 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>';
 }
  */
 echo '<td>';
 echo HW_UI_Component::build_select_tag($widgets_settings, $current_widgetconfig, array('name' => $aSkin_field_name . '[widget_config]', 'id' => $post_type . '_widget_config'));
 echo '</td>';
 /**
  * box sidebar
  */
 echo '<td>';
 echo HW_UI_Component::build_select_tag($sidebars, $current_box, array('name' => $aSkin_field_name . '[box_skin]', 'id' => $post_type . '_box_skin'));
 echo '</td>';
 /**
  * sidebar skins
  */
 echo '<td>';
 $sidebar_skins_data = array();
 $sidebar_skins = HW_AWC_Sidebar_Settings::available_widget_skins();
 foreach ($sidebar_skins as $theme_name => $opt) {
     $sidebar_skins_data[$theme_name] = $opt['title'];
 }
 echo HW_UI_Component::build_select_tag($sidebar_skins_data, $current_box_skin, array('name' => $aSkin_field_name . '[box_widget_skin]', 'id' => $post_type . '_box_widget_skin'));
 echo '</td>';
 /**
  * title
  */
 echo '<td><input type="text" name="' . $aSkin_field_name . '[title]" value="' . (isset($skins[$post_type]['title']) ? $skins[$post_type]['title'] : '') . '"/></td>';
 /**
  * get taxonomies terms assign to post type
  */
 echo '<td>';
 //echo '';
 foreach ($terms as $t) {
    /**
     * extra fields to any widget
     * @param object $t: widget class object
     * @param $return
     * @param array $instance: widget instance
     */
    public function _hw_awc_in_widget_form($t, $return, $instance)
    {
        /*begin custom sidebar format*/
        static $sw_list;
        if (!$sw_list) {
            $sw_list = get_option('sidebars_widgets');
        }
        //get all widgets
        global $wp_registered_sidebars;
        foreach ($sw_list as $sidebar => $widgets) {
            //get sidebar where widget nested on it
            if (is_array($widgets) && in_array($t->id, $widgets)) {
                //make sure you ignore the key 'array_version'
                $found_sidebar = true;
                break;
            }
        }
        if ($sidebar == 'array_version' || !isset($found_sidebar) || !isset($wp_registered_sidebars[$sidebar])) {
            echo '<div style="background:#fafafa;border:1px solid #dadada;padding:5px;"><p>Nhấn nút Lưu để hiển thị công cụ tùy chỉnh widget này hoặc nếu không thấy thì xóa widget và thêm lại.</p></div>';
            return;
        }
        //first check
        if (isset($wp_registered_sidebars[$sidebar]['old_id'])) {
            $old_sidebar = $wp_registered_sidebars[$sidebar]['old_id'];
        } else {
            $old_sidebar = $sidebar;
        }
        if (!HW_AWC_Sidebar_Settings::check_valid_sidebar_name($old_sidebar)) {
            echo "<div class='hwawc-message'>Do Sidebar cũ có ID ({$old_sidebar}) không hợp lệ, nên tạo mới sidebar với tên: ({$sidebar})";
            echo '<br/>Hiển thị sidebar:<code>dynamic_sidebar("' . $sidebar . '")</code>';
            echo '</div>';
            // return;  //fixed from callback '_hw_awc_init'
        }
        $params = $wp_registered_sidebars[$sidebar];
        //get sidebar param where widget nested on it
        //create feature tog
        if (class_exists('HW_ButtonToggle_widget')) {
            $btn_tog = new HW_ButtonToggle_widget($t, $instance);
        }
        //instance HW_SKIN for widget box title
        $skin = new HW_SKIN($t, HW_AWC_PATH, 'hw_awc_skins', 'hwawc-skin.php', 'skins');
        $skin->plugin_url = HW_AWC_URL;
        $skin->external_callback = false;
        $skin->init();
        //seem no longer use
        ?>
        <?php 
        if (isset($btn_tog)) {
            $btn_tog->set_button_toggle_start_wrapper('Tùy chỉnh widget');
        }
        ?>
        <div style="background:#fafafa;border:1px solid #dadada;padding:5px;">
            <!-- show widget ID on each widget in admin. -->
            <p>
            <div id="<?php 
        echo $t->get_field_id('show_widget_id');
        ?>
" style="padding:5px;background:pink;border:1px solid red;" name="<?php 
        echo $t->get_field_name('show_widget_id');
        ?>
" >
                ID: <strong><?php 
        echo $t->id;
        ?>
</strong><br/>
                <?php 
        if (is_plugin_active('amr-shortcode-any-widget/amr-shortcode-any-widget.php')) {
            echo 'Hiển thị nội dung widget này bởi shortcode:<br/>';
            echo '<code>[do_widget id=' . $t->id . ']</code>';
            echo '<a href="' . HW_AWC_URL . '/docs/amr-shortcode-any-widget.html' . '" target="_blank">Hướng dẫn</a>';
        } else {
            echo hw_install_plugin_link('amr-shortcode-any-widget', 'Nhúng widget này bằng shortcode');
        }
        //display widget content with feature "shortcode_params"
        if (!HW_AWC_WidgetFeatures::check_widget_feature($t, 'shortcode_params') && class_exists('HW_HOANGWEB_Settings')) {
            echo '<p>Kích hoạt feature "<a target="_blank" href="' . admin_url('options-general.php?page=' . HW_HOANGWEB_Settings::HW_SETTINGS_PAGE) . '">Tạo shortcode widget</a>" để hiển thị nội dung của widget này.</p>';
        }
        ?>
            </div>
            </p>
            <!-- widget features -->
            <?php 
        $this->load_widget_features($t, $instance);
        ?>
            <p>

            </p>
            <hr/>
            <!-- sidebar custom after_title & before_title -->
            <?php 
        if (isset($params['before_title'])) {
            ?>

                <p>
                    <label for="<?php 
            echo $t->get_field_id('awc_clear_widget_title');
            ?>
"><strong><?php 
            _e('Xóa tiêu đề widget');
            ?>
</strong></label><br/>
                    <input type="checkbox" name="<?php 
            echo $t->get_field_name('awc_clear_widget_title');
            ?>
" id="<?php 
            echo $t->get_field_id('awc_clear_widget_title');
            ?>
" <?php 
            checked(isset($instance['awc_clear_widget_title']) && $instance['awc_clear_widget_title'] ? 1 : 0);
            ?>
/><?php 
            _e('Xóa before_title & after_title');
            ?>
                    <br/>
                    <span style="font-size:12px">Nếu xóa tiêu đề (xóa before_title & after_title) thì check vào đây. <i>(Tùy chọn này sẽ xóa thẻ HTML có trong before_title & after_title và cả before_widget,after_widget nếu cần thiết để có thể hiển thị tốt widget mà không có title.)</i></span>
                    <br/>

                </p><hr/>

                <p>
                    <label><strong><?php 
            _e('Sửa before_title');
            ?>
</strong></label><br/>
                    <em>Hiện tại: (<font color="blue"><?php 
            echo htmlentities($params['before_title']);
            ?>
</font>)</em><br/>
                    <em><?php 
            if (!preg_match('#%\\d\\$s#', $params['before_title'])) {
                echo '<font color="red">Cảnh báo: before_title chưa sẵn sàng.</font>';
            }
            ?>
</em><br/>
                    <input <?php 
            ?>
 type="text" name="<?php 
            echo $t->get_field_name('format_before_title');
            ?>
" id="<?php 
            echo $t->get_field_id('format_before_title');
            ?>
" value="<?php 
            echo isset($instance['format_before_title']) ? $instance['format_before_title'] : '';
            ?>
"><br/>
                    <span style="font-size:12px"><i>(mỗi ID or chuỗi class ngăn cách bởi '|')</i></span>
                    <br/>
                    <span><em>ie: before_title=>"<?php 
            echo htmlentities('<h2 id="%1$s" class="%2$s" style="%3$s">');
            ?>
"</em></span>
                </p><hr/>
            <?php 
        }
        ?>
            <p>
                <label><strong><?php 
        _e('Sửa after_title');
        ?>
</strong></label><br/>
                <em>Hiện tại: (<font color="blue"><?php 
        echo htmlentities($params['after_title']);
        ?>
</font>)</em><br/>
                <em><?php 
        if (!preg_match('#%\\d\\$s#', $params['after_title'])) {
            echo '<font color="red">Cảnh báo: after_title chưa sẵn sàng.</font>';
        }
        ?>
</em><br/>
                <input <?php 
        ?>
 type="text" name="<?php 
        echo $t->get_field_name('format_after_title');
        ?>
" id="<?php 
        echo $t->get_field_id('format_after_title');
        ?>
" value="<?php 
        echo isset($instance['format_after_title']) ? $instance['format_after_title'] : '';
        ?>
"><br/>
                <span style="font-size:12px"><i>(mỗi ID or chuỗi class ngăn cách bởi '|')</i></span>
                <br/>
                <span><em>ie: after_title=>"<?php 
        echo htmlentities('</h2><div id="%1$s" class="%2$s" style="%3$s">');
        ?>
"</em></span>
            </p><hr/>
            <p>
                <label><strong><?php 
        _e('Sửa before_widget');
        ?>
</strong></label><br/>
                <em>Thêm class theo thứ tự bằng cách chèn tag (*1,*2,..) vào tham số before_widget: <br/>(Hiện tại:<font color="blue"><?php 
        echo htmlentities($params['before_widget']);
        ?>
</font>)</em><br/>
                <em><?php 
        if (!preg_match('#\\*\\d+#', $params['before_widget'])) {
            echo '<font color="red">Cảnh báo: before_widget chưa sẵn sàng.</font>';
        }
        ?>
</em>
                <input type="text" name="<?php 
        echo $t->get_field_name('preclasses_before_widget');
        ?>
" id="<?php 
        echo $t->get_field_id('preclasses_before_widget');
        ?>
" value="<?php 
        echo isset($instance['preclasses_before_widget']) ? $instance['preclasses_before_widget'] : '';
        ?>
"><br/>
                <span style="font-size:12px"><i>(mỗi chuỗi class tương ứng với *1|*2.. ngăn cách bởi '|'. VD: class1 class2|class3 class4 class5)</i></span>
            </p>
            <hr/>
            <p>
                <label for="<?php 
        echo $t->get_field_id('widget_skin');
        ?>
"><strong><?php 
        _e('Giao diện widget');
        ?>
</strong></label>
            <div>
                <select name="<?php 
        echo $t->get_field_name('widget_skin');
        ?>
" id="<?php 
        echo $t->get_field_id('widget_skin');
        ?>
">
                    <?php 
        foreach (HW_AWC_Sidebar_Settings::available_widget_skins() as $name => $field) {
            ?>
                        <option <?php 
            selected(isset($instance['widget_skin']) && $name == $instance['widget_skin'] ? 1 : 0);
            ?>
 value="<?php 
            echo $name;
            ?>
"><?php 
            echo isset($field['title']) ? $field['title'] : $name;
            ?>
</option>
                    <?php 
        }
        ?>
                </select><br/>
                <span>Quản lý skins, nhấn <a target="_blank" href="<?php 
        echo HW_AWC_Sidebar_Settings::get_edit_sidebar_setting_page_link($sidebar);
        ?>
">vào đây</a>.</span>
            </div>
            </p>
            <p>
                <strong>Mầu sắc</strong><br/>
                <em>Lưu ý: TH nếu xóa mầu và khi load lại trang cần xóa lại vì mầu khởi đầu là #FFFFFF.<br/> Nếu không xuất hiện hộp chọn mầu thì tự điền mã mầu và lưu lại để khởi tạo lại trình chọn mã mầu.</em>
            </p>
            <p>
                <input type="text" size="5" class="color {hash:true}" name="<?php 
        echo $t->get_field_name('bgcolor_widget');
        ?>
" id="<?php 
        echo $t->get_field_id('bgcolor_widget');
        ?>
" value="<?php 
        echo isset($instance['bgcolor_widget']) ? $instance['bgcolor_widget'] : '';
        ?>
"/>
                <label for="<?php 
        echo $t->get_field_id('bgcolor_widget');
        ?>
">Mầu nền widget</label>
                <a class="clear-jscolor button" href="javascript:void(0)">Xóa</a>
            </p>
            <p>
                <input type="text" size="5" class="color {hash:true}" name="<?php 
        echo $t->get_field_name('bgcolor_title');
        ?>
" id="<?php 
        echo $t->get_field_id('bgcolor_title');
        ?>
" value="<?php 
        echo isset($instance['bgcolor_title']) ? $instance['bgcolor_title'] : '';
        ?>
"/>
                <label for="<?php 
        echo $t->get_field_id('bgcolor_title');
        ?>
">Mầu nền tiêu đề</label>
                <a class="clear-jscolor button" href="javascript:void(0)" onclick="">Xóa</a>
            </p>
            <p>
                <input type="text" size="5" class="color {hash:true}" name="<?php 
        echo $t->get_field_name('bgcolor_box');
        ?>
" id="<?php 
        echo $t->get_field_id('bgcolor_box');
        ?>
" value="<?php 
        echo isset($instance['bgcolor_box']) ? $instance['bgcolor_box'] : '';
        ?>
"/>
                <label for="<?php 
        echo $t->get_field_id('bgcolor_box');
        ?>
">Mầu nền nội dung</label>
                <a class="clear-jscolor button" href="javascript:void(0)">Xóa</a>
            </p>

            <!-- bg title -->
            <p>
                <label><strong><?php 
        _e('Ảnh nền cho tiêu đề widget');
        ?>
</strong></label>
            <div>
                <?php 
        if (strpos($params['before_title'], '{css_title}') === false) {
            echo '<font color="red">Warning: không tìm thấy {css_title} tag trong tham số <em>before_title</em>. Để sử dụng trường này bạn cần thêm tag này vào tham số <em>before_title</em> cho sidebar hiện tại.</font>';
        }
        ?>
                <?php 
        if (isset($instance['bgimg_title'])) {
            ?>
                    <img class="user-preview-image" style="max-width:100%;" src="<?php 
            echo $instance['bgimg_title'];
            ?>
"><!-- display image -->
                <?php 
        }
        ?>
                <input type="hidden" name="<?php 
        echo $t->get_field_name('bgimg_title');
        ?>
" id="<?php 
        echo $t->get_field_id('bgimg_title');
        ?>
" value="<?php 
        echo isset($instance['bgimg_title']) ? $instance['bgimg_title'] : '';
        ?>
" class="regular-text" /><!-- show image url -->
                <input type='button' class="button-primary" value="Upload" id="<?php 
        echo $t->get_field_id('hw_awc_uploadimage');
        ?>
"/><br /><!-- upload button -->
                <script type="text/javascript">
                    jQuery(function( $ ) {
                        if(typeof hw_awc_btn_upload_image == 'function') {
                            hw_awc_btn_upload_image($( '#<?php 
        echo $t->get_field_id('hw_awc_uploadimage');
        ?>
' ), $( '#<?php 
        echo $t->get_field_id('bgimg_title');
        ?>
' ));
                        }

                    });
                </script>
                <p>

                    <input type="checkbox" name="<?php 
        echo $t->get_field_name('bgimg_title_css');
        ?>
" id="<?php 
        echo $t->get_field_id('bgimg_title_css');
        ?>
" onlick="this.value = this.checked" <?php 
        checked(isset($instance['bgimg_title_css']) ? 1 : 0);
        ?>
/>
                    <label for="<?php 
        echo $t->get_field_id('bgimg_title_css');
        ?>
"><?php 
        _e('Hiển thị ảnh nền cho tiêu đề widget');
        ?>
</label>
                </p>
            </div>
            </p>
            <!-- bg box -->
            <p>
                <label for="<?php 
        echo $t->get_field_id('hw_awc_upload_bgimg_box');
        ?>
"><strong><?php 
        _e('Ảnh nền cho nội dung widget');
        ?>
</strong></label><br/>
                <?php 
        if (strpos($params['after_title'], '{css_box}') === false && strpos($params['before_widget'], '{css_box}') === false) {
            echo '<div><font color="red">Warning: không tìm thấy {css_box} tag trong tham số <em>after_title</em> hoặc <em>before_widget</em>. Để sử dụng trường này bạn cần thêm tag này cho sidebar hiện tại.</font></div>';
        }
        ?>
                <?php 
        if (isset($instance['bgimg_box'])) {
            ?>
                    <img class="user-preview-image" style="max-width:100%;" src="<?php 
            echo $instance['bgimg_box'];
            ?>
"><!-- display image -->
                <?php 
        }
        ?>
                <input type="hidden" name="<?php 
        echo $t->get_field_name('bgimg_box');
        ?>
" id="<?php 
        echo $t->get_field_id('bgimg_box');
        ?>
"
                       value="<?php 
        echo isset($instance['bgimg_box']) ? $instance['bgimg_box'] : '';
        ?>
" class="regular-text" /><!-- show image url -->
                <input type='button' class="button-primary" value="Upload" id="<?php 
        echo $t->get_field_id('hw_awc_upload_bgimg_box');
        ?>
"/><br /><!-- upload button -->
            </p>
            <script type="text/javascript">
                jQuery(function( $ ) {
                    if(typeof hw_awc_btn_upload_image == 'function') {
                        hw_awc_btn_upload_image($( '#<?php 
        echo $t->get_field_id('hw_awc_upload_bgimg_box');
        ?>
' ),$('#<?php 
        echo $t->get_field_id('bgimg_box');
        ?>
'));
                    }

                });
                jQuery(function($){
                    //empty color input
                    var empty_color_input = function(obj){
                        $(obj).attr('value','').css({background:'#fff'});
                        $(obj).empty();
                        //remove color from input
                        //HW_AWC.jscolor_set(obj,'');//wrong it will reset to white color
                    };
                    //init jscolor when ajax response for all input field has 'color' class
                    $('input.color').each(function(i,obj){
                        var color = $(obj).val(),
                            clear_btn = $($(obj).next().next());

                        $(obj).data('clear_btn', clear_btn);
                        //bind clear color button
                        if(!$(obj).data('clear_color_btn')){
                            $(obj).data({
                                clear_color_btn:function(){
                                    empty_color_input(obj);
                                    //remove color from input
                                    //HW_AWC.jscolor_set(obj,'');//wrong it will reset to white color
                                }
                            });
                        }
                        clear_btn.bind('click',$(obj).data('clear_color_btn'));
                        //update color
                        if(color && $(obj).attr('value')){
                            HW_AWC.jscolor_set(obj,color);  //resume color in input tag
                        }
                        else {
                            setTimeout(function(){
                                empty_color_input(obj); //clear default white color
                                $(obj).data('clear_btn').trigger('click');
                            },1000);
                        }

                    });
                });

            </script>
        </div>
        <?php 
        if (isset($btn_tog)) {
            $btn_tog->set_button_toggle_end_wrapper();
        }
        //close feature tog
    }
 /**
  * The pre-defined validation callback method.
  *
  * The following hooks are available:
  *	- validation_{instantiated class name}_{field id} – [3.0.0+] receives the form submission value of the field that does not have a section. The first parameter: ( string|array ) submitted input value. The second parameter: ( string|array ) the old value stored in the database.
  *	- validation_{instantiated class name}_{section_id}_{field id} – [3.0.0+] receives the form submission value of the field that has a section. The first parameter: ( string|array ) submitted input value. The second parameter: ( string|array ) the old value stored in the database.
  *	- validation_{instantiated class name}_{section id} – [3.0.0+] receives the form submission values that belongs to the section.. The first parameter: ( array ) the array of submitted input values that belong to the section. The second parameter: ( array ) the array of the old values stored in the database.
  *	- validation_{page slug}_{tab slug} – receives the form submission values as array. The first parameter: submitted input array. The second parameter: the original array stored in the database.
  *	- validation_{page slug} – receives the form submission values as array. The first parameter: submitted input array. The second parameter: the original array stored in the database.
  *	- validation_{instantiated class name} – receives the form submission values as array. The first parameter: submitted input array. The second parameter: the original array stored in the database.
  */
 public function validation_HW_Sidebar_Settings($aInput, $aOldInput)
 {
     $enable_override_sidebar = HW_AWC_Sidebar_Settings::create_fieldname4sidebar('enable_override_sidebar', true);
     $status = isset($aInput[$enable_override_sidebar]) && $aInput[$enable_override_sidebar] ? '1' : '0';
     //disable preload stuff for skin
     //save current skin for enqueue
     //more skins
     $widget_skins = HW_AWC_Sidebar_Settings::available_widget_skins();
     foreach ($widget_skins as $name => $field) {
         $skin_field = HW_AWC_Sidebar_Settings::create_fieldname4sidebar($name, true);
         //also fixed sidebar name
         if (!empty($aInput[$skin_field])) {
             if (isset($aInput[$skin_field]['hash_skin']) && isset($aInput[$skin_field]['hwskin_config'])) {
                 $skin = APF_hw_skin_Selector_hwskin::resume_hwskin_instance($aInput[$skin_field]);
                 //
                 $skin->instance->save_skin_assets(array('skin' => $aInput[$skin_field], 'object' => 'sidebar-setting-' . $skin_field, 'status' => $status));
             }
         }
     }
     return $aInput;
 }