/**
 * 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);
}
 public function setUp()
 {
     $sliders = self::get_all_mlsliders();
     //_print($this->__get('oForm')->getValue());
     $fields = array();
     //fields setting
     /*get all post type terms*/
     $select_posttype = hwml_get_option('source_posttype');
     if (!is_string($select_posttype)) {
         $select_posttype = 'post';
     }
     // default post type
     //prepare terms list for active post type
     $data = array();
     $terms = HW_POST::get_all_terms_taxonomies($select_posttype);
     //get all terms from post type
     foreach ($terms as $t) {
         $data[base64_encode($t->slug . '|' . $t->taxonomy)] = $t->name;
     }
     $this->addSettingFields(array('field_id' => 'slideshow_source', 'type' => 'select', 'title' => __('Chọn nguồn slides'), 'description' => 'Lấy dữ liệu cho slideshow.', 'label' => array('metaslider' => 'Slider', 'posttype' => 'Post Type & Taxonomies')), array('field_id' => 'current_post', 'type' => 'checkbox', 'title' => __('Post hiện tại'), 'description' => 'Lấy ảnh gán vào post hiện tại.'), array('field_id' => 'source_posttype', 'type' => 'select', 'title' => 'Chọn Post Types', 'label' => get_post_types(), 'description' => __('Lựa chọn post type & nhấn cập nhật/xuất bản để lọc danh mục.')), array('field_id' => 'only_attachments', 'type' => 'checkbox', 'title' => __('Lấy ảnh gán vào post'), 'description' => 'Lấy toàn bộ ảnh gán vào post.'));
     //if(count($this->data) > 0){   //warning: don't put any condition to add setting field , it will not work!
     $this->addSettingFields(array('field_id' => 'post_type_terms', 'type' => 'checkbox', 'title' => 'Danh mục của (' . $select_posttype . ')', 'description' => !count($data) ? ' Không có dữ liệu !' : 'Chọn danh mục của post type đã chọn.', 'label' => $data), array('field_id' => 'tax_query_relation', 'type' => 'select', 'title' => 'Mối quan hệ AND/OR cho danh mục', 'description' => '', 'label' => array('AND' => 'AND', 'OR' => 'OR')));
     //}
     $this->addSettingFields(array('field_id' => 'pick_slider', 'type' => 'select', 'title' => __('Chọn nguồn slider', 'hwslider'), 'description' => __('Chọn dữ liệu sliders. Thêm/Sửa slides <a target="_blank" href="' . self::get_edit_sliders_url() . '">tại đây</a>.', 'hwslider'), 'label' => $sliders), array('field_id' => 'show_title', 'type' => 'checkbox', 'title' => 'Hiển thị tiêu đề slide', 'description' => 'Hiển thị tiêu đề slide'), array('field_id' => 'slider_theme', 'type' => 'hw_skin', 'title' => __('Chọn slider theme', 'hwslider'), 'description' => __('Chọn theme riêng cho slider', 'hwslider'), 'enable_skin_condition' => true, 'external_skins_folder' => 'hw_mlslider_skins', 'skin_filename' => 'mlslider-skin.php', 'enable_external_callback' => false, 'skins_folder' => 'themes', 'apply_current_path' => HWML_PLUGIN_PATH, 'plugin_url' => HWML_PLUGIN_URL, 'group' => 'group-others', 'hwskin_field_output_callback' => array($this, '_hwskin_field_output')));
     //add dynamic apf fields
     if (count($fields) > 0) {
         foreach ($fields as $opt) {
             $this->addSettingField($opt);
         }
     }
     // content_{page slug}_{tab slug}
     //add_filter( 'content_hw_sidebar_widgets_settings', array( $this, 'replyToInsertContents' ) );
 }