/**
  * show slider theme screenshot
  * @param $sCell
  * @param $iPostID
  */
 public function cell_hwml_shortcode_slider_theme($sCell, $iPostID)
 {
     $skin_info = get_post_meta($iPostID, 'slider_theme', true);
     $skin = APF_hw_skin_Selector_hwskin::resume_hwskin_instance($skin_info);
     if (count($skin)) {
         $data = $skin->instance->get_skin_data($skin->hash_skin);
         echo '<img class="hwml-shortcode-list hwml-skin-thumb" src="' . $data['screenshot'] . '"/>';
     }
 }
 /**
  * do footer skin
  */
 public static function do_footer_skin()
 {
     $footer_skin = hw_option('footer_skin');
     //get footer skin
     if (isset($footer_skin['hash_skin']) && isset($footer_skin['hwskin_config']) && class_exists('APF_hw_skin_Selector_hwskin')) {
         $skin = APF_hw_skin_Selector_hwskin::resume_hwskin_instance($footer_skin);
         $config = $skin->instance->get_file_skin_resource('functions.php', $skin->hash_skin);
         if (file_exists($config)) {
             include_once $config;
             //load footer skin configuration
         }
     }
 }
 /**
  * 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_Livechat_settings($aInput, $aOldInput)
 {
     if (isset($aInput['chat_skin']['skin_options'])) {
         //make sure exists current skin
         $options = $aInput['chat_skin']['skin_options'];
         //user skin options
         //resume hw_skin
         if (isset($aInput['chat_skin']['hash_skin']) && isset($aInput['chat_skin']['hwskin_config'])) {
             $skin = APF_hw_skin_Selector_hwskin::resume_hwskin_instance($aInput['chat_skin']);
             //
             if ($skin && isset($aInput['chat_skin']['hash_skin'])) {
                 $hash_skin = $aInput['chat_skin']['hash_skin'];
                 //current active skin
                 $skin_setting_file = $skin->instance->get_file_skin_setting($hash_skin);
                 //current skin setting
                 $skin_options = $skin->instance->get_file_skin_options();
                 //current skin options
                 if (file_exists($skin_setting_file)) {
                     include $skin_setting_file;
                 }
                 if (file_exists($skin_options)) {
                     include $skin_options;
                 }
                 if (isset($theme) && isset($theme['options'])) {
                     $default_options = $theme['options'];
                 } else {
                     $default_options = array();
                 }
                 if (isset($theme_options)) {
                     $options = HW_SKIN::merge_skin_options_values($options, $default_options, $theme_options);
                     //__save_session('y2',$options);
                     /*$_SESSION['y3']=$skin_setting;
                       $_SESSION['y4']=$default_options;*/
                 }
             }
         }
         //get demo live chat embed code
         if (isset($options['enable_demo_chat']) && strtolower($options['enable_demo_chat']) == 'on' && isset($options['demo_embedcode'])) {
             $aInput['chat_embed_code'] = $options['demo_embedcode'];
             //clear enable_demo_chat option to able to update 'enable_demo_chat' skin option in next time
             unset($aInput['chat_skin']['skin_options']['enable_demo_chat']);
         }
     }
     //save current skin for enqueue
     if (!empty($aInput['chat_skin'])) {
         HW_SKIN::save_enqueue_skin(array('type' => 'resume_skin', 'skin' => $aInput['chat_skin'], 'object' => 'livechat', 'status' => $aInput['enable_livechat']));
     }
     return $aInput;
 }
 /**
  * get qtranslate switcher
  */
 public static function get_qtrans_switcher()
 {
     $mqtrans_skin = hw_option('mqtrans_skin');
     //get mqtrans skin
     $other_service = hw_option('enable_googletranslate');
     //use google translate?
     if (isset($mqtrans_skin['hash_skin']) && isset($mqtrans_skin['hwskin_config'])) {
         $skin = APF_hw_skin_Selector_hwskin::resume_hwskin_instance($mqtrans_skin);
         //skin options
         //$skin_options = $mqtrans_skin['skin_options'];
         $html = '';
         //output
         $file = $skin->instance->get_skin_file($skin->hash_skin);
         //load footer template
         if (file_exists($file)) {
             HW_HOANGWEB::load_class('HW_String');
             HW_HOANGWEB::load_class('HW_Twig_Template');
             HW_HOANGWEB::load_class('HW_mqtranslate');
             //get theme setting file
             $setting = $skin->instance->get_file_skin_setting();
             //(new HW_SKIN);
             if (file_exists($setting)) {
                 include $setting;
             }
             //skin options
             $skin_options_file = $skin->instance->get_file_skin_options();
             //(new HW_SKIN)->enqueue_files_from_skin()
             $skin_options = isset($mqtrans_skin['skin_options']) ? $mqtrans_skin['skin_options'] : array();
             //user options
             $skin_options = HW_SKIN::merge_skin_options_values($skin_options, $setting, $skin_options_file);
             $data = array();
             //data send to twig template
             /*active google translate*/
             if ($other_service) {
                 $TranslateElement_opts = array('pageLanguage' => 'vi');
                 //layout
                 $layout = self::get_googletrans_layout_param(isset($skin_options['display_mode']) ? $skin_options['display_mode'] : '');
                 if ($layout) {
                     $TranslateElement_opts['layout'] = $layout;
                 }
                 //include languages
                 if (!empty($skin_options['specific_langs']) && is_array($skin_options['specific_langs'])) {
                     $TranslateElement_opts['includedLanguages'] = join($skin_options['specific_langs'], ',');
                 }
                 $data['google_translate_ID'] = !empty($skin_options['google_translate_ID']) ? $skin_options['google_translate_ID'] : HW_String::generateRandomString();
             } else {
                 //prepare data for template
                 if (class_exists('HW_mqtranslate')) {
                     // make sure use __autoload
                     $data = HW_mqtranslate::generateLanguageSelectCode();
                 }
             }
             //get templates folder from skin
             if (isset($theme) && isset($theme['templates_folder'])) {
                 $tpl = $theme['templates_folder'];
             } else {
                 $tpl = '';
             }
             if (class_exists('HW_Twig_Template')) {
                 $twig = HW_Twig_Template::create($skin->instance->get_file_skin_resource($tpl));
                 if (isset($data)) {
                     $twig->set_template_data($data);
                 }
                 //inject data to current twig for skin using
             }
             ob_start();
             //google translate
             if (isset($TranslateElement_opts)) {
                 $json = HW_SKIN_Option::build_json_options($TranslateElement_opts, null, 'layout');
                 echo '<script type="text/javascript">
                 function googleTranslateElementInit() {
                     new google.translate.TranslateElement(' . $json . ', "' . $data['google_translate_ID'] . '");
                 }
                 </script>
                 ';
             }
             $content = $skin->instance->render_skin_template(compact('wrapper', 'active_langs', 'text'), false);
             //data, return=false
             if ($content !== false) {
                 echo $content;
             }
             if ($skin->instance->allow_skin_file()) {
                 include $file;
             }
             $html = ob_get_contents();
             if ($html && ob_get_length()) {
                 ob_end_clean();
             }
         }
         //valid
         if (!isset($theme['styles'])) {
             $theme['styles'] = array();
         }
         if (!isset($theme['scripts'])) {
             $theme['scripts'] = array();
         }
         //put stuff from skin
         if (count($theme['styles']) || count($theme['scripts'])) {
             $skin->instance->enqueue_files_from_skin($theme['styles'], $theme['scripts']);
         }
         return $html;
     }
 }
 /**
  * modify field setting before render skin options fields
  * @param $field
  * @param $aField
  */
 public function _apf_renderOptionField($field, $aField)
 {
     if (empty($this->current_skin_setting)) {
         $menu = HW_NavMenu_Metabox_settings::get_active_menu();
         $skin = HW_NavMenu_Metabox_settings::get_menu_setting('skin', $menu);
         if ($skin) {
             $this->skin = APF_hw_skin_Selector_hwskin::resume_hwskin_instance($skin);
             $file = $this->skin->instance->get_skin_file($this->skin->hash_skin);
             if (file_exists($file)) {
                 $theme = array();
                 include $file;
                 $this->current_skin_setting = $theme;
             }
         }
     }
     if (!empty($this->current_skin_setting)) {
         $menu_args = $this->current_skin_setting['args'];
         if (isset($field['name']) && isset($menu_args[$field['name']])) {
             $field['value'] = $menu_args[$field['name']];
             //get args from skin for current menu
         }
     }
     if (isset($field['value']) && isset($field['description'])) {
         if (isset($field['method']) && $field['method'] == 'append') {
             $field['description'] .= '<br/>Thêm vào sau giá trị mặc định "<em><span style="color:blue">' . htmlspecialchars($field['value'], ENT_QUOTES) . '</span></em>" (thuộc về skin hiện tại)';
         } elseif (isset($field['method']) && $field['method'] == 'override') {
             $field['description'] .= '<br/>Sẽ thay thế giá trị mặc định "<em><span style="color:blue">' . htmlspecialchars($field['value'], ENT_QUOTES) . '</span></em>" (thuộc về skin hiện tại)';
         } else {
             $field['description'] .= '<br/>Giá trị mặc định "<em><span style="color:blue">' . htmlspecialchars($field['value'], ENT_QUOTES) . '</span></em>" (thuộc về skin hiện tại)';
         }
     }
     return $field;
 }
 /**
  * if this callback of the hook that mean you not link specific menu to wp_nav_menu
  * @hook filter 'wp_nav_menu_args'
  * @param $args
  */
 public function _modify_nav_menu_args($args)
 {
     //get current menu name
     $menu = self::get_menu_name($args);
     /**
      * get menu skin
      * first entry for through out menu filters
      */
     $skin = HW_NavMenu_Metabox_settings::get_menu_setting('skin', $menu);
     $enable_skin = HW_NavMenu_Metabox_settings::get_menu_setting('enable_skin', $menu);
     $enable_filter_menu = HW_NavMenu_Metabox_settings::get_menu_setting('enable_filter_menu', $menu);
     //add other menu setting to menu args
     $addition_menu_args = array('show_searchbox', 'remove_ul_wrap', 'only_anchor_tag_nav_menu', 'show_home_menu', 'allow_tags_nav_menu', 'show_icon');
     foreach ($addition_menu_args as $option) {
         $args[$option] = HW_NavMenu_Metabox_settings::get_menu_setting($option, $menu);
     }
     if ($enable_filter_menu && $enable_skin && $skin) {
         //parse SKIN object
         $this->skin = APF_hw_skin_Selector_hwskin::resume_hwskin_instance($skin);
         //parse into HW_SKIN object & saved as property
         $this->skin->file = $this->skin->instance->get_skin_file($this->skin->hash_skin);
         $options_config = $this->skin->instance->get_file_skin_options($this->skin->hash_skin);
         //theme options configuration
         $theme_setting = $this->skin->instance->get_file_skin_setting();
         //theme setting file
         //register twig loader
         if (class_exists('HW_Twig_Template')) {
             //Twig_Autoloader::register();
             //$loader = new Twig_Loader_Filesystem($this->skin->instance->get_file_skin_resource('tpl'));
             $this->twig = HW_Twig_Template::create($this->skin->instance->get_file_skin_resource('tpl'));
             #$this->twig = new Twig_Environment($loader);
             $args['twig'] = $this->twig->get();
             //reference twig object
         }
         if (file_exists($this->skin->file)) {
             $theme = array();
             $theme['styles'] = array();
             //init
             $theme['scripts'] = array();
             $theme['filters'] = array();
             //allow filters
             //keep this info (ex: menu) with filter that bind to callback to compare from current filter args
             $theme['menu'] = $menu;
             $user_options = array();
             //skin options
             if (file_exists($theme_setting)) {
                 include $theme_setting;
             }
             //theme setting
             if (file_exists($options_config)) {
                 include $options_config;
             }
             //options file
             if (isset($theme_options)) {
                 //$theme_options variable already exists in skin options
                 //$skin_options_config = hwskin_parse_theme_options($theme_options);
                 //get addition skin options value
                 $skin_options = isset($skin['skin_options']) ? $skin['skin_options'] : array();
                 if (empty($skin_options)) {
                     $skin_options = array();
                 }
                 //please go menu setting page & press on save button
                 $exclude_options = array('menu');
                 foreach ($exclude_options as $opt) {
                     if (isset($skin_options[$opt])) {
                         unset($skin_options[$opt]);
                     }
                 }
                 $user_options = HW_SKIN::get_skin_options($skin_options, $theme['args'], $theme_options);
                 $args = array_merge($args, $user_options);
                 //sync skin options with $args
                 //hope $args share to all remain menu filters in order to render final output menu to user
                 /*foreach($skin_options as $arg => $value){
                       $field_setting = $skin_options_config[$arg];
                       if(!isset($args[$arg])) $args[$arg] = '';   //set menu args from skin
                       //append if exists setting
                       if(isset($field_setting['method']) && $field_setting['method'] == 'append' && !empty($value)){
                           if(!in_array($value, preg_split('#[\s]+#',$args[$arg]))){
                               $args[$arg] .= (!empty($args[$arg])? ' ':'').trim($value);
                           }
                       }
                       //override setting if not exists
                       if(isset($field_setting['method']) && $field_setting['method'] == 'override' && !empty($value)){
                           $args[$arg] = $value;
                       }
                   }*/
             }
             //make sure have no ouput at here
             HW_SKIN::include_skin_file($this->skin->file);
             //extract wp_nav_menu_args from skin file
             /*if(isset($theme['args']) && is_array($theme['args'])){
                   //$args = array_merge($args, $theme['args']);
                   foreach($theme['args'] as $arg => $val){
                       if(isset($args[$arg])) $args[$arg] .= (!empty($args[$arg])? ' ':'').$val;     //append
                       else $args[$arg] = $val;    //create if not exists
                   }
               }*/
             $this->skin->instance->do_filters($theme['filters'], array($theme, $user_options));
             //do filters & actions that defined in skin
             //$this->skin->instance->enqueue_files_from_skin(null/*$theme['styles']*/, $theme['scripts']);    //put stuff from skin (note: css enqueue before)
             //new way for enqueue stuff from skin
             HW_SKIN::enqueue_skin_assets(array('instance' => $this->skin->instance, 'hash_skin' => $this->skin->hash_skin, 'skin_file' => $this->skin->file, 'theme_settings' => $theme, 'theme_options' => $args));
             //languages selector on the website
             $show_langs_switcher = HW_NavMenu_Metabox_settings::get_menu_setting('show_langs_switcher', $menu);
             //show search form in nav menu
             if ($show_langs_switcher) {
                 //get langs switcher output
                 $args['langs_switcher'] = hw_get_qtrans_switcher();
             }
             #$args = array_merge($args, $skin_options); //filtered values in above
             //if(isset($args['show_items_separator'])) ;
         }
         $args['walker'] = new HW_Nav_Menu_Walker();
     }
     $this->menu_args = (object) $args;
     //save current menu args
     /*if( 'primary' == $args['theme_location'] )
             {
                 $args['depth'] = -1;
                 $args['container_id'] = 'my_primary_menu';
             }
             if('menu1' == $args['menu']){    #maybe old wp version
                 $args['walker'] = new custom_walker();
             }
             //for custom menu widget
             if(isset($args['menu']) && isset($args['menu']->name) && $args['menu']->name == 'menu-header')
             {
     
             }*/
     return $args;
 }
 /**
  * pre-defined validation callback method
  * @param $sInput
  * @param $sOldInput
  * @return mixed
  */
 public function validation_HWML_Slider_Settings_Metabox($sInput, $sOldInput)
 {
     if (!isset($_SESSION['skin_options']) && isset($sInput['skin_options'])) {
         unset($sInput['skin_options']);
     }
     //disable old skin options & choose other skin options
     /*$skin = APF_hw_skin_Selector_hwskin::resume_hwskin_instance($sInput['slider_theme']);
       $skin_options_file = $skin->instance->get_file_skin_options($sInput['slider_theme']['hash_skin']);
       $theme_setting = $skin->instance->get_file_skin_setting();
       $skin_options = HW_SKIN::merge_skin_options_values($sInput['slider_theme']['skin_options'], $theme_setting, $skin_options_file);
       */
     //save current skin to db for this widget
     if (!empty($sInput['slider_theme'])) {
         if (isset($sInput['slider_theme']['hash_skin']) && isset($sInput['slider_theme']['hwskin_config'])) {
             $skin = APF_hw_skin_Selector_hwskin::resume_hwskin_instance($sInput['slider_theme']);
             //
             $skin->instance->save_skin_assets(array('skin' => $sInput['slider_theme'], 'object' => 'hw-mlslider-' . $sInput['post_ID']));
         }
     }
     /* Set a flag
             $_fIsValid = true;
     
             // Prepare an field error array.
             $_aErrors = array();
     
             // Use the debug method to see what are passed.
             // $this->oDebug->logArray( $sInput );
     
             // Check if a url is passed
             if ( ! filter_var( $sInput, FILTER_VALIDATE_URL ) ) {
     
                 $_fIsValid = false;
                 // $variable[ 'field_id' ]
                 $_aErrors['url'] = __( 'The value must be a url:', 'admin-page-framework-tutorials' ) . ' ' . $sInput;
     
             }
     
             // An invalid value is found.
             if ( ! $_fIsValid ) {
     
                 // Set the error array for the input fields.
                 $this->setFieldErrors( $_aErrors );
                 $this->setSettingNotice( __( 'There was something wrong with your input.', 'admin-page-framework-tutorials' ) );
                 return $sOldInput;
     
             }*/
     return $sInput;
 }
        ?>
