Exemplo n.º 1
0
/**
 * ajax  handle callback
 * @hook wp_ajax_{hw_help_popup}
 */
function hw_ajax_hw_help_popup()
{
    if (!wp_verify_nonce($_REQUEST['nonce'], "hw-module-help-nonce")) {
        exit("No naughty business please");
    }
    if (!isset($_REQUEST['file'])) {
        return;
    }
    HW_HOANGWEB::load_class('HW_WP');
    //enqueue syntax highlighter library
    if (class_exists('HW_Libraries', false)) {
        HW_Libraries::enqueue_jquery_libs('syntaxhighlighter_3.0.83');
        HW_Libraries::get('syntaxhighlighter_3.0.83')->enqueue_scripts('shBrushJScript.js', 'shBrushXml.js', 'shBrushPhp.js');
    }
    $file = HW_Encryptor::decrypt(urldecode($_REQUEST['file']));
    if (file_exists($file)) {
        echo file_get_contents($file);
    }
    HW_WP::hw_clean_wp_head();
    //wp_head();
    wp_footer();
    //init SyntaxHighlighter
    echo '
        <script type="text/javascript">
    //SyntaxHighlighter
    if(typeof SyntaxHighlighter != "undefined") SyntaxHighlighter.all();
    </script>
    ';
    die;
}
Exemplo n.º 2
0
/**
 * return all terms taxonomies base post type
 * @param $post_type: post type name
 * @param $args: addition arguments
 */
function hwrp_get_all_terms_taxonomies($post_type, $args = array())
{
    if (!class_exists('HW_POST')) {
        HW_HOANGWEB::load_class('HW_POST');
    }
    return HW_POST::get_all_terms_taxonomies($post_type, $args);
}
Exemplo n.º 3
0
 /**
  * auto load class
  * note: we rename autoload function to hw__autoload and load directly class in method HW_HOANGWEB::loadclass
  * ->why? because some hosting web server call autoload different behavior.
  * @param $lib: which class will be load
  */
 public static function hw__autoload($lib)
 {
     static $onces = array();
     //include $class_name . '.php';
     $libs = isset(HW_HOANGWEB::$hw_global['classes']) ? HW_HOANGWEB::$hw_global['classes'] : array();
     //load all libs
     $_lib = HW_HOANGWEB::get_class($lib);
     //= $libs[$lib]
     if (!empty($_lib) && is_string($lib) && !isset($onces[$lib]) && isset($_lib['class']) && !class_exists($_lib['class'], false)) {
         $debug = defined('WP_DEBUG') && WP_DEBUG;
         //debug version
         if (0 && $debug && isset($_lib['debug']) && file_exists($_lib['debug'])) {
             //for convernion i alway run release version
             $file = $libs[$lib]['debug'];
         } elseif (isset($_lib['release']) && file_exists($_lib['release'])) {
             $file = $_lib['release'];
         }
         //check required other
         if (isset($_lib['deps'])) {
             foreach ((array) $_lib['deps'] as $require) {
                 if (!$require || class_exists($require, false)) {
                     continue;
                 }
                 HW_HOANGWEB::register_class($require, HW_HOANGWEB::setup_classes($require));
             }
         }
         if (isset($file)) {
             require_once $file;
         }
         $onces[$lib] = true;
     }
 }
Exemplo n.º 4
0
 /**
  * main constructor
  */
 public function __construct()
 {
     HW_HOANGWEB::register_class('HW_Tabs', dirname(__FILE__) . '/class-ui-tabs.php');
     #HW_HOANGWEB::load_class('HW_Tabs');
     $this->enable_tab_settings();
     $this->enable_submit_button();
 }
 /**
  * setup form fields
  */
 public function setUp()
 {
     // Set the root menu
     $this->setRootMenuPage('Settings');
     // specifies to which parent menu to add.
     // Add the sub menus and the pages
     $this->addSubMenuItems(array('title' => 'Lưu cấu hình widgets', 'page_slug' => self::PAGE_SLUG));
     //define tabs
     $this->addInPageTabs(self::PAGE_SLUG, array('tab_slug' => 'widgets-config', 'title' => __('Cấu hình widgets')));
     $this->setInPageTabTag('h2');
     // sets the tag used for in-page tabs
     //init fields
     $this->addSettingFields(array('field_id' => 'list_saved_widgets_setting', 'type' => 'hw_admin_table', 'title' => '', 'show_title_column' => false, 'WP_List_Table' => 'HW_List_Table_Widgets_settings', 'columns' => array('id' => __('ID'), 'name' => __('Tên'), 'group' => __('Nhóm'), 'widget' => __('Widget'), 'description' => __('Mô tả'), 'setting' => __('Config')), 'sortable_columns' => array('id' => array('id', false), 'name' => array('name', false), 'group' => array('group', false))));
     /*$this->addSettingFields(
                 array(
                     'field_id' => 'test',
                     'type' => 'text',
                     'title' => 'Title 1',
     
                 )
             );*/
     //actions
     if (class_exists('HW_HELP')) {
         $page_hook = HW_HELP::load_settings_page_hook_slug(self::PAGE_SLUG);
     } else {
         $page_hook = 'load-settings_page_' . self::PAGE_SLUG;
     }
     add_action($page_hook, array($this, '_add_options'));
     if (class_exists('HW_HOANGWEB') && HW_HOANGWEB::is_current_screen('hw_widgets_settings')) {
         add_action('admin_enqueue_scripts', array($this, '_admin_enqueue_scripts'));
     }
 }
