/**
  * get related posts template by current post or specific post ID
  * @param $post_id: post ID or single post data
  */
 public function get_relatedposts_template_by_post($post_id = '')
 {
     if (!empty($post_id) && is_numeric($post_id)) {
         $post = get_post($post_id);
     }
     if (!isset($post)) {
         global $post;
         //get current post
     }
     if (empty($post)) {
         return;
     }
     //post not found (not single post page)
     //get post type
     $post_type = $post->post_type;
     $skins = hw_yarpp_get_option('hwrp_skins');
     if (!isset($skins[$post_type]) || !isset($skins[$post_type]['active'])) {
         return;
         //current post not support related posts skin
     }
     //get post terms
     if (!isset($skins[$post_type]['filter_terms']) || !$skins[$post_type]['filter_terms']) {
         //filter skin with terms
         $allow_terms = $skins[$post_type]['terms'];
         if (!HW_POST::check_post_terms($post, $allow_terms, false)) {
             return;
         }
         //not match requirement
         /*$terms = hwrp_get_all_post_terms($post, array('fields'=> 'slugs'));
           if(is_array($terms))
           foreach($terms as $slug){
               if( !in_array($slug,$allow_terms)) return;   //not match requirement
           }*/
     }
     //override template by checking detail term
     if (class_exists('APF_Related_templates')) {
         $result = APF_Related_templates::get_relatedposts_template_by_post($post);
         //from HW_HOANGWEB plugin
         if (!empty($result['template']['instance'])) {
             $skins[$post_type]['instance'] = $result['template']['instance'];
             //change active skin
             if (isset($result['template']['hash_skin'])) {
                 $skins[$post_type]['skin'] = $result['template']['hash_skin'];
             }
             $skins[$post_type]['options_data'] = $result;
             //detail related data
             //override
             if (isset($result['title'])) {
                 $skins[$post_type]['title'] = $result['title'];
             }
             //override skin
             if (isset($result['widget_config'])) {
                 $skins[$post_type]['widget_config'] = $result['widget_config'];
             }
             if (isset($result['sidebar'])) {
                 $skins[$post_type]['box_skin'] = $result['sidebar'];
             }
             if (isset($result['sidebar_widget_skin'])) {
                 $skins[$post_type]['box_widget_skin'] = $result['sidebar_widget_skin'];
             }
             return (object) $skins[$post_type];
         }
     }
     //get related posts skin for current post
     if (!isset($skins[$post_type]['instance']) && isset($skins[$post_type]['skin']) && !empty($skins[$post_type]['hwskin_config']) && class_exists('HW_SKIN')) {
         $skins[$post_type]['instance'] = HW_SKIN::resume_skin($skins[$post_type]['hwskin_config']);
         //resume hw_skin instance
         return (object) $skins[$post_type];
     }
 }
 /**
  * post types setting tab
  * @param $oAdminPage AdminPageFramework
  * @param $tab_id
  */
 protected function setUp_tab_posttype($oAdminPage, $tab_id)
 {
     /**
      * post type tab
      */
     $post_types = get_post_types('', 'names');
     if (function_exists('is_plugin_active') && is_plugin_active('codepress-admin-columns/codepress-admin-columns.php')) {
         $tip1 = 'Nhấn <a href="' . admin_url('options-general.php?page=codepress-admin-columns') . '" target="_blank">vào đây</a> nếu muốn hiển thị nhiều cột hơn.';
     } else {
         $tip1 = 'Kích hoạt plugin ' . hw_install_plugin_link('codepress-admin-columns/codepress-admin-columns.php', '<em>codepress-admin-columns</em>') . ' để cài đặt nhiều cột hơn. ';
     }
     $fields = array();
     $tab = $this->get_tabs($tab_id);
     $oAdminPage->addSettingField($tab_id);
     //group
     $oAdminPage->addSettingSections(self::HW_SETTINGS_PAGE, array('section_id' => $tab_id, 'title' => $tab['title'], 'description' => $tab['description'], 'section_tab_slug' => 'setting_tabs', 'repeatable' => false));
     $oAdminPage->addSettingField(array('field_id' => 'show_posts_thumbnail_column', 'type' => 'checkbox', 'title' => 'Hiển thị feature image', 'description' => 'Hiển thị thumbnail/feature image trong trang quản lý dữ liệu của post types. ' . $tip1, 'select_all_button' => true, 'select_none_button' => true, 'label' => $post_types));
     APF_Related_templates::register_field($oAdminPage);
     //submit button
     $oAdminPage->addSettingFields($tab_id, array('field_id' => 'submit', 'type' => 'submit', 'label' => 'Lưu lại', 'show_title_column' => false));
 }