function block_tribe_event_output($params)
{
    extract($params);
    $default_excerpt_length = 650;
    if (!isset($event_ID) || empty($event_ID)) {
        return;
    }
    $event = get_post($event_ID);
    // if block has event ID but the actual event does not exist then exit
    if (!isset($event)) {
        return;
    }
    // BLOCK CLASSES
    $block_classes = "outter-wrapper";
    if (!empty($custom_classes)) {
        $block_classes .= " " . $custom_classes;
    }
    ?>

		<!-- BLOCK: LATEST POSTS-->

	        <!-- start outter-wrapper -->   
	        <div <?php 
    pb_block_id_class($block_classes, $params);
    ?>
>
	            
	            <!-- block styles -->
	            <style type="text/css" scoped>
					<?php 
    include 'includes/inc_block_output_style.php';
    ?>
	            </style>
	            
	            <!-- start main-container -->
	            <div class="main-container">
	                <!-- start main wrapper -->
	                <div class="main wrapper clearfix">
	                    <!-- start main-content -->
	                    <div class="main-content">

	                    	<!-- Start Post --> 
	                    	<div class="clearfix tribe-events-tcblock">

								<!-- Event Cost -->
								<div class="tribe-events-event-cost">
									<span><?php 
    echo tribe_get_formatted_cost($event_ID);
    ?>
</span>
								</div>

								<!-- Event Title -->
								<h2 class="tribe-events-list-event-title summary">
									<?php 
    printf('<a class="url" href="%s" title="%s" rel="bookmark">%s</a>', esc_url(tribe_get_event_link($event_ID)), esc_attr(get_the_title($event_ID)), esc_attr(get_the_title($event_ID)));
    ?>
								</h2>
								
								<!-- Event Image -->
								<div class="tribe-events-event-image">
									<?php 
    if (has_post_thumbnail($event_ID) && get_post(get_post_thumbnail_id($event_ID))) {
        $post_thumbnail_src = wp_get_attachment_image_src(get_post_thumbnail_id($event_ID), 'full');
        printf('<a href="%s" title="%s"><img src="%s" title="%s"/></a>', esc_url(tribe_get_event_link($event_ID)), esc_attr(get_the_title($event_ID)), esc_url($post_thumbnail_src[0]), esc_attr(get_the_title($event_ID)));
    }
    ?>

								</div>
								
																
								<!-- Event Meta -->
								<div class="tribe-events-event-meta  vcard location">

									<!-- Schedule & Recurrence Details -->
									<div class="updated published time-details">
										<?php 
    printf('<span class="date-start dtstart">%s</span>', esc_attr(tribe_get_start_date($event_ID)));
    ?>
									</div>

									<!-- Venue Display Info -->
									<div class="tribe-events-venue-details">

										<span class="author fn org"><?php 
    echo tribe_get_venue($event_ID);
    ?>
</span>, 

										<address class="tribe-events-address">
											<span class="adr">
												<span class="street-address"><?php 
    echo tribe_get_address($event_ID);
    ?>
</span>
												<span class="delimiter">,</span>  
												<span class="locality"><?php 
    echo tribe_get_city($event_ID);
    ?>
</span>
												<span class="delimiter">,</span>  
												<span class="postal-code"><?php 
    echo tribe_get_zip($event_ID);
    ?>
</span> 
												<span class="country-name"><?php 
    echo tribe_get_country($event_ID);
    ?>
</span>
											</span>
										</address>

										<?php 
    printf('<a class="tribe-events-gmap" href="%s" title="Click to view a Google Map" target="_blank">- Google Map</a>', esc_url(tribe_get_map_link($event_ID)));
    ?>
	
									</div> <!-- .tribe-events-venue-details -->

								</div><!-- .tribe-events-event-meta -->

								
								
								<!-- Event Content -->
								<div class="tribe-events-list-event-description tribe-events-content description entry-summary">

									
									<?php 
    $event_excerpt = !empty($event->post_excerpt) ? do_shortcode($event->post_excerpt) : mb_make_excerpt($event->post_content, $default_excerpt_length, true);
    // excerpt
    echo "<p>";
    echo $event_excerpt;
    echo "</p>";
    // read more
    printf('<a href="%s" class="tribe-events-read-more" rel="bookmark">%s &raquo;</a>', esc_url(tribe_get_event_link($event_ID)), esc_attr(__('Find out more', "loc_sport_core_plugin")));
    ?>


									
								</div><!-- .tribe-events-list-event-description -->
	                         
	                        </div>


	                    </div>
	                    <!-- end main-content -->
	                </div>
	                <!-- end main wrapper -->
	            </div>
	             <!-- end main-container -->
	        </div>
	        <!-- end outter-wrapper -->
	        
		<!-- END BLOCK -->
		
		<?php 
    return true;
}
function display_cmb_cpt_project_settings($post)
{
    /**************************************
    	GET VALUES
    	***************************************/
    // OPTIONS
    $default_somevariable = 90;
    // DETAILS
    $cmb_project_client = get_post_meta($post->ID, 'cmb_project_client', true);
    $cmb_project_date = get_post_meta($post->ID, 'cmb_project_date', true);
    $cmb_project_url = get_post_meta($post->ID, 'cmb_project_url', true);
    // SLIDER
    $cmb_slider_feature = get_post_meta($post->ID, 'cmb_slider_feature', true);
    $cmb_slider_use_cap_header = get_post_meta($post->ID, 'cmb_slider_use_cap_header', true);
    $cmb_slider_cap_header = get_post_meta($post->ID, 'cmb_slider_cap_header', true);
    $cmb_slider_use_cap_text = get_post_meta($post->ID, 'cmb_slider_use_cap_text', true);
    $cmb_slider_cap_text = get_post_meta($post->ID, 'cmb_slider_cap_text', true);
    $cmb_slider_use_media = get_post_meta($post->ID, 'cmb_slider_use_media', true);
    $cmb_slider_media = get_post_meta($post->ID, 'cmb_slider_media', true);
    $cmb_exist = get_post_meta($post->ID, 'cmb_exist', true);
    //defaults
    if (empty($cmb_exist)) {
        $cmb_comp_feat_img = "checked";
        $cmb_comp_title = "checked";
        $cmb_comp_excerpt = "checked";
        $cmb_comp_meta = "checked";
        $cmb_excerpt = mb_make_excerpt($post->post_content, $default_excerpt_len, true);
        $cmb_slider_use_cap_header = "checked";
        $cmb_slider_cap_header = $post->post_title;
        $cmb_slider_use_cap_text = "checked";
        $cmb_slider_cap_text = mb_make_excerpt($post->post_content, $default_cap_text_len, true);
    }
    /**************************************
    	DISPLAY CONTENT
    	***************************************/
    ?>

	<!-- DETAILS -->

		<div class="option_heading">
			<span>Details</span>
		</div>

		<div class="option_item">
			<label for='cmb_project_client'><?php 
    _e("Client", "loc_sport_core_plugin");
    ?>
</label><br>
			<input type='text' id='cmb_project_client' name='cmb_project_client' class='widefat' value='<?php 
    if (!empty($cmb_project_client)) {
        echo htmlspecialchars($cmb_project_client);
    }
    ?>
'>
		</div>

		<div class="option_item">
			<label for='cmb_project_date'>Project date</label><br>
			<input type='text' id='cmb_project_date' name='cmb_project_date' class='widefat' value='<?php 
    if (!empty($cmb_project_date)) {
        echo $cmb_project_date;
    }
    ?>
'>
		</div>

		<div class="option_item">
			<label for='cmb_project_url'>Project URL</label><br>
			<input type='text' id='cmb_project_url' name='cmb_project_url' class='widefat' value='<?php 
    if (!empty($cmb_project_url)) {
        echo $cmb_project_url;
    }
    ?>
'>
		</div>

		<div class="option_item">
			<label for='cmb_project_excerpt'>Excerpt</label><br>
			<textarea id='cmb_project_excerpt' name='cmb_project_excerpt' class='widefat'><?php 
    if (!empty($cmb_project_excerpt)) {
        echo $cmb_project_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>
		</div>

	<!-- SLIDER -->

		<div class="option_heading">
			<span>Slider</span>
		</div>

		<div class="option_item">
			<input type='checkbox' id='cmb_slider_feature' name='cmb_slider_feature' value='checked' <?php 
    checked(!empty($cmb_slider_feature));
    ?>
>
			<label for='cmb_slider_feature'>Feature this post in slider</label>
		</div>

		<div id="popup_cmb_slider_options">

			<div class="option_item">
				<input type='checkbox' id='cmb_slider_use_cap_header' name='cmb_slider_use_cap_header' value='checked' <?php 
    checked(!empty($cmb_slider_use_cap_header));
    ?>
>
				<label for='cmb_slider_use_cap_header'>Use caption header</label>
				<input type='text' id='cmb_slider_cap_header' name='cmb_slider_cap_header' class='widefat' value='<?php 
    if (!empty($cmb_slider_cap_header)) {
        echo $cmb_slider_cap_header;
    }
    ?>
'>
				<button type="button" name="button_generate_header" id='button_generate_header' class="button-secondary auto_generate" value="<?php 
    echo $post->post_title;
    ?>
">Auto-generate</button>
			</div>

			<div class="option_item">
				<input type='checkbox' id='cmb_slider_use_cap_text' name='cmb_slider_use_cap_text' value='checked' <?php 
    checked(!empty($cmb_slider_use_cap_text));
    ?>
>
				<label for='cmb_slider_use_cap_text'>Use caption text</label>
				<textarea id='cmb_slider_cap_text' name='cmb_slider_cap_text' class='widefat'><?php 
    if (!empty($cmb_slider_cap_text)) {
        echo $cmb_slider_cap_text;
    }
    ?>
</textarea>
				<button type="button" name="button_generate_text" id='button_generate_text' class="button-secondary auto_generate" value="<?php 
    echo mb_make_excerpt($post->post_content, $default_cap_text_len, true);
    ?>
">Auto-generate</button>
			</div>

			<div class="option_item">
				<input type='checkbox' id='cmb_slider_use_media' name='cmb_slider_use_media' value='checked' <?php 
    checked(!empty($cmb_slider_use_media));
    ?>
>
				<label for='cmb_slider_use_media'>Use media in slider</label>
				<input type='text' id='cmb_slider_media' name='cmb_slider_media' class='widefat' value='<?php 
    if (!empty($cmb_slider_media)) {
        echo $cmb_slider_media;
    }
    ?>
'>
				<span class="item_hint">(Use media instead of featured image in slider. Remember to adjust sizes. Works best with width: 100% and height: 420px. NB: increases load times.</span>
			</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_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 block_people_output($params)
{
    extract($params);
    //	VARS
    $default_excerpt_length = 80;
    //	SET CLASSES
    $base_class = "boxed";
    $size_class = " " . mb_get_size_class_from_num($num_columns, "fourth");
    //	GET PEOPLE
    $query_args = array();
    $query_args = array('post_type' => 'cpt_people', 'posts_per_page' => -1, 'post_status' => 'publish', 'tax_query' => array(array('taxonomy' => 'people_category', 'field' => 'slug', 'terms' => $show)), 'suppress_filters' => false);
    // DETERMINE ORDER
    if ($orderby == "alphabetical_asc") {
        $query_args = array_merge($query_args, array('orderby' => 'title', 'order' => 'ASC'));
    } elseif ($orderby == "alphabetical_desc") {
        $query_args = array_merge($query_args, array('orderby' => 'title', 'order' => 'DESC'));
    } elseif ($orderby == "date_asc") {
        $query_args = array_merge($query_args, array('orderby' => 'date', 'order' => 'ASC'));
    } elseif ($orderby == "date_desc") {
        $query_args = array_merge($query_args, array('orderby' => 'date', 'order' => 'DESC'));
    } elseif ($orderby == "index_asc") {
        $query_args = array_merge($query_args, array('meta_key' => 'cmb_index', 'orderby' => 'meta_value_num', 'order' => 'ASC'));
    } elseif ($orderby == "index_desc") {
        $query_args = array_merge($query_args, array('meta_key' => 'cmb_index', 'orderby' => 'meta_value_num', 'order' => 'DESC'));
    } else {
        $query_args = array_merge($query_args, array('orderby' => 'rand'));
    }
    //	FINAL QUERY
    $results_people = get_posts($query_args);
    // UPDATE NUM PEOPLE
    if (count($results_people) < $num_people) {
        $num_people = count($results_people);
    }
    // BLOCK CLASSES
    $block_classes = "outter-wrapper";
    if (!empty($custom_classes)) {
        $block_classes .= " " . $custom_classes;
    }
    ?>

		<!-- BLOCK: PEOPLE-->

	        <!-- start outter-wrapper -->   
	        <div <?php 
    pb_block_id_class($block_classes, $params);
    ?>
>
	            
	            <!-- block styles -->
	            <style type="text/css" scoped>
					<?php 
    include 'includes/inc_block_output_style.php';
    ?>
	            </style>
	            
	            <!-- start main-container -->
	            <div class="main-container">
	                <!-- start main wrapper -->
	                <div class="main wrapper clearfix">
	                    <!-- start main-content -->
	                    <div class="main-content">

    	                	<?php 
    if (!empty($title)) {
        printf('<h1>%s</h1>', esc_attr($title));
    }
    ?>
    	                	<?php 
    if (!empty($text)) {
        printf('<p class="lead">%s</p>', do_shortcode($text));
    }
    ?>


	                    		<?php 
    for ($i = 0; $i < $num_people; $i++) {
        $last_class = ($i + 1) % $num_columns ? "" : " last";
        $final_class = $base_class . $size_class . $last_class;
        $this_person = $results_people[$i];
        // get custom fields
        $cmb_title = get_post_meta($this_person->ID, 'cmb_title', true);
        $cmb_excerpt = get_post_meta($this_person->ID, 'cmb_excerpt', true);
        $cmb_excerpt_is_quote = get_post_meta($this_person->ID, 'cmb_excerpt_is_quote', true);
        $cmb_show_social_links = get_post_meta($this_person->ID, 'cmb_show_social_links', true);
        $cmb_social_links = get_post_meta($this_person->ID, 'cmb_social_links', true);
        // get featured image
        $post_thumbnail_src = wp_get_attachment_image_src(get_post_thumbnail_id($this_person->ID), 'full');
        $img_alt = get_post_meta(get_post_thumbnail_id($this_person->ID), '_wp_attachment_image_alt', true);
        // var_dump($this_person);
        ?>

	                    			<?php 
        if ($i === 0 || $i % $num_columns === 0) {
            echo '<div class="clearfix">';
        }
        ?>

		    	                		<div class="<?php 
        echo $final_class;
        ?>
 personColumn">


		    	                			<!-- image -->
		    	                			<?php 
        if ($post_thumbnail_src) {
            if ($link_through == "checked") {
                printf('<a href="%s"><img src="%s" alt="%s" /></a>', esc_url(get_permalink($this_person->ID)), esc_url($post_thumbnail_src[0]), esc_attr($img_alt));
            } else {
                printf('<img src="%s" alt="%s" />', esc_url($post_thumbnail_src[0]), esc_attr($img_alt));
            }
        }
        ?>

		    	                			<div class="inner-box">

		    	                				<div class="person_info<?php 
        if ($even_height == "checked") {
            echo " even-height";
        }
        ?>
" data-even_height_group="inner-box-<?php 
        echo $block_index;
        ?>
">

			    	                				<!-- name -->
			    	                				<?php 
        if ($link_through == "checked") {
            printf('<h4><a href="%s">%s</a></h4>', esc_url(get_permalink($this_person->ID)), esc_attr($this_person->post_title));
        } else {
            printf('<h4>%s</h4>', esc_attr($this_person->post_title));
        }
        ?>

			    	                				<h5><?php 
        echo $cmb_title;
        ?>
</h5>
			    	                				<em class="<?php 
        if ($cmb_excerpt_is_quote == 'checked') {
            echo "quote";
        }
        ?>
"><?php 
        if (empty($cmb_excerpt)) {
            echo mb_make_excerpt($this_person->post_content, $default_excerpt_length, true);
        } else {
            echo do_shortcode($cmb_excerpt);
        }
        ?>
</em>

		    	                				</div>
		    	                				

                                            <?php 
        if ($cmb_show_social_links == "checked") {
            echo '<ul class="social-link">';
            for ($n = 0; $n < count($cmb_social_links); $n++) {
                ?>
                                                        <li><a href="<?php 
                echo $cmb_social_links[$n]['link'];
                ?>
" target="_blank"><em class="fa <?php 
                echo $cmb_social_links[$n]['icon'];
                ?>
"></em></a></li>
                                                    <?php 
            }
            echo '</ul>';
        }
        ?>

		    	                			</div>
		    	                		</div>
	                    				
	                    			<?php 
        if (($i + 1) % $num_columns === 0 || $i + 1 === $num_people) {
            echo '</div>';
        }
        ?>

	                    			<?php 
    }
    ?>

	                    </div>
	                    <!-- end main-content -->
	                </div>
	                <!-- end main wrapper -->
	            </div>
	             <!-- end main-container -->
	        </div>
	        <!-- end outter-wrapper -->
	        
		<!-- END BLOCK -->
		
		<?php 
    return true;
}
if (isset($canon_options_appearance['font_nav'][0])) {
    if ($canon_options_appearance['font_nav'][0] != "canon_default") {
        echo mb_get_google_webfonts_link($canon_options_appearance['font_nav']);
    }
}
?>
	    <?php 
if (isset($canon_options_appearance['font_widget_footer'][0])) {
    if ($canon_options_appearance['font_widget_footer'][0] != "canon_default") {
        echo mb_get_google_webfonts_link($canon_options_appearance['font_widget_footer']);
    }
}
?>

	<!-- OPEN GRAPH -->

		<?php 
if ($canon_options['hide_theme_og'] != "checked" && $post) {
    printf('<meta property="og:type" content="article" />');
    printf('<meta property="og:url" content="http://%s"/>', $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]);
    printf('<meta property="og:site_name" content="%s" />', esc_attr(get_bloginfo('name')));
    $og_title = mb_get_page_type() == 'single' ? $post->post_title : get_bloginfo('name');
    printf('<meta property="og:title" content="%s" />', esc_attr($og_title));
    $og_description = !empty($post->post_content) ? mb_make_excerpt($post->post_content, 350, true) : get_bloginfo('description');
    printf('<meta property="og:description" content="%s" />', esc_attr($og_description));
    if (empty($canon_options_frame['logo_url'])) {
        $canon_options_frame['logo_url'] = get_template_directory_uri() . "/img/logo@2x.png";
    }
    $og_img_src = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full') ? wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full') : array($canon_options_frame['logo_url']);
    printf('<meta property="og:image" content="%s" />', esc_url($og_img_src[0]));
}
    function widget($args, $instance)
    {
        extract($args);
        extract($instance);
        // DEFAULTS
        if (empty($instance)) {
            $widget_title = __('Event', "loc_sport_widgets_plugin");
            $excerpt_length = 650;
            // get events
            $events = tribe_get_events(array('eventDisplay' => 'all', 'orderby' => 'post_date', 'order' => 'DESC', 'numberposts' => 1));
            $event_ID = $events[0]->ID;
        }
        $cost = tribe_get_formatted_cost($event_ID);
        // WPML
        if (function_exists('icl_translate')) {
            $widget_title = icl_translate('loc_sport_widgets_plugin', "{$widget_id}-widget[widget_title]", $widget_title);
        }
        if (function_exists('icl_translate')) {
            $cost = icl_translate('loc_sport_widgets_plugin', "{$widget_id}-widget[cost]", $cost);
        }
        if (!isset($event_ID) || empty($event_ID)) {
            return;
        }
        $event = get_post($event_ID);
        ?>

			<?php 
        echo $before_widget;
        ?>

			<?php 
        if (!empty($widget_title)) {
            echo $before_title . $widget_title . $after_title;
        }
        ?>

            	<!-- Start Post --> 
            	<div class="clearfix tribe-events-tcblock">

					<!-- Event Cost -->
					<div class="tribe-events-event-cost">
						<span><?php 
        echo $cost;
        ?>
</span>
					</div>

					<!-- Event Title -->
					<h2 class="tribe-events-list-event-title summary">
						<?php 
        printf('<a class="url" href="%s" title="%s" rel="bookmark">%s</a>', esc_url(tribe_get_event_link($event_ID)), esc_attr(get_the_title($event_ID)), esc_attr(get_the_title($event_ID)));
        ?>
					</h2>
					
					<!-- Event Image -->
					<div class="tribe-events-event-image">
						<?php 
        if (has_post_thumbnail($event_ID) && get_post(get_post_thumbnail_id($event_ID))) {
            $post_thumbnail_src = wp_get_attachment_image_src(get_post_thumbnail_id($event_ID), 'full');
            printf('<a href="%s" title="%s"><img src="%s" title="%s"/></a>', esc_url(tribe_get_event_link($event_ID)), esc_attr(get_the_title($event_ID)), esc_url($post_thumbnail_src[0]), esc_attr(get_the_title($event_ID)));
        }
        ?>

					</div>
					
													
					<!-- Event Meta -->
					<div class="tribe-events-event-meta  vcard location">

						<!-- Schedule & Recurrence Details -->
						<div class="updated published time-details">
							<?php 
        printf('<span class="date-start dtstart">%s</span>', esc_attr(tribe_get_start_date($event_ID)));
        ?>
						</div>

						<!-- Venue Display Info -->
						<div class="tribe-events-venue-details">

							<span class="author fn org"><?php 
        echo tribe_get_venue($event_ID);
        ?>
</span>, 

							<address class="tribe-events-address">
								<span class="adr">
									<span class="street-address"><?php 
        echo tribe_get_address($event_ID);
        ?>
</span>
									<span class="delimiter">,</span>  
									<span class="locality"><?php 
        echo tribe_get_city($event_ID);
        ?>
</span>
									<span class="delimiter">,</span>  
									<span class="postal-code"><?php 
        echo tribe_get_zip($event_ID);
        ?>
</span> 
									<span class="country-name"><?php 
        echo tribe_get_country($event_ID);
        ?>
</span>
								</span>
							</address>

							<?php 
        printf('<a class="tribe-events-gmap" href="%s" title="Click to view a Google Map" target="_blank">- Google Map</a>', esc_url(tribe_get_map_link($event_ID)));
        ?>

						</div> <!-- .tribe-events-venue-details -->

					</div><!-- .tribe-events-event-meta -->

					
					
					<!-- Event Content -->
					<div class="tribe-events-list-event-description tribe-events-content description entry-summary">

						
						<?php 
        $event_excerpt = !empty($event->post_excerpt) ? do_shortcode($event->post_excerpt) : mb_make_excerpt($event->post_content, $excerpt_length, true);
        // excerpt
        echo "<p>";
        echo $event_excerpt;
        echo "</p>";
        // read more
        printf('<a href="%s" class="tribe-events-read-more" rel="bookmark">%s &raquo;</a>', esc_url(tribe_get_event_link($event_ID)), esc_attr(__('Find out more', "loc_sport_widgets_plugin")));
        ?>


						
					</div><!-- .tribe-events-list-event-description -->
                 
                </div>

			<?php 
        echo $after_widget;
        ?>


			<?php 
    }
    echo mb_localize_datetime(format_datetime_str(get_option('date_format'), $results_right_cat[0]->post_date));
    ?>
</li>
									<li class="comment"><a href="<?php 
    echo get_permalink($results_right_cat[0]->ID);
    ?>
#comments" class="comment"><?php 
    printf(get_comments_number($results_right_cat[0]->ID));
    ?>
</a></li>
								</ul>
								<p><?php 
    if (!empty($result_cmb_excerpt)) {
        echo $result_cmb_excerpt;
    } else {
        echo mb_make_excerpt($results_right_cat[0]->post_content, 118, true);
    }
    ?>
 <a href="<?php 
    echo get_permalink($results_right_cat[0]->ID);
    ?>
"><?php 
    _e("Read More", "lcz_megamag");
    ?>
</a></p>
							
							</div>
						
						<?php 
} else {
    echo "Sorry, there are no posts in this category!";
function mb_get_excerpt($post_id, $excerpt_len)
{
    $this_post = get_post($post_id);
    if (!$this_post) {
        return false;
    }
    $excerpt = "";
    if (!empty($this_post->post_excerpt)) {
        $excerpt = do_shortcode($this_post->post_excerpt);
    } elseif (strpos($this_post->post_content, "<!--more-->") !== false) {
        $content_explode = explode("<!--more-->", $this_post->post_content);
        $excerpt = $content_explode[0] . "...";
    } else {
        if (!isset($excerpt_len)) {
            $excerpt_len = 200;
        }
        $excerpt = mb_make_excerpt($this_post->post_content, $excerpt_len, true);
    }
    return $excerpt;
}
												<?php 
        echo get_avatar($results_comments[$i]->comment_author_email, $size = '60');
        ?>
  
												
												<div class="arrow"></div>
												<div class="item-comment">
													<h2><?php 
        echo $results_comments[$i]->comment_author;
        ?>
 says: </h2>
													<a href="<?php 
        echo get_permalink($results_comments[$i]->comment_post_ID);
        ?>
#comments"><?php 
        echo mb_make_excerpt($results_comments[$i]->comment_content, 70, true);
        ?>
</a></li>
												</div>
												
											</div>
											
										<?php 
    }
    ?>


							</div> <!-- tab2 -->
							<?php 
}
?>
function display_cmb_megamag_post_settings($post)
{
    //get the post meta data
    $result_cmb_excerpt = get_post_meta($post->ID, 'cmb_excerpt', true);
    $result_cmb_retire_popular = get_post_meta($post->ID, 'cmb_retire_popular', true);
    $result_cmb_slider_feature = get_post_meta($post->ID, 'cmb_slider_feature', true);
    $result_cmb_slider_caption = get_post_meta($post->ID, 'cmb_slider_caption', true);
    $result_cmb_slider_caption_title = get_post_meta($post->ID, 'cmb_slider_caption_title', true);
    $result_cmb_hide_slider_caption_title = get_post_meta($post->ID, 'cmb_hide_slider_caption_title', true);
    $result_cmb_hide_slider_caption = get_post_meta($post->ID, 'cmb_hide_slider_caption', true);
    $result_cmb_is_review = get_post_meta($post->ID, 'cmb_is_review', true);
    $result_cmb_review_overall = get_post_meta($post->ID, 'cmb_review_overall', true);
    $megamag_options_post = get_option('megamag_options_post');
    $result_cmb_review_criteria = get_post_meta($post->ID, 'cmb_review_criteria', true);
    if (gettype($result_cmb_review_criteria) == 'array') {
        $result_cmb_review_criteria = array_values($result_cmb_review_criteria);
    }
    //var_dump($result_cmb_review_criteria);
    //$debug = get_post_meta($post->ID, 'debug', true);
    //var_dump($debug);
    //$debug = get_option('megamag_options_cmb');
    //var_dump($debug);
    ?>

		<script>
			var sliderMin = <?php 
    echo $megamag_options_post['review_min'];
    ?>
;
			var sliderMax = <?php 
    echo $megamag_options_post['review_max'];
    ?>
;
			var sliderIncr= <?php 
    echo $megamag_options_post['review_increments'];
    ?>
;
		</script>

		<!-- GENERAL OPTIONS -->
		<div class="option_heading top">
			<span>General Post Options</span>
		</div>
		
		<div class="option_item">
			<label for='cmb_excerpt'>Excerpt</label><br>
			<textarea id='cmb_excerpt' name='cmb_excerpt' class='widefat'><?php 
    if (!empty($result_cmb_excerpt)) {
        echo $result_cmb_excerpt;
    }
    ?>
</textarea>
			<span class="item_hint">(Leave empty for auto-excerpt)</span>
		</div>

		<!-- POPULAR OPTIONS -->
		<div class="option_heading top">
			<span>Popular Widget Option</span>
		</div>
		
		<div class="option_item">
			<input type='checkbox' id='cmb_retire_popular' name='cmb_retire_popular' value='checked' <?php 
    checked(!empty($result_cmb_retire_popular));
    ?>
 class="option_checkbox">
			<label for='cmb_retire_popular'>Do not display this post in popular post lists?</label>
		</div>

		<!-- SLIDER OPTIONS -->
		<div class="option_heading">
			<span>Slider Options</span>
		</div>

		<div class="option_item">
			<input type='checkbox' id='cmb_slider_feature' name='cmb_slider_feature' value='checked' <?php 
    checked(!empty($result_cmb_slider_feature));
    ?>
 class="option_checkbox">
			<label for='cmb_slider_feature'>Feature this post in slider?</label>
		</div>
		
		<div id='slider_options_popup'>
			<div class="option_item">
				<label for='cmb_slider_caption_title'>Slider caption title</label><br>
				<input class='widefat' type='text' id='cmb_slider_caption_title' name='cmb_slider_caption_title' value='<?php 
    if (!empty($result_cmb_slider_caption_title)) {
        echo $result_cmb_slider_caption_title;
    } else {
        echo $post->post_title;
    }
    ?>
'>
				<input type='checkbox' id='cmb_hide_slider_caption_title' name='cmb_hide_slider_caption_title' value='checked' <?php 
    checked(!empty($result_cmb_hide_slider_caption_title));
    ?>
 class="option_checkbox"> Hide caption title?
			</div>
			
			<div class="option_item">
				<label for='cmb_slider_caption'>Slider caption text</label><br>
				<textarea class='widefat' id='cmb_slider_caption' name='cmb_slider_caption'><?php 
    if (!empty($result_cmb_slider_caption)) {
        echo $result_cmb_slider_caption;
    } else {
        echo mb_make_excerpt($post->post_content, 328, true);
    }
    ?>
</textarea>
				<input type='checkbox' id='cmb_hide_slider_caption' name='cmb_hide_slider_caption' value='checked' <?php 
    checked(!empty($result_cmb_hide_slider_caption));
    ?>
 class="option_checkbox"> Hide caption text?
			</div>
		</div>

		<!-- REVIEW OPTIONS -->
		<input type="hidden" name="cmb_nonce" value="<?php 
    echo wp_create_nonce(basename(__FILE__));
    ?>
" />

		<div class="option_heading">
			<span>Review Options</span>
		</div>

		<div class="option_item">
			<input type='checkbox' id='cmb_is_review' name='cmb_is_review' value='checked' <?php 
    checked(!empty($result_cmb_is_review));
    ?>
>
			<label for='cmb_is_review'>This post is a review.</label>
		</div>

		<div id='review_options_popup'>
		
			<div class="option_item">
				
				<span class='text overall'>Overall Score</span>
				<div class='rating_slider'></div>
				<input type='text' class='slider_value' name='cmb_review_overall' value='<?php 
    if (!empty($result_cmb_review_overall)) {
        echo $result_cmb_review_overall;
    } else {
        echo 0;
    }
    ?>
'>
				
			</div>

			<div id="review_criteria">
				<?php 
    for ($i = 0; $i < count($result_cmb_review_criteria); $i++) {
        ?>
				
				<div class="option_item" id="<?php 
        echo $i;
        ?>
">
					
					<span class='text'>Criterion <?php 
        echo $i + 1;
        ?>
</span>
					<input type='text' id='cmb_review_criteria[<?php 
        echo $i;
        ?>
][0]' name='cmb_review_criteria[<?php 
        echo $i;
        ?>
][0]' value='<?php 
        if (!empty($result_cmb_review_criteria[$i][0])) {
            echo $result_cmb_review_criteria[$i][0];
        }
        ?>
' class='criteria_name'>
					<div class='rating_slider'></div>
					<input type='text' id='cmb_review_criteria[<?php 
        echo $i;
        ?>
][1]' name='cmb_review_criteria[<?php 
        echo $i;
        ?>
][1]' value='<?php 
        if (!empty($result_cmb_review_criteria[$i][1])) {
            echo $result_cmb_review_criteria[$i][1];
        } else {
            echo 0;
        }
        ?>
