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); } }
function hocwp_meta_box_editor_gallery($args = array()) { $defaults = array('title' => __('Gallery', 'hocwp-theme'), 'field_id' => 'image_gallery', 'field_name' => 'gallery', 'field_args' => array('teeny' => true, 'toolbar' => false)); $args = wp_parse_args($args, $defaults); hocwp_meta_box_editor($args); }
function hocwp_theme_meta_product_tab_field_box_helper($posts) { foreach ($posts as $tab) { $id = hocwp_sanitize_id($tab->post_name); $args = array('post_type' => 'product', 'title' => $tab->post_title, 'field_id' => $id, 'id' => 'meta_box_' . $id); hocwp_meta_box_editor($args); } }