/**
  * render theme option field
  * @param $aField
  */
 private function renderOptionField($field, $field_name, $wrapper = true, $repeat = true)
 {
     if (!isset($field['type'])) {
         $field['type'] = 'checkbox';
     }
     //default set checkbox option
     //valid field type
     if (!in_array($field['type'], HW_SKIN_Option::allow_field_types())) {
         return;
     }
     if (!isset($field['id'])) {
         $field['id'] = mt_rand(5, 15);
     }
     //random id if not found
     $tag = '';
     $name = $field_name . '[skin_options][' . $field['id'] . ']';
     //field name
     $id = $this->field['id'] . '_nhp_theme_option_' . $field['id'];
     //field id
     $title = isset($field['title']) && $field['title'] ? $field['title'] : $field['id'];
     $desc = isset($field['desc']) ? $field['desc'] : '';
     //field value
     if (isset($this->value['skin_options']) && isset($this->value['skin_options'][$field['id']])) {
         $value = $this->value['skin_options'][$field['id']];
     } else {
         $value = '';
     }
     if ($wrapper) {
         $tag .= '<p style="margin-bottom:14px;">';
     }
     $field = HW_SKIN_Option::build_option_field($field, array('id' => $id, 'name' => $name, 'title' => $title, 'desc' => $desc, 'value' => $value), $tag, array(&$this, '_renderOptionField_callback'), array('field_name' => $field_name));
     /*if($field['type'] == 'checkbox') {  //checkbox
                 $tag .= '<label for="'.$id.'"><strong>'.$title.'</strong><br/>
                     <input type="'.$field['type'].'" name="'.$name.'" id="'.$id.'" '.($value? 'checked="checked"':'').'/>
                     </label><br/><em>'.$desc.'</em>';
             }
             elseif($field['type'] == 'text'){   //text
                 $tag .= '<label for="'.$id.'"><strong>'.$title.'</strong><br/>
                     <input type="'.$field['type'].'" name="'.$name.'" id="'.$id.'" value="'.($value).'"/>
                     </label><br/><em>'.$desc.'</em>';
             }
     
             elseif($field['type'] == 'select' && isset($field['options'])) {    //select
                 if(is_string($field['options'])) $field['options'] = explode(',',$field['options']);
     
                 $tag .= '<label for="'.$id.'"><strong>'.$title.'</strong><br/><select name="'.$name.'" id="'.$id.'">';
                 if(is_array($field['options']))
                     foreach($field['options'] as $option){
                         $tag .= '<option value="'.esc_attr($option).'" '.($option == $value? 'selected':'').'>'.$option.'</option>';
                     }
                 $tag .= '</select></label>';
                 $tag .= '<br/><em>'.$desc.'</em>';
     
             }
             elseif($field['type'] == 'string'){ //string field
                 if(isset($field['title'])) $tag .= "<h3>{$field['title']}</h3>";
                 if(isset($field['desc'])) $tag .= "<div>{$field['desc']}</div>";
             }
             */
     if ($wrapper) {
         $tag .= '</p>';
     }
     if ($repeat == true && isset($field['repeat'])) {
         //repeat current field
         if (isset($field['repeat']) && is_numeric($field['repeat'])) {
             for ($i = 1; $i < $field['repeat']; $i++) {
                 //- first repeat field
                 $save_id = $field['id'];
                 $field['id'] .= '_' . $i;
                 $field['title'] = $field['id'];
                 //sync for title
                 $tag .= $this->renderOptionField($field, $field_name, false, false);
                 $field['id'] = $save_id;
             }
         }
     }
     return $tag;
 }
 /**
  * render theme option field
  * @param $aField
  */
 public function renderOptionField($field, $_name, $_id, $values = null, $wrapper = true, $repeat = true)
 {
     if (!isset($field['type'])) {
         $field['type'] = 'text';
     }
     //default set checkbox option
     //valid field type
     if (!in_array($field['type'], array('select', 'checkbox', 'text', 'string', 'hidden'))) {
         return;
     }
     if (!isset($field['name'])) {
         $field['name'] = '';
         //valid field name
         //return ;  //allow type='string'
     }
     //filter field setting before render field form
     $field = apply_filters('hw_nhp_renderOptionField', $field);
     $tag = '';
     $name = $_name . '[' . $field['name'] . ']';
     //field name
     $id = $_id . '_' . $field['name'];
     //field id
     $title = isset($field['title']) ? $field['title'] : $field['name'];
     $desc = isset($field['description']) ? $field['description'] : '';
     //field value
     if (!empty($values) && isset($values[$field['name']])) {
         $value = esc_attr($values[$field['name']]);
     } else {
         $value = isset($field['value']) ? esc_attr($field['value']) : '';
         //default field value
     }
     $field_atts = array('id' => $id, 'name' => $name, 'value' => $value, 'title' => $title, 'desc' => $desc);
     if ($wrapper) {
         $tag .= '<p style="margin-bottom:14px;">';
     }
     HW_SKIN_Option::build_option_field($field, $field_atts, $tag);
     if ($wrapper) {
         $tag .= '</p>';
     }
     //repeat the field
     if ($repeat == true && isset($field['repeat'])) {
         //repeat current field
         if (isset($field['repeat']) && is_numeric($field['repeat'])) {
             for ($i = 1; $i < $field['repeat']; $i++) {
                 //- first repeat field
                 $save_id = $field['id'];
                 $field['id'] .= '_' . $i;
                 $field['title'] = $field['id'];
                 //sync for title
                 $tag .= $this->renderOptionField($field, $_name, $_id, $values, false, false);
                 $field['id'] = $save_id;
             }
         }
     }
     return $tag;
 }