Exemple #1
0
function hocwp_theme_more_product_meta_boxes_init($post_type, $post)
{
    if (hocwp_wc_installed()) {
        $args = array('posts_per_page' => -1, 'post_type' => 'hocwp_product_tab');
        $query = hocwp_query($args);
        if ($query->have_posts()) {
            hocwp_theme_meta_product_tab_field_box_helper($query->posts);
        }
    } else {
        if (hocwp_is_shop_site()) {
            hocwp_shop_product_meta_boxes($post_type, $post);
        }
    }
}
Exemple #2
0
function hocwp_shop_save_product_meta($post_id)
{
    if (!hocwp_can_save_post($post_id)) {
        return;
    }
    if (!hocwp_is_shop_site() || hocwp_wc_installed()) {
        return;
    }
    if (isset($_POST['sku'])) {
        update_post_meta($post_id, 'sku', $_POST['sku']);
    }
    $regular_price = hocwp_get_method_value('regular_price');
    $sale_price = hocwp_get_method_value('sale_price');
    $prices = hocwp_sanitize_product_price($regular_price, $sale_price, $post_id);
    update_post_meta($post_id, 'regular_price', $prices['regular_price']);
    update_post_meta($post_id, 'sale_price', $prices['sale_price']);
    update_post_meta($post_id, 'price', $prices['price']);
    if (isset($_POST['short_description'])) {
        update_post_meta($post_id, 'short_description', $_POST['short_description']);
    }
    $out_of_stock = hocwp_checkbox_post_data_value($_POST, 'out_of_stock');
    update_post_meta($post_id, 'out_of_stock', $out_of_stock);
    if (isset($_POST['gallery'])) {
        update_post_meta($post_id, 'gallery', $_POST['gallery']);
    }
}
$options = wp_parse_args($options, hocwp_option_reading_defaults());
$option = new HOCWP_Option(__('Reading', 'hocwp-theme'), 'hocwp_reading');
$option->set_parent_slug('hocwp_theme_option');
$option->set_use_media_upload(true);
$option->add_field(array('id' => 'statistics', 'title' => __('Statistics', 'hocwp-theme'), 'field_callback' => 'hocwp_field_input_checkbox', 'label' => __('Check here if you want to enable user statistics on your site.', 'hocwp-theme')));
$option->add_field(array('id' => 'trending', 'title' => __('Trending', 'hocwp-theme'), 'field_callback' => 'hocwp_field_input_checkbox', 'label' => __('Track trending post?', 'hocwp-theme')));
$option->add_field(array('id' => 'search_tracking', 'title' => __('Search Tracking', 'hocwp-theme'), 'field_callback' => 'hocwp_field_input_checkbox', 'label' => __('Tracking search query on your site?', 'hocwp-theme')));
$option->add_field(array('id' => 'post_statistics', 'title' => __('Post Statistics', 'hocwp-theme'), 'field_callback' => 'hocwp_field_input_checkbox', 'label' => __('Track post views on your site.', 'hocwp-theme')));
$option->add_field(array('id' => 'sticky_widget', 'title' => __('Sticky Widget', 'hocwp-theme'), 'field_callback' => 'hocwp_field_input_checkbox', 'label' => __('Make last widget fixed when scroll down.', 'hocwp-theme')));
$option->add_field(array('id' => 'redirect_404', 'title' => __('Redirect 404', 'hocwp-theme'), 'field_callback' => 'hocwp_field_input_checkbox', 'label' => __('Auto redirect 404 page to homepage.', 'hocwp-theme')));
$option->add_field(array('id' => 'bold_first_paragraph', 'title' => __('Bold First Paragraph', 'hocwp-theme'), 'field_callback' => 'hocwp_field_input_checkbox', 'label' => __('Automatically bold first paragraph of content?', 'hocwp-theme')));
$option->add_field(array('id' => 'enlarge_thumbnail', 'title' => __('Enlarge Thumbnail', 'hocwp-theme'), 'field_callback' => 'hocwp_field_input_checkbox', 'label' => __('Enlarge post thumbnail when using mobile?', 'hocwp-theme')));
$option->add_field(array('id' => 'content_none_title', 'title' => __('Content None Title', 'hocwp-theme')));
$excerpt_length = hocwp_get_value_by_key($options, 'excerpt_length');
$option->add_field(array('id' => 'excerpt_length', 'title' => __('Excerpt Length', 'hocwp-theme'), 'field_callback' => 'hocwp_field_input_number', 'value' => $excerpt_length));
if (hocwp_wc_installed() || hocwp_is_shop_site()) {
    $value = hocwp_get_product_posts_per_page();
    $option->add_field(array('id' => 'products_per_page', 'title' => __('Product Each Page', 'hocwp-theme'), 'field_callback' => 'hocwp_field_input_number', 'value' => $value));
}
$option->add_section(array('id' => 'breadcrumb', 'title' => __('Breadcrumb', 'hocwp-theme'), 'description' => __('Custom breadcrumb on your site.', 'hocwp-theme')));
$option->add_field(array('id' => 'breadcrumb_label', 'title' => __('Breadcrumb Label', 'hocwp-theme'), 'value' => hocwp_wpseo_internallink_value('breadcrumbs-prefix'), 'section' => 'breadcrumb'));
$option->add_field(array('id' => 'disable_post_title_breadcrumb', 'title' => __('Disable Post Title', 'hocwp-theme'), 'field_callback' => 'hocwp_field_input_checkbox', 'label' => __('Prevent post title to be shown on last item.', 'hocwp-theme'), 'section' => 'breadcrumb'));
$option->add_field(array('id' => 'link_last_item_breadcrumb', 'title' => __('Link Last Item', 'hocwp-theme'), 'field_callback' => 'hocwp_field_input_checkbox', 'label' => __('Add link to last item instead of text.', 'hocwp-theme'), 'section' => 'breadcrumb'));
$thumbnail_image_sizes = $options['thumbnail_image_sizes'];
$thumbnail_image_sizes = apply_filters('hocwp_thumbnail_image_sizes', $thumbnail_image_sizes);
$thumbnail_image_sizes = hocwp_sanitize_array($thumbnail_image_sizes);
if (hocwp_array_has_value($thumbnail_image_sizes)) {
    $option->add_section(array('id' => 'thumbnail_images', 'title' => __('Thumbnail Images', 'hocwp-theme'), 'description' => __('These settings affect the display and dimensions of images in your catalog – the display on the front-end will still be affected by CSS styles.', 'hocwp-theme')));
    foreach ($thumbnail_image_sizes as $thumbnail_size) {
        $thumbnail_size['section'] = 'thumbnail_images';
        $thumbnail_size['field_callback'] = 'hocwp_field_size';