Example #1
0
function metaboxes(array $meta_boxes)
{
    $prefix = '_cmb2_';
    // Start with underscore to hide from custom fields list
    $meta_boxes['headline_metabox'] = array('id' => 'headline_metabox', 'title' => __('Extra Fields', 'cmb2'), 'object_types' => array('headline'), 'context' => 'normal', 'priority' => 'high', 'show_names' => true, 'fields' => array(array('name' => 'Link text', 'id' => $prefix . 'link_text', 'type' => 'text', 'default' => 'Learn More'), array('name' => 'Links to', 'id' => $prefix . 'links_to', 'type' => 'select', 'options' => cmb2_get_post_options(array('post_type' => array('page', 'post'), 'numberposts' => -1, 'post_parent' => 0)))));
    return $meta_boxes;
}
 function strategy_habitat_metabox()
 {
     $prefix = '_strategy_habitat_meta_';
     $strategy_habitat_cmb = new_cmb2_box(array('id' => $prefix . 'strategy_habitat', 'title' => __('Strategy Habitat', 'odfw'), 'object_types' => array('strategy_habitat'), 'context' => 'normal', 'priority' => 'high'));
     $strategy_habitat_cmb->add_field(array('name' => __('Compass Link', 'odfw'), 'id' => $prefix . 'compass-link', 'type' => 'textarea_small', 'desc' => get_compass_instructions()));
     $strategy_habitat_cmb->add_field(array('name' => __('Ecoregions', 'odfw'), 'id' => $prefix . 'ecoregions', 'type' => 'textarea'));
     $strategy_habitat_cmb->add_field(array('name' => __('Characteristics', 'odfw'), 'id' => $prefix . 'characteristics', 'type' => 'wysiwyg'));
     $ecoregional_characteristics_group_field_id = $strategy_habitat_cmb->add_field(array('id' => 'ecoregional_characteristics_repeat_group', 'type' => 'group', 'desc' => __('Ecoregional Characteristics (if applicable)', 'odfw'), 'options' => array('group_title' => __('Ecoregional Characteristic #{#}', 'odfw'), 'add_button' => __('Add Another Ecoregion', 'odfw'), 'remove_button' => __('Remove this Ecoregion', 'odfw'), 'sortable' => true)));
     $strategy_habitat_cmb->add_group_field($ecoregional_characteristics_group_field_id, array('name' => __('Select an Ecoregion', 'odfw'), 'id' => $prefix . 'related_ecoregion', 'type' => 'select', 'show_option_none' => false, 'options' => cmb2_get_post_options(array('post_type' => 'ecoregion', 'numberposts' => 15))));
     $strategy_habitat_cmb->add_group_field($ecoregional_characteristics_group_field_id, array('name' => __('Selected Ecoregion Chracteristics', 'odfw'), 'id' => $prefix . 'selected_ecoregional_characteristics', 'type' => 'textarea'));
     $strategy_habitat_cmb->add_field(array('name' => __('Conservation Overview', 'odfw'), 'id' => $prefix . 'conservation_overview', 'type' => 'wysiwyg'));
     $strategy_habitat_cmb->add_field(array('name' => __('Limiting Factors', 'odfw'), 'id' => $prefix . 'limiting_factors', 'type' => 'wysiwyg'));
     $factor_group_field_id = $strategy_habitat_cmb->add_field(array('id' => 'factors_repeat_group', 'type' => 'group', 'description' => __('Factors and Approaches', 'odfw'), 'options' => array('group_title' => __('Factor {#}', 'odfw'), 'add_button' => __('Add Another Factor/Approach set', 'odfw'), 'remove_button' => __('Remove this factor', 'odfw'), 'sortable' => true)));
     $strategy_habitat_cmb->add_group_field($factor_group_field_id, array('name' => __('Factor Title', 'odfw'), 'id' => $prefix . 'factor_title', 'type' => 'text'));
     $strategy_habitat_cmb->add_group_field($factor_group_field_id, array('name' => __('Factor Description', 'odfw'), 'id' => $prefix . 'factor_description', 'type' => 'textarea'));
     $strategy_habitat_cmb->add_group_field($factor_group_field_id, array('name' => __('Approach', 'odfw'), 'id' => $prefix . 'approach', 'desc' => 'The word "approach" will be output automatically', 'type' => 'textarea'));
     $strategy_habitat_cmb->add_field(array('name' => __('Resources for more information', 'odfw'), 'id' => $prefix . 'resources', 'type' => 'wysiwyg'));
 }