public function __construct()
 {
     //list layouts
     $this->layouts = HW__Template::getTemplates();
     //only accept widget with id base 'hw_taxonomy_post_list_widget'
     if (class_exists('AWC_WidgetFeature_saveconfig')) {
         $this->saved_widgets_settings = AWC_WidgetFeature_saveconfig::get_widgets_settings(' where widget="hw_taxonomy_post_list_widget"');
     }
 }
 public function get_fields(&$sections)
 {
     global $wp_filter;
     $hw_register_hooks = array('hw_before_main_content' => 'hw_before_main_content', 'hw_after_main_content' => 'hw_after_main_content', 'hw_after_header' => 'hw_after_header', 'hw_before_loop' => 'hw_before_loop', 'hw_after_loop' => 'hw_after_loop');
     /*foreach($wp_filter as $tag => $priority){
           //echo "<br />&gt;&gt;&gt;&gt;&gt;t<strong>$tag</strong><br />";
           ksort($priority);
           $data[$tag] = $tag;
       }*/
     $layouts = HW__Template::getTemplates();
     //get template layouts
     /*float left right advertising*/
     $sections['template'] = array('icon' => NHP_OPTIONS_URL . 'img/glyphicons/glyphicons_064_lightbulb.png', 'title' => 'Giao diện', 'fields' => array('content_classes' => array('id' => 'content_classes', 'type' => 'hw_table_fields', 'title' => 'Thêm class vào thẻ body và loop post.', 'desc' => 'Thêm class vào thẻ body và loop post.', 'data_base_field' => 'col1', 'show_root_field' => true, 'fields' => array('col1' => array('options' => $layouts), 'col2' => array('name' => 'body_class', 'type' => 'text', 'description' => 'Thêm class vào thẻ body', 'attributes' => array('style' => 'border:1px solid red;', 'class' => 'hw-class')), 'col3' => array('name' => 'post_class', 'type' => 'text', 'description' => 'Thêm class vào filter post_class'), 'col4' => array('name' => 'remove_default', 'type' => 'checkbox', 'description' => 'Xóa classes mặc định.')), 'table_header' => array('col1' => 'Template/trang', 'col2' => 'Body class', 'col3' => 'Post class', 'col4' => 'Xóa mặc định')), 'show_breadcrumb' => array('id' => 'show_breadcrumb', 'type' => 'select', 'title' => 'Hiển thị thanh định hướng', 'desc' => 'Hiển thị thanh định hướng (breadcrumb) vào trước nội dung hook này.', 'options' => $hw_register_hooks)));
 }
 /**
  * ajax handle callback to get act object values
  */
 public function _hw_apf_rules_field_get_values()
 {
     if (!wp_verify_nonce($_REQUEST['nonce'], "hw_apf_rules_field_get_values_nonce")) {
         exit("hacked !");
     }
     //params
     if (isset($_POST['object']) && $_POST['object']) {
         $name = $_POST['object'];
     }
     //get object name
     if (isset($_POST['aField'])) {
         //get apf rules field setting
         $aField = $_POST['aField'];
         $aField = unserialize(base64_decode($aField));
     }
     if (isset($_POST['id'])) {
         $field_id = $_POST['id'];
     }
     if (isset($_POST['bindingFields'])) {
         $bindingFields = $_POST['bindingFields'];
     }
     //binding Fields
     //valid
     if (!isset($aField) || !isset($field_id)) {
         return;
     }
     //parse attribute
     $fname = 'act_values';
     $field_id = explode('__', $field_id);
     $field_name = $field_id[0] . '[' . $field_id[1] . '][' . $fname . ']';
     //field name
     $field_id = self::generate_id($field_name);
     //field id
     //list all post types
     if ($name == 'post_types') {
         $postypes = get_post_types('', 'names');
         $field = array('name' => $fname, 'type' => 'select', 'options' => $postypes);
     } elseif ($name == 'templates') {
         $field = array('name' => $fname, 'type' => 'select', 'options' => HW__Template::getTemplates());
     } elseif ($name == 'taxonomies') {
         $taxes = get_taxonomies();
         $field = array('name' => $fname, 'type' => 'select', 'options' => $taxes);
     } elseif ($name == 'terms') {
         $terms_tax = self::get_all_terms_taxonomies('');
         //field terms placeholder
         $field = array('name' => $fname, 'type' => 'select', 'options' => '');
     } elseif ($name == 'users') {
         //users options placeholder
         $field = array('name' => $fname, 'type' => 'select', 'options' => '');
     } elseif ($name == 'pages') {
         //placeholder
         $field = array('name' => $fname, 'type' => 'select', 'options' => '');
     } elseif ($name == 'posts') {
         $field = array('name' => $fname, 'type' => 'select', 'options' => '');
     } else {
         $field = apply_filters('apf_rules_field_get_values', array('name' => $fname, 'type' => 'select', 'options' => ''), $name);
     }
     if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
         //$result = json_encode($result);
         //display form field
         if (isset($field)) {
             if (!isset($field['attributes'])) {
                 $field['attributes'] = array();
             }
             $field['attributes']['id'] = $field_id;
             $field['attributes']['name'] = $field_name;
             $field['attributes']['data-id'] = $_POST['id'];
             //field tag id
             $field['attributes']['data-name'] = $fname;
             $field['attributes']['data-fieldname'] = $_POST['fname'];
             //inject some data
             $aField['selected_act'] = $name;
             //inject 'act' field value
             if (isset($bindingFields)) {
                 $aField['bindingFields'] = $bindingFields;
             }
             //binding fields
             //display field tag
             echo $this->renderField($field, $aField);
         }
     } else {
         header("Location: " . $_SERVER["HTTP_REFERER"]);
     }
     die;
 }