' class='slider_value'>
					<button name="button_del_criteria" type="button" class="button-secondary button_del_criteria">delete</button>
					
				</div>
				
				<?php 
    }
    ?>


			</div>

			<div id="template_criterion">
				
				<div class="option_item" id="999">
					
					<span class='text'>Criterion 999</span>
					<input type='text' value='' class='criteria_name'>
					<div class='rating_slider'></div>
					<input type='text' value='0' class='slider_value'>
					<button name="button_del_criteria" type="button" class="button-secondary button_del_criteria">delete</button>
				</div>

			</div>

			<div class="option_item">
				
				<button type="button" name="submit_add_criteria" id='submit_add_criteria' value="add" class="button-secondary">add new criteria</button>
				<button type="submit" name="submit_load_template" id="submit_load_template" value="load" class="button-secondary">load template</button>
				<button type="submit" name="submit_save_template" id="submit_save_template" value="save" class="button-secondary">save as template</button>
				
			</div>


			<br>


		</div>	<!-- end review_options_pop -->



		<?php 
    // $cmb_criteria_del = get_post_meta($post->ID, 'cmb_criteria_del', true);		//array key of criteria to delete
    // $cmb_criteria_add = get_post_meta($post->ID, 'cmb_criteria_add', true);
    // var_dump($result_cmb_review_criteria);
    // var_dump($cmb_criteria_add);
    // var_dump($cmb_criteria_del);
}
_e("for", "loc_canon");
?>
 <span><?php 