Exemplo n.º 6
0
/**
 * register all widget features
 */
function hwawc_register_widget_features()
{
    $group = 'widget-features';
    $features = array('saveconfig' => array('class' => 'AWC_WidgetFeature_saveconfig', 'alias' => 'save config'), 'grid_posts' => array('class' => 'AWC_WidgetFeature_grid_posts', 'alias' => 'grid posts'), 'fancybox' => array('class' => 'AWC_WidgetFeature_fancybox', 'alias' => 'fancybox'), 'fonticons' => array('class' => 'AWC_WidgetFeature_fonticons', 'alias' => 'font icons'), 'title_link' => array('class' => 'AWC_WidgetFeature_title_link', 'alias' => 'Widget title Link'), 'shortcode_params' => array('class' => 'AWC_WidgetFeature_shortcode_params', 'alias' => 'Shortcode params'), 'fixed_widget' => array('class' => 'AWC_WidgetFeature_fixed_widget', 'alias' => 'Fixed widget'), 'hide_widget' => array('class' => 'AWC_WidgetFeature_hide_widget', 'alias' => 'Hide Widget'), 'export' => array('class' => 'AWC_WidgetFeature_export', 'alias' => 'Export Widget'));
    foreach ($features as $name => $arg) {
        HW_HOANGWEB::register_class($arg['class'], HW_AWC_WidgetFeatures_PATH . "/{$name}/awc-widgetfeature-{$name}.php", $arg['alias'], $group);
    }
}
 /**
  * for backend
  */
 public function _admin_enqueue_scripts()
 {
     if (HW_HOANGWEB::is_current_screen('widgets')) {
         //ckeditor
         HW_Libraries::enqueue_jquery_libs('ckeditor');
         wp_enqueue_script('media');
         wp_enqueue_media();
     }
 }
Exemplo n.º 8
0
 /**
  * Main class constructor
  */
 public function __construct()
 {
     include_once dirname(__FILE__) . '/widget/hw-widget-multitranslate.php';
     //translate selector widget
     //load HW_mqtranslate class
     HW_HOANGWEB::register_class('HW_mqtranslate', dirname(__FILE__) . '/class-hw_mqtranslate.php');
     HW_HOANGWEB::load_class('HW_mqtranslate');
     add_action('wp_footer', array($this, '_hw_wp_footer'));
 }
Exemplo n.º 9
0
 /**
  * main class constructor
  */
 public function __construct()
 {
     HW_HOANGWEB::register_class('HW_Gmap', dirname(__FILE__) . '/includes/class-ui-gmap.php');
     //enable setting tab for this module
     $this->enable_tab_settings();
     $this->enable_submit_button();
     //register shortcode for display map
     add_shortcode('hw_googlemap', array($this, '_hw_render_google_map'));
 }
Exemplo n.º 10
0
 public function __construct()
 {
     HW_HOANGWEB::load_class('HW_Validation');
     //enable tab settings
     $this->enable_tab_settings();
     $this->enable_submit_button();
     //wp hooks
     $this->_setup_actions();
 }
 /**
  * initial
  */
 private static function init()
 {
     if (class_exists('HW_HOANGWEB')) {
         //load twig template engine
         HW_HOANGWEB::load_class('Twig_Autoloader');
         //if not work try this
         //if class not found try include directly
         //include_once(HW_HOANGWEB_PATH . '/lib/vendor/autoload.php');
     }
 }
