Esempio n. 1
0
function hocwp_video_source_meta_box($post_types = array())
{
    if (!hocwp_array_has_value($post_types)) {
        $post_types[] = 'post';
    }
    $meta = new HOCWP_Meta('post');
    $meta->set_post_types($post_types);
    $meta->set_title(__('Video Source Information', 'hocwp-theme'));
    $meta->set_id('hocwp_theme_video_source_information');
    $meta->add_field(array('field_args' => array('id' => 'video_url', 'label' => 'Video URL:')));
    $meta->add_field(array('field_args' => array('id' => 'video_code', 'label' => 'Video code:'), 'field_callback' => 'hocwp_field_textarea'));
    $meta->init();
}
Esempio n. 2
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();
    }
}
Esempio n. 3
0
function hocwp_meta_box_editor($args = array())
{
    global $pagenow;
    if ('post-new.php' == $pagenow || 'post.php' == $pagenow) {
        $post_type = hocwp_get_value_by_key($args, 'post_type');
        if (!is_array($post_type)) {
            $post_type = array($post_type);
        }
        $box_title = hocwp_get_value_by_key($args, 'title', __('Additional Information', 'hocwp-theme'));
        $current_type = hocwp_get_current_post_type();
        if (is_array($current_type)) {
            $current_type = current($current_type);
        }
        $box_id = hocwp_get_value_by_key($args, 'id');
        if (empty($box_id)) {
            $box_id = hocwp_sanitize_id($box_title);
            if (empty($box_id)) {
                return;
            }
        }
        if (!empty($current_type)) {
            $box_id = $current_type . '_' . $box_id;
        }
        $field_args = hocwp_get_value_by_key($args, 'field_args', array());
        $field_args = hocwp_sanitize_array($field_args);
        $field_args['field_callback'] = 'hocwp_field_editor';
        $field_args['label'] = '';
        $field_id = hocwp_get_value_by_key($args, 'field_id', hocwp_get_value_by_key($field_args, 'field_id'));
        $field_name = hocwp_get_value_by_key($args, 'field_name', hocwp_get_value_by_key($field_args, 'field_name'));
        hocwp_transmit_id_and_name($field_id, $field_name);
        if (empty($field_id)) {
            return;
        }
        $field_args['id'] = $field_id;
        $field_args['name'] = $field_name;
        $meta = new HOCWP_Meta('post');
        $meta->set_title($box_title);
        $meta->set_id($box_id);
        $meta->set_post_types($post_type);
        $meta->add_field($field_args);
        $meta->init();
    }
}
Esempio n. 4
0
function hocwp_term_meta_different_name_field($taxonomies = array())
{
    global $pagenow;
    if ('edit-tags.php' == $pagenow || 'term.php' == $pagenow) {
        if (!hocwp_array_has_value($taxonomies)) {
            $taxonomies = get_taxonomies(array('public' => true));
        }
        $taxonomies = apply_filters('hocwp_term_different_name_field_taxonomies', $taxonomies);
        hocwp_exclude_special_taxonomies($taxonomies);
        if (!hocwp_array_has_value($taxonomies)) {
            $taxonomies = array('category');
        }
        $meta = new HOCWP_Meta('term');
        $meta->set_taxonomies($taxonomies);
        $meta->add_field(array('id' => 'different_name', 'label' => __('Different Name', 'hocwp-theme')));
        $meta->init();
    }
}
Esempio n. 5
0
function hocwp_shop_product_meta_boxes($post_type, $post)
{
    if ('product' == $post_type) {
        $meta = new HOCWP_Meta('post');
        $meta->set_title(__('Product Information', 'hocwp-theme'));
        $meta->set_id('hocwp_product_information');
        $meta->add_post_type('product');
        $args = array('id' => 'sku', 'label' => __('SKU:', 'hocwp-theme'));
        $meta->add_field($args);
        $args = array('id' => 'regular_price', 'label' => __('Regular price:', 'hocwp-theme'), 'field_callback' => 'hocwp_field_input_number');
        $meta->add_field($args);
        $args = array('id' => 'sale_price', 'label' => __('Sale price:', 'hocwp-theme'), 'field_callback' => 'hocwp_field_input_number');
        $meta->add_field($args);
        $args = array('id' => 'out_of_stock', 'label' => __('Out of stock?', 'hocwp-theme'), 'field_callback' => 'hocwp_field_input_checkbox');
        $meta->add_field($args);
        $meta->init();
        $args = array('post_type' => 'product', 'field_id' => 'short_description', 'title' => __('Short Description', 'hocwp-theme'));
        hocwp_meta_box_editor($args);
        $args = array('post_type' => 'product', 'field_id' => 'gallery', 'title' => __('Gallery', 'hocwp-theme'));
        hocwp_meta_box_editor_gallery($args);
    }
}
Esempio n. 6
0
function hocwp_theme_meta_partner_information($post)
{
    $meta = new HOCWP_Meta('post');
    $meta->add_post_type('partner');
    $meta->set_id('hocwp_partner_information');
    $meta->set_title(__('Partner Information', 'hocwp-theme'));
    $args = array('id' => 'thumbnail', 'label' => __('Thumbnail:', 'hocwp-theme'), 'field_callback' => 'hocwp_field_media_upload', 'container' => true);
    $meta->add_field($args);
    $args = array('id' => 'url', 'label' => __('Url:', 'hocwp-theme'));
    $meta->add_field($args);
    $meta->init();
}
Esempio n. 7
0
    if ($use) {
        $name = __('Salaries', 'hocwp-theme');
        $singular = __('Salary', 'hocwp-theme');
        $args = array('name' => $name, 'singular_name' => $singular, 'slug' => hocwp_taxonomy_salary_base(), 'taxonomy' => 'salary', 'show_admin_column' => false, 'post_types' => array('post'));
        hocwp_register_taxonomy($args);
    }
    $name = __('Units', 'hocwp-theme');
    $singular = __('Unit', 'hocwp-theme');
    $args = array('name' => $name, 'singular_name' => $singular, 'slug' => 'currency_unit', 'taxonomy' => 'currency_unit', 'show_admin_column' => false, 'post_types' => array('post'));
    hocwp_register_taxonomy_private($args);
    hocwp_register_post_type_news();
}
add_action('init', 'hocwp_classifieds_post_type_and_taxonomy', 10);
if ('post.php' == $GLOBALS['pagenow'] || 'post-new.php' == $GLOBALS['pagenow']) {
    $current_user = wp_get_current_user();
    $meta = new HOCWP_Meta('post');
    $meta->add_post_type('post');
    $meta->set_title(__('General Information', 'hocwp-theme'));
    $meta->set_id('classifieds_general_information');
    $meta->add_field(array('id' => 'address', 'label' => __('Address:', 'hocwp-theme'), 'class' => 'hocwp-geo-address', 'default' => get_user_meta($current_user->ID, 'address', true)));
    $meta->add_field(array('id' => 'price', 'label' => __('Price:', 'hocwp-theme')));
    $meta->add_field(array('id' => 'phone', 'label' => __('Phone:', 'hocwp-theme'), 'default' => get_user_meta($current_user->ID, 'phone', true)));
    $meta->add_field(array('id' => 'email', 'label' => __('Email:', 'hocwp-theme'), 'default' => $current_user->user_email));
    $meta->add_field(array('id' => 'acreage', 'label' => __('Acreage:', 'hocwp-theme')));
    $meta->init();
    hocwp_meta_box_editor_gallery(array('post_type' => 'post'));
    hocwp_meta_box_google_maps();
}
function hocwp_classifieds_filter_taxonomy_base($base, $taxonomy)
{
    switch ($taxonomy) {