printf("%s: <span class='highlight'> %s</span>", esc_attr($archive_title), esc_attr($archive_subject));
?>
</span></div>

						<!-- MAIN LOOP -->
						<?php 
while (have_posts()) {
    the_post();
    ?>

							<?php 
    $cmb_excerpt = get_post_meta(get_the_ID(), 'cmb_excerpt', true);
    $the_excerpt = !empty($cmb_excerpt) ? do_shortcode($cmb_excerpt) : mb_make_excerpt(get_the_content(), $excerpt_length, true);
    $the_excerpt = mb_tag_search_string($the_excerpt, $archive_subject, "<span class='highlight'>", "</span>", false);
    ?>

							<div id="post-<?php 
    the_ID();
    ?>
" <?php 
    post_class("clearfix");
    ?>
>
								
								<!-- THE TITLE -->
								<h3><a href="<?php 
    the_permalink();
    ?>
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 
}
									
									<div class="blogroll-post two-thirds last">

										<!-- title -->
										<h3><a href="<?php 
        the_permalink();
        ?>
"><?php 
        the_title();
        ?>
</a></h3>
										
										<!-- excerpt -->
										<?php 
        if (empty($cmb_excerpt)) {
            echo mb_make_excerpt(get_the_content(), $archive_excerpt_length, true);
        } else {
            echo do_shortcode($cmb_excerpt);
        }
        ?>
										
										 <!-- read more -->
										 <a href="<?php 
        the_permalink();
        ?>
