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'] : '';
     $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();
 }
Пример #4
0
function hocwp_slider_meta_box_field($post_type, $post)
{
    if (!hocwp_is_post($post)) {
        return;
    }
    if ('hocwp_slider' == $post_type) {
        $post_id = $post->ID;
        $meta = new HOCWP_Meta('post');
        $meta->add_post_type('hocwp_slider');
        $meta->set_id('hocwp_slider_information');
        $meta->set_title(__('Slider Information', 'hocwp-theme'));
        $meta->is_on_sidebar(true);
        $all_options = '<option value="">-- ' . __('Choose position', 'hocwp-theme') . ' --</option>';
        $slider_items = hocwp_get_slider_positions();
        $position = hocwp_get_post_meta('position', $post->ID);
        foreach ($slider_items as $slider) {
            $args = array('value' => $slider['id'], 'text' => $slider['name'], 'selected' => $position);
            $all_options .= hocwp_field_get_option($args);
        }
        $args = array('id' => 'position', 'label' => __('Position:', 'hocwp-theme'), 'description' => __('Choose position where you want the slider to be displayed.', 'hocwp-theme'), 'field_class' => 'display-block', 'all_option' => $all_options, 'container_class' => 'margin-bottom-10', 'field_callback' => 'hocwp_field_select');
        $meta->add_field($args);
        $meta->add_field(array('id' => 'active', 'label' => __('Make slider active?', 'hocwp-theme'), 'field_callback' => 'hocwp_field_checkbox'));
        $meta->init();
        $meta = new HOCWP_Meta('post');
        $meta->add_post_type('hocwp_slider');
        $meta->set_title(__('Advanced Settings', 'hocwp-theme'));
        $meta->set_id('hocwp_slider_advanced_settings');
        $meta->is_on_sidebar(true);
        $meta->add_field(array('id' => 'height', 'label' => __('Height:', 'hocwp-theme'), 'field_callback' => 'hocwp_field_input_number', 'default' => 350));
        $meta->add_field(array('id' => 'fit_width', 'label' => __('Stretch slider to fit site width.', 'hocwp-theme'), 'field_callback' => 'hocwp_field_checkbox', 'default' => 1));
        $meta->init();
        $meta = new HOCWP_Meta('post');
        $meta->set_id('hocwp_slider_item_information');
        $meta->set_title(__('Slider Items', 'hocwp-theme'));
        $meta->add_post_type('hocwp_slider');
        $meta->set_use_media_upload(true);
        $meta->register_field('slider_items');
        $value = hocwp_get_slider_items($post_id, true);
        $list_items = $value['items'];
        $item_order = $value['order'];
        if (!is_array($item_order)) {
            $item_order = array();
        }
        $max_item_id = absint(hocwp_get_max_number($item_order));
        $field_html = '';
        foreach ($item_order as $key => $item_id) {
            $item = isset($list_items[$item_id]) ? $list_items[$item_id] : array();
            if (!hocwp_array_has_value($item)) {
                unset($item_order[$key]);
                continue;
            }
            $title = isset($item['title']) ? $item['title'] : '';
            $link = isset($item['link']) ? $item['link'] : '';
            $description = isset($item['description']) ? $item['description'] : '';
            $image_url = isset($item['image_url']) ? $item['image_url'] : '';
            $image_id = isset($item['image_id']) ? $item['image_id'] : 0;
            if ($image_id > 0) {
                $media_url = hocwp_get_media_image_url($image_id);
                if (!empty($media_url)) {
                    $image_url = $media_url;
                }
            }
            if (empty($image_url)) {
                continue;
            }
            ob_start();
            ?>
			<li data-item="<?php 
            echo $item_id;
            ?>
">
				<img class="item-image" src="<?php 
            echo $image_url;
            ?>
">

				<div class="item-info">
					<input type="text" name="slider_items[items][<?php 
            echo $item_id;
            ?>
][title]" class="item-title"
					       value="<?php 
            echo $title;
            ?>
" placeholder="<?php 
            _e('Title', 'hocwp-theme');
            ?>
">
					<input type="url" name="slider_items[items][<?php 
            echo $item_id;
            ?>
][link]" class="item-link"
					       value="<?php 
            echo $link;
            ?>
"
					       placeholder="<?php 
            _e('Link for this item', 'hocwp-theme');
            ?>
">
						<textarea name="slider_items[items][<?php 
            echo $item_id;
            ?>
][description]"
						          class="item-description"><?php 
            echo $description;
            ?>
