function mbdb_book_grid_meta_boxes()
{
    $mbdb_book_grid_metabox = new_cmb2_box(array('id' => 'mbdb_book_grid_metabox', 'title' => __('Book Grid Settings', 'mooberry-book-manager'), 'object_types' => array('page'), 'context' => 'normal', 'priority' => 'default', 'show_names' => true));
    $mbdb_book_grid_metabox->add_field(array('name' => __('Display Books on This Page?', 'mooberry-book-manager'), 'id' => '_mbdb_book_grid_display', 'type' => 'select', 'default' => 'no', 'options' => array('yes' => __('Yes', 'mooberry-book-manager'), 'no' => __('No', 'mooberry-book-manager'))));
    $mbdb_book_grid_metabox->add_field(array('name' => __('Books to Display', 'mooberry-book-manager'), 'id' => '_mbdb_book_grid_books', 'type' => 'select', 'options' => mbdb_book_grid_selection_options()));
    $mbdb_book_grid_metabox->add_field(array('name' => __('Select Books', 'mooberry-book-manager'), 'id' => '_mbdb_book_grid_custom', 'type' => 'multicheck', 'options' => mbdb_get_book_array()));
    $mbdb_book_grid_metabox->add_field(array('name' => __('Select Genres', 'mooberry-book-manager'), 'id' => '_mbdb_book_grid_genre', 'type' => 'multicheck', 'options' => mbdb_get_term_options('mbdb_genre')));
    $mbdb_book_grid_metabox->add_field(array('name' => __('Select Series', 'mooberry-book-manager'), 'id' => '_mbdb_book_grid_series', 'type' => 'multicheck', 'options' => mbdb_get_term_options('mbdb_series')));
    $mbdb_book_grid_metabox->add_field(array('name' => __('Select Tags', 'mooberry-book-manager'), 'id' => '_mbdb_book_grid_tag', 'type' => 'multicheck', 'options' => mbdb_get_term_options('mbdb_tag')));
    $mbdb_book_grid_metabox->add_field(array('name' => __('Select Publishers', 'mooberry-book-manager'), 'id' => '_mbdb_book_grid_publisher', 'type' => 'multicheck', 'options' => mbdb_get_publishers('no')));
    $mbdb_book_grid_metabox->add_field(array('name' => __('Select Editors', 'mooberry-book-manager'), 'id' => '_mbdb_book_grid_editor', 'type' => 'multicheck', 'options' => mbdb_get_term_options('mbdb_editor')));
    $mbdb_book_grid_metabox->add_field(array('name' => __('Select Illustrators', 'mooberry-book-manager'), 'id' => '_mbdb_book_grid_illustrator', 'type' => 'multicheck', 'options' => mbdb_get_term_options('mbdb_illustrator')));
    $mbdb_book_grid_metabox->add_field(array('name' => __('Select Cover Artists', 'mooberry-book-manager'), 'id' => '_mbdb_book_grid_cover_artist', 'type' => 'multicheck', 'options' => mbdb_get_term_options('mbdb_cover_artist')));
    $group_by_options = mbdb_book_grid_group_by_options();
    $count = count($group_by_options);
    for ($x = 1; $x < $count; $x++) {
        $mbdb_book_grid_metabox->add_field(array('name' => __('Group Books By', 'mooberry-book-manager'), 'id' => '_mbdb_book_grid_group_by_level_' . $x, 'type' => 'select', 'options' => $group_by_options));
        // put a warning at the 5th level
        if ($x == 5) {
            $mbdb_book_grid_metabox->add_field(array('name' => __('Warning: Setting more than 5 levels could cause the page to timeout and not display.', 'mooberry-book-manager'), 'type' => 'title', 'id' => '_mbdb_book_grid_warning', 'attributes' => array('display' => 'none')));
        }
    }
    $mbdb_book_grid_metabox->add_field(array('name' => __('Order By', 'mooberry-book-manager'), 'id' => '_mbdb_book_grid_order', 'type' => 'select', 'options' => mbdb_book_grid_order_options()));
    $mbdb_book_grid_metabox->add_field(array('name' => __('Use default cover height?', 'mooberry-book-manager'), 'id' => '_mbdb_book_grid_cover_height_default', 'type' => 'select', 'default' => 'yes', 'options' => array('yes' => __('Yes', 'mooberry-book-manager'), 'no' => __('No', 'mooberry-book-manager'))));
    $mbdb_book_grid_metabox->add_field(array('name' => __('Book Cover Height (px)', 'mooberry-book-manager'), 'id' => '_mbdb_book_grid_cover_height', 'type' => 'text_small', 'attributes' => array('type' => 'number', 'pattern' => '\\d*', 'min' => 50)));
    $mbdb_book_grid_metabox->add_field(array('name' => __('Additional Content (bottom)', 'mooberry-book-manager'), 'id' => '_mbdb_book_grid_description_bottom', 'type' => 'wysiwyg', 'description' => __('This displays under the book grid.', 'mooberry-book-manager'), 'options' => array('wpautop' => true, 'media_buttons' => true, 'textarea_rows' => 10, 'tabindex' => '', 'editor_css' => '', 'editor_class' => '', 'teeny' => false, 'dfw' => false, 'tinymce' => true, 'quicktags' => true)));
    $mbdb_book_grid_metabox = apply_filters('mbdb_book_grid_meta_boxes', $mbdb_book_grid_metabox);
}
function mbdb_book_metaboxes()
{
    $mbdb_options = get_option('mbdb_options');
    // SUMMARY
    $mbdb_summary_metabox = new_cmb2_box(array('id' => 'mbdb_summary_metabox', 'title' => __('Summary', 'mooberry-book-manager'), 'object_types' => array('mbdb_book'), 'context' => 'normal', 'priority' => 'high', 'show_names' => false));
    $mbdb_summary_metabox->add_field(array('name' => __('Summary', 'mooberry-book-manager'), 'id' => '_mbdb_summary', 'type' => 'wysiwyg', 'options' => array('wpautop' => true, 'media_buttons' => true, 'textarea_rows' => 10, 'tabindex' => '', 'editor_css' => '', 'editor_class' => '', 'teeny' => false, 'dfw' => false, 'tinymce' => true, 'quicktags' => true)));
    // EXCERPT
    $mbdb_excerpt_metabox = new_cmb2_box(array('id' => 'mbdb_excerpt_metabox', 'title' => __('Excerpt', 'mooberry-book-manager'), 'object_types' => array('mbdb_book'), 'context' => 'normal', 'priority' => 'high', 'show_names' => false));
    $mbdb_excerpt_metabox->add_field(array('name' => __('Excerpt', 'mooberry-book-manager'), 'id' => '_mbdb_excerpt', 'type' => 'wysiwyg', 'options' => array('wpautop' => true, 'media_buttons' => true, 'textarea_rows' => 15, 'tabindex' => '', 'editor_css' => '', 'editor_class' => '', 'teeny' => false, 'dfw' => false, 'tinymce' => true, 'quicktags' => true)));
    // REVIEWS
    $mbdb_reviews_metabox = new_cmb2_box(array('id' => 'mbdb_reviews_metabox', 'title' => _x('Reviews', 'noun: book reviews', 'mooberry-book-manager'), 'object_types' => array('mbdb_book'), 'context' => 'normal', 'priority' => 'high', 'show_names' => true));
    $mbdb_reviews_metabox->add_field(array('id' => '_mbdb_reviews', 'type' => 'group', 'description' => __('Add reviews of your book', 'mooberry-book-manager'), 'options' => array('group_title' => _x('Reviews', 'noun', 'mooberry-book-manager') . ' {#}', 'add_button' => __('Add Review', 'mooberry-book-manager'), 'remove_button' => __('Remove Review', 'mooberry-book-manager'), 'sortable' => true)));
    $mbdb_reviews_metabox->add_group_field('_mbdb_reviews', array('name' => __('Reviewer Name', 'mooberry-book-manager'), 'id' => 'mbdb_reviewer_name', 'type' => 'text_medium', 'sanitization_cb' => 'mbdb_validate_reviews'));
    $mbdb_reviews_metabox->add_group_field('_mbdb_reviews', array('name' => _x('Review Link', 'noun: URL to book review', 'mooberry-book-manager'), 'id' => 'mbdb_review_url', 'type' => 'text_url', 'desc' => 'http://www.someWebsite.com/', 'attributes' => array('pattern' => '^(https?:\\/\\/)?([\\da-zA-Z\\.-]+)\\.([a-zA-Z\\.]{2,6}).*')));
    $mbdb_reviews_metabox->add_group_field('_mbdb_reviews', array('name' => _x('Review Website Name', 'noun: name of website of book review', 'mooberry-book-manager'), 'id' => 'mbdb_review_website', 'type' => 'text_medium'));
    $mbdb_reviews_metabox->add_group_field('_mbdb_reviews', array('name' => _x('Review', 'noun: book review', 'mooberry-book-manager'), 'id' => 'mbdb_review', 'type' => 'textarea'));
    // EDITIONS
    $mbdb_editions_metabox = new_cmb2_box(array('id' => 'mbdb_editions_metabox', 'title' => __('Formats and Editions', 'mooberry-book-manager'), 'object_types' => array('mbdb_book'), 'context' => 'normal', 'priority' => 'high', 'show_names' => true));
    $mbdb_editions_metabox->add_field(array('id' => '_mbdb_editions', 'type' => 'group', 'description' => __("List the details of your book's hardcover, paperback, and e-book editions. Everything is optional except the format.", 'mooberry-book-manager'), 'options' => array('group_title' => __('Edition', 'mooberry-book-manager') . ' {#}', 'add_button' => __('Add New Edition', 'mooberry-book-manager'), 'remove_button' => __('Remove Edition', 'mooberry-book-manager'), 'sortable' => true)));
    $mbdb_editions_metabox->add_group_field('_mbdb_editions', array('name' => _x('Format', 'noun: format of a book', 'mooberry-book-manager'), 'id' => '_mbdb_format', 'type' => 'select', 'sanitization_cb' => 'mbdb_validate_editions', 'options' => mbdb_get_editions(), 'description' => __('Add more formats in Settings', 'mooberry-book-manager')));
    $mbdb_editions_metabox->add_group_field('_mbdb_editions', array('name' => __('EAN/ISBN', 'mooberry-book-manager'), 'id' => '_mbdb_isbn', 'type' => 'text_medium'));
    $mbdb_editions_metabox->add_group_field('_mbdb_editions', array('name' => __('Language', 'mooberry-book-manager'), 'id' => '_mbdb_language', 'type' => 'select', 'options' => mbdb_get_language_array(), 'default' => mbdb_get_default_language($mbdb_options)));
    $mbdb_editions_metabox->add_group_field('_mbdb_editions', array('name' => __('Number of Pages', 'mooberry-book-manager'), 'id' => '_mbdb_length', 'type' => 'text_small', 'attributes' => array('type' => 'number', 'pattern' => '\\d*', 'min' => 1)));
    $mbdb_editions_metabox->add_group_field('_mbdb_editions', array('name' => __('Height', 'mooberry-book-manager'), 'id' => '_mbdb_height', 'type' => 'text_small', 'attributes' => array('type' => 'number', 'step' => 'any', 'min' => 0)));
    $mbdb_editions_metabox->add_group_field('_mbdb_editions', array('name' => __('Width', 'mooberry-book-manager'), 'id' => '_mbdb_width', 'type' => 'text_small', 'attributes' => array('type' => 'number', 'step' => 'any', 'min' => 0)));
    $mbdb_editions_metabox->add_group_field('_mbdb_editions', array('name' => _x('Unit', 'units of measurement', 'mooberry-book-manager'), 'id' => '_mbdb_unit', 'type' => 'select', 'options' => mbdb_get_units_array(), 'default' => mbdb_get_default_unit($mbdb_options)));
    $mbdb_editions_metabox->add_group_field('_mbdb_editions', array('name' => __('Suggested Retail Price', 'mooberry-book-manager'), 'id' => '_mbdb_retail_price', 'type' => 'text_small', 'attributes' => array('pattern' => '^\\d*([.,]\\d{2}$)?', 'min' => 0)));
    $mbdb_editions_metabox->add_group_field('_mbdb_editions', array('name' => __('Currency', 'mooberry-book-manager'), 'id' => '_mbdb_currency', 'type' => 'select', 'options' => mbdb_get_currency_array(), 'default' => mbdb_get_default_currency($mbdb_options)));
    $mbdb_editions_metabox->add_group_field('_mbdb_editions', array('name' => __('Edition Title', 'mooberry-book-manager'), 'id' => '_mbdb_edition_title', 'type' => 'text_medium', 'desc' => __('First Edition, Second Edition, etc.', 'mooberry-book-mananger')));
    // ADDITIONAL INFORMATION
    $mbdb_additional_info_metabox = new_cmb2_box(array('id' => 'mbdb_additional_info_metabox', 'title' => __('Additional Information', 'mooberry-book-manager'), 'object_types' => array('mbdb_book'), 'context' => 'normal', 'priority' => 'high', 'show_names' => false));
    $mbdb_additional_info_metabox->add_field(array('name' => __('Additional Information', 'mooberry-book-manager'), 'id' => '_mbdb_additional_info', 'type' => 'wysiwyg', 'description' => __('Any additional information you want to display on the page. Will be shown at the bottom of the page, after the reviews.', 'mooberry-book-manager'), 'options' => array('wpautop' => true, 'media_buttons' => true, 'textarea_rows' => 15, 'tabindex' => '', 'editor_css' => '', 'editor_class' => '', 'teeny' => false, 'dfw' => false, 'tinymce' => true, 'quicktags' => true)));
    // COVER
    $mbdb_cover_image_metabox = new_cmb2_box(array('id' => 'mbdb_cover_image_metabox', 'title' => _x('Cover', 'noun', 'mooberry-book-manager'), 'object_types' => array('mbdb_book'), 'context' => 'side', 'priority' => 'default', 'show_names' => false, 'allow' => array('attachment')));
    $mbdb_cover_image_metabox->add_field(array('name' => _x('Book Cover', 'noun', 'mooberry-book-manager'), 'id' => '_mbdb_cover', 'type' => 'file', 'allow' => array('attachment')));
    // BOOK INFO
    $mbdb_bookinfo_metabox = new_cmb2_box(array('id' => 'mbdb_bookinfo_metabox', 'title' => __('Book Details', 'mooberry-book-manager'), 'object_types' => array('mbdb_book'), 'context' => 'side', 'priority' => 'default', 'show_names' => true));
    $mbdb_bookinfo_metabox->add_field(array('name' => __('Subtitle', 'mooberry-book-manager'), 'id' => '_mbdb_subtitle', 'type' => 'text_small'));
    $mbdb_bookinfo_metabox->add_field(array('name' => __('Release Date', 'mooberry-book-manager'), 'id' => '_mbdb_published', 'type' => 'text_date', 'desc' => 'yyyy/mm/dd', 'date_format' => 'Y/m/d', 'sanitization_cb' => 'mbdb_format_date'));
    $mbdb_bookinfo_metabox->add_field(array('name' => __('Publisher', 'mooberry-book-manager'), 'id' => '_mbdb_publisherID', 'type' => 'select', 'options' => mbdb_get_publishers(), 'desc' => __('Set up Publishers in Settings.', 'mooberry-book-manager')));
    $mbdb_bookinfo_metabox->add_field(array('name' => __('Goodreads Link', 'mooberry-book-manager'), 'id' => '_mbdb_goodreads', 'type' => 'text_url', 'desc' => 'http://www.goodreads.com/your/Unique/Text/', 'attributes' => array('pattern' => '^(https?:\\/\\/)?www.goodreads.com.*')));
    $mbdb_bookinfo_metabox->add_field(array('name' => __('Series Order', 'mooberry-book-manager'), 'id' => '_mbdb_series_order', 'desc' => __('(leave blank if not part of a series)', 'mooberry-book-manager'), 'type' => 'text_small', 'attributes' => array('type' => 'number', 'step' => 'any', 'min' => 0)));
    // BUYLINKS
    $mbdb_buylinks_metabox = new_cmb2_box(array('id' => 'mbdb_buylinks_metabox', 'title' => _x('Retailer Links', 'noun: URLs to book retailers', 'mooberry-book-manager'), 'object_types' => array('mbdb_book'), 'context' => 'side', 'priority' => 'default', 'show_names' => true));
    $mbdb_buylinks_metabox->add_field(array('id' => '_mbdb_buylinks', 'type' => 'group', 'description' => __('Add links where readers can purchase your book', 'mooberry-book-manager'), 'options' => array('group_title' => _x('Retailer Link', 'noun', 'mooberry-book-manager') . ' {#}', 'add_button' => __('Add Retailer Link', 'mooberry-book-manager'), 'remove_button' => __('Remove Retailer Link', 'mooberry-book-manager'), 'sortable' => true)));
    $mbdb_buylinks_metabox->add_group_field('_mbdb_buylinks', array('name' => __('Retailer', 'mooberry-book-manager'), 'id' => '_mbdb_retailerID', 'type' => 'select', 'options' => mbdb_get_retailers(), 'sanitization_cb' => 'mbdb_validate_retailers', 'description' => __('Add more retailers in Settings', 'mooberry-book-manager')));
    $mbdb_buylinks_metabox->add_group_field('_mbdb_buylinks', array('name' => _x('Link', 'noun: URL', 'mooberry-book-manager'), 'id' => '_mbdb_buylink', 'type' => 'text_url', 'desc' => 'http://www.someWebsite.com/', 'attributes' => array('pattern' => mbdb_url_validation_pattern())));
    // DOWNLOAD LINKS
    $mbdb_downloadlinks_metabox = new_cmb2_box(array('id' => 'mbdb_downloadlinks_metabox', 'title' => _x('Download Links', 'noun', 'mooberry-book-manager'), 'object_types' => array('mbdb_book'), 'context' => 'side', 'priority' => 'low', 'show_names' => true));
    $mbdb_downloadlinks_metabox->add_field(array('id' => '_mbdb_downloadlinks', 'type' => 'group', 'description' => __('If your book is available to download for free, add the links for each format.', 'mooberry-book-manager'), 'options' => array('group_title' => _x('Download Link', 'noun', 'mooberry-book-manager') . ' {#}', 'add_button' => __('Add Download Link', 'mooberry-book-manager'), 'remove_button' => __('Remove Download Link', 'mooberry-book-manager'), 'sortable' => true)));
    $mbdb_downloadlinks_metabox->add_group_field('_mbdb_downloadlinks', array('name' => _x('Format', 'noun', 'mooberry-book-manager'), 'id' => '_mbdb_formatID', 'type' => 'select', 'options' => mbdb_get_formats(), 'sanitization_cb' => 'mbdb_validate_downloadlinks', 'description' => __('Add more formats in Settings', 'mooberry-book-manager')));
    $mbdb_downloadlinks_metabox->add_group_field('_mbdb_downloadlinks', array('name' => _x('Link', 'noun', 'mooberry-book-manager'), 'id' => '_mbdb_downloadlink', 'type' => 'text_url', 'attributes' => array('pattern' => mbdb_url_validation_pattern())));
    $mbdb_summary_metabox = apply_filters('mbdb_summary_metabox', $mbdb_summary_metabox);
    $mbdb_editions_metabox = apply_filters('mbdb_editions_metabox', $mbdb_editions_metabox);
    $mbdb_excerpt_metabox = apply_filters('mbdb_excerpt_metabox', $mbdb_excerpt_metabox);
    $mbdb_reviews_metabox = apply_filters('mbdb_reviews_metabox', $mbdb_reviews_metabox);
    $mbdb_additional_info_metabox = apply_filters('mbdb_additional_info_metabox', $mbdb_additional_info_metabox);
    $mbdb_cover_image_metabox = apply_filters('mbdb_cover_image_metabox', $mbdb_cover_image_metabox);
    $mbdb_bookinfo_metabox = apply_filters('mbdb_bookinfo_metabox', $mbdb_bookinfo_metabox);
    $mbdb_buylinks_metabox = apply_filters('mbdb_buylinks_metabox', $mbdb_buylinks_metabox);
    $mbdb_downloadlinks_metabox = apply_filters('mbdb_downloadlinks_metabox', $mbdb_downloadlinks_metabox);
}