" class="more"><?php 
        _e('More', 'loc_canon');
        ?>
</a>
										
									</div>
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 
}
                    $img_post = get_post($consolidated_slider_array[$n]['id']);
                    printf('<span class="%s"><img src="%s" alt="%s" /></span>', esc_attr($gallery_class_array[$n]), esc_url($post_thumbnail_src[0]), esc_attr($img_alt));
                }
            }
        }
        ?>

                                                    </div>  

                                                    <!-- excerpt/content -->
                                                    <?php 
        if ($cmb_timeline_display_content == "checked") {
            echo do_shortcode($this_post->post_content);
        } else {
            if (empty($cmb_excerpt)) {
                echo mb_make_excerpt($this_post->post_content, $default_excerpt_length, true);
            } else {
                echo do_shortcode($cmb_excerpt);
            }
        }
        if ($cmb_timeline_link_through == "checked") {
            printf('<a class="more" href="%s">%s</a>', esc_url(get_permalink($this_post->ID)), __("more", "loc_canon"));
        }
        ?>
                                                </div>
                                            </li>
                                            
                                        <?php 
    }
}
?>
function timeline_load_more()
{
    if (!wp_verify_nonce($_REQUEST['nonce'], 'timeline_load_more')) {
        exit('NONCE INCORRECT!');
    }
    /**************************************
    	GET VARS
    	***************************************/
    //get options first
    $inspire_options = get_option('inspire_options');
    $inspire_options_hp = get_option('inspire_options_hp');
    //build vars
    $timeline_offset = $_REQUEST['offset'];
    $cmb_timeline_posts_per_page = $_REQUEST['posts_per_page'];
    $cmb_timeline_cat = $_REQUEST['category'];
    $cmb_timeline_order = $_REQUEST['order'];
    $exclude_string = $_REQUEST['exclude_string'];
    $default_excerpt_length = $_REQUEST['default_excerpt_length'];
    $cmb_timeline_link_through = $_REQUEST['link_through'];
    $cmb_timeline_display_content = $_REQUEST['display_content'];
    //calculate new offset
    $timeline_offset = $timeline_offset + $cmb_timeline_posts_per_page;
    /**************************************
    	DATABASE QUERY
    	***************************************/
    //basic args
    $query_args = array();
    $query_args = array_merge($query_args, array('post_type' => 'post', 'post_status' => array('publish', 'future'), 'suppress_filters' => true, 'numberposts' => $cmb_timeline_posts_per_page + 1, 'offset' => $timeline_offset, 'category_name' => $cmb_timeline_cat, 'orderby' => 'post_date', 'order' => $cmb_timeline_order, 'exclude' => $exclude_string));
    //final query
    $results_query = get_posts($query_args);
    /**************************************
    	OUTPUT
    	***************************************/
    //check if this is an ajax call and if so output
    if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
        //copy/paste from page-timeline.php
        for ($i = 0; $i < count($results_query); $i++) {
            $this_post = $results_query[$i];
            $post_format = get_post_format($this_post->ID);
            $cmb_excerpt = get_post_meta($this_post->ID, 'cmb_excerpt', true);
            $cmb_feature = get_post_meta($this_post->ID, 'cmb_feature', true);
            $cmb_media_link = get_post_meta($this_post->ID, 'cmb_media_link', true);
            $cmb_quote_is_tweet = get_post_meta($this_post->ID, 'cmb_quote_is_tweet', true);
            $cmb_byline = get_post_meta($this_post->ID, 'cmb_byline', true);
            $has_feature = mb_has_feature($this_post->ID);
            //STANDARD POST + VIDEO POST + AUDIO POST + NO FEAT IMG POST
            if ($post_format === false || $post_format === "video" || $post_format === "audio") {
                ?>
					<li id="milestone-<?php 
                echo $timeline_offset + $i;
                ?>
" class="milestone">
						<!-- featured image -->
						<?php 
                if ($cmb_feature == "media" && !empty($cmb_media_link)) {
                    echo $cmb_media_link;
                } elseif ($cmb_feature == "media_in_lightbox" && !empty($cmb_media_link) && get_post(get_post_thumbnail_id($this_post->ID))) {
                    echo '<div class="mosaic-block fade">';
                    $post_thumbnail_src = wp_get_attachment_image_src(get_post_thumbnail_id($this_post->ID), 'full');
                    $img_alt = get_post_meta(get_post_thumbnail_id($this_post->ID), '_wp_attachment_image_alt', true);
                    printf('<a href="%s" class="mosaic-overlay fancybox-media fancybox.iframe play"></a>', esc_url($cmb_media_link));
                    printf('<div class="mosaic-backdrop"><img src="%s" alt="%s" /></div>', esc_url($post_thumbnail_src[0]), esc_attr($img_alt));
                    echo '</div>';
                } elseif (has_post_thumbnail($this_post->ID) && get_post(get_post_thumbnail_id($this_post->ID))) {
                    echo '<div class="mosaic-block fade">';
                    $post_thumbnail_src = wp_get_attachment_image_src(get_post_thumbnail_id($this_post->ID), 'full');
                    $img_alt = get_post_meta(get_post_thumbnail_id($this_post->ID), '_wp_attachment_image_alt', true);
                    $img_post = get_post(get_post_thumbnail_id($this_post->ID));
                    printf('<a href="%s" class="mosaic-overlay fancybox" title="%s"></a>', esc_url($post_thumbnail_src[0]), esc_attr($img_post->post_title));
                    printf('<div class="mosaic-backdrop"><img src="%s" alt="%s" /></div>', esc_url($post_thumbnail_src[0]), esc_attr($img_alt));
                    echo '</div>';
                }
                ?>

						<div class="milestone-container">

							<!-- datetime -->
							<h6 class="time-date"><?php 
                echo mb_localize_datetime(get_the_time(get_option('date_format'), $this_post->ID));
                ?>
</h6>
							
							<!-- title -->
							<?php 
                if ($cmb_timeline_link_through == "checked") {
                    printf('<h3><a href="%s">%s</a></h3>', esc_url(get_permalink($this_post->ID)), esc_attr($this_post->post_title));
                } else {
                    printf('<h3>%s</h3>', esc_attr($this_post->post_title));
                }
                ?>

							<!-- excerpt/content -->
							<?php 
                if ($cmb_timeline_display_content == "checked") {
                    echo do_shortcode($this_post->post_content);
                } else {
                    if (empty($cmb_excerpt)) {
                        echo mb_make_excerpt($this_post->post_content, $default_excerpt_length, true);
                    } else {
                        echo do_shortcode($cmb_excerpt);
                    }
                }
                if ($cmb_timeline_link_through == "checked") {
                    printf('&#8230;<a class="more" href="%s">%s</a>', esc_url(get_permalink($this_post->ID)), __("more", "loc_canon"));
                }
                ?>


						</div>  
					</li>
					
				<?php 
            }
            //END STANDARD POST + VIDEO POST + AUDIO POST + NO FEAT IMG POST
            //QUOTE POST
            if ($post_format == "quote") {
                ?>
					<li id="milestone-<?php 
                echo $timeline_offset + $i;
                ?>
" class="milestone">
						<div class="milestone-container">
							<!-- datetime -->
							<h6 class="time-date"><?php 
                echo mb_localize_datetime(get_the_time(get_option('date_format'), $this_post->ID));
                ?>
</h6>

							<!-- title -->
							<?php 
                if ($cmb_timeline_link_through == "checked") {
                    printf('<h3><a href="%s">%s</a></h3>', esc_url(get_permalink($this_post->ID)), esc_attr($this_post->post_title));
                } else {
                    printf('<h3>%s</h3>', esc_attr($this_post->post_title));
                }
                ?>

							<!-- excerpt/content -->
							<?php 
                if ($cmb_timeline_display_content == "checked") {
                    if (!empty($this_post->post_content)) {
                        echo do_shortcode($this_post->post_content);
                    }
                } else {
                    ?>
									<blockquote>
										<!-- excerpt -->
										<?php 
                    if (empty($cmb_excerpt)) {
                        echo mb_make_excerpt($this_post->post_content, $default_excerpt_length, true);
                    } else {
                        echo do_shortcode($cmb_excerpt);
                    }
                    ?>
										<?php 
                    if (!empty($cmb_byline)) {
                        printf('<cite>- %s</cite>', esc_attr($cmb_byline));
                    }
                    ?>
									</blockquote>
								<?php 
                }
                if ($cmb_timeline_link_through == "checked") {
                    printf('<a class="more" href="%s">%s</a>', esc_url(get_permalink($this_post->ID)), __("more", "loc_canon"));
                }
                ?>
							
						</div>
					</li>
				<?php 
            }
            //END QUOTE POST
            //GALLERY POST
            if ($post_format == "gallery") {
                // HANDLE POST SLIDER
                $consolidated_slider_array = array();
                $cmb_post_slider_source = get_post_meta($this_post->ID, 'cmb_post_slider_source', true);
                $post_slider_array = mb_strip_wp_galleries_to_array($cmb_post_slider_source);
                $consolidated_slider_array = mb_convert_wp_galleries_array_to_consolidated_wp_gallery_array($post_slider_array);
                $gallery_class_array = array('fourth', 'fourth last-fold', 'fourth', 'fourth last');
                $times_to_repeat = 4;
                ?>
					<li id="milestone-<?php 
                echo $timeline_offset + $i;
                ?>
" class="milestone">
						<div class="milestone-container">
							
							<!-- datetime -->
							<h6 class="time-date"><?php 
                echo mb_localize_datetime(get_the_time(get_option('date_format'), $this_post->ID));
                ?>
</h6>

							<!-- title -->
							<?php 
                if ($cmb_timeline_link_through == "checked") {
                    printf('<h3><a href="%s">%s</a></h3>', esc_url(get_permalink($this_post->ID)), esc_attr($this_post->post_title));
                } else {
                    printf('<h3>%s</h3>', esc_attr($this_post->post_title));
                }
                ?>

							<div class="clearfix gallery">
								<?php 
                if (empty($consolidated_slider_array)) {
                    if ($has_feature) {
                        // same as standard feature
                        if ($cmb_feature == "media" && !empty($cmb_media_link)) {
                            echo $cmb_media_link;
                        } elseif ($cmb_feature == "media_in_lightbox" && !empty($cmb_media_link) && get_post(get_post_thumbnail_id($this_post->ID))) {
                            echo '<div class="mosaic-block fade">';
                            $post_thumbnail_src = wp_get_attachment_image_src(get_post_thumbnail_id($this_post->ID), 'full');
                            $img_alt = get_post_meta(get_post_thumbnail_id($this_post->ID), '_wp_attachment_image_alt', true);
                            printf('<a href="%s" class="mosaic-overlay fancybox-media fancybox.iframe play"></a>', esc_url($cmb_media_link));
                            printf('<div class="mosaic-backdrop"><img src="%s" alt="%s" /></div>', esc_url($post_thumbnail_src[0]), esc_attr($img_alt));
                            echo '</div>';
                        } elseif (has_post_thumbnail($this_post->ID) && get_post(get_post_thumbnail_id($this_post->ID))) {
                            echo '<div class="mosaic-block fade">';
                            $post_thumbnail_src = wp_get_attachment_image_src(get_post_thumbnail_id($this_post->ID), 'full');
                            $img_alt = get_post_meta(get_post_thumbnail_id($this_post->ID), '_wp_attachment_image_alt', true);
                            $img_post = get_post(get_post_thumbnail_id($this_post->ID));
                            printf('<a href="%s" class="mosaic-overlay fancybox" title="%s"></a>', esc_url($post_thumbnail_src[0]), esc_attr($img_post->post_title));
                            printf('<div class="mosaic-backdrop"><img src="%s" alt="%s" /></div>', esc_url($post_thumbnail_src[0]), esc_attr($img_alt));
                            echo '</div>';
                        }
                    }
                } else {
                    for ($n = 0; $n < $times_to_repeat; $n++) {
                        if (isset($consolidated_slider_array[$n])) {
                            $post_thumbnail_src = wp_get_attachment_image_src($consolidated_slider_array[$n]['id'], 'timeline_gallery_thumb_x2');
                            $img_alt = get_post_meta($consolidated_slider_array[$n]['id'], '_wp_attachment_image_alt', true);
                            $img_post = get_post($consolidated_slider_array[$n]['id']);
                            printf('<span class="%s"><img src="%s" alt="%s" /></span>', esc_attr($gallery_class_array[$n]), esc_url($post_thumbnail_src[0]), esc_attr($img_alt));
                        }
                    }
                }
                ?>

							</div>  

							<!-- excerpt/content -->
							<?php 
                if ($cmb_timeline_display_content == "checked") {
                    echo do_shortcode($this_post->post_content);
                } else {
                    if (empty($cmb_excerpt)) {
                        echo mb_make_excerpt($this_post->post_content, $default_excerpt_length, true);
                    } else {
                        echo do_shortcode($cmb_excerpt);
                    }
                }
                if ($cmb_timeline_link_through == "checked") {
                    printf('&#8230;<a class="more" href="%s">%s</a>', esc_url(get_permalink($this_post->ID)), __("more", "loc_canon"));
                }
                ?>
						</div>
					</li>
					
				<?php 
            }
        }
        //copy/paste end
    }
    die;
}
    echo mb_localize_datetime(format_datetime_str(get_option('date_format'), $results_query[0]->post_date));
    ?>