</textarea>
				</div>
				<div class="clear"></div>
				<div class="advance">
					<div class="dashicons dashicons-editor-expand"></div>
					<div class="box-content">
						<div class="settings">
							<div class="col-left col50 hocwp-col">
								<?php 
            $field_args = array('name' => 'slider_items[items][' . $item_id . '][background_color]', 'label' => __('Background Color', 'hocwp-theme'), 'value' => hocwp_get_value_by_key($item, 'background_color'));
            hocwp_field_color_picker($field_args);
            ?>
							</div>
							<div class="col-right col50 hocwp-col">

							</div>
						</div>
					</div>
				</div>
				<input type="hidden" class="item-image-url" value="<?php 
            echo $image_url;
            ?>
"
				       name="slider_items[items][<?php 
            echo $item_id;
            ?>
][image_url]">
				<input type="hidden" class="item-image-id" value="<?php 
            echo $image_id;
            ?>
"
				       name="slider_items[items][<?php 
            echo $item_id;
            ?>
][image_id]">
				<span title="<?php 
            _e('Delete this item', 'hocwp-theme');
            ?>
"
				      class="item-icon icon-delete icon-sortable-ui"></span>
				<span title="<?php 
            _e('Re-order this item', 'hocwp-theme');
            ?>
"
				      class="item-icon icon-drag icon-sortable-ui"></span>
				<span title="<?php 
            _e('Add child item', 'hocwp-theme');
            ?>
"
				      class="item-icon icon-add icon-sortable-ui"></span>
			</li>
			<?php 
            $field_html .= ob_get_clean();
        }
        $meta->add_field(array('id' => 'list_slider_items', 'class' => 'list-slider-items ui-sortable sortable hocwp-sortable', 'tag' => 'ul', 'field_callback' => 'hocwp_field_html_tag', 'attributes' => array('data-max-id' => $max_item_id, 'data-items' => count($item_order), 'data-post' => $post->ID, 'data-disable-selection' => 0), 'html' => $field_html, 'after_html' => '<input type="hidden" name="slider_items[order]" value="' . implode(',', $item_order) . '" class="item-order" autocomplete="off">'));
        $meta->add_field(array('id' => 'add_slider', 'label' => __('Add item', 'hocwp-theme'), 'field_callback' => 'hocwp_field_button'));
        $meta->init();
    }
}
 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();
 }
