public function form($instance)
 {
     $this->instance = $instance;
     $title = hocwp_get_value_by_key($instance, 'title');
     $icon = hocwp_get_value_by_key($instance, 'icon');
     $icon = hocwp_sanitize_media_value($icon);
     $icon_hover = hocwp_get_value_by_key($instance, 'icon_hover');
     $icon_hover = hocwp_sanitize_media_value($icon_hover);
     $icon_html = hocwp_get_value_by_key($instance, 'icon_html');
     $link = hocwp_get_value_by_key($instance, 'link');
     $text = hocwp_get_value_by_key($instance, 'text');
     $title_link = hocwp_get_value_by_key($instance, 'title_link', hocwp_get_value_by_key($this->args, 'title_link'));
     hocwp_field_widget_before($this->admin_args['class']);
     hocwp_widget_field_title($this->get_field_id('title'), $this->get_field_name('title'), $title);
     $args = array('id' => $this->get_field_id('icon'), 'name' => $this->get_field_name('icon'), 'value' => $icon['url'], 'label' => __('Icon:', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_media_upload', $args);
     $args = array('id' => $this->get_field_id('icon_hover'), 'name' => $this->get_field_name('icon_hover'), 'value' => $icon_hover['url'], 'label' => __('Icon hover:', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_media_upload', $args);
     $args = array('id' => $this->get_field_id('icon_html'), 'name' => $this->get_field_name('icon_html'), 'value' => $icon_html, 'label' => __('Icon HTML:', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_input_text', $args);
     $args = array('id' => $this->get_field_id('link'), 'name' => $this->get_field_name('link'), 'value' => $link, 'label' => __('Link:', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_input_text', $args);
     $args = array('id' => $this->get_field_id('text'), 'name' => $this->get_field_name('text'), 'value' => $text, 'label' => __('Text:', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_textarea', $args);
     $args = array('id' => $this->get_field_id('title_link'), 'name' => $this->get_field_name('title_link'), 'value' => $title_link, 'label' => __('Display title as link?', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_input_checkbox', $args);
     hocwp_field_widget_after();
 }
 public function form($instance)
 {
     $this->instance = $instance;
     $title = isset($instance['title']) ? $instance['title'] : '';
     $feedburner_name = hocwp_get_value_by_key($instance, 'feedburner_name');
     $button_text = hocwp_get_value_by_key($instance, 'button_text', hocwp_get_value_by_key($this->args, 'button_text'));
     $placeholder = hocwp_get_value_by_key($instance, 'placeholder', hocwp_get_value_by_key($this->args, 'placeholder'));
     $description = hocwp_get_value_by_key($instance, 'description', hocwp_get_value_by_key($this->args, 'description'));
     $desc_position = hocwp_get_value_by_key($instance, 'desc_position', hocwp_get_value_by_key($this->args, 'desc_position'));
     hocwp_field_widget_before($this->admin_args['class']);
     hocwp_widget_field_title($this->get_field_id('title'), $this->get_field_name('title'), $title);
     $args = array('id' => $this->get_field_id('feedburner_name'), 'name' => $this->get_field_name('feedburner_name'), 'value' => $feedburner_name, 'label' => __('Name:', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_input_text', $args);
     $args = array('id' => $this->get_field_id('button_text'), 'name' => $this->get_field_name('button_text'), 'value' => $button_text, 'label' => __('Button text:', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_input_text', $args);
     $args = array('id' => $this->get_field_id('placeholder'), 'name' => $this->get_field_name('placeholder'), 'value' => $placeholder, 'label' => __('Placeholder:', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_input_text', $args);
     $args = array('id' => $this->get_field_id('description'), 'name' => $this->get_field_name('description'), 'value' => $description, 'label' => __('Description:', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_textarea', $args);
     $lists = $this->args['desc_positions'];
     $all_option = '';
     foreach ($lists as $lkey => $lvalue) {
         $all_option .= hocwp_field_get_option(array('value' => $lkey, 'text' => $lvalue, 'selected' => $desc_position));
     }
     $args = array('id' => $this->get_field_id('desc_position'), 'name' => $this->get_field_name('desc_position'), 'value' => $desc_position, 'all_option' => $all_option, 'label' => __('Description position:', 'hocwp-theme'), 'class' => 'desc-position');
     hocwp_widget_field('hocwp_field_select', $args);
     hocwp_field_widget_after();
 }
 public function form($instance)
 {
     $this->instance = $instance;
     $title = isset($instance['title']) ? $instance['title'] : '';
     $category = $this->get_category_from_instance($instance);
     hocwp_field_widget_before($this->admin_args['class']);
     hocwp_widget_field_title($this->get_field_id('title'), $this->get_field_name('title'), $title);
     $all_option = '';
     $lists = hocwp_get_terms('link_category');
     foreach ($lists as $lvalue) {
         $selected = '';
         if (!hocwp_array_has_value($category)) {
             $category[] = array('value' => '');
         }
         foreach ($category as $ptvalue) {
             $ptype = isset($ptvalue['value']) ? $ptvalue['value'] : '';
             if ($lvalue->term_id == $ptype) {
                 $selected = $lvalue->term_id;
                 break;
             }
         }
         $all_option .= hocwp_field_get_option(array('value' => $lvalue->term_id, 'text' => $lvalue->name, 'selected' => $selected));
     }
     $args = array('id' => $this->get_field_id('category'), 'name' => $this->get_field_name('category'), 'all_option' => $all_option, 'value' => $category, 'label' => __('Category:', 'hocwp-theme'), 'placeholder' => __('Choose category', 'hocwp-theme'), 'multiple' => true);
     hocwp_widget_field('hocwp_field_select_chosen', $args);
     hocwp_field_widget_after();
 }
 public function form($instance)
 {
     $this->instance = $instance;
     $title = isset($instance['title']) ? $instance['title'] : '';
     hocwp_field_widget_before($this->admin_args['class']);
     hocwp_widget_field_title($this->get_field_id('title'), $this->get_field_name('title'), $title);
     hocwp_field_widget_after();
 }
 public function form($instance)
 {
     $this->instance = $instance;
     $title = isset($instance['title']) ? $instance['title'] : '';
     $sidebar = hocwp_get_value_by_key($instance, 'sidebar');
     hocwp_field_widget_before($this->admin_args['class']);
     hocwp_widget_field_title($this->get_field_id('title'), $this->get_field_name('title'), $title);
     $args = array('id' => $this->get_field_id('sidebar'), 'name' => $this->get_field_name('sidebar'), 'value' => $sidebar, 'label' => __('Sidebar:', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_select_sidebar', $args);
     hocwp_field_widget_after();
 }
 public function form($instance)
 {
     $this->instance = $instance;
     $title = hocwp_get_value_by_key($instance, 'title');
     $order = hocwp_get_value_by_key($instance, 'order', hocwp_get_value_by_key($this->args, 'order'));
     $description = hocwp_get_value_by_key($instance, 'description');
     hocwp_field_widget_before($this->admin_args['class']);
     hocwp_widget_field_title($this->get_field_id('title'), $this->get_field_name('title'), $title);
     $args = array('id' => $this->get_field_id('order'), 'name' => $this->get_field_name('order'), 'value' => $order, 'label' => __('Order:', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_input_text', $args);
     $args = array('id' => $this->get_field_id('description'), 'name' => $this->get_field_name('description'), 'value' => $description, 'label' => __('Description:', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_textarea', $args);
     hocwp_field_widget_after();
 }
 public function form($instance)
 {
     $this->instance = $instance;
     $title = isset($instance['title']) ? $instance['title'] : '';
     $page_name = isset($instance['page_name']) ? $instance['page_name'] : '';
     $href = isset($instance['href']) ? $instance['href'] : '';
     $tabs = hocwp_get_value_by_key($instance, 'tabs', $this->args['tabs']);
     if (!is_array($tabs)) {
         $tabs = explode(',', $tabs);
     }
     $tabs = array_map('trim', $tabs);
     $width = isset($instance['width']) ? $instance['width'] : $this->args['width'];
     $height = isset($instance['height']) ? $instance['height'] : $this->args['height'];
     $hide_cover = (bool) (isset($instance['hide_cover']) ? $instance['hide_cover'] : $this->args['hide_cover']);
     $show_facepile = (bool) (isset($instance['show_facepile']) ? $instance['show_facepile'] : $this->args['show_facepile']);
     $show_posts = (bool) (isset($instance['show_posts']) ? $instance['show_posts'] : $this->args['show_posts']);
     $hide_cta = (bool) (isset($instance['hide_cta']) ? $instance['hide_cta'] : $this->args['hide_cta']);
     $small_header = (bool) (isset($instance['small_header']) ? $instance['small_header'] : $this->args['small_header']);
     $adapt_container_width = (bool) (isset($instance['adapt_container_width']) ? $instance['adapt_container_width'] : $this->args['adapt_container_width']);
     hocwp_field_widget_before($this->admin_args['class']);
     hocwp_widget_field_title($this->get_field_id('title'), $this->get_field_name('title'), $title);
     $args = array('id' => $this->get_field_id('page_name'), 'name' => $this->get_field_name('page_name'), 'value' => $page_name, 'label' => __('Page name:', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_input', $args);
     $args = array('id' => $this->get_field_id('href'), 'name' => $this->get_field_name('href'), 'value' => $href, 'label' => __('Page url:', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_input', $args);
     if (is_array($tabs)) {
         $tabs = implode(',', $tabs);
     }
     $args = array('id' => $this->get_field_id('tabs'), 'name' => $this->get_field_name('tabs'), 'value' => $tabs, 'label' => __('Tabs:', 'hocwp-theme'), 'placeholder' => 'timeline,events,messages');
     hocwp_widget_field('hocwp_field_input', $args);
     $args = array('id_width' => $this->get_field_id('width'), 'name_width' => $this->get_field_name('width'), 'id_height' => $this->get_field_id('height'), 'name_height' => $this->get_field_name('height'), 'value' => array($width, $height), 'label' => __('Size:', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_size', $args);
     $args = array('id' => $this->get_field_id('hide_cover'), 'name' => $this->get_field_name('hide_cover'), 'value' => $hide_cover, 'label' => __('Hide cover photo in the header?', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_input_checkbox', $args);
     $args = array('id' => $this->get_field_id('show_facepile'), 'name' => $this->get_field_name('show_facepile'), 'value' => $show_facepile, 'label' => __('Show profile photos when friends like this?', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_input_checkbox', $args);
     $args = array('id' => $this->get_field_id('show_posts'), 'name' => $this->get_field_name('show_posts'), 'value' => $show_posts, 'label' => __('Show posts from the Page\'s timeline?', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_input_checkbox', $args);
     $args = array('id' => $this->get_field_id('hide_cta'), 'name' => $this->get_field_name('hide_cta'), 'value' => $hide_cta, 'label' => __('Hide the custom call to action button?', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_input_checkbox', $args);
     $args = array('id' => $this->get_field_id('small_header'), 'name' => $this->get_field_name('small_header'), 'value' => $small_header, 'label' => __('Use the small header instead?', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_input_checkbox', $args);
     $args = array('id' => $this->get_field_id('adapt_container_width'), 'name' => $this->get_field_name('adapt_container_width'), 'value' => $adapt_container_width, 'label' => __('Try to fit inside the container width?', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_input_checkbox', $args);
     hocwp_field_widget_after();
 }
 public function form($instance)
 {
     $this->instance = $instance;
     $title = isset($instance['title']) ? $instance['title'] : '';
     $banner_image = isset($instance['banner_image']) ? $instance['banner_image'] : '';
     $banner_url = isset($instance['banner_url']) ? $instance['banner_url'] : '';
     hocwp_field_widget_before($this->admin_args['class']);
     hocwp_widget_field_title($this->get_field_id('title'), $this->get_field_name('title'), $title);
     $args = array('id' => $this->get_field_id('banner_image'), 'name' => $this->get_field_name('banner_image'), 'value' => $banner_image, 'label' => __('Image url:', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_media_upload', $args);
     $args = array('id' => $this->get_field_id('banner_url'), 'name' => $this->get_field_name('banner_url'), 'value' => $banner_url, 'label' => __('Image link:', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_input_text', $args);
     $nofollow = hocwp_get_value_by_key($instance, 'nofollow', hocwp_get_value_by_key($this->args, 'nofollow'));
     $args = array('id' => $this->get_field_id('nofollow'), 'name' => $this->get_field_name('nofollow'), 'value' => $nofollow, 'label' => __('Add rel nofollow for this link?', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_input_checkbox', $args);
     hocwp_field_widget_after();
 }
 public function form($instance)
 {
     $this->instance = $instance;
     $title = isset($instance['title']) ? $instance['title'] : '';
     $page_name = isset($instance['page_name']) ? $instance['page_name'] : '';
     $href = isset($instance['href']) ? $instance['href'] : '';
     $width = isset($instance['width']) ? $instance['width'] : $this->args['width'];
     $height = isset($instance['height']) ? $instance['height'] : $this->args['height'];
     $hide_cover = (bool) (isset($instance['hide_cover']) ? $instance['hide_cover'] : $this->args['hide_cover']);
     $show_facepile = (bool) (isset($instance['show_facepile']) ? $instance['show_facepile'] : $this->args['show_facepile']);
     $hide_cta = (bool) (isset($instance['hide_cta']) ? $instance['hide_cta'] : $this->args['hide_cta']);
     $small_header = (bool) (isset($instance['small_header']) ? $instance['small_header'] : $this->args['small_header']);
     $adapt_container_width = (bool) (isset($instance['adapt_container_width']) ? $instance['adapt_container_width'] : $this->args['adapt_container_width']);
     $fixed = hocwp_get_value_by_key($instance, 'fixed', $this->args['fixed']);
     $only_link = hocwp_get_value_by_key($instance, 'only_link', $this->args['only_link']);
     $button_text = hocwp_get_value_by_key($instance, 'button_text', $this->args['button_text']);
     hocwp_field_widget_before($this->admin_args['class']);
     hocwp_widget_field_title($this->get_field_id('title'), $this->get_field_name('title'), $title);
     $args = array('id' => $this->get_field_id('page_name'), 'name' => $this->get_field_name('page_name'), 'value' => $page_name, 'label' => __('Page name:', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_input', $args);
     $args = array('id' => $this->get_field_id('href'), 'name' => $this->get_field_name('href'), 'value' => $href, 'label' => __('Page url:', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_input', $args);
     $args = array('id' => $this->get_field_id('button_text'), 'name' => $this->get_field_name('button_text'), 'value' => $button_text, 'label' => __('Button text:', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_input', $args);
     $position = hocwp_get_value_by_key($instance, 'position', $this->args['position']);
     $lists = $this->args['positions'];
     $all_option = '';
     foreach ($lists as $lkey => $lvalue) {
         $all_option .= hocwp_field_get_option(array('value' => $lkey, 'text' => $lvalue, 'selected' => $position));
     }
     $args = array('id' => $this->get_field_id('position'), 'name' => $this->get_field_name('position'), 'value' => $position, 'all_option' => $all_option, 'label' => __('Position:', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_select', $args);
     $args = array('id_width' => $this->get_field_id('width'), 'name_width' => $this->get_field_name('width'), 'id_height' => $this->get_field_id('height'), 'name_height' => $this->get_field_name('height'), 'value' => array($width, $height), 'label' => __('Size:', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_size', $args);
     $args = array('id' => $this->get_field_id('hide_cover'), 'name' => $this->get_field_name('hide_cover'), 'value' => $hide_cover, 'label' => __('Hide cover photo in the header?', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_input_checkbox', $args);
     $args = array('id' => $this->get_field_id('show_facepile'), 'name' => $this->get_field_name('show_facepile'), 'value' => $show_facepile, 'label' => __('Show profile photos when friends like this?', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_input_checkbox', $args);
     $args = array('id' => $this->get_field_id('hide_cta'), 'name' => $this->get_field_name('hide_cta'), 'value' => $hide_cta, 'label' => __('Hide the custom call to action button?', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_input_checkbox', $args);
     $args = array('id' => $this->get_field_id('small_header'), 'name' => $this->get_field_name('small_header'), 'value' => $small_header, 'label' => __('Use the small header instead?', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_input_checkbox', $args);
     $args = array('id' => $this->get_field_id('adapt_container_width'), 'name' => $this->get_field_name('adapt_container_width'), 'value' => $adapt_container_width, 'label' => __('Try to fit inside the container width?', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_input_checkbox', $args);
     $args = array('id' => $this->get_field_id('only_link'), 'name' => $this->get_field_name('only_link'), 'value' => $only_link, 'label' => __('Display only link button to Messenger page?', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_input_checkbox', $args);
     $args = array('id' => $this->get_field_id('fixed'), 'name' => $this->get_field_name('fixed'), 'value' => $fixed, 'label' => __('Display Messenger box as fixed position?', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_input_checkbox', $args);
     hocwp_field_widget_after();
 }
 public function form($instance)
 {
     $this->instance = $instance;
     $title = isset($instance['title']) ? $instance['title'] : '';
     $register = hocwp_get_value_by_key($instance, 'register', hocwp_get_value_by_key($this->args, 'register'));
     $button_text = hocwp_get_value_by_key($instance, 'button_text', hocwp_get_value_by_key($this->args, 'button_text'));
     $captcha = hocwp_get_value_by_key($instance, 'captcha', hocwp_get_value_by_key($this->args, 'captcha'));
     $captcha_label = hocwp_get_value_by_key($instance, 'captcha_label', hocwp_get_value_by_key($this->args, 'captcha_label'));
     $captcha_placeholder = hocwp_get_value_by_key($instance, 'captcha_placeholder', hocwp_get_value_by_key($this->args, 'captcha_placeholder'));
     $description = hocwp_get_value_by_key($instance, 'description', hocwp_get_value_by_key($this->args, 'description'));
     $desc_position = hocwp_get_value_by_key($instance, 'desc_position', hocwp_get_value_by_key($this->args, 'desc_position'));
     $fields = $this->get_value_fields($instance);
     $all_fields = explode(',', $fields);
     hocwp_field_widget_before($this->admin_args['class']);
     hocwp_widget_field_title($this->get_field_id('title'), $this->get_field_name('title'), $title);
     $args = array('id' => $this->get_field_id('fields'), 'name' => $this->get_field_name('fields'), 'value' => $fields, 'label' => __('Fields:', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_input_text', $args);
     foreach ($all_fields as $field_name) {
         $field = hocwp_get_value_by_key($this->args['fields'], $field_name);
         if (hocwp_array_has_value($field)) {
             foreach ($field as $key => $data) {
                 $field_label = hocwp_uppercase_first_char($field_name);
                 $field_label .= ' ' . strtolower($key);
                 $field_callback = 'hocwp_field_input_text';
                 if ('required' == $key) {
                     $field_label .= '?';
                     $field_callback = 'hocwp_field_input_checkbox';
                 } else {
                     $field_label .= ':';
                 }
                 $field_value = $this->get_value_field($instance, $field_name, $key);
                 $args = array('id' => $this->get_field_id('subscribe_' . $field_name . '_' . $key), 'name' => $this->get_field_name('subscribe_' . $field_name . '_' . $key), 'value' => $field_value, 'label' => $field_label);
                 hocwp_widget_field($field_callback, $args);
             }
         }
     }
     $args = array('id' => $this->get_field_id('button_text'), 'name' => $this->get_field_name('button_text'), 'value' => $button_text, 'label' => __('Button text:', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_input_text', $args);
     $args = array('id' => $this->get_field_id('description'), 'name' => $this->get_field_name('description'), 'value' => $description, 'label' => __('Description:', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_textarea', $args);
     $lists = $this->args['desc_positions'];
     $all_option = '';
     foreach ($lists as $lkey => $lvalue) {
         $all_option .= hocwp_field_get_option(array('value' => $lkey, 'text' => $lvalue, 'selected' => $desc_position));
     }
     $args = array('id' => $this->get_field_id('desc_position'), 'name' => $this->get_field_name('desc_position'), 'value' => $desc_position, 'all_option' => $all_option, 'label' => __('Description position:', 'hocwp-theme'), 'class' => 'desc-position');
     hocwp_widget_field('hocwp_field_select', $args);
     if ($captcha) {
         $args = array('id' => $this->get_field_id('captcha_label'), 'name' => $this->get_field_name('captcha_label'), 'value' => $captcha_label, 'label' => __('Captcha label:', 'hocwp-theme'));
         hocwp_widget_field('hocwp_field_input_text', $args);
         $args = array('id' => $this->get_field_id('captcha_placeholder'), 'name' => $this->get_field_name('captcha_placeholder'), 'value' => $captcha_placeholder, 'label' => __('Captcha placeholder:', 'hocwp-theme'));
         hocwp_widget_field('hocwp_field_input_text', $args);
     }
     $args = array('id' => $this->get_field_id('captcha'), 'name' => $this->get_field_name('captcha'), 'value' => $captcha, 'label' => __('Using captcha in form?', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_input_checkbox', $args);
     $args = array('id' => $this->get_field_id('register'), 'name' => $this->get_field_name('register'), 'value' => $register, 'label' => __('Add suscriber as a user?', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_input_checkbox', $args);
     hocwp_field_widget_after();
 }
 public function form($instance)
 {
     $this->instance = $instance;
     $title = hocwp_get_value_by_key($instance, 'title');
     $number = hocwp_get_value_by_key($instance, 'number', hocwp_get_value_by_key($this->args, 'number'));
     $time = hocwp_get_value_by_key($instance, 'time', hocwp_get_value_by_key($this->args, 'time'));
     $exclude_users = hocwp_get_value_by_key($instance, 'exclude_users');
     $users = hocwp_json_string_to_array($exclude_users);
     $show_count = hocwp_get_value_by_key($instance, 'show_count', hocwp_get_value_by_key($this->args, 'show_count'));
     $link_author_name = hocwp_get_value_by_key($instance, 'link_author_name', hocwp_get_value_by_key($this->args, 'link_author_name'));
     $none_text = hocwp_get_value_by_key($instance, 'none_text', hocwp_get_value_by_key($this->args, 'none_text'));
     hocwp_field_widget_before($this->admin_args['class']);
     hocwp_widget_field_title($this->get_field_id('title'), $this->get_field_name('title'), $title);
     $args = array('id' => $this->get_field_id('number'), 'name' => $this->get_field_name('number'), 'value' => $number, 'label' => __('Number:', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_input_number', $args);
     $lists = $this->args['times'];
     $all_option = '';
     foreach ($lists as $key => $lvalue) {
         $all_option .= hocwp_field_get_option(array('value' => $key, 'text' => $lvalue, 'selected' => $time));
     }
     $args = array('id' => $this->get_field_id('time'), 'name' => $this->get_field_name('time'), 'all_option' => $all_option, 'value' => $time, 'label' => __('Time:', 'hocwp-theme'), 'multiple' => true);
     hocwp_widget_field('hocwp_field_select', $args);
     $lists = get_users();
     $all_option = '';
     foreach ($lists as $lvalue) {
         $selected = '';
         foreach ($users as $data) {
             $user_name = hocwp_get_value_by_key($data, 'value');
             if ($lvalue->ID == $user_name) {
                 $selected = $user_name;
             }
         }
         $all_option .= hocwp_field_get_option(array('value' => $lvalue->ID, 'text' => $lvalue->display_name, 'selected' => $selected));
     }
     $args = array('id' => $this->get_field_id('exclude_users'), 'name' => $this->get_field_name('exclude_users'), 'all_option' => $all_option, 'value' => $exclude_users, 'label' => __('Exclude users:', 'hocwp-theme'), 'placeholder' => __('Choose user', 'hocwp-theme'), 'multiple' => true);
     hocwp_widget_field('hocwp_field_select_chosen', $args);
     $args = array('id' => $this->get_field_id('show_count'), 'name' => $this->get_field_name('show_count'), 'value' => $show_count, 'label' => __('Show count', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_input_checkbox', $args);
     $args = array('id' => $this->get_field_id('link_author_name'), 'name' => $this->get_field_name('link_author_name'), 'value' => $link_author_name, 'label' => __('Link author name', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_input_checkbox', $args);
     $args = array('id' => $this->get_field_id('none_text'), 'name' => $this->get_field_name('none_text'), 'value' => $none_text, 'label' => __('No commenter text:', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_input', $args);
     hocwp_field_widget_after();
 }
 public function form($instance)
 {
     $this->instance = $instance;
     $title = hocwp_get_value_by_key($instance, 'title');
     $taxonomy = $this->get_taxonomy_from_instance($instance);
     $number = hocwp_get_value_by_key($instance, 'number', hocwp_get_value_by_key($this->args, 'number'));
     $thumbnail_size = hocwp_get_value_by_key($instance, 'thumbnail_size', hocwp_get_value_by_key($this->args, 'thumbnail_size'));
     $full_width_item = hocwp_get_value_by_key($instance, 'full_width_item', hocwp_get_value_by_key($this->args, 'full_width_item'));
     $count_format = hocwp_get_value_by_key($instance, 'count_format', hocwp_get_value_by_key($this->args, 'count_format'));
     $show_count = hocwp_get_value_by_key($instance, 'show_count', hocwp_get_value_by_key($this->args, 'show_count'));
     $hide_thumbnail = hocwp_get_value_by_key($instance, 'hide_thumbnail', hocwp_get_value_by_key($this->args, 'hide_thumbnail'));
     $only_thumbnail = hocwp_get_value_by_key($instance, 'only_thumbnail', hocwp_get_value_by_key($this->args, 'only_thumbnail'));
     $order = hocwp_get_value_by_key($instance, 'order', hocwp_get_value_by_key($this->args, 'order'));
     $orderby = hocwp_get_value_by_key($instance, 'orderby', hocwp_get_value_by_key($this->args, 'orderby'));
     $different_name = (bool) hocwp_get_value_by_key($instance, 'different_name', hocwp_get_value_by_key($this->args, 'different_name'));
     $in_current_post = (bool) hocwp_get_value_by_key($instance, 'in_current_post', hocwp_get_value_by_key($this->args, 'in_current_post'));
     $hide_empty = hocwp_get_value_by_key($instance, 'hide_empty', hocwp_get_value_by_key($this->args, 'hide_empty'));
     $only_parent = hocwp_get_value_by_key($instance, 'only_parent', hocwp_get_value_by_key($this->args, 'only_parent'));
     $child_of_current = hocwp_get_value_by_key($instance, 'child_of_current', hocwp_get_value_by_key($this->args, 'child_of_current'));
     $child_of_parent = hocwp_get_value_by_key($instance, 'child_of_parent', hocwp_get_value_by_key($this->args, 'child_of_parent'));
     $parent_as_title = hocwp_get_value_by_key($instance, 'parent_as_title', hocwp_get_value_by_key($this->args, 'parent_as_title'));
     hocwp_field_widget_before($this->admin_args['class']);
     hocwp_widget_field_title($this->get_field_id('title'), $this->get_field_name('title'), $title);
     $lists = get_taxonomies(array('_builtin' => false, 'public' => true), 'objects');
     if (!array_key_exists('post_tag', $lists)) {
         array_unshift($lists, get_taxonomy('post_tag'));
     }
     if (!array_key_exists('category', $lists)) {
         array_unshift($lists, get_taxonomy('category'));
     }
     $all_option = '';
     foreach ($lists as $lvalue) {
         $selected = '';
         if (!hocwp_array_has_value($taxonomy)) {
             $taxonomy[] = array('value' => 'category');
         }
         foreach ($taxonomy as $ptvalue) {
             $ptype = isset($ptvalue['value']) ? $ptvalue['value'] : '';
             if ($lvalue->name == $ptype) {
                 $selected = $lvalue->name;
                 break;
             }
         }
         $all_option .= hocwp_field_get_option(array('value' => $lvalue->name, 'text' => $lvalue->labels->singular_name, 'selected' => $selected));
     }
     $args = array('id' => $this->get_field_id('taxonomy'), 'name' => $this->get_field_name('taxonomy'), 'all_option' => $all_option, 'value' => $taxonomy, 'label' => __('Taxonomy:', 'hocwp-theme'), 'placeholder' => __('Choose taxonomy', 'hocwp-theme'), 'multiple' => true);
     hocwp_widget_field('hocwp_field_select_chosen', $args);
     $args = array('id' => $this->get_field_id('number'), 'name' => $this->get_field_name('number'), 'value' => $number, 'label' => __('Number items:', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_input_number', $args);
     $lists = $this->args['orderbys'];
     $all_option = '';
     foreach ($lists as $lkey => $lvalue) {
         $all_option .= hocwp_field_get_option(array('value' => $lkey, 'text' => $lvalue, 'selected' => $orderby));
     }
     $args = array('id' => $this->get_field_id('orderby'), 'name' => $this->get_field_name('orderby'), 'value' => $orderby, 'all_option' => $all_option, 'label' => __('Order by:', 'hocwp-theme'), 'class' => 'orderby');
     hocwp_widget_field('hocwp_field_select', $args);
     $lists = $this->args['orders'];
     $all_option = '';
     foreach ($lists as $lkey => $lvalue) {
         $all_option .= hocwp_field_get_option(array('value' => strtolower($lvalue), 'text' => strtoupper($lvalue), 'selected' => $order));
     }
     $args = array('id' => $this->get_field_id('order'), 'name' => $this->get_field_name('order'), 'value' => $order, 'all_option' => $all_option, 'label' => __('Order:', 'hocwp-theme'), 'class' => 'order');
     hocwp_widget_field('hocwp_field_select', $args);
     $args = array('id_width' => $this->get_field_id('thumbnail_size_width'), 'name_width' => $this->get_field_name('thumbnail_size_width'), 'id_height' => $this->get_field_id('thumbnail_size_height'), 'name_height' => $this->get_field_name('thumbnail_size_height'), 'value' => $thumbnail_size, 'label' => __('Thumbnail size:', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_size', $args);
     $lists = $this->args['full_width_items'];
     $all_option = '';
     foreach ($lists as $lkey => $lvalue) {
         $all_option .= hocwp_field_get_option(array('value' => $lkey, 'text' => $lvalue, 'selected' => $full_width_item));
     }
     $args = array('id' => $this->get_field_id('full_width_item'), 'name' => $this->get_field_name('full_width_item'), 'value' => $full_width_item, 'all_option' => $all_option, 'label' => __('Full width items:', 'hocwp-theme'), 'class' => 'full-width-item');
     hocwp_widget_field('hocwp_field_select', $args);
     $args = array('id' => $this->get_field_id('count_format'), 'name' => $this->get_field_name('count_format'), 'value' => $count_format, 'label' => __('Count format:', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_input', $args);
     $args = array('id' => $this->get_field_id('hide_thumbnail'), 'name' => $this->get_field_name('hide_thumbnail'), 'value' => $hide_thumbnail, 'label' => __('Hide term thumbnail?', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_input_checkbox', $args);
     $args = array('id' => $this->get_field_id('show_count'), 'name' => $this->get_field_name('show_count'), 'value' => $show_count, 'label' => __('Show count?', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_input_checkbox', $args);
     $args = array('id' => $this->get_field_id('only_thumbnail'), 'name' => $this->get_field_name('only_thumbnail'), 'value' => $only_thumbnail, 'label' => __('Only thumbnail?', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_input_checkbox', $args);
     $args = array('id' => $this->get_field_id('different_name'), 'name' => $this->get_field_name('different_name'), 'value' => $different_name, 'label' => __('Use different term name?', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_input_checkbox', $args);
     $args = array('id' => $this->get_field_id('in_current_post'), 'name' => $this->get_field_name('in_current_post'), 'value' => $in_current_post, 'label' => __('Get term in current post?', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_input_checkbox', $args);
     $args = array('id' => $this->get_field_id('only_parent'), 'name' => $this->get_field_name('only_parent'), 'value' => $only_parent, 'label' => __('Show terms have no parent only?', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_input_checkbox', $args);
     $args = array('id' => $this->get_field_id('child_of_current'), 'name' => $this->get_field_name('child_of_current'), 'value' => $child_of_current, 'label' => __('Get all childs of current term?', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_input_checkbox', $args);
     $args = array('id' => $this->get_field_id('child_of_parent'), 'name' => $this->get_field_name('child_of_parent'), 'value' => $child_of_parent, 'label' => __('Get all childs of parent if current term has no child?', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_input_checkbox', $args);
     $args = array('id' => $this->get_field_id('parent_as_title'), 'name' => $this->get_field_name('parent_as_title'), 'value' => $parent_as_title, 'label' => __('Display parent term as widget title?', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_input_checkbox', $args);
     $args = array('id' => $this->get_field_id('hide_empty'), 'name' => $this->get_field_name('hide_empty'), 'value' => $hide_empty, 'label' => __('Hide term if it doesn\'t have post.', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_input_checkbox', $args);
     hocwp_field_widget_after();
 }
 public function form($instance)
 {
     $this->instance = $instance;
     $title = hocwp_get_value_by_key($instance, 'title');
     $post_type = $this->get_post_type_from_instance($instance);
     $number = hocwp_get_value_by_key($instance, 'number', hocwp_get_value_by_key($this->args, 'number'));
     $by = hocwp_get_value_by_key($instance, 'by', hocwp_get_value_by_key($this->args, 'by'));
     $category = hocwp_get_value_by_key($instance, 'category', json_encode(hocwp_get_value_by_key($this->args, 'category')));
     $category = hocwp_json_string_to_array($category);
     $thumbnail_size = hocwp_get_value_by_key($instance, 'thumbnail_size', hocwp_get_value_by_key($this->args, 'thumbnail_size'));
     $full_width_post = hocwp_get_value_by_key($instance, 'full_width_post', hocwp_get_value_by_key($this->args, 'full_width_post'));
     $title_length = hocwp_get_value_by_key($instance, 'title_length', hocwp_get_value_by_key($this->args, 'title_length'));
     $excerpt_length = hocwp_get_value_by_key($instance, 'excerpt_length', hocwp_get_value_by_key($this->args, 'excerpt_length'));
     $hide_thumbnail = hocwp_get_value_by_key($instance, 'hide_thumbnail', hocwp_get_value_by_key($this->args, 'hide_thumbnail'));
     $widget_title_link_category = hocwp_get_value_by_key($instance, 'widget_title_link_category', hocwp_get_value_by_key($this->args, 'widget_title_link_category'));
     $category_as_widget_title = hocwp_get_value_by_key($instance, 'category_as_widget_title', hocwp_get_value_by_key($this->args, 'category_as_widget_title'));
     hocwp_field_widget_before($this->admin_args['class']);
     hocwp_widget_field_title($this->get_field_id('title'), $this->get_field_name('title'), $title);
     $lists = get_post_types(array('_builtin' => false, 'public' => true), 'objects');
     if (!array_key_exists('post', $lists)) {
         $lists[] = get_post_type_object('post');
     }
     $all_option = '';
     foreach ($lists as $lvalue) {
         $selected = '';
         if (!hocwp_array_has_value($post_type)) {
             $post_type[] = array('value' => 'post');
         }
         foreach ($post_type as $ptvalue) {
             $ptype = isset($ptvalue['value']) ? $ptvalue['value'] : '';
             if ($lvalue->name == $ptype) {
                 $selected = $lvalue->name;
                 break;
             }
         }
         $all_option .= hocwp_field_get_option(array('value' => $lvalue->name, 'text' => $lvalue->labels->singular_name, 'selected' => $selected));
     }
     $args = array('id' => $this->get_field_id('post_type'), 'name' => $this->get_field_name('post_type'), 'all_option' => $all_option, 'value' => $post_type, 'label' => __('Post type:', 'hocwp-theme'), 'placeholder' => __('Choose post types', 'hocwp-theme'), 'multiple' => true);
     hocwp_widget_field('hocwp_field_select_chosen', $args);
     $args = array('id' => $this->get_field_id('number'), 'name' => $this->get_field_name('number'), 'value' => $number, 'label' => __('Number posts:', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_input_number', $args);
     $lists = $this->args['bys'];
     $all_option = '';
     foreach ($lists as $lkey => $lvalue) {
         $all_option .= hocwp_field_get_option(array('value' => $lkey, 'text' => $lvalue, 'selected' => $by));
     }
     $args = array('id' => $this->get_field_id('by'), 'name' => $this->get_field_name('by'), 'value' => $by, 'all_option' => $all_option, 'label' => __('Get by:', 'hocwp-theme'), 'class' => 'get-by');
     hocwp_widget_field('hocwp_field_select', $args);
     $all_option = '';
     $taxonomies = hocwp_get_hierarchical_taxonomies();
     foreach ($taxonomies as $tkey => $tax) {
         $lists = hocwp_get_hierarchical_terms(array($tkey));
         if (hocwp_array_has_value($lists)) {
             $all_option .= '<optgroup label="' . $tax->labels->singular_name . '">';
             foreach ($lists as $lvalue) {
                 $selected = '';
                 if (hocwp_array_has_value($category)) {
                     foreach ($category as $cvalue) {
                         $term_id = isset($cvalue['value']) ? $cvalue['value'] : 0;
                         if ($lvalue->term_id == $term_id) {
                             $selected = $lvalue->term_id;
                             break;
                         }
                     }
                 }
                 $all_option .= hocwp_field_get_option(array('value' => $lvalue->term_id, 'text' => $lvalue->name, 'selected' => $selected, 'attributes' => array('data-taxonomy' => $tkey)));
             }
             $all_option .= '</optgroup>';
         }
     }
     $args = array('id' => $this->get_field_id('category'), 'name' => $this->get_field_name('category'), 'all_option' => $all_option, 'value' => $category, 'label' => __('Category:', 'hocwp-theme'), 'placeholder' => __('Choose terms', 'hocwp-theme'), 'multiple' => true, 'class' => 'select-category');
     if ('category' != $by) {
         $args['hidden'] = true;
     }
     hocwp_widget_field('hocwp_field_select_chosen', $args);
     $args = array('id_width' => $this->get_field_id('thumbnail_size_width'), 'name_width' => $this->get_field_name('thumbnail_size_width'), 'id_height' => $this->get_field_id('thumbnail_size_height'), 'name_height' => $this->get_field_name('thumbnail_size_height'), 'value' => $thumbnail_size, 'label' => __('Thumbnail size:', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_size', $args);
     $lists = $this->args['full_width_posts'];
     $all_option = '';
     foreach ($lists as $lkey => $lvalue) {
         $all_option .= hocwp_field_get_option(array('value' => $lkey, 'text' => $lvalue, 'selected' => $full_width_post));
     }
     $args = array('id' => $this->get_field_id('full_width_post'), 'name' => $this->get_field_name('full_width_post'), 'value' => $full_width_post, 'all_option' => $all_option, 'label' => __('Full width posts:', 'hocwp-theme'), 'class' => 'full-width-post');
     hocwp_widget_field('hocwp_field_select', $args);
     $args = array('id' => $this->get_field_id('title_length'), 'name' => $this->get_field_name('title_length'), 'value' => $title_length, 'label' => __('Title length:', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_input_number', $args);
     $args = array('id' => $this->get_field_id('excerpt_length'), 'name' => $this->get_field_name('excerpt_length'), 'value' => $excerpt_length, 'label' => __('Excerpt length:', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_input_number', $args);
     $slider = hocwp_get_value_by_key($instance, 'slider', hocwp_get_value_by_key($this->args, 'slider'));
     $args = array('id' => $this->get_field_id('slider'), 'name' => $this->get_field_name('slider'), 'value' => $slider, 'label' => __('Display post as slider?', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_input_checkbox', $args);
     $args = array('id' => $this->get_field_id('hide_thumbnail'), 'name' => $this->get_field_name('hide_thumbnail'), 'value' => $hide_thumbnail, 'label' => __('Hide post thumbnail?', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_input_checkbox', $args);
     $args = array('id' => $this->get_field_id('widget_title_link_category'), 'name' => $this->get_field_name('widget_title_link_category'), 'value' => $widget_title_link_category, 'label' => __('Link widget title with category?', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_input_checkbox', $args);
     $args = array('id' => $this->get_field_id('category_as_widget_title'), 'name' => $this->get_field_name('category_as_widget_title'), 'value' => $category_as_widget_title, 'label' => __('Display category name as widget title?', 'hocwp-theme'));
     hocwp_widget_field('hocwp_field_input_checkbox', $args);
     hocwp_field_widget_after();
 }
function hocwp_widget_field($callback, $args)
{
    if (hocwp_callback_exists($callback)) {
        $hidden = isset($args['hidden']) ? $args['hidden'] : false;
        $container_class = '';
        if ($hidden) {
            hocwp_add_string_with_space_before($container_class, 'hidden');
        }
        hocwp_field_widget_before($container_class, true);
        $args = hocwp_field_sanitize_widget_args($args);
        if ('hocwp_field_select_chosen' == $callback) {
            $args['before'] = '<div class="hocwp-widget-field">';
            $args['after'] = '</div>';
        }
        call_user_func($callback, $args);
        hocwp_field_widget_after();
    }
}