Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Single product fields define
- *
- * @param array $meta_boxes metaboxes.
- */
- function my_product_fields( $meta_boxes ) {
- $fields = array(
- array(
- 'name' => __( 'Section' ),
- 'id' => 'section',
- 'type' => 'select',
- 'options' => array(
- 'select' => __( 'Select' ),
- 'product_info' => __( 'Product Info' ),
- 'pricing' => __( 'Pricing' ),
- ),
- ),
- );
- $fields[] = array(
- 'id' => 'product_info',
- 'type' => 'group',
- 'visible' => array( 'section', '=', 'product_info' ),
- 'fields' => array(
- array(
- 'id' => 'infos',
- 'type' => 'group',
- 'clone' => true,
- 'sort_clone' => true,
- 'collapsible' => true,
- 'save_state' => true,
- 'group_title' => __( 'Item' ) . ' - {title}',
- 'add_button' => __( 'Add Item' ),
- 'fields' => array(
- array(
- 'name' => __( 'Title' ),
- 'id' => 'title',
- 'type' => 'text',
- 'size' => 60,
- ),
- array(
- 'name' => __( 'Description' ),
- 'id' => 'desc',
- 'type' => 'text',
- 'size' => 100,
- ),
- ),
- ),
- ),
- );
- $fields[] = array(
- 'id' => 'pricing',
- 'type' => 'group',
- 'visible' => array( 'section', '=', 'pricing' ),
- 'fields' => array(
- array(
- 'name' => __( 'Type' ),
- 'id' => 'pricing_type',
- 'type' => 'select',
- 'options' => array(
- 'simple' => __( 'Simple' ),
- 'table' => __( 'Table' ),
- ),
- ),
- array(
- 'name' => __( 'Enable Icons' ),
- 'id' => 'pricing_enable_icons',
- 'type' => 'switch',
- 'visible' => array( 'pricing_type', '=', 'table' ),
- ),
- array(
- 'name' => __( 'Title' ),
- 'id' => 'title',
- 'type' => 'text',
- 'size' => 60,
- ),
- array(
- 'name' => __( 'Description' ),
- 'id' => 'desc',
- 'type' => 'text',
- 'size' => 80,
- ),
- array(
- 'name' => __( 'Enable separate pricing' ),
- 'id' => 'seperate_pricing',
- 'type' => 'switch',
- ),
- array(
- 'name' => __( 'Price suffix' ),
- 'id' => 'price_suffix',
- 'type' => 'text',
- 'hidden' => array( 'seperate_pricing', true ),
- ),
- array(
- 'name' => __( 'Price Monthly suffix' ),
- 'id' => 'price_monthly_suffix',
- 'type' => 'text',
- 'columns' => 3,
- 'visible' => array( 'seperate_pricing', true ),
- ),
- array(
- 'name' => __( 'Price Yearly suffix' ),
- 'id' => 'price_yearly_suffix',
- 'type' => 'text',
- 'columns' => 3,
- 'visible' => array( 'seperate_pricing', true ),
- ),
- array(
- 'name' => __( 'Plan Features' ),
- 'id' => 'plan_features',
- 'type' => 'group',
- 'clone' => true,
- 'sort_clone' => true,
- 'collapsible' => true,
- 'save_state' => true,
- 'group_title' => '{#}. ' . __( 'Feature' ) . ' - {name}',
- 'add_button' => __( 'Add Feature' ),
- 'hidden' => array( 'pricing_type', '=', 'simple' ),
- 'fields' => array(
- array(
- 'name' => __( 'Name' ),
- 'id' => 'name',
- 'type' => 'text',
- 'size' => 80,
- 'required' => true,
- ),
- array(
- 'name' => __( 'Icons' ),
- 'id' => 'icons',
- 'type' => 'image_advanced',
- 'visible' => array( 'pricing_enable_icons', true ),
- ),
- array(
- 'name' => __( 'Sub features' ),
- 'id' => 'sub_features',
- 'type' => 'image_advanced',
- ),
- ),
- ),
- array(
- 'name' => __( 'Plans' ),
- 'id' => 'plans',
- 'type' => 'group',
- 'clone' => true,
- 'sort_clone' => true,
- 'collapsible' => true,
- 'save_state' => true,
- 'group_title' => __( 'Plan' ) . ' - {title}',
- 'add_button' => __( 'Add Plan' ),
- 'fields' => array(
- array(
- 'name' => __( 'Title' ),
- 'id' => 'title',
- 'type' => 'text',
- 'size' => 40,
- ),
- array(
- 'name' => __( 'Price prefix' ),
- 'id' => 'price_prefix',
- 'type' => 'text',
- 'columns' => 3,
- ),
- array(
- 'name' => __( 'Price' ),
- 'id' => 'price',
- 'type' => 'number',
- 'step' => 0.01,
- 'required' => true,
- 'columns' => 3,
- 'hidden' => array( 'seperate_pricing', true ),
- ),
- array(
- 'name' => __( 'Price monthly' ),
- 'id' => 'price_monthly',
- 'type' => 'number',
- 'step' => 0.01,
- 'required' => true,
- 'columns' => 3,
- 'visible' => array( 'seperate_pricing', true ),
- ),
- array(
- 'name' => __( 'Price yearly' ),
- 'id' => 'price_yearly',
- 'type' => 'number',
- 'step' => 0.01,
- 'required' => true,
- 'columns' => 3,
- 'visible' => array( 'seperate_pricing', true ),
- ),
- array(
- 'id' => 'btn',
- 'type' => 'group',
- 'visible' => array( 'pricing_type', '=', 'simple' ),
- 'fields' => array(
- array(
- 'name' => __( 'Label' ),
- 'id' => 'label',
- 'type' => 'text',
- ),
- array(
- 'name' => __( 'URL' ),
- 'id' => 'url',
- 'type' => 'text',
- ),
- ),
- ),
- array(
- 'id' => 'features',
- 'type' => 'group',
- 'clone' => true,
- 'sort_clone' => true,
- 'collapsible' => true,
- 'save_state' => true,
- 'group_title' => '{#}. ' . __( 'Feature' ),
- 'add_button' => __( 'Add Feature' ),
- 'visible' => array( 'pricing_type', '=', 'table' ),
- 'fields' => array(
- array(
- 'name' => __( 'Checked' ),
- 'id' => 'checked',
- 'type' => 'switch',
- 'visible' => array( 'pricing_enable_icons', true ),
- ),
- array(
- 'name' => __( 'Description' ),
- 'id' => 'desc',
- 'type' => 'text',
- 'size' => 60,
- ),
- array(
- 'id' => 'sub_features',
- 'type' => 'group',
- 'clone' => true,
- 'sort_clone' => true,
- 'collapsible' => true,
- 'save_state' => true,
- 'group_title' => __( 'Sub Feature' ),
- 'add_button' => __( 'Add Sub Feature' ),
- 'visible' => array( 'pricing_enable_icons', true ),
- 'fields' => array(
- array(
- 'name' => __( 'Checked' ),
- 'id' => 'checked',
- 'type' => 'switch',
- ),
- ),
- ),
- ),
- ),
- ),
- ),
- array(
- 'id' => 'btn_compare',
- 'type' => 'group',
- 'collapsible' => true,
- 'group_title' => __( 'Compare Link' ),
- 'visible' => array( 'pricing_type', '=', 'simple' ),
- 'fields' => array(
- array(
- 'name' => __( 'Label' ),
- 'id' => 'label',
- 'type' => 'text',
- ),
- array(
- 'name' => __( 'URL' ),
- 'id' => 'url',
- 'type' => 'text',
- ),
- ),
- ),
- ),
- );
- // Section.
- $meta_boxes[] = array(
- 'id' => 'box_product_sections',
- 'title' => __( 'Sections' ),
- 'post_types' => array( 'product' ),
- 'context' => 'after_editor',
- 'priority' => 'high',
- 'style' => 'seamless',
- 'fields' => array(
- array(
- 'id' => 'sections',
- 'type' => 'group',
- 'clone' => true,
- 'sort_clone' => true,
- 'collapsible' => true,
- 'save_state' => true,
- 'group_title' => __( 'Section' ) . ' - {section}',
- 'add_button' => __( 'Add Section' ),
- 'fields' => $fields,
- ),
- ),
- );
- return $meta_boxes;
- }
- add_filter( 'rwmb_meta_boxes', 'my_product_fields' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement