/**
  * @param array $tab_info
  * @param array $options
  */
 public function __construct($tab_info = array(), $options = array())
 {
     parent::__construct($tab_info, $options);
     //valid
     if (!is_array($options)) {
         $options = array();
     }
     if (!is_array($tab_info)) {
         $tab_info = array();
     }
     if (empty($tab_container)) {
         $tab_container = HW_String::generateRandomString();
     }
     $default_options = array('animate' => false, 'animationSpeed' => '1000', 'updateHash' => false);
     //easytabs options
     $this->set_options(array_merge($default_options, $options));
     //params
     $params = array('container_id' => 'hw-tabs-container', 'container_class' => $tab_container, 'tabs_menu_class' => 'tabs_menu_class', 'current_tab_class' => '', 'tab_content_class' => '');
     if (class_exists('HW_Module_Tabs') && HW_Module_Tabs::is_active()) {
         $setting = HW_Module_Tabs::get();
         $params['container_id'] = $setting->get_field_value('container_id', 'hw-tabs-container');
         $params['tabs_menu_class'] = $setting->get_field_value('tabs_menu_class');
         $params['current_tab_class'] = $setting->get_field_value('current_tab_class');
         $params['tab_content_class'] = $setting->get_field_value('tab_content_class');
     }
     $this->set_params($tab_info, $params);
     /*$this->info['container_id'] = $tab_container;
       $this->info['tabs_menu_class'] = $tab_container;*/
 }
 /**
  * Sets up the form.
  *
  * Alternatively you may use load_{instantiated class name} method.
  */
 public function load($oAdminWidget)
 {
     //get all hwml shortcodes
     $hwml_data = HWMLShortcode_Manager::get_hwml_slideshow_posts();
     HW_UI_Component::empty_select_option($hwml_data);
     //register form fields
     $this->addSettingFields(array('field_id' => 'title', 'type' => 'text', 'title' => __('Tiêu đề', 'hwml'), 'default' => ''), array('field_id' => 'slider', 'type' => 'select', 'label' => $hwml_data, 'title' => __('Chọn slider', 'hwml'), 'description' => ''), array('field_id' => 'use_default_slider', 'type' => 'checkbox', 'title' => 'Lấy slider mặc định', 'description' => 'Sử dụng slider đã thiết lập mặc định <a href="' . HW_NHP_Main_Settings::get_setting_page_url() . '" target="_blank">tại đây</a>.'), array());
 }
 /**
  * Sets up the form.
  *
  * Alternatively you may use load_{instantiated class name} method.
  */
 public function load($oAdminWidget)
 {
     //get all hwml shortcodes
     $data = hw_gallery_get_galleries();
     $galleries = array();
     foreach ($data as $gallery) {
         $galleries[$gallery['id']] = $gallery['title'];
     }
     HW_UI_Component::empty_select_option($galleries);
     //register form fields
     $this->addSettingFields(array('field_id' => 'title', 'type' => 'text', 'title' => __('Tiêu đề', 'hw-gallery'), 'default' => ''), array('field_id' => 'gallery', 'type' => 'select', 'label' => $galleries, 'title' => __('Chọn Gallery', 'hw-gallery'), 'description' => ''), array());
 }
 /**
  * buid condition select tag
  * @param $value
  * @param array $atts
  * @return string
  */
 public static function get_conditions_select_tag($value, $atts = array())
 {
     HW_HOANGWEB::load_class('HW_UI_Component');
     $options = array();
     $dynamic_settings = self::get_active_conditions_settings();
     foreach ($dynamic_settings as $id => $item) {
         $options[$id] = $item['title'];
     }
     if (class_exists('HW_Conditions_Manager', false)) {
         $guide_link = '(<a href="' . HW_Conditions_Manager::admin_condition_mananger_link() . '" target="_blank">Thêm điều kiện</a>)';
     } else {
         $guide_link = '';
     }
     return HW_UI_Component::build_select_tag($options, $value, $atts, true) . $guide_link;
 }
 /**
  * main class constructor
  */
 public function __construct()
 {
     //list taxonomies
     $tax_data = HW_POST::hw_list_taxonomies(array('hw-ml-slider'));
     //array_unshift($tax_data, '--Select--');
     HW_UI_Component::empty_select_option($tax_data);
     $this->tax_data = $tax_data;
     //list templates for current theme
     $this->theme_templates_list = array('-1' => 'Mặc định');
     $templates = hw_list_active_theme_templates();
     foreach ($templates as $file) {
         $this->theme_templates_list[base64_encode($file['path'])] = $file['name'];
     }
     //add action filters
     $this->add_actions();
 }
 /**
  * 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>';
 }
/**
 * render facebook comment box
 * @param $atts attributes
 */