Exemplo n.º 12
0
 /**
  * construct
  */
 public function __construct()
 {
     if (!$this->check_already()) {
         return;
     }
     if (class_exists('HW_HOANGWEB')) {
         //load twig template engine
         #HW_HOANGWEB::load_class('Twig_Autoloader');    //please load what just you used, because this library use in class 'HW_Twig_Template'. For reason, php play on hosting and it make sence to read you code,
         HW_HOANGWEB::load_class('HW_Twig_Template');
     }
     $this->setup_hooks();
     //init hooks
 }
 /**
  * main class construct method
  */
 public function __construct()
 {
     parent::__construct();
     $this->setMenuItem(array('title' => 'Cài Modules', 'page_slug' => 'hw-install-module'));
     //$this->enable_submit_button();
     $this->support_fields(array('hw_html', 'hw_upload'));
     add_action('admin_enqueue_scripts', array(&$this, 'admin_enqueue_scripts'));
     add_action('hw_upload_file_success', array($this, 'success_upload_callback'));
     add_action('hw_upload_file_error', array($this, 'fail_upload_callback'));
     HW_HOANGWEB::register_ajax('search_module', array(&$this, '_ajax_search_package_modules'));
     if (class_exists('APF_hw_upload_field') && APF_hw_upload_field::is_success()) {
         //do something
     }
 }
    /**
     * render map
     * @param $atts
     */
    public function render_googlemap($atts = array())
    {
        HW_HOANGWEB::load_class('HW_String');
        $module = $this->_option('module');
        $id = HW_String::generateRandomString();
        //options
        $width = HW_Validation::format_unit(isset($atts['width']) ? $atts['width'] : ($module ? $module->get_field_value('width') : ''));
        $height = HW_Validation::format_unit(isset($atts['height']) ? $atts['height'] : ($module ? $module->get_field_value('height') : ''));
        $show_searchbox = isset($atts['show_searchbox']) ? (int) $atts['show_searchbox'] : ($module ? $module->get_field_value('show_searchbox') : '');
        if (!empty($atts['location'])) {
            $location = $atts['location'];
            if (is_array($location)) {
                $location = json_encode($location);
            }
        } elseif (!empty($atts['address'])) {
            $location = '"' . $atts['address'] . '"';
        } else {
            $location = '""';
        }
        #$atts['location'] = isset($atts['location'])? HW_Gmap::getLocationFromAddress($atts['location']) : array();
        #$location_json = json_encode($atts['location']);
        $input_box_id = 'pac-input-' . $id;
        //input box search location
        $map_canvas_id = 'map-canvas-' . $id;
        //map canvas
        $out = '<div class="hw-module-map-container">';
        if ($show_searchbox) {
            $out .= '<input id="' . $input_box_id . '" class="controls hw-pac-input" type="text" placeholder="Tìm kiếm">';
        }
        $out .= '<div id="' . $map_canvas_id . '" class="hw-map-canvas"></div>';
        $out .= '
        <style>
            .hw-map-canvas{
                ' . ($width ? "width:{$width};" : '') . '
                ' . ($height ? "height:{$height};" : '') . '
            }
        </style>
        <script>
        jQuery(function($){
            google.maps.event.addDomListener(window, "load", function(){
                __hw_module_map.map_initialize("#' . $map_canvas_id . '","#' . $input_box_id . '",' . $location . ');
            });
        });

        </script>
        ';
        $out .= '</div>';
        return $out;
    }
