function display_cmb_canon_posts($post)
{
    /**************************************
    	GET VALUES
    	***************************************/
    // OPTIONS
    $default_excerpt_len = 300;
    $canon_options_post = get_option('canon_options_post');
    // DEFAULTS
    $cmb_exist = get_post_meta($post->ID, 'cmb_exist', true);
    if (empty($cmb_exist)) {
        update_post_meta($post->ID, 'cmb_quote_is_tweet', 'unchecked');
        update_post_meta($post->ID, 'cmb_single_style', 'full');
        update_post_meta($post->ID, 'cmb_sidebar_id', 'canon_archive_sidebar_widget_area');
        update_post_meta($post->ID, 'cmb_feature', 'image');
        update_post_meta($post->ID, 'cmb_hide_from_archive', 'unchecked');
        update_post_meta($post->ID, 'cmb_hide_from_gallery', 'unchecked');
        update_post_meta($post->ID, 'cmb_hide_from_popular', 'unchecked');
    }
    // GET CUSTOM FIELDS
    $cmb_single_style = get_post_meta($post->ID, 'cmb_single_style', true);
    $cmb_sidebar_id = get_post_meta($post->ID, 'cmb_sidebar_id', true);
    $cmb_feature = get_post_meta($post->ID, 'cmb_feature', true);
    $cmb_media_link = get_post_meta($post->ID, 'cmb_media_link', true);
    $cmb_excerpt = get_post_meta($post->ID, 'cmb_excerpt', true);
    $cmb_quote_is_tweet = get_post_meta($post->ID, 'cmb_quote_is_tweet', true);
    $cmb_byline = get_post_meta($post->ID, 'cmb_byline', true);
    $cmb_multi_intro = get_post_meta($post->ID, 'cmb_multi_intro', true);
    $cmb_hide_from_archive = get_post_meta($post->ID, 'cmb_hide_from_archive', true);
    $cmb_hide_from_gallery = get_post_meta($post->ID, 'cmb_hide_from_gallery', true);
    $cmb_hide_from_popular = get_post_meta($post->ID, 'cmb_hide_from_popular', true);
    $cmb_hide_feat_img = get_post_meta($post->ID, 'cmb_hide_feat_img', true);
    // POST SLIDER
    $cmb_post_show_post_slider = get_post_meta($post->ID, 'cmb_post_show_post_slider', true);
    $cmb_post_slider_source = get_post_meta($post->ID, 'cmb_post_slider_source', true);
    // GET POST ATTACHMENTS
    $args = array('post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'orderby' => 'title', 'order' => 'ASC', 'post_parent' => $post->ID);
    $post_attachments = get_posts($args);
    // GET REGISTERED SIDEBARS ARRAY
    $registered_sidebars_array = array();
    foreach ($GLOBALS['wp_registered_sidebars'] as $key => $value) {
        array_push($registered_sidebars_array, $value);
    }
    /**************************************
    	DISPLAY CONTENT
    	***************************************/
    ?>

	<!-- GENERAL -->

		<div class="option_heading">
			<span><?php 
    _e("General", "loc_sport_core_plugin");
    ?>
</span>
		</div>

		<!-- specific post format options: quote -->
		<div class="options_post_format default_hidden" data-post_format="quote">
			
			<?php 
    fw_cmb_option(array('type' => 'checkbox', 'title' => __('Display quote as a tweet', 'loc_sport_core_plugin'), 'slug' => 'cmb_quote_is_tweet', 'post_id' => $post->ID));
    fw_cmb_option(array('type' => 'text', 'title' => __('Quote byline', 'loc_sport_core_plugin'), 'slug' => 'cmb_byline', 'class' => 'widefat', 'post_id' => $post->ID));
    ?>

		</div>


		<?php 
    fw_cmb_option(array('type' => 'select', 'title' => __('Post style', 'loc_sport_core_plugin'), 'slug' => 'cmb_single_style', 'select_options' => array('full' => __('Featured full width (standard)', 'loc_sport_core_plugin'), 'boxed' => __('Featured boxed', 'loc_sport_core_plugin'), 'compact' => __('Featured compact', 'loc_sport_core_plugin'), 'full_sidebar' => __('Featured full width w. sidebar', 'loc_sport_core_plugin'), 'boxed_sidebar' => __('Featured boxed w. sidebar', 'loc_sport_core_plugin'), 'compact_sidebar' => __('Featured compact w. sidebar', 'loc_sport_core_plugin'), 'multi' => __('Multi post', 'loc_sport_core_plugin')), 'post_id' => $post->ID));
    ?>

		<div class="dynamic_option default_hidden" data-listen_to="#cmb_single_style" data-listen_for="multi">

			<?php 
    fw_cmb_option(array('type' => 'textarea', 'title' => __('Multi post intro', 'loc_sport_core_plugin'), 'slug' => 'cmb_multi_intro', 'cols' => '100', 'rows' => '5', 'class' => 'widefat', 'post_id' => $post->ID));
    ?>

		</div>

		<div class="dynamic_option default_hidden" data-listen_to="#cmb_single_style" data-listen_for="full_sidebar boxed_sidebar compact_sidebar">

			<div class="option_item">
				<label for='cmb_sidebar_id'><?php 
    _e("Select sidebar", "loc_sport_core_plugin");
    ?>
</label><br>
				<select name="cmb_sidebar_id">
					<?php 
    for ($i = 0; $i < count($registered_sidebars_array); $i++) {
        ?>
		     				<option value="<?php 
        echo $registered_sidebars_array[$i]['id'];
        ?>
" <?php 
        if (isset($cmb_sidebar_id)) {
            if ($cmb_sidebar_id == $registered_sidebars_array[$i]['id']) {
                echo "selected='selected'";
            }
        }
        ?>
><?php 
        echo $registered_sidebars_array[$i]['name'];
        ?>
</option> 
						<?php 
    }
    ?>
				</select> 
			</div>

		</div>

		<?php 
    fw_cmb_option(array('type' => 'select', 'title' => __('Feature style', 'loc_sport_core_plugin'), 'slug' => 'cmb_feature', 'select_options' => array('image' => __('Featured image', 'loc_sport_core_plugin'), 'media' => __('Use embeddable media instead of featured image', 'loc_sport_core_plugin'), 'media_in_lightbox' => __('Use featured image but open media link in lightbox', 'loc_sport_core_plugin')), 'post_id' => $post->ID));
    fw_cmb_option(array('type' => 'textarea', 'title' => __('Featured media - <i>(optional)</i>', 'loc_sport_core_plugin'), 'slug' => 'cmb_media_link', 'cols' => '100', 'rows' => '5', 'class' => 'widefat', 'post_id' => $post->ID));
    ?>


		<div class="option_item">
			<label for='cmb_excerpt'><?php 
    _e("Excerpt / Quote", "loc_sport_core_plugin");
    ?>
</label><br>
			<textarea id='cmb_excerpt' name='cmb_excerpt' class='widefat' rows='5'><?php 
    if (!empty($cmb_excerpt)) {
        echo $cmb_excerpt;
    }
    ?>
</textarea>
			<button type="button" name="button_generate_excerpt" id='button_generate_excerpt' class="button-secondary auto_generate" value="<?php 
    echo mb_make_excerpt($post->post_content, $default_excerpt_len, true);
    ?>
">Auto-generate</button>
			<span class="item_hint float_right"><?php 
    _e("HTML allowed", "loc_sport_core_plugin");
    ?>
</span>
		</div>

		<?php 
    fw_cmb_option(array('type' => 'checkbox_multiple', 'title' => __('Display quote as a tweet', 'loc_sport_core_plugin'), 'slug' => 'cmb_quote_is_tweet', 'checkboxes' => array('cmb_hide_from_archive' => __('Hide from blog', 'loc_sport_core_plugin'), 'cmb_hide_from_gallery' => __('Hide from gallery', 'loc_sport_core_plugin'), 'cmb_hide_from_popular' => __('Hide from popular lists', 'loc_sport_core_plugin')), 'post_id' => $post->ID));
    ?>

		<?php 
    if (has_post_thumbnail($post->ID)) {
        ?>
				<div class="option_item">
					<input type="hidden" name="cmb_hide_feat_img" value="unchecked" />
					<input type='checkbox' id='cmb_hide_feat_img' name='cmb_hide_feat_img' value='checked' <?php 
        checked($cmb_hide_feat_img == "checked");
        ?>
>
					<label for='cmb_hide_feat_img'><?php 
        _e("Hide featured image in post", "loc_sport_core_plugin");
        ?>
</label>
				</div>
					
			<?php 
    }
    ?>
	

		<!-- 
		--------------------------------------------------------------------------
			POST SLIDER
	    -------------------------------------------------------------------------- 
		-->

		<div class="option_heading">
			<span><?php 
    _e("Post Slider", "loc_sport_core_plugin");
    ?>
</span>
		</div>

		<div class="option_item">
			<input type="hidden" name="cmb_post_show_post_slider" value="unchecked" />
			<input type='checkbox' id='cmb_post_show_post_slider' name='cmb_post_show_post_slider' value='checked' <?php 
    checked($cmb_post_show_post_slider == "checked");
    ?>
>
			<label for='cmb_post_show_post_slider'><?php 
    _e("Show post slider", "loc_sport_core_plugin");
    ?>
</label><br>
		</div>

		<div class="dynamic_option default-hidden" data-listen_to="#cmb_post_show_post_slider" data-listen_for="checked">

			<ul class="wp_galleries_source_hints">
				<li><?php 
    _e("The post slider will replace the featured image at the top of the post.", "loc_sport_core_plugin");
    ?>
</li>
				<li><?php 
    _e("Add WordPress galleries using the Add Media button. You can add as many WordPress galleries as you would like.", "loc_sport_core_plugin");
    ?>
</li>
				<li><?php 
    _e("The images from these WordPress galleries will be used in the post slider.", "loc_sport_core_plugin");
    ?>
</li>
				<li><?php 
    _e("The images will appear in the same order as they appear in the galleries. Duplicate images will be removed.", "loc_sport_core_plugin");
    ?>
</li>
			</ul>

			<?php 
    wp_editor($cmb_post_slider_source, 'cmb_post_slider_source', array('textarea_name' => 'cmb_post_slider_source', 'teeny' => true, 'media_buttons' => true, 'tinymce' => true, 'quicktags' => true, 'textarea_rows' => 20, 'editor_class' => 'post_slider_source'));
    ?>

		</div>




		<!-- add nonce -->
		<input type="hidden" name="cmb_nonce" value="<?php 
    echo wp_create_nonce(basename(__FILE__));
    ?>
" />
		<input type="hidden" name="cmb_exist" value="true" />






		<?php 
}
function display_cmb_canon_pages($post)
{
    /**************************************
    	GET VALUES
    	***************************************/
    //to be or not to be
    $cmb_exist = get_post_meta($post->ID, 'cmb_exist', true);
    //defaults
    if (empty($cmb_exist)) {
        update_post_meta($post->ID, 'cmb_page_sidebar_id', 'canon_page_sidebar_widget_area');
        update_post_meta($post->ID, 'cmb_gallery_style', 'isotope');
        update_post_meta($post->ID, 'cmb_gallery_num_columns', 3);
        update_post_meta($post->ID, 'cmb_portfolio_click', 'lightbox');
        update_post_meta($post->ID, 'cmb_portfolio_num_columns', 3);
        update_post_meta($post->ID, 'cmb_pages_contact', array('use_embeddable_media' => 'checked', 'grayscale' => 'checked', 'embed_code' => '<iframe width="100%" height="550" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://maps.google.com.au/maps?f=q&source=s_q&hl=en&geocode=&q=San+Diego,+CA,+United+States&aq=0&oq=san+die&sll=-25.335448,135.745076&sspn=83.735932,130.605469&ie=UTF8&hq=&hnear=San+Diego,+California,+United+States&ll=32.715329,-117.157255&spn=0.164801,0.255089&t=m&z=13&output=embed"></iframe>'));
        update_post_meta($post->ID, 'cmb_timeline_order', 'DESC');
        update_post_meta($post->ID, 'cmb_timeline_link_through', 'checked');
        update_post_meta($post->ID, 'cmb_timeline_display_content', 'unchecked');
        update_post_meta($post->ID, 'cmb_timeline_posts_per_page', 10);
        update_post_meta($post->ID, 'cmb_pages_template_attachment', 'none');
        update_post_meta($post->ID, 'cmb_hide_page_title', 'unchecked');
    }
    //page with sidebar specific
    $cmb_page_sidebar_id = get_post_meta($post->ID, 'cmb_page_sidebar_id', true);
    //gallery specific
    $cmb_gallery_style = get_post_meta($post->ID, 'cmb_gallery_style', true);
    $cmb_gallery_num_columns = get_post_meta($post->ID, 'cmb_gallery_num_columns', true);
    $cmb_gallery_source = get_post_meta($post->ID, 'cmb_gallery_source', true);
    //portfolio specific
    $cmb_portfolio_click = get_post_meta($post->ID, 'cmb_portfolio_click', true);
    $cmb_portfolio_num_columns = get_post_meta($post->ID, 'cmb_portfolio_num_columns', true);
    $cmb_portfolio_cat = get_post_meta($post->ID, 'cmb_portfolio_cat', true);
    //blog specific
    $cmb_pages_blog_style = get_post_meta($post->ID, 'cmb_pages_blog_style', true);
    //contact specific
    $cmb_pages_contact = get_post_meta($post->ID, 'cmb_pages_contact', true);
    //timeline specific
    $cmb_timeline_cat = get_post_meta($post->ID, 'cmb_timeline_cat', true);
    $cmb_timeline_order = get_post_meta($post->ID, 'cmb_timeline_order', true);
    $cmb_timeline_link_through = get_post_meta($post->ID, 'cmb_timeline_link_through', true);
    $cmb_timeline_display_content = get_post_meta($post->ID, 'cmb_timeline_display_content', true);
    $cmb_timeline_posts_per_page = get_post_meta($post->ID, 'cmb_timeline_posts_per_page', true);
    //pagebuilder specific
    $cmb_pages_template_attachment = get_post_meta($post->ID, 'cmb_pages_template_attachment', true);
    $cmb_template_id = get_post_meta($post->ID, 'cmb_template_id', true);
    //get pagebuilder templates
    $results_templates = get_posts(array('numberposts' => -1, 'post_type' => 'pb_template', 'orderby' => 'post_title', 'order' => 'ASC'));
    //cmb elements
    $cmb_hide_page_title = get_post_meta($post->ID, 'cmb_hide_page_title', true);
    //make sure (empty) arrays are defined as arrays
    if (empty($cmb_pages_contact)) {
        $cmb_pages_contact = array();
    }
    /**************************************
    	DISPLAY CONTENT
    
    			TEMPLATE SPECIFIC: DEFAULT EMPTY
    			TEMPLATE SPECIFIC: PAGE WITH SIDEBAR 
    			TEMPLATE SPECIFIC: GALLERY 
    			TEMPLATE SPECIFIC: PORTFOLIO 
    			TEMPLATE SPECIFIC: BLOG 
    			TEMPLATE SPECIFIC: CONTACT
    			TEMPLATE SPECIFIC: TIMELINE
    			CMB ELEMENT: PAGEBUILDER ATTACHMENT
    			CMB ELEMENT: PAGEBUILDER TEMPLATE ID
    			CMB ELEMENT: HIDE PAGE TITLE
    
    	***************************************/
    ?>


		<!-- 
		--------------------------------------------------------------------------
			TEMPLATE SPECIFIC: DEFAULT EMPTY
	    -------------------------------------------------------------------------- 
		-->


		<div class="option_item default_hidden option_template_specific 
						option_page-galleries						

		">
			<i><?php 
    _e("No additional page settings available for this template type.", "loc_sport_core_plugin");
    ?>
</i>
		</div>

		<!-- 
		--------------------------------------------------------------------------
			TEMPLATE SPECIFIC: PAGE WITH SIDEBAR 
	    -------------------------------------------------------------------------- 
		-->

		<div class=" default_hidden option_template_specific option_page option_default">

			<?php 
    // get array of registered sidebars
    $registered_sidebars_array = array();
    foreach ($GLOBALS['wp_registered_sidebars'] as $key => $value) {
        array_push($registered_sidebars_array, $value);
    }
    ?>

			<div class="option_item">
				<label for='cmb_page_sidebar_id'><?php 
    _e("Select sidebar", "loc_sport_core_plugin");
    ?>
</label><br>
				<select name="cmb_page_sidebar_id">
					<?php 
    for ($i = 0; $i < count($registered_sidebars_array); $i++) {
        ?>
		     				<option value="<?php 
        echo $registered_sidebars_array[$i]['id'];
        ?>
" <?php 
        if (isset($cmb_page_sidebar_id)) {
            if ($cmb_page_sidebar_id == $registered_sidebars_array[$i]['id']) {
                echo "selected='selected'";
            }
        }
        ?>
><?php 
        echo $registered_sidebars_array[$i]['name'];
        ?>
</option> 
						<?php 
    }
    ?>
				</select> 
			</div>

		</div>

		<!-- 
		--------------------------------------------------------------------------
			TEMPLATE SPECIFIC: GALLERY 
	    -------------------------------------------------------------------------- 
		-->

		<div class=" default_hidden option_template_specific option_page-gallery">

			<div class="option_heading">
				<span><?php 
    _e("Gallery Settings", "loc_sport_core_plugin");
    ?>
</span>
			</div>

			<?php 
    fw_cmb_option(array('type' => 'select', 'title' => __('Gallery Style', 'loc_sport_core_plugin'), 'slug' => 'cmb_gallery_style', 'select_options' => array('slider' => __('Gallery Slider', 'loc_sport_core_plugin'), 'isotope' => __('Gallery Isotope', 'loc_sport_core_plugin'), 'singles' => __('Gallery Singles', 'loc_sport_core_plugin'), 'masonry' => __('Gallery Masonry', 'loc_sport_core_plugin')), 'post_id' => $post->ID));
    fw_cmb_option(array('type' => 'number', 'title' => __('Number of columns', 'loc_sport_core_plugin'), 'slug' => 'cmb_gallery_num_columns', 'min' => '1', 'max' => '5', 'step' => '1', 'width_px' => '60', 'post_id' => $post->ID));
    ?>

			<div class="option_item">

				<ul class="wp_galleries_source_hints">
					<li><?php 
    _e("Add WordPress galleries using the Add Media button. You can add as many WordPress galleries as you would like.", "loc_cph");
    ?>
</li>
					<li><?php 
    _e("You can add a caption to each image when creating your WordPress gallery.", "loc_cph");
    ?>
</li>
					<li><?php 
    _e("The images and captions from these WordPress galleries will be used in the gallery.", "loc_cph");
    ?>
</li>
					<li><?php 
    _e("The images will appear in the same order as they appear in the galleries. Duplicate images will be removed.", "loc_cph");
    ?>
</li>
					<li><?php 
    _e('You can use the Text editor to rearrange the WordPress gallery shortcodes', "loc_cph");
    ?>
</li>
					<li><?php 
    _e('You can use the Text editor to add a category attribute to the shortcodes e.g. [gallery ids="1,2,3" category="My Category"]', "loc_cph");
    ?>
</li>
				</ul>

				<?php 
    wp_editor($cmb_gallery_source, 'cmb_gallery_source', array('textarea_name' => 'cmb_gallery_source', 'teeny' => true, 'media_buttons' => true, 'tinymce' => true, 'quicktags' => true, 'textarea_rows' => 30, 'editor_class' => 'gallery_source'));
    ?>

			</div>


		</div>

		<!-- 
		--------------------------------------------------------------------------
			TEMPLATE SPECIFIC: PORTFOLIO 
	    -------------------------------------------------------------------------- 
		-->

		<div class=" default_hidden option_template_specific option_page-portfolio">

			<div class="option_heading">
				<span><?php 
    _e("Portfolio Settings", "loc_trades_core_plugin");
    ?>
</span>
			</div>

			<?php 
    fw_cmb_option(array('type' => 'select', 'title' => __('Clicking image', 'loc_trades_core_plugin'), 'slug' => 'cmb_portfolio_click', 'select_options' => array('lightbox' => __('Opens lightbox', 'loc_trades_core_plugin'), 'post' => __('Opens post', 'loc_trades_core_plugin')), 'post_id' => $post->ID));
    fw_cmb_option(array('type' => 'number', 'title' => __('Number of columns', 'loc_sport_core_plugin'), 'slug' => 'cmb_portfolio_num_columns', 'min' => '1', 'max' => '5', 'step' => '1', 'width_px' => '60', 'post_id' => $post->ID));
    ?>


			<div class="option_item">

				<label for='cmb_portfolio_cat'><?php 
    _e("Project categories to be displayed in portfolio", "loc_trades_core_plugin");
    ?>
</label><br>

     			<?php 
    $categories = get_categories(array('orderby' => 'name', 'order' => 'ASC', 'taxonomy' => 'project_category'));
    $categories = array_values($categories);
    if (empty($categories)) {
        echo "<i>No Project categories found.</i>";
    }
    for ($i = 0; $i < count($categories); $i++) {
        ?>
						<input type="checkbox" id="cmb_portfolio_cat[<?php 
        echo $categories[$i]->slug;
        ?>
]" name="cmb_portfolio_cat[<?php 
        echo $categories[$i]->slug;
        ?>
]" class="checkbox" value="checked" <?php 
        checked(isset($cmb_portfolio_cat[$categories[$i]->slug]));
        ?>
/> 
						<?php 
        echo $categories[$i]->name;
        ?>
<br>
					<?php 
    }
    ?>


			</div>


		</div>


		<!-- 
		--------------------------------------------------------------------------
			TEMPLATE SPECIFIC: BLOG 
	    -------------------------------------------------------------------------- 
		-->

		<div class=" default_hidden option_template_specific option_page-blog">

			<div class="option_heading">
				<span><?php 
    _e("Blog Settings", "loc_sport_core_plugin");
    ?>
</span>
			</div>

			<?php 
    fw_cmb_option(array('type' => 'select', 'title' => __('Blog Style', 'loc_sport_core_plugin'), 'slug' => 'cmb_pages_blog_style', 'select_options' => array('default' => __('Site default', 'loc_sport_core_plugin'), 'full' => __('Blog full width', 'loc_sport_core_plugin'), 'sidebar' => __('Blog with sidebar', 'loc_sport_core_plugin')), 'post_id' => $post->ID));
    ?>


		</div>



		<!-- 
		--------------------------------------------------------------------------
			TEMPLATE SPECIFIC: CONTACT
	    -------------------------------------------------------------------------- 
		-->

		<div class=" default_hidden option_template_specific option_page-contact">

			<!-- CONTACT -->
			<div class="option_heading togglable">
				<span><?php 
    _e("Contact", "loc_sport_core_plugin");
    ?>
</span>
			</div>

			<div class="option_content_container">

				<?php 
    fw_cmb_option(array('type' => 'checkbox', 'title' => __('Use embeddable media instead of featured image', 'loc_sport_core_plugin'), 'slug' => 'cmb_pages_contact[use_embeddable_media]', 'post_id' => $post->ID));
    fw_cmb_option(array('type' => 'checkbox', 'title' => __('Grayscale media <i>(if available)</i>', 'loc_sport_core_plugin'), 'slug' => 'cmb_pages_contact[grayscale]', 'post_id' => $post->ID));
    fw_cmb_option(array('type' => 'text', 'title' => __('Embed code', 'loc_sport_core_plugin'), 'slug' => 'cmb_pages_contact[embed_code]', 'class' => 'widefat', 'post_id' => $post->ID));
    ?>

			</div>

		</div>


		<!-- 
		--------------------------------------------------------------------------
			TEMPLATE SPECIFIC: TIMELINE
	    -------------------------------------------------------------------------- 
		-->

		<div class=" default_hidden option_template_specific option_page-timeline">

			<!-- CONTACT -->
			<div class="option_heading togglable">
				<span><?php 
    _e("Timeline", "loc_sport_core_plugin");
    ?>
</span>
			</div>

			<div class="option_content_container">

     			<?php 
    $categories = get_categories(array('orderby' => 'name', 'order' => 'ASC'));
    $categories = array_values($categories);
    ?>

				<div class="option_item">
					<label for='cmb_timeline_cat'><?php 
    _e("Timeline displays", "loc_sport_core_plugin");
    ?>
</label><br>
					<select id="cmb_timeline_cat" name="cmb_timeline_cat"> 
			 			<option value="" <?php 
    if (isset($cmb_timeline_cat)) {
        if ($cmb_timeline_cat == "") {
            echo "selected='selected'";
        }
    }
    ?>
><?php 
    _e("All categories", "loc_sport_core_plugin");
    ?>
</option> 

		     			<?php 
    foreach ($categories as $single_category) {
        ?>
		     					<option value="<?php 
        echo $single_category->slug;
        ?>
" <?php 
        if (isset($cmb_timeline_cat)) {
            if ($cmb_timeline_cat == $single_category->slug) {
                echo "selected='selected'";
            }
        }
        ?>
><?php 
        echo $single_category->name;
        ?>
 <?php 
        _e("category", "loc_sport_core_plugin");
        ?>
</option> 
		     				<?php 
    }
    ?>

					</select> 
				</div>

				<?php 
    fw_cmb_option(array('type' => 'select', 'title' => __('Chronology', 'loc_sport_core_plugin'), 'slug' => 'cmb_timeline_order', 'select_options' => array('DESC' => __('Descending', 'loc_sport_core_plugin'), 'ASC' => __('Ascending', 'loc_sport_core_plugin')), 'post_id' => $post->ID));
    fw_cmb_option(array('type' => 'checkbox', 'title' => __('Link through to posts', 'loc_sport_core_plugin'), 'slug' => 'cmb_timeline_link_through', 'post_id' => $post->ID));
    fw_cmb_option(array('type' => 'checkbox', 'title' => __('Display content instead of excerpts', 'loc_sport_core_plugin'), 'slug' => 'cmb_timeline_display_content', 'post_id' => $post->ID));
    fw_cmb_option(array('type' => 'number', 'title' => __('Posts per page', 'loc_sport_core_plugin'), 'slug' => 'cmb_timeline_posts_per_page', 'min' => '1', 'max' => '10000', 'step' => '1', 'width_px' => '60', 'post_id' => $post->ID));
    ?>

			</div>

		</div>


		<!-- 
		--------------------------------------------------------------------------
			CMB ELEMENT: PAGEBUILDER ATTACHMENT
	    -------------------------------------------------------------------------- 
		-->

		<div class=" default_hidden option_template_specific option_page-blog">

			<div class="option_content_container">

				<div class="option_heading">
					<span><?php 
    _e("Pagebuilder Settings", "loc_sport_core_plugin");
    ?>
</span>
				</div>

				<?php 
    fw_cmb_option(array('type' => 'select', 'title' => __('Pagebuilder Attachment', 'loc_sport_core_plugin'), 'slug' => 'cmb_pages_template_attachment', 'select_options' => array('none' => __('Do not attach', 'loc_sport_core_plugin'), 'prepend' => __('Prepend', 'loc_sport_core_plugin'), 'append' => __('Append', 'loc_sport_core_plugin')), 'post_id' => $post->ID));
    ?>

			</div>

		</div>


		<!-- 
		--------------------------------------------------------------------------
			CMB ELEMENT: PAGEBUILDER TEMPLATE ID
	    -------------------------------------------------------------------------- 
		-->

		<div class=" default_hidden option_template_specific option_page-pagebuilder option_page-placeholder option_page-blog">

			<div class="option_content_container">

				<div class="option_item">
					<label for='cmb_template_id'><?php 
    _e("Pagebuilder Template", "loc_sport_core_plugin");
    ?>
</label><br>
					<select id="cmb_template_id" name="cmb_template_id"> 
		     			<option value="" <?php 
    if (isset($cmb_template_id)) {
        if ($cmb_template_id == "") {
            echo "selected='selected'";
        }
    }
    ?>
>No template</option> 
		     			<option value="">---</option> 
		     			<?php 
    for ($i = 0; $i < count($results_templates); $i++) {
        ?>
  
				     			<option value="<?php 
        echo $results_templates[$i]->ID;
        ?>
" <?php 
        if (isset($cmb_template_id)) {
            if ($cmb_template_id == $results_templates[$i]->ID) {
                echo "selected='selected'";
            }
        }
        ?>
><?php 
        if (empty($results_templates[$i]->post_title)) {
            echo '&#060; untitled template &#062;';
        } else {
            echo $results_templates[$i]->post_title;
        }
        ?>
</option> 
		     				<?php 
    }
    ?>
					</select> 
				</div>

			</div>

		</div>

		<!-- 
		--------------------------------------------------------------------------
			CMB ELEMENT: HIDE PAGE TITLE
	    -------------------------------------------------------------------------- 
		-->

		<div class=" default_hidden option_template_specific option_page option_default option_page-full-width">

			<div class="option_content_container">

				<?php 
    fw_cmb_option(array('type' => 'checkbox', 'title' => __('Hide page title', 'loc_sport_core_plugin'), 'slug' => 'cmb_hide_page_title', 'post_id' => $post->ID));
    ?>

			</div>

		</div>





		<!-- add nonce -->
		<input type="hidden" name="cmb_nonce" value="<?php 
    echo wp_create_nonce(basename(__FILE__));
    ?>
" />
		<input type="hidden" name="cmb_exist" value="true" />
		<?php 
}
function display_cmb_cpt_project($post)
{
    /**************************************
    	GET VALUES
    	***************************************/
    // OPTIONS
    $default_excerpt_len = 300;
    $canon_options_post = get_option('canon_options_post');
    //SET DEFAULT
    if (!isset($canon_options_post['post_slider'])) {
        $canon_options_post['post_slider'] = "automatic";
    }
    // GENERAL
    $cmb_feature = get_post_meta($post->ID, 'cmb_feature', true);
    $cmb_media_link = get_post_meta($post->ID, 'cmb_media_link', true);
    $cmb_excerpt = get_post_meta($post->ID, 'cmb_excerpt', true);
    $cmb_portfolio_client_name = get_post_meta($post->ID, 'cmb_portfolio_client_name', true);
    $cmb_portfolio_client_url = get_post_meta($post->ID, 'cmb_portfolio_client_url', true);
    $cmb_hide_feat_img = get_post_meta($post->ID, 'cmb_hide_feat_img', true);
    // POST SLIDER
    $cmb_post_show_post_slider = get_post_meta($post->ID, 'cmb_post_show_post_slider', true);
    $cmb_post_slider_source = get_post_meta($post->ID, 'cmb_post_slider_source', true);
    $cmb_exist = get_post_meta($post->ID, 'cmb_exist', true);
    //GET POST ATTACHMENTS
    $args = array('post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'orderby' => 'title', 'order' => 'ASC', 'post_parent' => $post->ID);
    $post_attachments = get_posts($args);
    //defaults
    if (empty($cmb_exist)) {
        update_post_meta($post->ID, 'cmb_feature', 'image');
    }
    /**************************************
    	DISPLAY CONTENT
    	***************************************/
    ?>

	<!-- GENERAL -->

		<div class="option_heading">
			<span><?php 
    _e("General", "loc_sport_core_plugin");
    ?>
</span>
		</div>

		<?php 
    fw_cmb_option(array('type' => 'select', 'title' => __('Feature style', 'loc_sport_core_plugin'), 'slug' => 'cmb_feature', 'select_options' => array('image' => __('Featured image', 'loc_sport_core_plugin'), 'media' => __('Use embeddable media instead of featured image', 'loc_sport_core_plugin'), 'media_in_lightbox' => __('Use featured image but open media link in lightbox', 'loc_sport_core_plugin')), 'post_id' => $post->ID));
    fw_cmb_option(array('type' => 'text', 'title' => __('Featured media - <i>(optional)</i>', 'loc_sport_core_plugin'), 'slug' => 'cmb_media_link', 'class' => 'widefat', 'post_id' => $post->ID));
    ?>


		<div class="option_item">
			<label for='cmb_excerpt'><?php 
    _e("Excerpt", "loc_sport_core_plugin");
    ?>
</label><br>
			<textarea id='cmb_excerpt' name='cmb_excerpt' class='widefat' rows='5'><?php 
    if (!empty($cmb_excerpt)) {
        echo $cmb_excerpt;
    }
    ?>
</textarea>
			<button type="button" name="button_generate_excerpt" id='button_generate_excerpt' class="button-secondary auto_generate" value="<?php 
    echo mb_make_excerpt($post->post_content, $default_excerpt_len, true);
    ?>
">Auto-generate</button>
			<span class="item_hint float_right"><?php 
    _e("HTML allowed", "loc_sport_core_plugin");
    ?>
</span>
		</div>


		<?php 
    fw_cmb_option(array('type' => 'text', 'title' => __('Client name', 'loc_trades_core_plugin'), 'slug' => 'cmb_portfolio_client_name', 'class' => 'widefat', 'post_id' => $post->ID));
    fw_cmb_option(array('type' => 'text', 'title' => __('Client URL', 'loc_trades_core_plugin'), 'slug' => 'cmb_portfolio_client_url', 'class' => 'widefat', 'post_id' => $post->ID));
    ?>

		<?php 
    if (has_post_thumbnail($post->ID)) {
        ?>
				<div class="option_item">
					<input type="hidden" name="cmb_hide_feat_img" value="unchecked" />
					<input type='checkbox' id='cmb_hide_feat_img' name='cmb_hide_feat_img' value='checked' <?php 
        checked($cmb_hide_feat_img == "checked");
        ?>
>
					<label for='cmb_hide_feat_img'><?php 
        _e("Hide featured image in post", "loc_sport_core_plugin");
        ?>
</label>
				</div>
					
			<?php 
    }
    ?>
	

		<!-- 
		--------------------------------------------------------------------------
			POST SLIDER
	    -------------------------------------------------------------------------- 
		-->

		<div class="option_heading">
			<span><?php 
    _e("Project Slider", "loc_sport_core_plugin");
    ?>
</span>
		</div>

		<div class="option_item">
			<input type="hidden" name="cmb_post_show_post_slider" value="unchecked" />
			<input type='checkbox' id='cmb_post_show_post_slider' name='cmb_post_show_post_slider' value='checked' <?php 
    checked($cmb_post_show_post_slider == "checked");
    ?>
>
			<label for='cmb_post_show_post_slider'><?php 
    _e("Show project slider", "loc_sport_core_plugin");
    ?>
</label><br>
		</div>

		<div class="dynamic_option default-hidden" data-listen_to="#cmb_post_show_post_slider" data-listen_for="checked">

			<ul class="wp_galleries_source_hints">
				<li><?php 
    _e("The project slider will replace the featured image at the top of the post.", "loc_sport_core_plugin");
    ?>
</li>
				<li><?php 
    _e("Add WordPress galleries using the Add Media button. You can add as many WordPress galleries as you would like.", "loc_sport_core_plugin");
    ?>
</li>
				<li><?php 
    _e("The images from these WordPress galleries will be used in the project slider.", "loc_sport_core_plugin");
    ?>
</li>
				<li><?php 
    _e("The images will appear in the same order as they appear in the galleries. Duplicate images will be removed.", "loc_sport_core_plugin");
    ?>
</li>
			</ul>

			<?php 
    wp_editor($cmb_post_slider_source, 'cmb_post_slider_source', array('textarea_name' => 'cmb_post_slider_source', 'teeny' => true, 'media_buttons' => true, 'tinymce' => true, 'quicktags' => true, 'textarea_rows' => 20, 'editor_class' => 'post_slider_source'));
    ?>

		</div>






		<!-- add nonce -->
		<input type="hidden" name="cmb_nonce" value="<?php 
    echo wp_create_nonce(basename(__FILE__));
    ?>
" />
		<input type="hidden" name="cmb_exist" value="true" />






		<?php 
}
function display_cmb_canon_cpt_people($post)
{
    /**************************************
    	GET VALUES
    	***************************************/
    // OPTIONS
    $default_excerpt_len = 80;
    $cmb_title = get_post_meta($post->ID, 'cmb_title', true);
    $cmb_info = get_post_meta($post->ID, 'cmb_info', true);
    $cmb_excerpt = get_post_meta($post->ID, 'cmb_excerpt', true);
    $cmb_excerpt_is_quote = get_post_meta($post->ID, 'cmb_excerpt_is_quote', true);
    $cmb_index = get_post_meta($post->ID, 'cmb_index', true);
    $cmb_show_social_links = get_post_meta($post->ID, 'cmb_show_social_links', true);
    $cmb_social_links = get_post_meta($post->ID, 'cmb_social_links', true);
    $cmb_exist = get_post_meta($post->ID, 'cmb_exist', true);
    //make sure (empty) arrays are defined as arrays
    if (empty($cmb_social_links)) {
        $cmb_social_links = array();
    }
    //defaults
    if (empty($cmb_exist)) {
        update_post_meta($post->ID, 'cmb_excerpt_is_quote', 'unchecked');
        update_post_meta($post->ID, 'cmb_show_social_links', 'checked');
        update_post_meta($post->ID, 'cmb_index', 1000);
    }
    /**************************************
    	DISPLAY CONTENT
    	***************************************/
    ?>

	<!-- DETAILS -->

		<div class="option_heading">
			<span><?php 
    _e("Details", "loc_sport_core_plugin");
    ?>
</span>
		</div>

		<?php 
    fw_cmb_option(array('type' => 'text', 'title' => __('Title / position', 'loc_sport_core_plugin'), 'slug' => 'cmb_title', 'class' => 'widefat', 'post_id' => $post->ID));
    fw_cmb_option(array('type' => 'textarea', 'title' => __('Info', 'loc_sport_core_plugin'), 'slug' => 'cmb_info', 'rows' => '5', 'hint' => __('Optional. HTML allowed.', 'loc_sport_core_plugin'), 'class' => 'widefat', 'post_id' => $post->ID));
    ?>

		<div class="option_item">
			<label for='cmb_excerpt'><?php 
    _e("Excerpt / Quote", "loc_sport_core_plugin");
    ?>
</label><br>
			<textarea id='cmb_excerpt' name='cmb_excerpt' class='widefat' rows='5'><?php 
    if (!empty($cmb_excerpt)) {
        echo $cmb_excerpt;
    }
    ?>
</textarea>
			<button type="button" name="button_generate_excerpt" id='button_generate_excerpt' class="button-secondary auto_generate" value="<?php 
    echo mb_make_excerpt($post->post_content, $default_excerpt_len, true);
    ?>
">Auto-generate</button>
			<span class="item_hint float_right"><?php 
    _e("Optional. HTML allowed", "loc_sport_core_plugin");
    ?>
</span>
		</div>

		<?php 
    fw_cmb_option(array('type' => 'checkbox', 'title' => __('Display excerpt as quote', 'loc_sport_core_plugin'), 'slug' => 'cmb_excerpt_is_quote', 'post_id' => $post->ID));
    fw_cmb_option(array('type' => 'number', 'title' => __('Position index <span class="item_hint">(determines order of appearance)</span>', 'loc_sport_core_plugin'), 'slug' => 'cmb_index', 'min' => '1', 'max' => '100000', 'step' => '1', 'width_px' => '60', 'post_id' => $post->ID));
    ?>
		



	<!-- SOCIAL LINKS -->

		<div class="option_heading">
			<span>Social Links</span>
		</div>

		<div class="option_item">
		
			<input type="hidden" name="cmb_show_social_links" value="unchecked" />
			<input type='checkbox' name='cmb_show_social_links' value='checked' <?php 
    checked($cmb_show_social_links == "checked");
    ?>
>
			<label for='cmb_show_social_links'><?php 
    _e("Show social links:", "loc_sport_core_plugin");
    ?>
</label>

			<table class='form-table cmb_social_links'>
				<?php 
    $font_awesome_array = mb_get_font_awesome_icon_names_in_array();
    $social_links_num = !empty($cmb_social_links) ? count($cmb_social_links) : 1;
    for ($i = 0; $i < $social_links_num; $i++) {
        ?>

					<tr valign='top' class='cmb_social_links_row'>
						<th scope='row'>Social link <?php 
        echo $i + 1;
        ?>
</th>
						<td>
							<select class="cmb_social_links_icon fa_select" name='cmb_social_links[<?php 
        echo $i;
        ?>
][icon]'> 
								<?php 
        for ($n = 0; $n < count($font_awesome_array); $n++) {
            ?>
				     					<option value="<?php 
            echo $font_awesome_array[$n];
            ?>
" <?php 
            if (isset($cmb_social_links[$i]['icon'])) {
                if ($cmb_social_links[$i]['icon'] == $font_awesome_array[$n]) {
                    echo "selected='selected'";
                }
            }
            ?>
><?php 
            echo $font_awesome_array[$n];
            ?>
</option> 
									<?php 
        }
        ?>
							</select> 

							<i class="fa <?php 
        if (isset($cmb_social_links[$i]['icon'])) {
            echo $cmb_social_links[$i]['icon'];
        } else {
            echo "fa-flag";
        }
        ?>
"></i>

							<input type='text' class='cmb_social_links_link' name='cmb_social_links[<?php 
        echo $i;
        ?>
][link]' value='<?php 
        if (isset($cmb_social_links[$i]['link'])) {
            echo $cmb_social_links[$i]['link'];
        }
        ?>
'>
						</td>
					</tr>

					<?php 
    }
    ?>
			</table>

			<table class='form-table cmb_social_links_control'>
				<tr valign='top'>
					<th scope='row'></th>
					<td>
						<input type="button" class="button cmb_button_add_social_link" value="Add social link" />
						<input type="button" class="button cmb_button_remove_social_link" value="Remove social link" />
					</td>
				</tr>

			</table>
		</div>


		<!-- add nonce -->
		<input type="hidden" name="cmb_nonce" value="<?php 
    echo wp_create_nonce(basename(__FILE__));
    ?>
" />
		<input type="hidden" name="cmb_exist" value="true" />
		<?php 
}