Пример #7
0
function hocwp_fetch_administrative_boundaries_ajax_callback()
{
    $result = array();
    $default = hocwp_get_method_value('default');
    $default = str_replace('\\', '', $default);
    //$type = hocwp_get_method_value('type');
    if (empty($default)) {
    }
    $html_data = $default;
    $parent = hocwp_get_method_value('parent');
    if (hocwp_id_number_valid($parent)) {
        $taxonomy = hocwp_get_method_value('taxonomy');
        if (!empty($taxonomy)) {
            $terms = hocwp_get_terms($taxonomy, array('parent' => $parent, 'orderby' => 'NAME'));
            if (hocwp_array_has_value($terms)) {
                foreach ($terms as $term) {
                    $option = hocwp_field_get_option(array('value' => $term->term_id, 'text' => $term->name));
                    $html_data .= $option;
                }
            }
        }
    }
    $result['html_data'] = $html_data;
    wp_send_json($result);
}
Пример #8
0
function hocwp_theme_meta_box_ads_information($post_type, $post)
{
    global $pagenow;
    if ('hocwp_ads' == $post_type) {
        if (hocwp_is_post($post)) {
            $post_id = $post->ID;
        } else {
            $post_id = 0;
        }
        $meta = new HOCWP_Meta('post');
        $meta->add_post_type('hocwp_ads');
        $meta->set_id('hocwp_ads_information');
        $meta->set_title(__('Ads Information', 'hocwp-theme'));
        $meta->add_field(array('id' => 'image', 'label' => __('Image:', 'hocwp-theme'), 'container' => true, 'field_callback' => 'hocwp_field_media_upload'));
        $meta->add_field(array('id' => 'url', 'label' => __('Url:', 'hocwp-theme')));
        $positions = hocwp_get_ads_positions();
        if (hocwp_array_has_value($positions)) {
            $all_option = hocwp_field_get_option(array('text' => '--Choose Position--'));
            $selected = get_post_meta($post_id, 'position', true);
            foreach ($positions as $position) {
                $all_option .= hocwp_field_get_option(array('text' => $position['name'], 'value' => $position['id'], 'selected' => $selected));
            }
            $field_args = array('id' => 'position', 'label' => __('Position:', 'hocwp-theme'), 'field_callback' => 'hocwp_field_select', 'all_option' => $all_option);
            $meta->add_field($field_args);
        }
        $meta->add_field(array('id' => 'expire', 'label' => __('Expire:', 'hocwp-theme'), 'field_callback' => 'hocwp_field_datetime_picker'));
        do_action('hocwp_meta_box_ads_fields', $meta, $post);
        $meta->init();
        $args = array('id' => 'code_box', 'title' => __('Code:', 'hocwp-theme'), 'field_id' => 'code', 'post_type' => $post_type, 'field_args' => array('teeny' => true));
        hocwp_meta_box_editor($args);
    }
}
$defaults = hocwp_option_defaults();
$option = new HOCWP_Option(__('Theme Custom', 'hocwp-theme'), 'hocwp_theme_custom');
$options = $option->get();
$option->set_parent_slug($parent_slug);
$option->add_section(array('id' => 'music', 'title' => __('Music', 'hocwp-theme'), 'description' => __('Play music on your site as background music.', 'hocwp-theme')));
$option->add_field(array('id' => 'background_music', 'title' => __('Embed Code', 'hocwp-theme'), 'class' => 'widefat', 'row' => 3, 'field_callback' => 'hocwp_field_textarea', 'section' => 'music'));
$lists = hocwp_get_value_by_key($defaults, array('theme_custom', 'background_music', 'play_ons'));
$play_on = hocwp_get_value_by_key($defaults, array('theme_custom', 'background_music', 'play_on'));
$all_option = '';
$value = hocwp_get_value_by_key($options, 'play_on');
if (empty($value)) {
    $value = $play_on;
}
if (hocwp_array_has_value($lists)) {
    foreach ($lists as $key => $item) {
        $tmp_option = hocwp_field_get_option(array('value' => $key, 'text' => $item, 'selected' => $value));
        $all_option .= $tmp_option;
    }
}
$option->add_field(array('id' => 'play_on', 'title' => __('Play On', 'hocwp-theme'), 'field_callback' => 'hocwp_field_select', 'section' => 'music', 'all_option' => $all_option, 'default' => $play_on));
$option->add_section(array('id' => 'background', 'title' => __('Background', 'hocwp-theme'), 'description' => __('Custom background of your site.', 'hocwp-theme')));
$option->add_field(array('id' => 'background_image', 'title' => __('Image', 'hocwp-theme'), 'field_callback' => 'hocwp_field_media_upload', 'section' => 'background'));
$option->add_field(array('id' => 'background_size', 'title' => __('Size', 'hocwp-theme'), 'section' => 'background'));
$option->add_field(array('id' => 'background_repeat', 'title' => __('Repeat', 'hocwp-theme'), 'label' => __('Check here if you want background to be repeated.', 'hocwp-theme'), 'field_callback' => 'hocwp_field_input_checkbox', 'section' => 'background'));
$option->add_field(array('id' => 'background_position', 'title' => __('Position', 'hocwp-theme'), 'section' => 'background'));
$option->add_field(array('id' => 'background_color', 'title' => __('Color', 'hocwp-theme'), 'field_callback' => 'hocwp_field_color_picker', 'section' => 'background'));
$option->add_field(array('id' => 'background_attachment', 'title' => __('Attachment', 'hocwp-theme'), 'section' => 'background'));
$option->add_field(array('id' => 'background_lazyload', 'title' => __('Lazy Load', 'hocwp-theme'), 'label' => __('Check here if you want to load background with Lazy Load.', 'hocwp-theme'), 'field_callback' => 'hocwp_field_input_checkbox', 'default' => 0, 'section' => 'background'));
$option->set_use_color_picker(true);
$option->set_use_media_upload(true);
$option->set_use_style_and_script(true);
 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();
 }
Пример #12
0
function hocwp_field_select_country($args = array())
{
    hocwp_field_sanitize_args($args);
    $class = isset($args['class']) ? $args['class'] : '';
    hocwp_add_string_with_space_before($class, 'select-country');
    $args['field_class'] = $class;
    $select_none = isset($args['select_none']) ? $args['select_none'] : '<option value="">--' . __('Choose country', 'hocwp-theme') . '--</option>';
    $countries = hocwp_get_countries();
    $value = isset($args['value']) ? $args['value'] : '';
    $all_option = $select_none;
    foreach ($countries as $code => $country) {
        $option = hocwp_field_get_option(array('value' => $code, 'text' => $country['name'], 'selected' => $value));
        $all_option .= $option;
    }
    $args['all_option'] = $all_option;
    hocwp_field_select($args);
}