Exemplo n.º 15
0
 /**
  * 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;
 }
 /**
  * bind class to field which to build skin options
  * @param $field_obj: field type class instance
  */
 public function __construct($field_obj, HW_SKIN $skin = null)
 {
     $this->fieldType_ref = $field_obj;
     //if current context for HW_SKIN class
     if (empty($skin) && $field_obj instanceof HW_SKIN) {
         $skin = $field_obj;
     }
     if (!empty($skin)) {
         $this->skin = $skin;
     }
     //save skin object
     add_filter('renderOptionField', array(__CLASS__, '_renderOptionField'));
     if (!class_exists('HW_UI_Component', false) && class_exists('HW_HOANGWEB')) {
         HW_HOANGWEB::load_class('HW_UI_Component');
     }
 }
 /**
  * register sidebar
  * @param $args
  * @param $assoc_args
  */
 public function add_sidebar($args, $assoc_args)
 {
     $params = $this->get_cmd_args();
     #var_dump($params);
     foreach ($params as $param) {
         //$name = $this->get_cmd_arg($assoc_args, 'name');
         //$id = $this->get_cmd_arg($assoc_args, 'id', $name);
         if (!empty($param['name'])) {
             $name = $param['name'];
         }
         if (!empty($param['id'])) {
             $id = $param['id'];
         } else {
             $id = $name;
         }
         //valid sidebar id
         $id = preg_replace('#[\\s]+#', '-', $id);
         if (!$name) {
             $name = $id;
         }
         $desc = isset($param['description']) ? $param['description'] : '';
         //$this->get_cmd_arg($assoc_args, 'description');
         $before_widget = isset($param['before_widget']) ? $param['before_widget'] : '';
         //$this->get_cmd_arg($assoc_args, 'before_widget');
         $before_title = isset($param['before_title']) ? $param['before_title'] : '';
         //$this->get_cmd_arg($assoc_args, 'before_title');
         $after_title = isset($param['after_title']) ? $param['after_title'] : '';
         //$this->get_cmd_arg($assoc_args, 'after_title');
         $after_widget = isset($param['after_widget']) ? $param['after_widget'] : '';
         //$this->get_cmd_arg($assoc_args, 'after_widget');
         HW_HOANGWEB::load_class('HW_String');
         $sidebar = array('id' => $id, 'name' => $name, 'description' => $desc, 'before_widget' => $before_widget, 'before_title' => $before_title, 'after_title' => $after_title, 'after_widget' => $after_widget);
         if (!empty($sidebar['id'])) {
             hwawc_register_sidebar($sidebar);
             WP_CLI::success(sprintf(' register sidebar `%s` successful.', $name));
         }
     }
 }
        /**
         * load option widget
         * @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;
            $is_hide = $this->get_field_value('hide_option');
            $condition = $this->get_field_value('condition');
            #$dynamic_settings = HW_Condition::get_active_conditions_settings();
            ?>
        <fieldset><legend>Ẩn widget</legend>

        <p>
            <input type="checkbox" class="" name="<?php 
            echo $this->get_field_name('hide_option');
            ?>
" id="<?php 
            echo $this->get_field_id('hide_option');
            ?>
" <?php 
            checked($is_hide);
            ?>
/>
            <label for="<?php 
            echo $this->get_field_id('hide_option');
            ?>
"><strong>Kích hoạt ẩn</strong></label>
        </p>
            <p>
                <label for="<?php 
            echo $this->get_field_id('condition');
            ?>
"><strong>Điều kiện</strong></label>
                <?php 
            echo HW_Condition::get_conditions_select_tag($condition, array('name' => $this->get_field_name('condition'), 'id' => $this->get_field_id('condition')));
            ?>
            </p>
        </fieldset>
    <?php 
        }
Exemplo n.º 19
0
/**
 * 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>';
    }
}
 /**
  * ajax callback to get taxonomies for specific post type
  */
 public function _hw_change_taxonomies_posttype()
 {
     if (!wp_verify_nonce($_REQUEST['nonce'], "hw_change_posttype_taxonomies_nonce")) {
         exit("No naughty business please");
     }
     if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
         $post_types = $_REQUEST['posttype'];
         #if(is_string($post_types)) $post_types = preg_split('#[\s,]+#',$post_types);
         HW_HOANGWEB::load_class('HW_POST');
         $data = HW_POST::get_posttypes_taxonomies($post_types);
         //get all taxonomies assigned to post types
         //get all posts by post types
         $posts_result = HW_POST::get_all_posts_by_posttypes($post_types);
         //$html = '<select';
         $result['data'] = $data;
         $result['posts'] = $posts_result;
         $result = json_encode($result);
         echo $result;
     } else {
         header("Location: " . $_SERVER["HTTP_REFERER"]);
     }
     die;
 }
<?php