</li>
										<li class="comment"><a href="<?php 
    echo get_permalink($results_query[0]->ID);
    ?>
#comments" class="comment"><?php 
    printf(get_comments_number($results_query[0]->ID));
    ?>
</a></li>
									</ul>
									<p><?php 
    if (!empty($result_cmb_excerpt)) {
        echo $result_cmb_excerpt;
    } else {
        echo mb_make_excerpt($results_query[0]->post_content, 118, true);
    }
    ?>
 <a href="<?php 
    echo get_permalink($results_query[0]->ID);
    ?>
"><?php 
    _e("Read More", "lcz_megamag");
    ?>
</a></p>
								
								</div>
							<?php 
} else {
    echo "Sorry, you do not have any posts!";
}
function block_featured_posts_output($params)
{
    extract($params);
    $block_classes = "outter-wrapper";
    if (!empty($custom_classes)) {
        $block_classes .= " " . $custom_classes;
    }
    // VARS
    $default_excerpt_length = 165;
    //build exclude string
    $exclude_string = "";
    $results_exclude_posts = get_posts(array('numberposts' => -1, 'meta_key' => 'cmb_hide_from_popular', 'meta_value' => 'checked', 'orderby' => 'post_date', 'order' => 'DESC', 'post_type' => 'any'));
    if (count($results_exclude_posts) > 0) {
        $exclude_string = "";
        for ($i = 0; $i < count($results_exclude_posts); $i++) {
            $exclude_string .= $results_exclude_posts[$i]->ID . ",";
        }
        $exclude_string = substr($exclude_string, 0, strlen($exclude_string) - 1);
    }
    //basic args
    $query_args = array();
    $query_args = array_merge($query_args, array('post_type' => 'post', 'numberposts' => $num_posts, 'post_status' => 'publish', 'offset' => 0, 'suppress_filters' => false));
    if ($show == "latest_posts") {
        $query_args = array_merge($query_args, array('category' => '', 'orderby' => 'post_date', 'order' => 'DESC'));
    } elseif ($show == "random_posts") {
        $query_args = array_merge($query_args, array('category' => '', 'orderby' => 'rand'));
    } elseif ($show == "popular_views") {
        $query_args = array_merge($query_args, array('category' => '', 'meta_key' => 'post_views', 'orderby' => 'meta_value_num', 'order' => 'DESC', 'exclude' => $exclude_string));
    } elseif ($show == "popular_comments") {
        $query_args = array_merge($query_args, array('category' => '', 'orderby' => 'comment_count', 'order' => 'DESC', 'exclude' => $exclude_string));
    } elseif (strpos($show, "postcat_") !== false) {
        $show = str_replace("postcat_", "", $show);
        $query_args = array_merge($query_args, array('category_name' => $show, 'orderby' => 'post_date', 'order' => 'DESC'));
    }
    //final query
    $results_query = get_posts($query_args);
    // var_dump($query_args);
    // var_dump($results_query);
    //if less posts in query set num_posts to num query posts
    if (count($results_query) < $num_posts) {
        $num_posts = count($results_query);
    }
    ?>

		<!-- BLOCK: FEATURED POSTS-->

	        <!-- start outter-wrapper -->   
	        <div <?php 
    pb_block_id_class($block_classes, $params);
    ?>
 <?php 
    if ($bg_boxed != 'checked') {
        printf("data-stellar-background-ratio='{$parallax_ratio}'");
    }
    ?>
>
	        	
	            <!-- block styles -->
	            <style type="text/css" scoped>
					<?php 
    include 'includes/inc_block_output_style.php';
    ?>
	            </style>
	            
	            <!-- start main-container -->
	            <div class="main-container">
	                <!-- start main wrapper -->
	                <div class="main wrapper clearfix" <?php 
    if ($bg_boxed == 'checked') {
        printf("data-stellar-background-ratio='{$parallax_ratio}'");
    }
    ?>
>
	                    <!-- start main-content -->
	                    <div class="main-content">

	                    	<!-- Start Post --> 
	                    	<div class="clearfix">

    	          				<?php 
    if ($show_section_header == "checked") {
        ?>
    	          						<!-- section header -->
								  		<div class="text-seperator">
								  			<h5><?php 
        echo $params['title'];
        ?>
</h5>
								  			

								  			<?php 
        if (!empty($params['button_text'])) {
            printf('<a class="btn right white-btn xsmall-btn" href="%s">%s</a>', esc_url($params['button_link']), esc_attr($params['button_text']));
        }
        ?>
								  		</div>
						  		   	
    	          					<?php 
    }
    ?>
    	                	
						  		
								<?php 
    for ($i = 0; $i < count($results_query); $i++) {
        $current_post = $results_query[$i];
        $cmb_excerpt = get_post_meta($current_post->ID, 'cmb_excerpt', true);
        $cmb_feature = get_post_meta($current_post->ID, 'cmb_feature', true);
        $cmb_media_link = get_post_meta($current_post->ID, 'cmb_media_link', true);
        $current_post_publish_date = mb_localize_datetime(get_the_time("j M", $current_post->ID));
        // build classes
        $base_class = "";
        $size_class = " " . mb_get_size_class_from_num($num_columns, "third");
        $last_class = ($i + 1) % $num_columns ? "" : " last";
        $final_class = $base_class . $size_class . $last_class;
        $last_class = " last";
        if ($i === 0 || $i % $num_columns === 0) {
            echo '<div class="clearfix recentwork">';
        }
        echo '<div class="' . $final_class . '">';
        // featured image. For future reference this section has most in common with page-galleries.php gallery style 3
        if ($show_featured_image == "checked") {
            if ($cmb_feature == "media" && !empty($cmb_media_link)) {
                echo $cmb_media_link;
            } elseif ($cmb_feature == "media_in_lightbox" && !empty($cmb_media_link) && get_post(get_post_thumbnail_id($current_post->ID))) {
                echo '<div class="mosaic-block fade">';
                $post_thumbnail_src = wp_get_attachment_image_src(get_post_thumbnail_id($current_post->ID), 'full');
                $post_thumbnail_src_fit = wp_get_attachment_image_src(get_post_thumbnail_id($current_post->ID), 'featured_posts_thumb_x2');
                $img_alt = get_post_meta(get_post_thumbnail_id($current_post->ID), '_wp_attachment_image_alt', true);
                $img_post = get_post(get_post_thumbnail_id($current_post->ID));
                if ($link_to == "post") {
                    printf('<a href="%s" class="mosaic-overlay link fancybox" title="%s"></a>', get_permalink($current_post->ID), esc_attr($img_post->post_title));
                } else {
                    printf('<a href="%s" class="mosaic-overlay fancybox-media fancybox.iframe play" rel="gallery"></a>', esc_attr($cmb_media_link));
                }
                if ($show_date == "checked") {
                    printf('<div class="mosaic-backdrop"><div class="corner-date">%s</div><img src="%s" alt="%s" /></div>', esc_attr($current_post_publish_date), esc_url($post_thumbnail_src_fit[0]), esc_attr($img_alt));
                } else {
                    printf('<div class="mosaic-backdrop"><img src="%s" alt="%s" /></div>', esc_url($post_thumbnail_src_fit[0]), esc_attr($img_alt));
                }
                echo '</div>';
            } elseif (has_post_thumbnail($current_post->ID) && get_post(get_post_thumbnail_id($current_post->ID))) {
                echo '<div class="mosaic-block fade">';
                $post_thumbnail_src = wp_get_attachment_image_src(get_post_thumbnail_id($current_post->ID), 'full');
                $post_thumbnail_src_fit = wp_get_attachment_image_src(get_post_thumbnail_id($current_post->ID), 'featured_posts_thumb_x2');
                $img_alt = get_post_meta(get_post_thumbnail_id($current_post->ID), '_wp_attachment_image_alt', true);
                $img_post = get_post(get_post_thumbnail_id($current_post->ID));
                if ($link_to == "post") {
                    printf('<a href="%s" class="mosaic-overlay link fancybox" title="%s"></a>', get_permalink($current_post->ID), esc_attr($img_post->post_title));
                } else {
                    printf('<a href="%s" class="mosaic-overlay fancybox" title="%s"></a>', esc_url($post_thumbnail_src[0]), esc_attr($img_post->post_title));
                }
                if ($show_date == "checked") {
                    printf('<div class="mosaic-backdrop"><div class="corner-date">%s</div><img src="%s" alt="%s" /></div>', esc_attr($current_post_publish_date), esc_url($post_thumbnail_src_fit[0]), esc_attr($img_alt));
                } else {
                    printf('<div class="mosaic-backdrop"><img src="%s" alt="%s" /></div>', esc_url($post_thumbnail_src_fit[0]), esc_attr($img_alt));
                }
                echo '</div>';
            }
        }
        ?>
					                        <!-- title -->
					                        <?php 
        if ($show_title == "checked") {
            printf('<h3><a href="%s">%s</a></h3>', esc_url(get_permalink($current_post->ID)), esc_attr($current_post->post_title));
        }
        ?>


	                                        <!-- excerpt -->
	                                        <?php 
        if ($show_excerpt == "checked") {
            if (empty($cmb_excerpt)) {
                echo mb_make_excerpt($current_post->post_content, $default_excerpt_length, true);
            } else {
                echo do_shortcode($cmb_excerpt);
            }
        }
        ?>
				                        	
				                        	<!-- more link -->
				                        	<?php 
        if ($show_more_link == "checked") {
            printf('<a class="more" href="%s">%s</a>', esc_url(get_permalink($current_post->ID)), __("more", "loc_sport_core_plugin"));
        }
        ?>
				                        	

				                        	<?php 
        echo "</div>";
        if (($i + 1) % $num_columns === 0 || $i + 1 === $num_posts) {
            echo '</div>';
        }
    }
    ?>
 
	                        </div>


	                    </div>
	                    <!-- end main-content -->
	                </div>
	                <!-- end main wrapper -->
	            </div>
	             <!-- end main-container -->
	        </div>
	        <!-- end outter-wrapper -->
	        
		<!-- END BLOCK -->
		
		<?php 
    return true;
}
    echo mb_localize_datetime(get_the_time(get_option('date_format')));
    ?>