"  /></a>
        <!-- <div class="label_text"><p><?php 
        echo $query->post->post_excerpt;
        ?>
</p></div> -->
    <!-- </li> -->
<?php 
    }
}
?>
  <!--  </ul> -->
    </div>
</div>
<script type="text/javascript">
 <?php 
$options = APF_hw_skin_Selector_hwskin::build_json_options($user_theme_options);
?>
 jQuery(window).load(function () {    //because it render directly so please don't wrapper in jquery event that will make ui crash & any lib (here is nivoSlider) not work
     jQuery('#nivo-slider-<?php 
echo $slider_id;
?>
').nivoSlider(
         <?php 
echo $options;
?>
 );
});


</script>
            the_title();
        }
        ?>
</h2>
    </li> -->

<?php 
    }
}
?>
       <!-- </ul> -->
    </div>
</div>
<?php 
//remove key not belong jcarousel option
$options = APF_hw_skin_Selector_hwskin::build_json_options($user_theme_options, 'template_file');
?>
<script type="text/javascript">
    jQuery(document).ready(function ($) {
        jQuery("#makeMeScrollable-<?php 
echo $slider_id;
?>
").smoothDivScroll(<?php 
echo $options;
?>
);
        <?php 
if (!empty($options['pause_on_hover']) && $options['pause_on_hover']) {
    ?>
        // Mouse over
        jQuery("#makeMeScrollable-<?php 
 /**
  * display socials icon
  * @param string $skin
  */
 public static function do_social_skin($skin = '')
 {
     //valid
     //if(empty($skin)) $skin = 'default';
     //get option
     $social = hw_option('social_skin');
     if (!isset($social['all_skins'])) {
         printf('<em>Vui lòng nhấn Save changes <a href="%s">ở đây</a> trước khi sử dụng.</em>', admin_url('admin.php?page=hoangweb-theme-options&tab=socials-options'));
         return;
     }
     $data_skins = unserialize(base64_decode($social['all_skins']));
     //get user skin
     if (empty($skin) && isset($social['hash_skin'])) {
         //default user selected skin
         $hash_skin = $social['hash_skin'];
     } elseif ($skin && isset($data_skins[$skin])) {
         //get any skin by name
         $hash_skin = $data_skins[$skin];
     }
     if (!isset($hash_skin)) {
         return;
     }
     //validate
     if ($hash_skin && isset($social['hwskin_config']) && class_exists('APF_hw_skin_Selector_hwskin')) {
         $skin = APF_hw_skin_Selector_hwskin::resume_hwskin_instance($social);
         $file = $skin->instance->get_skin_file($hash_skin);
         //(new HW_SKIN)->get_skin_url('');
         //get theme setting file
         $setting = $skin->instance->get_file_skin_setting();
         if (file_exists($setting)) {
             include $setting;
         }
         //$skin_url = $skin->instance->get_skin_url('');
         $skin_variables = $skin->instance->get_skin_variables();
         if (file_exists($file)) {
             HW_HOANGWEB::load_class('HW_Twig_Template');
             //get templates folder from skin
             if (isset($theme) && isset($theme['templates_folder'])) {
                 $tpl = $theme['templates_folder'];
             } else {
                 $tpl = '';
             }
             //prepare data for template
             $data = array('facebook_url' => hw_option('fb_url'), 'googleplus_url' => hw_option('gplus_url'), 'twitter_url' => hw_option('twitter_url'), 'youtube_url' => hw_option('youtube_url'), 'skin_variables' => $skin_variables, 'SKIN_URL' => $skin_variables['url']);
             $twig = HW_Twig_Template::create($skin->instance->get_file_skin_resource($tpl));
             $twig->set_template_data($data);
             //inject data to current twig for skin using
             $content = $skin->instance->render_skin_template($data, false);
             //data, return=false
             if ($content !== false) {
                 echo $content;
             }
             if ($skin->instance->allow_skin_file()) {
                 include $file;
             }
             //load footer skin configuration
         }
         //valid
         if (!isset($theme['styles'])) {
             $theme['styles'] = array();
         }
         if (!isset($theme['scripts'])) {
             $theme['scripts'] = array();
         }
         //put stuff from skin
         if (count($theme['styles']) || count($theme['scripts'])) {
             $skin->instance->enqueue_files_from_skin($theme['styles'], $theme['scripts']);
         }
     }
 }
 /**
  * get footer, instead of calling get_footer()
  * @param $slug from get_footer() param
  */
 public static function get_footer($slug = '')
 {
     $footer_skin = hw_option('footer_skin');
     //get footer skin
     //skin options
     if (!empty($footer_skin) && !empty($footer_skin['skin_options'])) {
         $skin_options = $footer_skin['skin_options'];
         extract($skin_options);
     }
     if (isset($footer_skin['hash_skin']) && isset($footer_skin['hwskin_config'])) {
         $skin = APF_hw_skin_Selector_hwskin::resume_hwskin_instance($footer_skin);
         $file = $skin->instance->get_skin_file($skin->hash_skin);
         //get theme setting file
         $setting = $skin->instance->get_file_skin_setting();
         //(new HW_SKIN);
         if (file_exists($setting)) {
             include $setting;
         }
         $skin->instance->render_skin_template(compact('col', 'col_1', 'col_2', 'col_3'), true);
         //render skin twig template
         //load footer template
         if ($skin->instance->allow_skin_file() && file_exists($file)) {
             include_once $file;
         }
         //valid
         if (!isset($theme['styles'])) {
             $theme['styles'] = array();
         }
         if (!isset($theme['scripts'])) {
             $theme['scripts'] = array();
         }
         //put stuff from skin
         /*if(count($theme['styles']) || count($theme['scripts'])) {
               $skin->instance->enqueue_files_from_skin($theme['styles'], $theme['scripts']);
           }
           */
         if (isset($theme['filters'])) {
             $skin->instance->do_filters($theme['filters'], $theme);
         }
         //do skin filter/action
         //enqueue stuff from skin using new way
         HW_SKIN::enqueue_skin_assets(array_merge(array('skin_file' => $file, 'theme_settings' => $theme), (array) $skin));
     } else {
         get_footer($slug);
         //include default footer-$slug.php
     }
     do_action('hw_get_footer');
     //modify footer output, you can add close html tag for example to make fit your wp theme
 }
<?php

/**
 * Plugin name: perfect scrollbar
 */
//include theme setting
include 'theme-setting.php';
//valid theme options
if (!empty($scrollbar_theme_options['width'])) {
    $width = self::format_unit($scrollbar_theme_options['width']);
}
if (!empty($scrollbar_theme_options['height'])) {
    $height = self::format_unit($scrollbar_theme_options['height']);
}
//remove key not belong option
$options = APF_hw_skin_Selector_hwskin::build_json_options($scrollbar_theme_options, 'width,height');
?>
<script type="text/javascript">
    jQuery(function($)
    {
        jQuery("#<?php 
echo $hwtpl_wrapper_id;
?>
 .<?php 
echo $hwtpl_scrollbar_wrapper_class;
?>
").perfectScrollbar(<?php 
echo $options;
?>
);
    });
 /**
  * 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;
 }
 /**
  *
  */
 public function _hw_wp_footer()
 {
     if (hw_livechat_option('enable_livechat')) {
         //load mobile detector library
         if (function_exists('hwlib_load_library')) {
             $mobile_detect = hwlib_load_library('HW_Mobile_Detect');
             if ($mobile_detect->object->isMobile() && !hw_livechat_option('active_on_mobile')) {
                 return;
                 //do not show chatbox on mobile device
             }
         }
         /*if(class_exists('HW_Mobile_Detect')) {
               HW_PHP_Libraries::get('HW_Mobile_Detect');
           }*/
         //get embed live chat code
         $embed = hw_livechat_option('chat_embed_code');
         if ($embed) {
             echo $embed;
         }
         /**
          * apply skin
          */
         $skin_data = hw_livechat_option('chat_skin');
         $skin = APF_hw_skin_Selector_hwskin::resume_hwskin_instance($skin_data);
         if ($skin && !empty($skin->instance)) {
             $file = $skin->instance->get_skin_file($skin->hash_skin);
             if (file_exists($file)) {
                 $theme = array();
                 //valid
                 include $file;
                 //depricated
                 /*if(!isset($theme['styles'])) $theme['styles'] = array();
                                     if(!isset($theme['scripts'])) $theme['scripts'] = array();
                 
                                     if(count($theme['styles']) || count($theme['scripts'])) {
                                         $skin->instance->enqueue_files_from_skin(null//$theme['styles']//, $theme['scripts']);  //enqueued css before
                                     }*/
                 HW_SKIN::enqueue_skin_assets(array_merge(array('skin_file' => $file), (array) $skin));
             }
         }
     }
 }
 /**
  * add shortcode to display slider on website
  * @param array $attsa
  */
 public function _hwml_shortcode_slider($atts = array())
 {
     $default = array('id' => false, 'restrict_to' => false);
     extract(shortcode_atts($default, $atts, 'hwml_slider'));
     if (!$id) {
         return false;
     }
     // handle [hwml_slider id=123 restrict_to=home]
     if ($restrict_to && $restrict_to == 'home' && !is_front_page()) {
         //front page
         return;
     }
     if ($restrict_to && $restrict_to != 'home' && !is_page($restrict_to)) {
         //for page
         return;
     }
     $id = trim($id, '&quot;');
     $post = get_post($id);
     //_print(get_post_custom($id));
     $slider_id = get_post_meta($id, 'pick_slider', true);
     //meta slider id
     $slider_theme = get_post_meta($id, 'slider_theme', true);
     //slider theme
     $source = get_post_meta($id, 'slideshow_source', true);
     //choose slideshow source
     if (!$slider_id && !$slider_theme) {
         throw new Exception('Lỗi custom field (hwml-shortcode)?');
         return;
     }
     //instance HW_SKIN
     $skin = APF_hw_skin_Selector_hwskin::resume_hwskin_instance($slider_theme);
     //current skin file
     $file = $skin->instance->get_skin_file($skin->hash_skin);
     $skin_config = $skin->instance->get_config(false);
     $skin_info = $skin->instance->get_active_skin_info();
     $options_config = $skin->instance->get_file_skin_options($skin->hash_skin);
     //theme options configuration
     $theme_setting = $skin->instance->get_file_skin_setting();
     //(new HW_SKIN)->get_file_skin_setting()
     //theme options
     $user_theme_options = isset($slider_theme['skin_options']) && is_array($slider_theme['skin_options']) ? $slider_theme['skin_options'] : array();
     /*
     //load skin resource
     if(file_exists($options_config)) include($options_config);   //include define theme options
     if(file_exists($theme_setting)) include($theme_setting);        //theme setting
     
     if( isset($theme_options) && isset($theme)){
         $default = isset($theme['options']) ? $theme['options'] : array();
     
         $result = HW_SKIN::get_skin_options($user_theme_options, $default,$theme_options);
         $user_theme_options = array_merge($user_theme_options, $result);
     }
     */
     //new way
     $user_theme_options = HW_SKIN::merge_skin_options_values($user_theme_options, $theme_setting, $options_config);
     //get default template for this skin base slideshow source
     $default_template = $skin_info[0] . '/' . $skin_info[1] . trim($skin_config['skin_name'], '.php') . '_template_' . $source . '.php';
     //default template
     if (file_exists($default_template) && isset($user_theme_options['template_file']) && $user_theme_options['template_file'] == APF_hw_skin_Selector_hwskin::DEFAULT_TEMPLATE) {
         $file = $default_template;
         //change template file
     } elseif (isset($user_theme_options['template_file']) && $user_theme_options['template_file'] != APF_hw_skin_Selector_hwskin::DEFAULT_TEMPLATE) {
         $file = base64_decode($user_theme_options['template_file']);
     }
     if (file_exists($file)) {
         //get data
         $show_title = get_post_meta($id, 'show_title', true);
         $data = array();
         //valid data
         if (isset($user_theme_options['template_file'])) {
             unset($user_theme_options['template_file']);
         }
         //get sides from metaslider
         if ($source == 'metaslider') {
             $query = $this->get_mlslider_metaslides($slider_id);
             $data['posts'] = Timber::get_posts($query->query_vars);
         }
         //get sides from posts
         if ($source == 'posttype') {
             //get query post types
             $posttype = get_post_meta($id, 'source_posttype', true);
             //get active post types
             $current_post = get_post_meta($id, 'current_post', true);
             //get active post types
             $only_attachment = get_post_meta($id, 'only_attachments', true);
             //get only attachments
             $args = array('order' => 'ASC', 'posts_per_page' => -1);
             $query = null;
             $images = array();
             if ($current_post) {
                 global $post;
                 if (is_single()) {
                     $images = get_children(array('post_parent' => $post->ID, 'post_type' => 'attachment', 'post_mime_type' => 'image'));
                 }
             } else {
                 //get all selected terms assign to post type
                 $pt_terms = get_post_meta($id, 'post_type_terms', true);
                 $tax_query_relation = get_post_meta($id, 'tax_query_relation', true);
                 $terms_tax = array();
                 //prepare tax query
                 $tax_query = array();
                 //tax_query param
                 if ($tax_query_relation) {
                     $tax_query['relation'] = $tax_query_relation;
                 }
                 if (is_array($pt_terms)) {
                     foreach ($pt_terms as $t => $enable) {
                         if ($enable) {
                             $tax = base64_decode($t);
                             $tax = explode('|', $tax);
                             if (!isset($terms_tax[$tax[1]])) {
                                 $terms_tax[$tax[1]] = array();
                             }
                             $terms_tax[$tax[1]][] = $tax[0];
                         }
                     }
                 }
                 //build tax_query param
                 foreach ($terms_tax as $tax => $terms) {
                     $tax_query[] = array('taxonomy' => $tax, 'field' => 'slug', 'terms' => $terms, 'operator' => 'IN');
                 }
                 //$terms = wp_get_post_terms($id,'category',array("fields" => "ids"));
                 $args['post_type'] = $posttype;
                 $args['tax_query'] = $tax_query;
                 $query = new WP_Query($args);
                 $data['posts'] = Timber::get_posts($args);
                 //get only attachments image
                 if ($only_attachment) {
                     //refercence http://wordpress.stackexchange.com/questions/52315/get-attachments-for-all-posts-of-particular-post-type
                     if ($query->have_posts()) {
                         while ($query->have_posts()) {
                             $query->the_post();
                             // arguments for get_posts
                             $attachment_args = array('post_type' => 'attachment', 'post_mime_type' => 'image', 'post_status' => null, 'post_parent' => get_the_ID());
                             // get the posts
                             $this_posts_attachments = get_posts($attachment_args);
                             // append those posts onto the array
                             $images[get_the_ID()] = $this_posts_attachments;
                             // make an array with the post_id as the key, just in case that's useful
                         }
                     }
                 }
             }
         }
         //skin data
         $options = APF_hw_skin_Selector_hwskin::build_json_options($user_theme_options, 'template_file');
         $slider_theme = !empty($user_theme_options['theme']) ? $user_theme_options['theme'] : 'default';
         $data = compact('slider_id', 'options', 'slider_theme', 'show_title');
         $data['context'] = $this;
         /**
          * parse theme
          */
         $content = $skin->instance->render_skin_template($data, false);
         //implement skin template
         if ($content !== false) {
             echo $content;
         }
         $theme = array();
         //valid
         if ($skin->instance->allow_skin_file()) {
             include_once $file;
         }
         /*if(!isset($theme['styles'])) $theme['styles'] = array();
                     if(!isset($theme['scripts'])) $theme['scripts'] = array();
         
                     if(count($theme['styles']) || count($theme['scripts'])) {
                         $skin->instance->enqueue_files_from_skin($theme['styles'], $theme['scripts']);
                     }*/
         //enqueue stuff from skin
         HW_SKIN::enqueue_skin_assets(array('instance' => $skin->instance, 'hash_skin' => $skin->hash_skin, 'skin_file' => $file, 'theme_settings' => $theme, 'theme_options' => $user_theme_options));
     }
 }