#/root>
if (class_exists('HW_HOANGWEB')) {
    HW_HOANGWEB::load_fieldtype('APF_hw_condition_rules');
}
//load query rules apf field
if (class_exists('AdminPageFramework_MetaBox')) {
    class HW_Conditions_Metabox extends AdminPageFramework_MetaBox
    {
        private static $instance;
        //current class instance
        /**
         * set class instance
         * @param $inst: an object instanceof this class
         */
        public static function setInstance($inst)
        {
            if ($inst instanceof HW_Conditions_Metabox) {
                self::$instance = $inst;
            }
        }
        /**
         * return once instance for this class
         * @return mixed
         */
        public static function getInstance()
        {
            return self::$instance;
        }
        /**
Exemplo n.º 22
0
 /**
  * return registered widget features
  */
 public static function get_all_features()
 {
     $data = array();
     $features = HW_HOANGWEB::get_classes_by_group('widget-features');
     foreach ($features as $item) {
         $feature_name = trim(self::get_feature_name_byClass($item['class']));
         $data[$feature_name] = $item['alias'];
     }
     return $data;
 }
Exemplo n.º 23
0
require_once 'lib/customizer-custom-controls/hw-theme-customizer.php';
/**
 * initialize
 */
require_once 'hw-install.php';
/**
 * register class
 */
//set autoload admin notices class
HW_HOANGWEB::load_class('HW_WP_NOTICES');
//feature button toggle class
HW_HOANGWEB::load_class('HW_ButtonToggle_widget');
//set autoload HW_POST class
HW_HOANGWEB::load_class('HW_POST');
/**
 * acf untilities
 */
//include_once('classes/plugins/hw_acf_api.php');
HW_HOANGWEB::load_class('HW_ACF_API');
/**
 * featured
 */
//include_once('plugins/video/video.php');
add_action('admin_enqueue_scripts', 'HW_ButtonToggle_widget::_hwbtw_admin_enqueue_scripts', 10);
//admin enqueue scripts
add_filter('widget_update_callback', 'HW_ButtonToggle_widget::_hwbtw_in_widget_form_update', 10, 3);
//update widget instance
//start instance
new HW_HOANGWEB();
#delete_option('hw_install_modules');exit();
#do_action('hw_hoangweb_loaded');    //load after all masterial loaded in this plugin
Exemplo n.º 24
0
 /**
  * @hook in_admin_header
  */
 public function replace_wp_menu()
 {
     global $menu, $submenu;
     $new_submenu = HW_HOANGWEB::get_wp_option('hw_custom_wp_submenu');
     //get_transient('hw-replace-admin-submenu');
     $new_menu = HW_HOANGWEB::get_wp_option('hw_custom_wp_menu');
     //get_transient('hw-replace-admin-menu');
     if ($new_submenu) {
         $submenu = $new_submenu;
     }
     if ($new_menu) {
         $menu = $new_menu;
     }
 }
 /**
  * enqueue stuff in library
  */
 public function enqueue()
 {
     HW_HOANGWEB::load_class('HW_URL');
     //load HW_URL utility
     $this->enqueue_libs();
     //other libs of dependencies for this lib
     $this->enqueue_scripts();
     //enqueue required scripts of this lib
     $this->enqueue_styles();
     //enqueue required styles of this lib
 }
 /**
  * valid classes attribute value
  * @param array|string $classes
  * @return string
  */
 private function valid_classes_attr($classes)
 {
     HW_HOANGWEB::load_class('HW_Validation');
     return HW_Validation::valid_classes_attr($classes);
 }
 /**
  * build & save custom wp menus
  */
 public function save_custom_wp_menus()
 {
     //refresh cache for first
     $this->refresh_wp_menus_cache();
     $submenu = HW_SESSION::get_session('submenu');
     $menu = HW_SESSION::get_session('menu');
     #HW_Modules_Manager::build_modules_wp_menu();
     if ($menu) {
         HW_HOANGWEB::add_wp_option('hw_custom_wp_menu', $menu);
     }
     if ($submenu) {
         HW_HOANGWEB::add_wp_option('hw_custom_wp_submenu', $submenu);
     }
     //remove sessions
     HW_SESSION::del_session('submenu', 'menu');
     $this->command_log('Build & Save custom wp menus !');
 }
 /**
  * @wp_hook action admin_enqueue_scripts
  */
 public function _admin_enqueue_scripts()
 {
     if (HW_HOANGWEB::is_current_screen(array('widgets'))) {
         $this->enqueue_script('title_link.js', array('jquery'));
         // plugins_url('/title_link.js', __FILE__)
         //wp link poup
         wp_enqueue_script('wplink');
         wp_enqueue_script('wpdialogs');
         wp_enqueue_script('wpdialogs-popup');
         //also might need this
         // need these styles
         wp_enqueue_style('wp-jquery-ui-dialog');
         wp_enqueue_style('editor.min.css', includes_url('css/editor.min.css'), null);
         wp_enqueue_style('thickbox');
     }
 }
 /**
  * ajax handle
  * list terms taxonomy
  * @ajax hw_change_taxonomy
  */
 public function _ajax_hw_change_taxonomy()
 {
     if (!wp_verify_nonce($_REQUEST['nonce'], "hw_change_tax_nonce")) {
         exit("No naughty business please");
     }
     if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
         HW_HOANGWEB::load_class('HW_POST');
         if (!isset($_REQUEST['_tax'])) {
             $_REQUEST['_tax'] = 'category';
         }
         //default tax
         $data = HW_POST::list_tax_terms($_REQUEST['_tax'], array('hide_empty' => 0));
         $result['data'] = $data;
         $result = json_encode($result);
         echo $result;
     } else {
         header("Location: " . $_SERVER["HTTP_REFERER"]);
     }
     die;
 }
 /**
  * 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;
     }
 }