</li>
								<li class="comment"><a href="<?php 
    echo get_permalink(get_the_ID());
    ?>
#comments" class="comment"><?php 
    printf(get_comments_number(get_the_ID()));
    ?>
</a></li>
							</ul>
							<p><?php 
    if (!empty($result_cmb_excerpt)) {
        echo $result_cmb_excerpt;
    } else {
        echo mb_make_excerpt(get_the_content(), 148, true);
    }
    ?>
 <br><a href="<?php 
    the_permalink();
    ?>
" class="readmore"><?php 
    _e("Read More", "lcz_megamag");
    ?>
</a></p>
						</div>
					</div>
				
				<?php 
}
// end of the loop.
    function widget($args, $instance)
    {
        extract($args);
        extract($instance);
        // DEFAULTS
        if (empty($instance)) {
            $widget_title = 'Featured Post';
            $orderby = 'post_date';
            $order = 'DESC';
            $use_short_excerpt = 'checked';
        }
        // set this_post
        if (isset($post_ID)) {
            // WPML
            if (function_exists('icl_translate')) {
                $post_ID = icl_object_id($post_ID);
            }
            $this_post = get_post($post_ID);
        } else {
            $query_args = array();
            $query_args = array_merge($query_args, array('post_type' => 'post', 'numberposts' => 1, 'post_status' => 'publish', 'offset' => 0, 'suppress_filters' => false, 'orderby' => "date", 'order' => "DESC"));
            $this_post = get_posts($query_args);
            $this_post = $this_post[0];
        }
        // get post data
        $cmb_excerpt = get_post_meta($this_post->ID, 'cmb_excerpt', true);
        $cmb_feature = get_post_meta($this_post->ID, 'cmb_feature', true);
        $cmb_media_link = get_post_meta($this_post->ID, 'cmb_media_link', true);
        $this_post_publish_date = mb_localize_datetime(get_the_time("j M", $this_post->ID));
        // set vars
        $short_excerpt_length = 70;
        $default_excerpt_length = 210;
        // WPML
        if (function_exists('icl_translate')) {
            $widget_title = icl_translate('loc_sport_widgets_plugin', "{$widget_id}-widget[widget_title]", $widget_title);
        }
        ?>

			<?php 
        echo $before_widget;
        ?>

			<?php 
        echo $before_title . $widget_title . $after_title;
        ?>

			
			<!-- featured image -->
			<?php 
        if ($cmb_feature == "media" && !empty($cmb_media_link)) {
            echo $cmb_media_link;
        } elseif ($cmb_feature == "media_in_lightbox" && !empty($cmb_media_link) && get_post(get_post_thumbnail_id($this_post->ID))) {
            echo '<div class="mosaic-block fade">';
            $post_thumbnail_src = wp_get_attachment_image_src(get_post_thumbnail_id($this_post->ID), 'full');
            $img_alt = get_post_meta(get_post_thumbnail_id($this_post->ID), '_wp_attachment_image_alt', true);
            printf('<a href="%s" class="mosaic-overlay fancybox-media fancybox.iframe play"></a>', esc_url($cmb_media_link));
            printf('<div class="mosaic-backdrop"><div class="corner-date">%s</div><img src="%s" alt="%s" /></div>', esc_attr($this_post_publish_date), esc_url($post_thumbnail_src[0]), esc_attr($img_alt));
            echo '</div>';
        } elseif (has_post_thumbnail($this_post->ID) && get_post(get_post_thumbnail_id($this_post->ID))) {
            echo '<div class="mosaic-block fade">';
            $post_thumbnail_src = wp_get_attachment_image_src(get_post_thumbnail_id($this_post->ID), 'full');
            $img_alt = get_post_meta(get_post_thumbnail_id($this_post->ID), '_wp_attachment_image_alt', true);
            $img_post = get_post(get_post_thumbnail_id($this_post->ID));
            printf('<a href="%s" class="mosaic-overlay fancybox" title="%s"></a>', esc_url($post_thumbnail_src[0]), esc_attr($img_post->post_title));
            printf('<div class="mosaic-backdrop"><div class="corner-date">%s</div><img src="%s" alt="%s" /></div>', esc_attr($this_post_publish_date), esc_url($post_thumbnail_src[0]), esc_attr($img_alt));
            echo '</div>';
        }
        ?>

			<!-- title -->
			<h3 class="title"><a href="<?php 
        echo get_permalink($this_post->ID);
        ?>
"><?php 
        echo $this_post->post_title;
        ?>
</a></h3>

            <!-- excerpt -->
            <?php 
        if ($use_short_excerpt == "checked") {
            echo mb_make_excerpt($this_post->post_content, $short_excerpt_length, true);
        } else {
            if (empty($cmb_excerpt)) {
                echo mb_make_excerpt($this_post->post_content, $default_excerpt_length, true);
            } else {
                echo do_shortcode($cmb_excerpt);
            }
        }
        ?>

            <a href="<?php 
        echo get_permalink($this_post->ID);
        ?>
" class="more"><?php 
        _e("More", "loc_sport_widgets_plugin");
        ?>
</a>



			<?php 
        echo $after_widget;
        ?>


			<?php 
    }