function _hw_fb_comment_display($atts)
{
    HW_HOANGWEB::load_class('HW_UI_Component');
    $inst = HW_Module_Comments::get();
    $options = $inst->get_tab('facebook')->get_values();
    $atts = array();
    $appId = isset($options['appId']) ? $options['appId'] : '';
    $width = !empty($options['width']) ? HW_Validation::format_unit($options['width']) : '100%';
    $num_posts = !empty($options['num_posts']) ? $options['num_posts'] : '5';
    $colorscheme = !empty($options['colorscheme']) ? $options['colorscheme'] : 'light';
    $order_by = !empty($options['order_by']) ? $options['order_by'] : 'social';
    //order_by
    $show_count = !empty($options['show_count']) ? $options['show_count'] : 0;
    $comment_text = !empty($options['comment_text']) ? $options['comment_text'] : __('Bình luận');
    echo '<div id="fb-root"></div>';
    #echo '<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>';
    echo "\r\n<script>(function(d, s, id) {\r\n  var js, fjs = d.getElementsByTagName(s)[0];\r\n  if (d.getElementById(id)) return;\r\n  js = d.createElement(s); js.id = id;\r\n  js.src = '//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.5&appId={$appId}';\r\n  fjs.parentNode.insertBefore(js, fjs);\r\n}(document, 'script', 'facebook-jssdk'));</script>";
    //show count
    if ($show_count) {
        echo '<span class="fb-comments-count" data-href="' . get_permalink() . '"></span> ' . $comment_text;
    }
    if (isset($options['html5'])) {
        $atts['data-href'] = get_permalink();
        $atts['data-width'] = $width;
        $atts['data-numposts'] = $num_posts;
        $atts['data-order-by'] = $order_by;
        $atts['data-colorscheme'] = $colorscheme;
        echo '<div class="fb-comments" ' . HW_UI_Component::generateAttributes($atts) . '></div>';
    } else {
        $atts['href'] = get_permalink();
        $atts['width'] = $width;
        $atts['num_posts'] = $num_posts;
        $atts['order_by'] = $order_by;
        $atts['width'] = $width;
        echo '<fb:comments ' . HW_UI_Component::generateAttributes($atts) . '></fb:comments>';
    }
}
 /**
  * construct method
  * @param $args
  * @param $options
  */
 public function __construct($args = array(), $options = array())
 {
     parent::__construct($args, $options);
     //load cloudzoom lib
     HW_Libraries::enqueue_jquery_libs('cloudzoom');
     $this->cloudzoom_id = HW_String::generateRandomString();
     //valid
     if (!is_array($args)) {
         $args = array();
     }
     //params
     $default_params = array('images_from_current_post' => '0', 'zoombig_width' => '300px', 'zoombig_height' => '', 'container_id' => 'cloudzoom-container', 'container_class' => '', 'thumb_anchor_class' => 'cloudzoom-thumb-anchor-class', 'thumb_img_class' => 'cloudzoom-thumb-img-class', 'smallthumb_container_class' => 'cloudzoom-smallthumb-container', 'smallthumb_class' => 'cloudzoom-smallthumb-class', 'smallthumb_item_class' => 'cloudzoom-smallthumb-item-class', 'smallthumb_anchor_class' => 'cloudzoom-smallthumb-anchor-class', 'smallthumb_img_class' => 'cloudzoom-smallthumb-img-class');
     if (class_exists('HW_Module_Cloudzoom') && HW_Module_Cloudzoom::is_active()) {
         $setting = HW_Module_Cloudzoom::get();
         $params['images_from_current_post'] = $setting->get_field_value('images_from_current_post');
         $params['zoombig_width'] = $setting->get_field_value('zoombig_width');
         $params['zoombig_height'] = $setting->get_field_value('zoombig_height');
         $params['container_id'] = $setting->get_field_value('container_id');
         $params['container_class'] = $setting->get_field_value('container_class');
         $params['thumb_anchor_class'] = $setting->get_field_value('thumb_anchor_class');
         $params['thumb_img_class'] = $setting->get_field_value('thumb_img_class');
         $params['smallthumb_container_class'] = $setting->get_field_value('smallthumb_container_class');
         $params['smallthumb_class'] = $setting->get_field_value('smallthumb_class');
         $params['smallthumb_item_class'] = $setting->get_field_value('smallthumb_item_class');
         $params['smallthumb_anchor_class'] = $setting->get_field_value('smallthumb_anchor_class');
         $params['smallthumb_img_class'] = $setting->get_field_value('smallthumb_img_class');
     }
     $this->set_params($default_params);
     if (is_array($args)) {
         $this->set_params($args);
     }
     //cloud options
     if (is_array($options)) {
         $this->set_options($options);
     }
 }
 /**
  * Triggered when the tab is loaded.
  * @param $oAdminPage
  */
 public function replyToAddFormElements($oAdminPage)
 {
     $modules_pos = HW_Modules_Manager::get_modules_displayable();
     //list displayable modules
     $avaiable_pages = HW__Template::get_pages_select();
     //pages
     //get all register positions
     $positions = HW_Module_Positions::get_positions();
     HW_UI_Component::empty_select_option($positions);
     //condition
     $conditions = array();
     $dynamic_settings = HW_Condition::get_active_conditions_settings();
     foreach ($dynamic_settings as $id => $item) {
         $conditions[$id] = $item['title'];
     }
     HW_UI_Component::empty_select_option($conditions);
     $this->addFieldLabel('Cấu hình vị trí của các modules');
     $this->addFields(array('field_id' => 'modules_position', 'type' => 'hw_table_fields', 'title' => '', 'show_title_column' => false, 'repeatable' => false, 'show_root_field' => true, 'data_base_field' => 'col1', 'attributes' => array('hw_table_fields' => array()), 'fields' => array('col1' => array('name' => 'module', 'type' => 'select', 'options' => $modules_pos, 'description' => ''), 'col2' => array('name' => 'condition', 'type' => 'select', 'options' => $conditions, 'description' => ''), 'col3' => array('name' => 'page', 'type' => 'select', 'options' => $avaiable_pages, 'description' => ''), 'col4' => array('name' => 'position', 'type' => 'select', 'options' => $positions)), 'table_header' => array('col1' => 'Module', 'col2' => 'Điều kiện', 'col3' => 'Trang hiển thị', 'col4' => 'Vị trí')));
 }
        /**
         * load option widget title link
         * @param WP_Widget $t: widget object
         * @param array $instance: widget data
         */
        function do_widget_feature($t, $instance = array())
        {
            HW_HOANGWEB::load_class('HW_UI_Component');
            $this->widget_instance = $instance;
            $title = self::get_widget_title($t, $instance);
            $link = $this->get_field_value('link_widget_title');
            //link targets
            $link_targets = array('_blank' => '_blank', '_self' => '_self', '_parent' => '_parent', '_top' => '_top');
            ?>
        <fieldset><legend>Liên kết tiêu đề</legend>
            <!-- hidden fields -->
            <input type="hidden" name="<?php 
            echo $this->get_field_name('title');
            ?>
" id="<?php 
            echo $this->get_field_id('title');
            ?>
" value="<?php 
            echo $title;
            ?>
"/>
            <input type="hidden" name="<?php 
            echo $this->get_field_name('widget_name');
            ?>
" id="<?php 
            echo $this->get_field_id('widget_name');
            ?>
" value="<?php 
            echo $t->id_base;
            ?>
"/>

            <p><em>Chú ý: Đặt tiêu đề widget và nhấn lưu widget một lần nữa sau khi chọn liên kết.</em></p>
        <p>
            <label for="<?php 
            echo $this->get_field_id('link_widget_title');
            ?>
"><strong>Trỏ Liên kết vào tiêu đề</strong></label>
            <input type="text" class="hwawc-hidden" name="<?php 
            echo $this->get_field_name('link_widget_title');
            ?>
" id="<?php 
            echo $this->get_field_id('link_widget_title');
            ?>
" value="<?php 
            echo $link;
            ?>
"/>
        <div>
            <button class="button" id="<?php 
            echo $this->get_field_id('insert-link-btn');
            ?>
">Chọn liên kết</button>
                <span class="link">
                    <?php 
            if ($link) {
                ?>
                        <a href="<?php 
                echo $link;
                ?>
" target="_blank">Mở liên kết</a>
                    <?php 
            }
            ?>
                </span>
        </div>
            <div>
                <label for="<?php 
            $this->get_field_id('target_attr');
            ?>
"><strong>Target</strong></label>
                <?php 
            echo HW_UI_Component::build_select_tag($link_targets, $this->get_field_value('target_attr'), array('name' => $this->get_field_name('target_attr'), 'id' => $this->get_field_id('target_attr')));
            ?>
            </div>

        <script>
            var wpLinkL10n = {"title":"Insert\/edit link","update":"Update","save":"Add Link","noTitle":"(no title)","noMatchesFound":"No matches found."};
            jQuery('#<?php 
            echo $this->get_field_id('insert-link-btn');
            ?>
').on('click', function(event) {
                event.preventDefault();

                hw_awc_open_link_dialog(function(url){console.log(url);
                    jQuery('#<?php 
            echo $this->get_field_id('link_widget_title');
            ?>
').val(url).attr('value',url);

                },'<?php 
            echo $this->get_field_id('link_widget_title');
            ?>
',jQuery(this).next());

                return false;
            });
        </script>
        </p>
        </fieldset>
    <?php 
        }
 /**
  * extend from wordpress core
  * @param string $output
  * @param object $category
  * @param int $depth
  * @param array $args
  * @param int $id
  */
 public function start_el(&$output, $category, $depth = 0, $args = array(), $id = 0)
 {
     if (!empty($args['mydata']['skin_setting'])) {
         $skin_setting = $args['mydata']['skin_setting'];
     }
     $this->current_cat = new HW_TimberTerm($category);
     /** This filter is documented in wp-includes/category-template.php */
     $cat_name = apply_filters('list_cats', esc_attr($category->name), $category);
     //valid
     $options = (object) $args['options'];
     if (!isset($options->before)) {
         $options->before = '';
     }
     if (!isset($options->submenu_before)) {
         $options->submenu_before = '';
     }
     if (!isset($options->after)) {
         $options->after = '';
     }
     if (!isset($options->submenu_after)) {
         $options->submenu_after = '';
     }
     if (!isset($options->link_before)) {
         $options->link_before = '';
     }
     if (!isset($options->submenu_link_before)) {
         $options->submenu_link_before = '';
     }
     if (!isset($options->link_after)) {
         $options->link_after = '';
     }
     if (!isset($options->submenu_link_after)) {
         $options->submenu_link_after = '';
     }
     //whether current menu item has sub menu
     $item_has_sub = $this->item_has_sub($category);
     //separator
     if (!empty($options->ex_separator) && isset($options->show_items_separator)) {
         $output .= $options->ex_separator;
     }
     $data['args'] = hwArray::cloneArray($options);
     $data['indent'] = $indent = $depth ? str_repeat("\t", $depth) : '';
     $data['item_has_sub'] = $item_has_sub;
     $id = apply_filters('hw_cat_item_id', 'cat-item-' . $category->term_id, $category, $args, $depth);
     $data['id'] = ' id="cat-' . esc_attr($category->term_id) . '"';
     if ($item_has_sub && !empty($options->remove_link_parent)) {
         $data['remove_link_parent'] = true;
     } else {
         $data['remove_link_parent'] = false;
     }
     //item class
     //category item class
     $classes[] = 'cat-item cat-item-' . $category->term_id;
     if (!empty($args['current_category'])) {
         $_current_category = get_term($args['current_category'], $category->taxonomy);
         if ($category->term_id == $args['current_category']) {
             $classes[] = 'current-cat';
             if (isset($skin_setting['current_item_class'])) {
                 $classes[] = ' ' . $skin_setting['current_item_class'];
             }
         } elseif ($category->term_id == $_current_category->parent) {
             $classes[] = 'current-cat-parent';
         }
     }
     if ($item_has_sub && !empty($options->menu_item_class_has_submenu)) {
         //cat item class has submenu
         $classes[] = $options->menu_item_class_has_submenu;
     }
     if ($depth > 0 && !empty($options->menu_item_class_submenu)) {
         //cat item class in submenu
         $classes[] = $options->menu_item_class_submenu;
     }
     $data['classes'] = $class_names = join(' ', apply_filters('cat_item_css_class', HW_Validation::valid_classes_attr(array_filter($classes)), $category, $args, $depth));
     //custom fields
     $custom_item = get_post_custom($category->term_id);
     $data['field-01'] = isset($custom_item['menu-item-field-01'][0]) ? $custom_item['menu-item-field-01'][0] : '';
     $data['field-02'] = isset($custom_item['menu-item-field-02'][0]) ? $custom_item['menu-item-field-02'][0] : '';
     //cat item image
     if (isset($options->show_icon) && $options->show_icon) {
         $image_url = HW_ACF_Taxonomy::get_field_image($category);
         if ($image_url) {
             $image_img = '<img src="' . $image_url . '" class="hw-cat-item-icon"/>';
         } else {
             $image_img = '';
         }
     }
     $data['image_url'] = isset($image_url) ? $image_url : '';
     $data['image_img'] = isset($image_img) ? $image_img : '';
     /**
      * anchor attributes
      */
     $atts = array();
     $atts['href'] = esc_url(get_term_link($category));
     $atts['class'] = array();
     //anchor classes
     if ($item_has_sub && isset($options->anchor_class_has_submenu)) {
         //anchor class has submenu
         $atts['class'][] = $options->anchor_class_has_submenu;
     }
     if ($depth > 0 && !empty($options->anchor_class_submenu)) {
         //anchor class in submenu
         $atts['class'][] = $options->anchor_class_submenu;
     }
     $atts = apply_filters('hw_cat_link_attributes', $atts, $category, $args, $depth, $this);
     //validation
     $atts['class'] = HW_Validation::valid_classes_attr(array_filter($atts['class']));
     $atts['class'] = join(' ', $atts['class']);
     if ($args['use_desc_for_title'] && !empty($category->description)) {
         $atts['title'] = esc_attr(strip_tags(apply_filters('category_description', $category->description, $category)));
     }
     $attributes = HW_UI_Component::generateAttributes($atts);
     //addition attribute build for item link
     if ($depth == 0 && !empty($options->anchor_attrs)) {
         $attributes .= " {$options->anchor_attrs}";
     } elseif ($depth != 0 && !empty($options->anchor_attrs_submenu)) {
         $attributes .= " {$options->anchor_attrs_submenu}";
     }
     //attributes item link for submenu
     if ($item_has_sub && !empty($options->anchor_attrs_has_submenu)) {
         $attributes .= " {$options->anchor_attrs_has_submenu}";
     }
     $data['attributes'] = $attributes;
     $data['title'] = apply_filters('the_title', $category->name, $category->term_id);
     $link = $options->before;
     $link .= '<a ' . $attributes . ' >';
     $link .= $options->link_before . $cat_name . $options->link_after;
     $link .= '</a>';
     $link .= $options->after;
     //feed image
     if (!empty($args['feed_image']) || !empty($args['feed'])) {
         $link .= ' ';
         if (empty($args['feed_image'])) {
             $link .= '(';
         }
         $link .= '<a href="' . esc_url(get_term_feed_link($category->term_id, $category->taxonomy, $args['feed_type'])) . '"';
         if (empty($args['feed'])) {
             $alt = ' alt="' . sprintf(__('Feed for all posts filed under %s'), $cat_name) . '"';
         } else {
             $alt = ' alt="' . $args['feed'] . '"';
             $name = $args['feed'];
             $link .= empty($args['title']) ? '' : $args['title'];
         }
         $link .= '>';
         if (empty($args['feed_image'])) {
             $link .= $name;
         } else {
             $link .= "<img src='" . $args['feed_image'] . "'{$alt}" . ' />';
         }
         $link .= '</a>';
         if (empty($args['feed_image'])) {
             $link .= ')';
         }
     }
     if (!empty($args['show_count'])) {
         $link .= ' (' . number_format_i18n($category->count) . ')';
     }
     //render cat item
     if (isset($args['twig']) && HW_NAVMENU::twig_asset_exists('start_el.twig', $args['twig'])) {
         $tpl = $args['twig']->loadTemplate('start_el.twig');
         $data['term'] = $this->current_cat;
         $output .= $tpl->render($data);
     } else {
         if ('list' == $args['style']) {
             $output .= $indent . "\t<li";
             //class attr
             $output .= ' class="' . $class_names . '"';
             $output .= ">{$link}\n";
         } else {
             $output .= "\t{$link}<br />\n";
         }
     }
 }
/**
 * return HTML for select tag of terms list from taxonomy
 * @param $tax
 * @param $focus
 * @param array $atts
 * @param array $args
 * @return string|void
 */
function hw_get_terms_list($tax, $focus, $atts = array(), $args = array())
{
    if (!$tax) {
        return;
    }
    HW_HOANGWEB::load_class('HW_UI_Component');
    if (is_array($args)) {
        $args = array();
    }
    $args['order'] = 'ASC';
    $args['fields'] = 'all';
    $args['hide_empty'] = 0;
    //build atts
    $attrs = HW_UI_Component::generateAttributes($atts);
    /*foreach($atts as $att => $v){
    		$a.=$att.'="'.$v.'" ';
    	}*/
    $out = __('Rỗng');
    $terms_data = get_terms($tax, $args);
    if (is_wp_error($terms_data)) {
        return '';
    }
    if (count($terms_data)) {
        $out = '<select ' . trim($attrs) . '>';
        $out .= '<option value="">----All----</option>';
        foreach ($terms_data as $item) {
            if (!isset($item->slug)) {
                continue;
            }
            if ($item->slug == $focus) {
            }
            $out .= '<option ' . selected($item->slug, $focus, false) . ' value="' . $item->slug . '">' . $item->name . '</option>';
        }
        $out .= '</select>';
    }
    return $out;
}
    /**
     * @hook wp_footer
     */
    function print_footer()
    {
        if (is_product()) {
            $setting = self::get()->get_values();
            $thumbnailsContainer = isset($setting['smallthumb_container']) ? $setting['smallthumb_container'] : '.product .thumbnails';
            $productImages = isset($setting['productImages']) ? $setting['productImages'] : '.product .images > a';
            $mouseEvent = isset($setting['mouseEvent']) ? $setting['mouseEvent'] : 'mouseover';
            //css generator
            $css = array($thumbnailsContainer . ' img' => array('width' => get_option('woocommerce_thumbnail_image_width') . 'px'), '.cloud-zoom-big' => array());
            if (!empty($setting['zoombig_width'])) {
                $css['.cloud-zoom-big']['width'] = HW_Validation::format_unit($setting['zoombig_width']) . ' !important';
            }
            if (!empty($setting['zoombig_height'])) {
                $css['.cloud-zoom-big']['height'] = HW_Validation::format_unit($setting['zoombig_height']) . ' !important';
            }
            echo HW_UI_Component::generateCSS($css);
            ?>

            <script type="text/javascript">
                jQuery(document).ready(function($){
                    var $thumbnailsContainer, $thumbnails,$productImages, addCloudZoom;
                    $('a.zoom').unbind('click.fb');
                    $thumbnailsContainer = $('<?php 
            echo $thumbnailsContainer;
            ?>
');
                    $thumbnails = $('a', $thumbnailsContainer);

                    $productImages = $('<?php 
            echo $productImages;
            ?>
');
                    addCloudZoom = function(el){

                        el.addClass('cloud-zoom').CloudZoom();

                    }

                    if($thumbnails.length){
                        <?php 
            if ($mouseEvent == 'click') {
                echo '$thumbnails.unbind(\'click\');';
            }
            ?>

                        $thumbnails.bind('<?php 
            echo $mouseEvent;
            ?>
',function(){
                            var $image = $(this).clone(false);
                            $image.insertAfter($productImages);
                            $productImages.remove();
                            $productImages = $image;
                            $('.mousetrap').remove();
                            addCloudZoom($productImages);

                            return false;

                        })

                    }
                    addCloudZoom($productImages);

                });
            </script>
<?php 
        }
    }
 /**
  * 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) {
     $skin_for_term_field = $aSkin_field_name . '[terms][]';
     $skin_for_term_field_id = 'hwrp_skins_' . $post_type . '_term_' . $t->slug;
     $term_in_list = isset($skins[$post_type]['terms']) && in_array($t->slug, $skins[$post_type]['terms']) ? 'checked="checked"' : '';
     //check term already skin
 /**
  * get all pages
  * @param bool $empty_item
  * @return array
  */
 public static function get_pages_select($empty_item = true)
 {
     $pages = get_pages();
     $options = array();
     foreach ($pages as $page) {
         $options[$page->ID] = $page->post_title;
     }
     if ($empty_item) {
         HW_UI_Component::empty_select_option($options);
     }
     return $options;
 }
        /**
         * load options fixed widget feature
         * @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
            $enable_fixed = $this->get_field_value('awc_enable_fixed_widget');
            $lib = $this->get_field_value('awc_fixedobj_lib');
            echo '<div class="awc-widget-feature-fixed_widget"><fieldset><legend>Fixed widget</legend>';
            if (class_exists('HW_NHP_Main_Settings', false)) {
                echo '<p><a href="' . HW_NHP_Main_Settings::get_setting_page_url() . '" target="_blank">Kích hoạt & cấu hình fixed widget</a></p>';
            }
            echo '<div ><input type="checkbox" name="' . $this->get_field_name('awc_enable_fixed_widget') . '" id="' . $this->get_field_id('awc_enable_fixed_widget') . '" ' . esc_attr($enable_fixed ? 'checked="checked"' : '') . '/>';
            echo '<label for="' . $this->get_field_id('awc_enable_fixed_widget') . '"><strong>Kích hoạt fixed widget</strong></label></div>';
            //grids column
            echo '<label for="' . $this->get_field_id('awc_fixedobj_lib') . '"><strong>Chọn thư viện</strong></label>';
            $fixed_libs = array('sticky' => 'Sticky', 'sticky-kit' => 'Sticky Kit');
            echo HW_UI_Component::build_select_tag($fixed_libs, $lib, array('name' => $this->get_field_name('awc_fixedobj_lib'), 'id' => $this->get_field_id('awc_fixedobj_lib')));
            #echo '<div><label for="'.$t->get_field_id('awc_grid_fancybox').'"><strong>Số cột posts grid:</strong></label>';
            #echo '<input size="5" type="text" name="'.$t->get_field_name('awc_grid_fancybox').'" id="'.$t->get_field_id('awc_grid_fancybox').'" value="'.$instance['awc_grid_fancybox'].'"/></div>';
            /*echo '<div>
                        <span>Cài đặt options</span><br/>
            
                    </div>';*/
            if ($lib == 'sticky-kit') {
                if (file_exists(plugin_dir_path(__FILE__) . '/options-sticky-kit.php')) {
                    include plugin_dir_path(__FILE__) . '/options-sticky-kit.php';
                }
            } elseif (file_exists(plugin_dir_path(__FILE__) . '/options.php')) {
                include plugin_dir_path(__FILE__) . '/options.php';
            }
            //build theme options
            if (isset($theme_options)) {
                echo '<div id="' . $this->get_field_id('fixed_widget-settings') . '" class="">';
                echo $this->build_options($theme_options);
                echo '</div>';
            }
            echo '<script>
        jQuery(function($) {

        });
        </script>
        ';
            echo '</fieldset></div>';
        }
 /**
  * fields setting for positions tab
  */
 private function setting_form_positions_tab()
 {
     global $wp_registered_sidebars;
     $position_tab = $this->add_tab(array('id' => 'sidebars_pos', 'title' => 'Vị trí hiển thị', 'description' => 'Quản lý Vị trí hiển thị'));
     //get all register positions
     $positions = HW_Module_Positions::get_positions();
     HW_UI_Component::empty_select_option($positions);
     $position_tab->addFieldLabel('Cấu hình vị trí của sidebars');
     //list all avaiable sidebars
     $sidebars_list = array();
     foreach ($wp_registered_sidebars as $sidebar) {
         $sidebar = self::_valid_sidebar($sidebar);
         //valid
         if (!isset($sidebar['id'])) {
             continue;
         }
         $sidebars_list[$sidebar['id']] = !empty($sidebar['name']) ? $sidebar['name'] : $sidebar['description'];
     }
     $position_tab->addFields(array('field_id' => 'sidebars_position', 'type' => 'hw_table_fields', 'title' => '', 'show_title_column' => false, 'repeatable' => false, 'show_root_field' => true, 'data_base_field' => 'col1', 'attributes' => array('hw_table_fields' => array()), 'fields' => array('col1' => array('name' => 'sidebar', 'type' => 'select', 'options' => $sidebars_list, 'description' => ''), 'col2' => array('name' => 'position', 'type' => 'select', 'options' => $positions)), 'table_header' => array('col1' => 'Sidebar', 'col2' => 'Vị trí')));
 }