function igv_cmb_metaboxes()
{
    // Start with an underscore to hide fields from custom fields list
    $prefix = '_igv_';
    /**
     * Metaboxes declarations here
     * Reference: https://github.com/WebDevStudios/CMB2/blob/master/example-functions.php
     */
    // RECIPE
    $recipe_metabox = new_cmb2_box(array('id' => 'recipe_metabox', 'title' => __('Recipe Metabox', 'cmb2'), 'object_types' => array('recipe'), 'context' => 'normal', 'priority' => 'high', 'show_names' => true));
    $ingredient_group = $recipe_metabox->add_field(array('id' => $prefix . 'ingredient_group', 'type' => 'group', 'description' => __('Select ingredient from drop-down. Wrap ingredient **name** in text with double asterix to indicate what should be linked to the ingredient\'s archive.', 'cmb2'), 'options' => array('group_title' => __('Ingredient {#}', 'cmb2'), 'add_button' => __('Add Another Ingredient', 'cmb2'), 'remove_button' => __('Remove Ingredient', 'cmb2'), 'sortable' => true)));
    $recipe_metabox->add_group_field($ingredient_group, array('name' => __('Ingredient', 'cmb2'), 'desc' => __('', 'cmb2'), 'id' => 'ingredient', 'type' => 'select', 'show_option_none' => true, 'options' => cmb2_get_term_options('ingredient')));
    $recipe_metabox->add_group_field($ingredient_group, array('name' => __('English', 'cmb2'), 'id' => 'english', 'type' => 'text'));
    $recipe_metabox->add_group_field($ingredient_group, array('name' => __('Español', 'cmb2'), 'id' => 'espanol', 'type' => 'text'));
    // PAGE
    $page_metabox = new_cmb2_box(array('id' => 'page_metabox', 'title' => __('Page Metabox', 'cmb2'), 'object_types' => array('page'), 'context' => 'normal', 'priority' => 'high', 'show_names' => true));
    $page_metabox->add_field(array('name' => __('Sidebar', 'cmb2'), 'desc' => __('optional sidebar content', 'cmb2'), 'id' => $prefix . 'sidebar', 'type' => 'wysiwyg'));
    // EVENT
    $event_metabox = new_cmb2_box(array('id' => 'event_metabox', 'title' => __('Event Metabox', 'cmb2'), 'object_types' => array('events'), 'context' => 'normal', 'priority' => 'high', 'show_names' => true));
    $event_metabox->add_field(array('name' => __('Time & Date', 'cmb2'), 'desc' => __('...', 'cmb2'), 'id' => $prefix . 'date', 'type' => 'text_datetime_timestamp'));
    $event_metabox->add_field(array('name' => __('Location', 'cmb2'), 'desc' => __('(optional)', 'cmb2'), 'id' => $prefix . 'location', 'type' => 'text'));
    $event_metabox->add_field(array('name' => __('Location link', 'cmb2'), 'desc' => __('(optional)', 'cmb2'), 'id' => $prefix . 'location_link', 'type' => 'text_url'));
    $event_metabox->add_field(array('name' => __('Ticket link', 'cmb2'), 'desc' => __('(optional)', 'cmb2'), 'id' => $prefix . 'ticket_link', 'type' => 'text_url'));
    // PRESS
    $press_metabox = new_cmb2_box(array('id' => 'press_metabox', 'title' => __('Press Metabox', 'cmb2'), 'object_types' => array('press'), 'context' => 'normal', 'priority' => 'high', 'show_names' => true));
    $press_metabox->add_field(array('name' => __('External link', 'cmb2'), 'desc' => __('(optional)', 'cmb2'), 'id' => $prefix . 'link', 'type' => 'text'));
    $press_metabox->add_field(array('name' => __('Download PDF/file', 'cmb2'), 'desc' => __('(optional)', 'cmb2'), 'id' => $prefix . 'file', 'type' => 'file'));
    // FRIEND
    $friend_metabox = new_cmb2_box(array('id' => 'friend_metabox', 'title' => __('Contact Details', 'cmb2'), 'object_types' => array('friend'), 'context' => 'normal', 'priority' => 'high', 'show_names' => true));
    $friend_metabox->add_field(array('name' => __('Website link', 'cmb2'), 'desc' => __('(optional)', 'cmb2'), 'id' => $prefix . 'website_link', 'type' => 'text_url'));
    $friend_metabox->add_field(array('name' => __('Email address', 'cmb2'), 'desc' => __('(optional)', 'cmb2'), 'id' => $prefix . 'email', 'type' => 'text'));
    $friend_metabox->add_field(array('name' => __('Phone number', 'cmb2'), 'desc' => __('(optional)', 'cmb2'), 'id' => $prefix . 'phone', 'type' => 'text'));
}
Example #2
0
/**
 * Hook in and add a demo metabox. Can only happen on the 'cmb2_init' hook.
 */
function style_register_demo_metabox()
{
    // Start with an underscore to hide fields from custom fields list
    $prefix = '_style_demo_';
    /**
     * Sample metabox to demonstrate each field type included
     */
    $cmb_demo = new_cmb2_box(array('id' => $prefix . 'metabox', 'title' => __('Test Metabox', 'cmb2'), 'object_types' => array('catalog')));
    $cmb_demo->add_field(array('name' => __('Выберете совместимые материалы'), 'id' => $prefix . 'materials', 'type' => 'multicheck', 'options' => cmb2_get_term_options('materials', array('orderby' => 'term_group', 'hide_empty' => 0)), 'before' => 'prefix_set_field_data_attr'));
}
 function setupSpeciesPageCustomFields()
 {
     $prefix = 'sp_pages_meta_';
     //$species_sub_pages = array(110,111,112, 113, 114, 115, 116);
     $page_cmb = new_cmb2_box(array('id' => $prefix . 'taxo-wrap', 'title' => __('Species Taxonomy Select', 'odfw'), 'object_types' => array('page'), 'show_on' => array('key' => 'id', 'value' => array(110, 111, 112, 113, 114, 115, 116)), 'context' => 'side', 'priority' => 'low'));
     $page_cmb->add_field(array('desc' => 'Select the species taxonomy term this page is associated with', 'id' => $prefix . 'taxonomy', 'type' => 'select', 'options' => cmb2_get_term_options('species')));
 }