<?php

	$deep_thisPostID = get_the_ID(); $deep_color_code = get_option("deep_style_color");

	if (get_post_meta($deep_thisPostID, "deep_enable_custom_pagetitle_options_value", true) == "no" || !get_post_meta($deep_thisPostID, "deep_enable_custom_pagetitle_options_value", true)){
		$type = get_option("deep_header_type_single_post");
		$thecolor = deep_hex2rgb(str_replace("__USE_THEME_MAIN_COLOR__", $deep_color_code, get_option("deep_header_color_single_post"))); 
		$opacity = intval(str_replace("%","",get_option("deep_header_opacity_single_post")))/100;
		$color = "rgba(".$thecolor[0].",".$thecolor[1].",".$thecolor[2].",".$opacity.")";
		$image = get_option("deep_header_image_single_post"); 
		$background_position = get_option("deep_pagetitle_background_position_single_post");
		$pattern = is_string(get_option("deep_header_pattern_single_post")) ? DEEP_PATTERNS_URL.get_option("deep_header_pattern_single_post") : ""; 
		$custompattern = get_option("deep_header_custom_pattern_single_post"); 
		$margintop = get_option("deep_header_text_margin_top_single_post");	
		$banner = get_option("deep_banner_slider_single_post");
		$showtitle = get_option("deep_hide_pagetitle_single_post") == "on" ? true : false;
		$showsectitle = get_option("deep_hide_sec_pagetitle_single_post") == "on" ? true : false;
		$tcolor = get_option("deep_header_text_color_single_post");
		$tsize = intval(str_replace(" ", "", get_option("deep_header_text_size_single_post")),10)."px";
		
		/* New 4.0 */
		$lettersinglepostspacing = str_replace(" ", "", get_option("deep".'_header_singlepost_text_letterspacing'));
		$titlesinglepostlineheight = get_option("deep".'_header_singlepost_text_lineheight');
		$titlesingleposttransform = get_option("deep_header_singlepost_text_transform");
		
		$titlesecsinglepostletterspacing = str_replace(" ", "", get_option("deep".'_secondary_title_singlepost_text_letterspacing'));
		$titlesecsinglepostlineheight = get_option("deep".'_secondary_title_singlepost_text_lineheight');
		$titlesecsingleposttransform = get_option("deep_secondary_title_singlepost_text_transform");
		
		$tfont = get_option("deep_header_text_font_single_post");
		$stcolor = get_option("deep_secondary_title_text_color_single_post");
		$stsize = intval(str_replace(" ", "", get_option("deep_secondary_title_text_size_single_post")),10)."px";
		$stfont = get_option("deep_secondary_title_font_single_post");
		$stmargin = intval(str_replace(" ", "", get_option("deep_header_sec_text_margin_top_single_post")),10)."px";
		$originalalign = get_option("deep_header_text_alignment_single_post");
		$pt_parallax = get_option("deep_pagetitle_image_parallax_single_post") == "on" ? true : false;
		$pt_overlay = get_option("deep_pagetitle_image_overlay_single_post") == "on" ? true : false;
		$pt_overlay_type = get_option("deep_pagetitle_overlay_type_single_post");
		$pt_overlay_the_color = deep_hex2rgb(str_replace("__USE_THEME_MAIN_COLOR__", $deep_color_code, get_option("deep_pagetitle_overlay_color_single_post")));
		$pt_overlay_pattern = (is_string(get_option("deep_pagetitle_overlay_pattern_single_post"))) ? DEEP_PATTERNS_URL.get_option("deep_pagetitle_overlay_pattern_single_post") : "";
		$pt_overlay_opacity = intval(str_replace("%","",get_option("deep_pagetitle_overlay_opacity_single_post")))/100;
		$pt_overlay_color = "rgba(".$pt_overlay_the_color[0].",".$pt_overlay_the_color[1].",".$pt_overlay_the_color[2].",".$pt_overlay_opacity.")";
		$breadcrumbs = get_option("deep_breadcrumbs_single_post");
		$breadcrumbs_margintop = get_option('deep_breadcrumbs_text_margin_top_single_post');
		$pagetitlepadding = get_option('deep_page_title_padding_single_post');
	} else {
		$type = get_post_meta($deep_thisPostID, "deep_header_type_value", true);
		$thecolor = deep_hex2rgb(get_post_meta($deep_thisPostID, "deep_header_color_value", true)); 
		$opacity = intval(str_replace("%","",get_post_meta($deep_thisPostID, "deep_header_color_opacity_value", true)))/100;
		$color = "rgba(".$thecolor[0].",".$thecolor[1].",".$thecolor[2].",".$opacity.")";
		$image = get_post_meta($deep_thisPostID, "deep_header_image_value", true);
		$image = explode('|!|',$image);
		$background_position = get_post_meta($deep_thisPostID, "deep_header_background_position_value", true);
		if (isset($image[1])) $image = explode('|*|',$image[1]);
		$image = $image[0];
		$pattern = DEEP_PATTERNS_URL.get_post_meta($deep_thisPostID, "deep_header_pattern_value", true).".jpg";
		$custompattern = get_option("deep_header_custom_pattern_value"); 
		$margintop = get_post_meta($deep_thisPostID, "deep_header_text_margin_top_value", true);
		$banner = get_post_meta($deep_thisPostID, "deep_banner_slider_value", true);
		$showtitle = get_post_meta($deep_thisPostID, "deep_hide_pagetitle_value", true) == "yes" ? true : false;
		$showsectitle = get_post_meta($deep_thisPostID, "deep_hide_sec_pagetitle_value", true) == "yes" ? true : false;
		$tcolor = get_post_meta($deep_thisPostID, "deep_header_text_color_value", true);
		$tsize = intval(str_replace(" ", "", get_post_meta($deep_thisPostID, "deep_header_text_size_value", true)),10)."px";
		
		
		/* New 4.0 */
		$lettersinglepostspacing = str_replace(" ", "", get_post_meta($deep_thisPostID, "deep_header_singlepost_text_letterspacing_value", true));
		$titlesinglepostlineheight = get_post_meta($deep_thisPostID, "deep_header_singlepost_text_lineheight_value", true);
		$titlesingleposttransform = get_post_meta($deep_thisPostID, "deep_header_singlepost_text_transform_value", true);

		$titlesecsinglepostletterspacing = str_replace(" ", "", get_post_meta($deep_thisPostID, "deep_secondary_title_singlepost_text_letterspacing_value", true));
		$titlesecsinglepostlineheight = get_post_meta($deep_thisPostID, "deep_secondary_title_singlepost_text_lineheight_value", true);
		$titlesecsingleposttransform = get_post_meta($deep_thisPostID, "deep_secondary_title_singlepost_text_transform_value", true);
		
		
		$tfont = get_post_meta($deep_thisPostID, "deep_header_text_font_value", true);
		$stcolor = get_post_meta($deep_thisPostID, "deep_secondary_title_text_color_value", true);
		$stsize = intval(str_replace(" ", "", get_post_meta($deep_thisPostID, "deep_secondary_title_text_size_value", true)),10)."px";
		$stfont = get_post_meta($deep_thisPostID, "deep_secondary_title_font_value", true);
		$stmargin = intval(str_replace(" ", "", get_post_meta($deep_thisPostID, "deep_header_secondary_text_margin_top_value", true)),10)."px";
		$originalalign = get_post_meta($deep_thisPostID, "deep_header_text_alignment_value", true);
		$pt_parallax = get_post_meta($deep_thisPostID, "deep_pagetitle_image_parallax_value", true) == "on" ? true : false;
		$pt_overlay = get_post_meta($deep_thisPostID, "deep_pagetitle_image_overlay_value", true) == "on" ? true : false;
		$pt_overlay_type = get_post_meta($deep_thisPostID, "deep_pagetitle_overlay_type_value", true);
		$pt_overlay_the_color = deep_hex2rgb(get_post_meta($deep_thisPostID, "deep_pagetitle_overlay_color_value", true));
		$pt_overlay_pattern = DEEP_PATTERNS_URL.get_post_meta($deep_thisPostID, "deep_pagetitle_overlay_pattern_value", true).".jpg";
		$pt_overlay_opacity = intval(str_replace("%","",get_post_meta($deep_thisPostID, "deep_pagetitle_overlay_opacity_value", true)))/100;
		$pt_overlay_color = "rgba(".$pt_overlay_the_color[0].",".$pt_overlay_the_color[1].",".$pt_overlay_the_color[2].",".$pt_overlay_opacity.")";
		$breadcrumbs = get_post_meta($deep_thisPostID, "deep_enable_breadcrumbs_value", true) == "yes" ? "on" : "off";
		$breadcrumbs_margintop = intval(str_replace(" ", "", get_post_meta($deep_thisPostID, "deep_breadcrumbs_margin_top_value", true)),10)."px";
		$pagetitlepadding = intval(str_replace(" ", "", get_post_meta($deep_thisPostID, "deep_page_title_padding_value", true)),10)."px";
	}
	$height = "auto";
	
	$textalign = $originalalign;
	if ($originalalign == "titlesleftcrumbsright") $textalign = "left";
	if ($originalalign == "titlesrightcrumbsleft") $textalign = "right";

	if (is_array($tfont)) $tfont = ""; $deep_import_fonts[] = $tfont;
	$principalfont = explode("|",$tfont);
	$principalfont[0] = $principalfont[0]."', 'Arial', 'sans-serif";
	if (!isset($principalfont[1])) $principalfont[1] = "";
		
	if (is_array($stfont)) $stfont = ""; $deep_import_fonts[] = $stfont;
	$secondaryfont = explode("|",$stfont);
	$secondaryfont[0] = $secondaryfont[0]."', 'Arial', 'sans-serif";
	if (!isset($secondaryfont[1])) $secondaryfont[1] = "";
	
	deep_set_import_fonts($deep_import_fonts);

	if ($type != "without"){
		
		$ptitleaux = $bcaux = "";
		if ($originalalign == "titlesleftcrumbsright" || $originalalign == "titlesrightcrumbsleft"){
			$ptitleaux .= "max-width: 50%;";
			$bcaux .= "max-width: 50%;";
			if ($originalalign == "titlesleftcrumbsright"){
				$ptitleaux .= "float:left;";
				$bcaux .= "float:right;";
			} else {
				$ptitleaux .= "float:right;";
				$bcaux .= "float:left;";
			}
		}
		$bcaux .= "margin-top:".intval($breadcrumbs_margintop,10)."px;";
		switch($originalalign){
			case "left": case "titlesrightcrumbsleft":
				$bcaux .= "text-align: left;";
			break;
			case "right": case "titlesleftcrumbsright":
				$bcaux .= "text-align:right;";
			break;
			case "center": 
				$bcaux .= "text-align:center;";
			break;
		}
		?>
		<div class="fullwidth-container <?php if ($type == "pattern") echo "bg-pattern"; ?> <?php if ($pt_parallax) echo "parallax"; ?><?php if (($type == "image" || $type == "pattern" || $type == "featured_image") && get_option('deep_enable_grayscale') == 'on') echo " deep_grayscale "; if (get_option('deep_pagetitle_animations') == 'on') echo " wpb_animate_when_almost_visible wpb_fadeIn fadeIn";?>" <?php if ($pt_parallax) echo 'data-stellar-ratio="0.5"'; ?>
			<?php
				$deep_output = ".fullwidth-container{";
				if ($type == "featured_image"){
					$type = "image";
					$image = wp_get_attachment_url( get_post_thumbnail_id($deep_thisPostID) );
				}
				 if ($height != "") $deep_output.= "height: ". $height . ";";
				if ($type == "none") $deep_output.= "background: none;"; 
				if ($type == "color") $deep_output.= "background: " . $color . ";";
				if ($type == "image") $deep_output.= "background: url(" . $image . ") no-repeat; background-size: 100% auto;";  
				 if ($type == "pattern") $deep_output.= "background: url('" . $pattern . "') 0 0 repeat;";
				$deep_output .= "}";
				deep_set_custom_inline_css($deep_output);
				
				
			?> <?php if ($type == "image" && !$pt_parallax) echo ' data-background-alignment="'. esc_attr( $background_position ) .'" '; ?>>
			<?php
				if ($type == "image" && $pt_overlay){
					$deep_output = ".pagetitle_overlay{";
					echo '<div class="pagetitle_overlay"></div> '; 
					if ($pt_overlay_type == "color") $deep_output.= 'background-color:'.$pt_overlay_color.' !important';
					else $deep_output.= 'background:url('.$pt_overlay_pattern.') repeat;opacity:'.$pt_overlay_opacity.' !important;';
					$deep_output .= "}";
					deep_set_custom_inline_css($deep_output);
				}
				if ($type === "banner"){
					?> 
					<div class="revBanner">
						<?php
							if (substr($banner, 0, 10) === "revSlider_"){
								if (!function_exists('putRevSlider')){
									echo esc_html__('Please install the missing plugin - Revolution Slider.', 'deep');
								} else {
									putRevSlider(substr($banner, 10));
								}
							} 
							if (substr($banner, 0, 13) === "masterSlider_"){
								if (!function_exists('masterslider')){
									echo esc_html__('Please install the missing plugin - MasterSlider.', 'deep');
								} else {
									echo do_shortcode( '[masterslider alias="'.substr($banner, 13).'"]' );
								}
							}
							if (substr($banner, 0, 12) === "layerSlider_"){
								if (!function_exists('layerslider')){
									echo esc_html__('Please install the missing plugin - LayerSlider.', 'deep');
								} else {
									echo do_shortcode( '[layerslider id="'.substr($banner, 12).'"]' );
								}
							}
						?>
					</div> 
					<?php
				} else {
				?>
				<div class="container present-container <?php echo esc_attr($originalalign); if (get_option('deep_pagetitle_animations') == 'on') echo " wpb_animate_when_almost_visible wpb_fadeInUpnShort fadeInUpShort";?>">
					<?php
						$deep_output = ".present-container{padding: ".esc_attr($pagetitlepadding)." 25px;}";
						deep_set_custom_inline_css($deep_output);
					?>
					<div class="pageTitle">
					<?php
						$deep_output = ".present-container .pageTitle{text-align: ".esc_attr($textalign).";".esc_attr($ptitleaux)."}";
						deep_set_custom_inline_css($deep_output);
						if ($showtitle){
							?>
							<h1 class="page_title">
								<?php if (is_front_page() && is_home()) echo wp_kses(get_option('deep_blog_single_primary_title'), 'post'); else echo wp_kses(get_the_title($deep_thisPostID), 'post'); ?>
							</h1>
							<?php
							
							/* New 4.0 */	
							$deep_output = ".present-container h1.page_title{color: #$tcolor; font-size: $tsize; 
							
							letter-spacing: $lettersinglepostspacing; line-height: $titlesinglepostlineheight; text-transform: $titlesingleposttransform;";
							
							if ($margintop != "") $deep_output .= esc_attr("margin-top: ".intval($margintop,10)."px;");
							if ($originalalign === "center") $deep_output .= esc_attr("text-indent: ".($lettersinglepostspacing).";");
							
							$deep_output .= "}";
							deep_set_custom_inline_css($deep_output);
						}
						if ($showsectitle){
							if (get_post_meta($post->ID, 'secondaryTitle_value', true) != "" || get_option('deep_blog_secondary_title') != ""){
								?>
								<h2 class="secondaryTitle">
									<?php echo wp_kses(get_post_meta($post->ID, 'secondaryTitle_value', true), 'post'); ?>
								</h2>
								<?php
								$deep_output = ".present-container .secondaryTitle{color: #$stcolor; font-size: $stsize; margin-top:{$stmargin};letter-spacing: $titlesecsinglepostletterspacing; line-height: $titlesecsinglepostlineheight; text-transform: $titlesecsingleposttransform;}";
								deep_set_custom_inline_css($deep_output);
							}
						}
					?>

					
					
						<?php
					}
					
					if (get_option("deep_display_metas_single") == "on"){
							
					/* new metas on pagetitle */
					if ((get_post_meta( $deep_thisPostID , 'boldway_single_display_metas_value' , true ) == "yes" || get_post_meta( $deep_thisPostID , 'boldway_single_display_metas_value' , true ) == "") && (get_post_meta( $deep_thisPostID , 'boldway_single_display_metas_where_value' , true ) == 'pagetitle' || get_post_meta( $deep_thisPostID , 'boldway_single_display_metas_where_value' , true ) == '')){
						
						?>
						<div class="metas-container">
									<?php
										$metas = isset($wp_query->queried_object->ID) ? explode(",", get_post_meta( $wp_query->queried_object->ID , 'boldway_single_metas_value' , true )) : array("date,author,tags,categories");
										if (!empty($metas)){
											
											$deep_output = "body .deep-apply-tcolor,body .deep-apply-tcolor a, body .deep-apply-tcolor i{ color:#".esc_attr($tcolor)." !important; }";
											deep_set_custom_inline_css($deep_output);
											
											$firstMeta = true;
											foreach ($metas as $meta){
												switch ($meta){
													case "date":
														
														?>
														<p class="blog-date deep-apply-tcolor"><i class="mi-clock"></i><?php echo get_the_date(); ?></p>
														<?php
													break;
													case "author":
														
														?>
														<p><a class="the_author deep-apply-tcolor" href="<?php echo get_author_posts_url( get_the_author_meta('ID') ); ?>"><i class="mi-user"></i><?php  esc_html(the_author_meta('display_name')); ?></a></p>
														<?php
													break;
													// case "tags":
													// 	$posttags = get_the_tags();
													// 	if ($posttags) {
													// 		
													// 		$first = true;
													// 		echo '<p class="deep-apply-tcolor"><i class="fa fa-tags"></i> ';
													// 		
													// 		foreach($posttags as $tag) {
													// 			if ($tag->name != "uncategorized"){
													// 				if ($first){
													// 					echo "<a href='".esc_url( get_term_link($tag) )."'>".esc_html($tag->name)."</a>"; 
													// 					$first = false;
													// 				} else {
													// 					echo "<span>, </span><a href='".esc_url( get_term_link($tag) )."'>".esc_html($tag->name)."</a>";
													// 				}
													// 			}
													// 		  }
													// 		  echo '</p>';
													// 	}
													// break;
													case "categories":
														$postcats = get_the_category();
														if ($postcats) {
															
															$first = true;
															echo '<p class="deep-apply-tcolor"><i class="mi-folder"></i> ';
															
															
															foreach($postcats as $cat) {
																if ($cat->name != "uncategorized"){
																	if ($first){
																		echo "<a  href='".esc_url( get_term_link($cat) )."'>".esc_html($cat->name)."</a>"; 
																		$first = false;
																	} else {
																		echo "<span>, </span><a href='".esc_url( get_term_link($cat) )."'>".esc_html($cat->name)."</a>"; 
																	}	
																}
															  }
															  echo '</p>';
														}
													break;
													case "comments":
														
														echo '<p class="deep-apply-tcolor"><i class="mi-message"></i> ';
														echo get_comments_number();
														echo '</p>';
													break;
													
												}
											}
										}
										
									?>
								
					</div>		
				</div>	
							
		<?php }}
			
		?>
		<?php
		if ($breadcrumbs == "on"){
			?>
			<div class="deep_breadcrumbs" style="<?php echo esc_attr($bcaux); ?>">
				<?php deep_the_breadcrumb(); ?>
			</div>
			<?php
		}
		?> 

		</div>
		
		</div>
	</div>
		<?php
	}
	
	$is_custom_sidebar_layout = get_post_meta($deep_thisPostID, 'enable_post_custom_sidebar_layout_value', true) == "true" ? true : false;
	$sidebar_scheme = $is_custom_sidebar_layout ? get_post_meta( $deep_thisPostID, 'sidebar_for_default_value', true ) : get_option('deep_blog_single_sidebar');
	$sidebar = $is_custom_sidebar_layout ? get_post_meta( $deep_thisPostID, 'sidebars_available_value', true ) : get_option('deep_sidebars_available');
	$sidebar = deep_convert_to_class($sidebar);
	if ($sidebar == "") $sidebar = "defaultblogsidebar";
	$deep_inline_script = "";
	switch ( $sidebar_scheme ){
		case "none":
			?>
			<div class="blog-default wideblog <?php if (get_option('deep_blog_sidebars_animations') == 'on') echo " wpb_animate_when_almost_visible wpb_fadeInUpnShort fadeInUpShort"; ?>">
				<div class="master_container container">
					<section class="page_content col-xs-12 col-md-12">
						<div class="blog-default-bg">
							<?php 
								if (post_password_required()) echo get_the_password_form();
							    else $deep_inline_script = deep_print_single_post($deep_inline_script); 
							?>
						</div>
					</section>
					<div class="single-extras"><?php deep_print_single_extras($deep_inline_script); ?></div>
				</div>
			</div>
			<?php
		break;
		case "left":
			?>
			<div class="blog-default <?php if (get_option('deep_blog_sidebars_animations') == 'on') echo " wpb_animate_when_almost_visible wpb_fadeInUpnShort fadeInUpShort"; ?>">
				<div class="master_container container">
					<section class="page_content left sidebar col-xs-12 col-md-3">
						
						<div class="blog-sidebar-bg">
							<?php 
							if ($sidebar === "defaultblogsidebar"){
								get_sidebar();
							} else {
								if ( function_exists('dynamic_sidebar')) { 
									ob_start();
									do_shortcode(dynamic_sidebar($sidebar));
									$html = ob_get_contents();
									ob_end_clean();
									$html = wp_kses_no_null( $html, array( 'slash_zero' => 'keep' ) );
									$html = wp_kses_normalize_entities($html);
									echo wp_kses_hook($html, 'post', array()); 
								}	
							}
							?>
						</div>
					</section>
					<section class="page_content right col-xs-12 col-md-9">
						<div class="blog-default-bg">
							<?php 
								if (post_password_required()) echo get_the_password_form();
							    else $deep_inline_script = deep_print_single_post($deep_inline_script); 
							?>
						</div>
					</section>
					<div class="single-extras"><?php deep_print_single_extras($deep_inline_script); ?></div>
				</div>
			</div>
			<?php
		break;
		case "right":
			?>
			
			<div class="blog-default <?php if (get_option('deep_blog_sidebars_animations') == 'on') echo " wpb_animate_when_almost_visible wpb_fadeInUpnShort fadeInUpShort"; ?>">
				<div class="master_container container">
					<section class="page_content left col-xs-12 col-md-9">
						<div class="blog-default-bg">
							<?php 
								if (post_password_required()) echo get_the_password_form();
							    else $deep_inline_script = deep_print_single_post($deep_inline_script); 
							?>
						</div>
					</section>
					<section class="page_content right sidebar col-xs-12 col-md-3">
						<div class="blog-sidebar-bg">
							<?php 
							if ($sidebar === "defaultblogsidebar"){
								get_sidebar();
							} else {
								if ( function_exists('dynamic_sidebar')) { 
									ob_start();
									do_shortcode(dynamic_sidebar($sidebar));
									$html = ob_get_contents();
									ob_end_clean();
									$html = wp_kses_no_null( $html, array( 'slash_zero' => 'keep' ) );
									$html = wp_kses_normalize_entities($html);
									echo wp_kses_hook($html, 'post', array()); 
								}
							}
							?>
						</div>
					</section>
					<div class="single-extras"><?php deep_print_single_extras($deep_inline_script); ?></div>
				</div>
			</div>
			
			<?php
		break;
		default:
			?>
			<div class="blog-default wideblog">
				<div class="master_container container <?php if (get_option('deep_blog_sidebars_animations') == 'on') echo " wpb_animate_when_almost_visible wpb_fadeInUpnShort fadeInUpShort"; ?>">
					<section class="page_content col-xs-12 col-md-12">
						<div class="blog-default-bg">
							<?php $deep_inline_script = deep_print_single_post($deep_inline_script); ?>
						</div>
					</section>
					<div class="single-extras"><?php deep_print_single_extras($deep_inline_script); ?></div>
				</div>
			</div>
			<?php
		break;
	}	

	function deep_print_single_extras($deep_inline_script){
		
		
		
		if (get_option("deep_post_single_social_shares") == "on" && get_option('deep_post_single_socials') != "" && defined('DEEP_PLG_ACTIVE')){
			$post_single_socials = explode(",",get_option('deep_post_single_socials'));
			?>
			<div class="share-buttons">
				
				<h5><?php
					if (function_exists('icl_t')){
						echo sprintf(esc_html__("%s","deep"), icl_t( 'deep', 'SHARE THIS', get_option('deep_share_post_text')));
					} else {
						echo sprintf(esc_html__("%s","deep"), get_option("deep_share_post_text"));
					}
				?></h5>
				
				<!--  NEW STUFF -->
				<div class="posts-shares <?php if (get_option('deep_blog_sidebars_animations') == 'on') echo " wpb_animate_when_almost_visible wpb_fadeInUpnShort fadeInUpShort"; ?>">
					<div class="social-shares clearfix">
						<ul>
							<?php
								if (in_array("facebook", $post_single_socials)){
									?>
									<li>
										<a href="<?php echo esc_url("https://www.facebook.com/sharer.php?u=".get_the_permalink()."&amp;t=".get_the_title()); ?>" class="share-facebook" target="_blank" title="facebook"><i class="fab fa-facebook-f"></i><?php esc_html_e( '', 'deep' )?></a>
									</li>
									<?php
								}
							
								
								if (in_array("twitter", $post_single_socials)){
									?>
									<li><a 
									href="<?php echo esc_url("https://twitter.com/intent/tweet?button_hashtag=share&ref_src=".get_the_permalink()."&amp;t=".get_the_title()); ?>" target="_blank" class="twitter" title="twitter">
										<i>
											<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path id="twitter_x_svg" opacity="1" d="M389.2 48h70.6L305.6 224.2 487 464H345L233.7 318.6 106.5 464H35.8L200.7 275.5 26.8 48H172.4L272.9 180.9 389.2 48zM364.4 421.8h39.1L151.1 88h-42L364.4 421.8z"/></svg>
										</i>
									
									</a></li>
									<?php
								}
								if (in_array("linkedin", $post_single_socials)){
									?>
									<li>
										<a href="<?php echo esc_url("https://linkedin.com/shareArticle?mini=true&amp;url=".get_the_permalink()."&amp;title=".get_the_title()); ?>" target="_blank" class="share-linkedin" title="linkedin"><i class="fab fa-linkedin-in"></i><?php esc_html_e( '', 'deep' )?></a>
									</li>
									<?php
								}
								if (in_array("pinterest", $post_single_socials)){
									?>
									<li>
										<a href="<?php $url = wp_get_attachment_url( get_post_thumbnail_id(get_the_ID()) ); echo esc_url("https://www.pinterest.com/pin/create/button/?url=".get_the_permalink()."&amp;media=".$url."&amp;") ?>" target="_blank" class="share-pinterest" title="pinterest"><i class="fab fa-pinterest"></i><?php esc_html_e( '', 'deep' )?></a>
									</li>
									<?php
								}
								if (in_array("tumblr", $post_single_socials)){
									?>
									<li>
										<a href="<?php echo esc_url("https://www.tumblr.com/share/?url=".get_the_permalink()."&amp;title=".get_the_title()); ?>" target="_blank" title="tumblr"><i class="fab fa-tumblr"></i><?php esc_html_e( '', 'deep' )?></a>							
									</li>
									<?php
								}
								if (in_array("email", $post_single_socials)){
									?>
									<li>
										<a href="<?php echo esc_url("mailto:?subject=".get_the_title()."&amp;body=".get_the_permalink()); ?>" class="share-mail" title="email"><i class="fa fa-envelope"></i> <?php esc_html_e( '', 'deep' )?></a>
									</li>
									<?php
								}
							?>	
						</ul>
					</div>
					
				</div>
				
			 </div> 
			<?php
		}
		?>
		
		<?php	if (get_option("deep_single_post_nav") == "on"){ 
			
		?>
		
		<nav id="nav-below" role="article" class="navigation_with_thumbnails <?php if (get_option('deep_blog_sidebars_animations') == 'on') echo " wpb_animate_when_almost_visible wpb_fadeInUpnShort fadeInUpShort"; ?>">
		
			<?php 
				wp_reset_postdata();
				ob_start();
				$prevPost = get_previous_post();
				$prevthumbnail = $prevPost != "" ? get_the_post_thumbnail($prevPost->ID, 'full') : false;
				$prevtitle = $prevPost != "" ? "<div class='nav-title'>".esc_html($prevPost->post_title)."</div>" : "";
				$nextPost = get_next_post();
				$nextthumbnail = $nextPost != "" ? get_the_post_thumbnail($nextPost->ID, 'full') : false;
				$nexttitle = $nextPost != "" ? "<div class='nav-title'>".esc_html($nextPost->post_title)."</div>" : "";
				if ($prevPost == "" || $nextPost == "") echo "<div class='full-width-nav'>";
				if (function_exists('icl_t')){
					if ($prevPost != "") previous_post_link( '<div class="nav-previous"><div class="nav-previous-thumb">'.$prevthumbnail.'</div><div class="navcontentens-side">%link'.$prevtitle.'</div></div>', sprintf(esc_html__("%s",'deep'), icl_t( 'deep', 'Previous post', get_option('deep_single_previous_text')))); 
					
					if ($nextPost != "") next_post_link( '<div class="nav-next"><div class="nav-next-thumb">'.$nextthumbnail.'</div><div class="navcontentens-side">'.'%link'.$nexttitle.'</div></div>', sprintf(esc_html__("%s",'deep'), icl_t( 'deep', 'Next post', get_option('deep_single_next_text')) )); 
					
				} else {
					if ($prevPost != "") previous_post_link( '<div class="nav-previous"><div class="nav-previous-thumb">'.$prevthumbnail.'</div><div class="navcontentens-side">%link'.$prevtitle.'</div></div>', sprintf(esc_html__("%s",'deep'), get_option('deep_single_previous_text')));
					 
					if ($nextPost != "") next_post_link( '<div class="nav-next"><div class="nav-next-thumb">'.$nextthumbnail.'</div><div class="navcontentens-side">'.'%link'.$nexttitle.'</div></div>', sprintf(esc_html__("%s",'deep'), get_option('deep_single_next_text') )); 
				if ($prevPost == "" || $nextPost == "") echo "</div>";
				}
				if (get_post_meta(get_the_ID(), '_wpb_vc_js_status', true)){
					if (get_option('deep_header_style_type') == 'style8')
						$nav_output = '[vc_row][vc_column]'.ob_get_clean().'[/vc_column][/vc_row]';
					else 
						$nav_output = '[vc_row full_width="stretch_row_content_no_spaces"][vc_column]'.ob_get_clean().'[/vc_column][/vc_row]';
				}
				else $nav_output = ob_get_clean();
				echo do_shortcode($nav_output);
			?>
		
		</nav>	
		
		<?php
		}
		?>
		
		
		<?php	if (get_option("deep_single_basic_post_nav") == "on"){ 
			
		?>

		<nav id="nav-below" role="article" class="navigation <?php if (get_option('deep_blog_sidebars_animations') == 'on') echo " wpb_animate_when_almost_visible wpb_fadeInUpnShort fadeInUpShort"; ?>">
			<?php 
				if (function_exists('icl_t')){
					previous_post_link( '<div class="nav-previous"><i class="fa fa-angle-left"></i>%link</div>', sprintf(esc_html__("%s",'deep'), icl_t( 'deep', '', get_option('deep_single_previous_text')))); 
					next_post_link( '<div class="nav-next">%link<i class="fa fa-angle-right"></i></div>', sprintf(esc_html__("%s",'deep'), icl_t( 'deep', '', get_option('deep_single_next_text')) )); 
				} else {
					previous_post_link( '<div class="nav-previous"><i class="fa fa-angle-left"></i>%link</div>', sprintf(esc_html__("%s",'deep'), get_option('deep_single_previous_text'))); 
					next_post_link( '<div class="nav-next">%link<i class="fa fa-angle-right"></i></div>', sprintf(esc_html__("%s",'deep'), get_option('deep_single_next_text') )); 
				}
			?>
		</nav>    
		
		<?php
			
			}
			
			
		/* related posts */
		
		$show_related_posts = $from_panel = false;
		$show_related_posts = ((get_post_meta( get_the_ID(), 'boldway_show_related_posts_value', true ) == "yes") ? get_post_meta( get_the_ID(), 'deep_related_posts_criteria_value', true ) : ((get_post_meta( get_the_ID(), 'boldway_show_related_posts_value', true ) == "panel") ? ((get_option( 'deep_show_related_posts' ) == "on") ? get_option( 'deep_related_posts_criteria' ) : false) : false ));
		if (get_post_meta( get_the_ID(), 'boldway_show_related_posts_value', true ) == "panel" || get_post_meta( get_the_ID(), 'boldway_show_related_posts_value', true ) == "") $from_panel = true;
		
		if ($show_related_posts){
			
			wp_enqueue_script('ultimate-vc-addons-slick');
			
			$maxposts = get_post_meta( get_the_ID(), 'deep_related_posts_max_value', true );
			$postsperrow = get_post_meta( get_the_ID(), 'deep_related_posts_per_row_value', true );
			if ($from_panel){
				$maxposts = get_option( 'deep_related_posts_max' );
				$postsperrow = get_option('deep_related_posts_per_row' );
			}
			
			$args = array(
				"post_type" => "post",
				"status" => "publish",
				"orderby" => "date",
				"order" => "DESC",
				"post__not_in" => array(get_the_ID()),
				"showposts" => intval($maxposts) > 0 ? intval($maxposts) : -1
			);
			switch ($show_related_posts){
				case "random": $args["orderby"] = "rand"; break;
				case "number_of_comments": $args["orderby"] = "comment_count"; break;
				case "category": 
					$cats = wp_get_post_categories( get_the_ID() );
					//remove uncategorized if no cat if select. show the lot.
					if ( count($cats) < 2 && ($key = array_search(0, $cats)) !== false) {
						unset($cats[$key]);
					}
					$args['cat'] = $cats;
				break;
				case "tag": 
					$tags = wp_get_post_tags( get_the_ID() );
					//remove uncategorized if no tag if select. show the lot.
					if ( count($tags) < 2 && ($key = array_search(0, $tags)) !== false) {
						unset($tags[$key]);
					}
					$args['tax_query'] = array( 
						array(
							'taxonomy'  => 'post_tag',
							'field'     => 'term_id',
							'terms'     => array_map(function($x){ return $x->term_id; }, $tags)
						)
					);
				break;
			}

			$related_posts = get_posts($args);
			
			if (count($related_posts)){
				ob_start();
				?>
				<div class="deep_related_posts container">
					<?php
						$title = $from_panel ? get_option( 'boldway_related_posts_title' ) : get_post_meta( get_the_ID(), 'boldway_related_posts_title_value', true );
						if (!is_string($title)) $title = "";
						if (strlen(trim($title))>0) echo "<h3 class='related_posts_title'>".wp_kses($title, 'post')."</h3>";
						
						$subtitle = $from_panel ? get_option( 'boldway_related_posts_subtitle' ) : get_post_meta( get_the_ID(), 'boldway_related_posts_subtitle_value', true );
						if (!is_string($subtitle)) $subtitle = "";
						if (strlen(trim($subtitle))>0) echo "<p class='related_posts_subtitle'>".wp_kses($subtitle, 'post')."</p>";
					?>
					<div class="related_posts_listing">
					<?php
						foreach ($related_posts as $post){
							$this_posttype = get_post_meta( $post->ID, 'posttype_value', true );
							echo "<div class='related_post col-xs-12 col-md-". 12/intval($postsperrow) ." ".esc_attr( $this_posttype )."'><a href='". get_permalink( $post->ID ) ."' ><div class='related_post_bg'>"; 
							
							if ($this_posttype == "video"){
								echo "<div class='video_thumb'>";
								$videosType = get_post_meta($post->ID, "videoSource_value", true);
								if ($videosType != "embed"){
									$videos = get_post_meta($post->ID, "videoCode_value", true);
									$videos = preg_replace( '/\s+/', '', $videos );
									$vid = explode(",",$videos);
								}
								switch (get_post_meta($post->ID, "videoSource_value", true)){
									case "media":
										$video = explode("|!|",get_post_meta($post->ID, 'videoMediaLibrary_value', true));
										if (isset($video[1])) {
											$ext = explode(".",$video[1]);
											if (isset($ext)) $ext = $ext[count($ext)-1];
											?>
											<video controls="controls" class="video-controls"><source type="video/<?php echo esc_attr($ext); ?>" src="<?php echo esc_url($video[1]); ?>"></video>
											<?php
										}
									break;
									case "youtube":
										if (isset($vid[0])) echo "<iframe src='//www.youtube.com/embed/".esc_attr($vid[0])."' frameborder='0' allowfullscreen></iframe>";
										break;
									case "vimeo":
										if (isset($vid[0])) echo '<iframe src="https://player.vimeo.com/video/'.esc_attr($vid[0]).'" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>';
										break;
								}
								echo "</div>";
								
								if (!isset($deep_inline_script)) $deep_inline_script = "";
								$deep_inline_script .= ' jQuery(".video_thumb").fitVids(); ';
							} else if ($this_posttype == "quote"){
								?>
								<div class="quote_thumb">
									<div class="post-quote">
										<blockquote><i class="fa fa-quote-left"></i> <?php echo wp_kses(get_post_meta($post->ID, 'quote_text_value', true), 'post'); ?><i class="fa fa-quote-right"></i></blockquote>
										<span class="author-quote"><?php echo wp_kses(get_post_meta($post->ID, 'quote_author_value', true), 'post'); ?></span>
									</div>
								</div>
								<?php
							} else if ($this_posttype == "gallery"){
								$slider = get_post_meta($post->ID,'gallery_slider_value',true);
								if ($slider != '-1'){
									echo "<div class='gallery_thumb'>";
									if (substr($slider, 0, 10) === "revSlider_"){
										if (!function_exists('putRevSlider')){
											echo esc_html__('Please install the missing plugin - Revolution Slider.', 'deep');
										} else {
											putRevSlider(substr($slider, 10));
										}
									} else {
										
										if (!function_exists('masterslider')){
											echo esc_html__('Please install the missing plugin - MasterSlider.', 'deep');
										} else {
											echo do_shortcode( '[masterslider alias="'.substr($slider, 13).'"]' );
										}
									}
									echo "</div>";
								}
							} else if ($this_posttype == "audio"){
								echo "<div class='audio_thumb'>";
								?>
								<div class="audioContainer">
									<?php
										if (get_post_meta($post->ID, 'audioSource_value', true) == 'embed') echo get_post_meta($post->ID, 'audioCode_value', true); 
										else {
											$audio = explode("|!|",get_post_meta($post->ID, 'audioMediaLibrary_value', true));
											if (isset($audio[1])) {
												$ext = explode(".",$audio[1]);
												if (isset($ext)) $ext = $ext[count($ext)-1];
												?>
												<audio controls="controls"><source type="audio/<?php echo esc_attr($ext); ?>" src="<?php echo esc_url($audio[1]); ?>"></audio>
												<?php
											}
										}
									?>
								</div>
								<?php
								echo "</div>";
							} else {
								$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'deep_portfolio' );
								if ($image && $image[0]) echo "<div class='featured_image'><img alt='".esc_attr($post->post_title)."' src='".esc_url($image[0])."' /></div>";
							}
							
							$titlefont = get_option('deep_blog_masonry_title_font');
							if (is_array($titlefont)) $titlefont = ""; $deep_import_fonts[] = $titlefont;
							$titlefont = explode("|",$titlefont);
							$titlefont[0] = $titlefont[0]."', 'Arial', 'sans-serif";
							if (!isset($titlefont[1])) $titlefont[1] = "";
							$titlecolor = intval(get_option('deep_blog_masonry_title_color'),10);
							$titlesize = get_option('deep_blog_masonry_title_size');
							if (!is_null($titlesize)) $titlesize = str_replace(" ", "", $titlesize);

							if ($title != "" && $this_posttype != "quote") echo "<h5 class='title'>{$post->post_title}</h5>";
							echo "</a>";
							if ($post->post_content != ""){
								$text = apply_filters('the_content', $post->post_content);
								$text = str_replace(']]>', ']]&gt;', $text);
								$excerpt_length = apply_filters('excerpt_length', 20);
								$excerpt_more = apply_filters('excerpt_more', ' ');
								$text = wp_trim_words( $text, $excerpt_length, $excerpt_more );
								if ($this_posttype != "quote") echo "<div class='excerpt'>".apply_filters('wp_trim_excerpt', $text)."</div>";
							}
							
								printf( '<a class="blog-read-more" href="%1$s">%2$s</a>',
									get_permalink( $post ), get_option("deep_read_more")
								);
									
							echo "</div></div>";
							
							
							$deep_output = "title{color: #$titlecolor; font-size: $titlesize; font-family: '{$titlefont[0]}'; font-weight: {$titlefont[1]};}";
							deep_set_custom_inline_css($deep_output);
							
						}
					?>
					</div>
				</div>
				
				<?php
				if (get_post_meta(get_the_ID(), '_wpb_vc_js_status', true)){
					if (get_option('deep_header_style_type') == 'style8')
						$related_posts_output = '[vc_row el_class="single-post-related-container"][vc_column]'.ob_get_clean().'[/vc_column][/vc_row]';
					else 
						$related_posts_output = '[vc_row full_width="stretch_row_content_no_spaces"][vc_column]'.ob_get_clean().'[/vc_column][/vc_row]';
				}
				else $related_posts_output = ob_get_clean();
				echo do_shortcode($related_posts_output);
				
				// adicionar o resto das options tipo qtos por linha, numero maximo de posts, com ou sem slider (e as respectivas slider options)
				$slider = get_post_meta( get_the_ID(), 'deep_related_posts_slider_value', true ) == "yes" ? true : false;
				if ($from_panel) $slider = get_option( 'deep_related_posts_slider' ) == "on" ? true : false;
				if ($slider){
					
					$nav = get_post_meta( get_the_ID(), 'deep_related_posts_slider_nav_value', true ) == "yes" ? true : false;
					$controlnav = get_post_meta( get_the_ID(), 'deep_related_posts_slider_controlnav_value', true ) == "yes" ? true : false;
					$autoplay = get_post_meta( get_the_ID(), 'deep_related_posts_slider_autoplay_value', true ) == "yes" ? true : false;
					if ($from_panel){
						$nav = get_option( 'deep_related_posts_slider_nav' ) == "on" ? true : false;
						$controlnav = get_option( 'deep_related_posts_slider_controlnav' ) == "on" ? true : false;
						$autoplay = get_option( 'deep_related_posts_slider_autoplay' ) == "on" ? true : false;
					}
					
					if (!isset($deep_inline_script)) $deep_inline_script = "";
					$deep_inline_script .= '
						jQuery(document).ready(function(){
							"use strict";
							jQuery(".deep_related_posts .related_posts_listing").slick({';
							if ($controlnav) $deep_inline_script .= 'dots:true,';
							if ($autoplay) $deep_inline_script .= 'autoplay:true,autoplaySpeed:5000,';
							$deep_inline_script .= 'speed:1500,infinite:true,';
							if ($nav) $deep_inline_script .= 'arrows:true,';
							$deep_inline_script .= 'adaptiveHeight:true,';
							if ($nav){
								$deep_inline_script .= 'prevArrow:"<button type=\'button\' class=\'slick-prev default\'><i class=\'ultsl-arrow-left6\'></i></button>",nextArrow:"<button type=\'button\' class=\'slick-next default\'><i class=\'ultsl-arrow-right6\'></i></button>",';
								$deep_output = ".deep_related_posts button[type='button']{ color: rgb(51, 51, 51); font-size: 24px; display: block; }.deep_related_posts i.ultsl-record{ color:#333333; }";
								deep_set_custom_inline_css($deep_output);
							}
							$deep_inline_script .= 'slidesToScroll:'.esc_js($postsperrow).',slidesToShow:'.esc_js($postsperrow).',swipe:true,draggable:true,touchMove:true,pauseOnHover:true,pauseOnDotsHover:true,mobileFirst:true,customPaging:function(slider,i){return "<i type=\'button\' class=\'ultsl-record\' data-role=\'none\'></i>";},';
							$middle_res = intval($postsperrow) > 2 ? 2 : intval($postsperrow) ;
							$deep_inline_script .= 'responsive:[{breakpoint: 1024,settings:{slidesToShow:'.esc_js( intval($postsperrow) ).',slidesToScroll: '.esc_js( intval($postsperrow) ).'}},{breakpoint: 768,settings:{slidesToShow: '. esc_js($middle_res) .',slidesToScroll: '. esc_js($middle_res) .'}},{breakpoint: 480,settings:{slidesToShow: 1,slidesToScroll: 1}},{breakpoint: 0,settings:{slidesToShow: 1,slidesToScroll: 1}}]
							});
						});
					';
					
				}
			}
		}
		/* endof related posts */
		?>
		
		
		<?php
		if (get_option("deep_display_comments") == "on"){
			if (comments_open( get_the_ID() ) || get_comments_number( get_the_ID() ) ){
				?>
				<div>
					<div class="the_comments">
						<?php comments_template( '', true ); ?>
					</div>
				</div>
  
		<?php
			}
		}
		$deep_inline_script .= '
			jQuery(document).ready(function(){
				"use strict";
				jQuery(".social-shares a[target=\'_blank\']").on("click", function(){
					newwindow=window.open(jQuery(this).attr("href"),"","height=450,width=700");
					if (window.focus) {newwindow.focus()}
					return false;
				});
			});
		';
		wp_add_inline_script('deep-global', $deep_inline_script, 'after');
		
	}

	function deep_print_single_post($deep_inline_script){
		?>
		<article id="post-<?php esc_attr(the_ID()); ?>" class="post">
				
				   
			<?php
			
			$posttype = get_post_meta(get_the_ID(), 'posttype_value', true);
			
			$postid = get_the_ID(); 
			?>
			
			<div class="postcontent">

			<?php
				
				switch($posttype){
					case "image":
						if (wp_get_attachment_url( get_post_thumbnail_id($postid)) && get_post_meta( $postid, 'deep_display_featured_image_value', true ) == "yes" ){
						?>
							<div class="featured-image-thumb">
								<img src="<?php echo esc_url(wp_get_attachment_url( get_post_thumbnail_id($postid))); ?>" title="<?php the_title_attribute() ?>"/>
									
							</div>
							<?php 
							
						}
					break;
					
					case "slider": 
						$randClass = rand(0,1000);
						?>
						<div class="flexslider flex-not-ready <?php echo esc_attr($posttype); ?>" id="<?php echo esc_attr($randClass); ?>">
							<ul class="slides">
								<?php
									$sliderData = get_post_meta($postid, "sliderImages_value", true);
									$slide = explode("|*|",$sliderData);
									foreach ($slide as $s){
										if ($s != ""){
											$params = explode("|!|",$s);
											$attachment = get_post( $params[0] );
											echo "<li>";
											echo "<img src='".esc_url($params[1])."' >";
											echo "</li>";	
										}
									}
								?>
							</ul>
						</div>
						<?php
						$animation = get_option("deep_posts_flex_transition_singles");
						$directionNav = get_option("deep_posts_flex_navigation_singles");
						$slideshowSpeed = get_option("deep_posts_flex_slide_duration_singles", 3000);
						$pauseOnHover = get_option("deep_posts_flex_pause_hover_singles");
						$controlNav = get_option("deep_posts_flex_controls_singles");
						$slideshow = get_option("deep_posts_flex_autoplay_singles");
						$height = intval(get_option("deep_posts_flex_height_singles",400));
						if (!$height) $height = "auto";
						$animationDuration = get_option("deep_posts_flex_transition_duration_singles", 1000);
						if ($directionNav == "on" || $directionNav == "true") $directionNav = true; else $directionNav = false;
						if ($pauseOnHover == "on" || $pauseOnHover == "true") $pauseOnHover = true; else $pauseOnHover = false;
						if ($controlNav == "on" || $controlNav == "true") $controlNav = true; else $controlNav = false;
						if ($slideshow == "on" || $slideshow == "true") $slideshow = true; else $slideshow = false;
						
						$deep_inline_script .= '
							jQuery(document).ready(function(){
								"use strict";
								jQuery("#'.esc_js($randClass).'.flexslider").flexslider({
									animation: "'.esc_js($animation).'",
									slideDirection: "horizontal", 
									directionNav: "'.esc_js($directionNav).'",
									slideshowSpeed: '.esc_js($slideshowSpeed).',
									controlsContainer: "#'.esc_js($randClass).' .flex-viewport",
									pauseOnAction: false,
									pauseOnHover: "'.esc_js($pauseOnHover).'",
									keyboardNav: false,
									controlNav: "'.esc_js($controlNav).'",
									slideshow: "'.esc_js($slideshow).'",
									animationSpeed: '.esc_js($animationDuration).',
									start: function(slider){
										jQuery("#'.esc_html($randClass).'.flexslider").removeClass("flex-not-ready").css("overflow","visible").find(".slides").css("max-height", "'.esc_js( $height ).'px");
										jQuery(slider).find(".flex-direction-nav").css({ "position":"absolute", "width":"100%", "top":"50%" });
										jQuery(slider).flexslider("next");
									}
								});
								jQuery("#'.esc_js($randClass).' ul.slides li, #'.esc_js($randClass).' ul.slides li a").css({"max-height":"'.esc_js($height).'","overflow":"hidden"});
							});
						';		
					break;
					
					case "audio":
						$randClass = rand(0,1000);
						?>
						<div class="audioContainer">
							<?php
								if (get_post_meta($postid, 'audioSource_value', true) == 'embed') echo get_post_meta($postid, 'audioCode_value', true); 
								else {
									$audio = explode("|!|",get_post_meta($postid, 'audioMediaLibrary_value', true));
									if (isset($audio[1])) {
										$ext = explode(".",$audio[1]);
										if (isset($ext)) $ext = $ext[count($ext)-1];
										?>
										<audio controls="controls"><source type="audio/<?php echo esc_attr($ext); ?>" src="<?php echo esc_url($audio[1]); ?>"></audio>
										<?php
									}
								}
							?>
						</div>
						<?php
					break;
					
					case "video":
						$videosType = get_post_meta($postid, "videoSource_value", true);
						if ($videosType != "embed"){
							$videos = get_post_meta($postid, "videoCode_value", true);
							$videos = preg_replace( '/\s+/', '', $videos );
							$vid = explode(",",$videos);
						}
						switch (get_post_meta($postid, "videoSource_value", true)){
							case "media":
								echo "<video id='html5video' preload='metadata' controls='controls'>";
								$media = get_post_meta($postid, 'videoMediaLibrary_value', true);
								$media = explode("|*|",$media);
								foreach ($media as $m){
									if (strlen($m) > 0){
										$videoattrs = explode("|!|",$m);
										$ext = explode('.',$videoattrs[1]);
										$ext = $ext[count($ext)-1];
										echo "<source src=".esc_url($videoattrs[1])." type='video/".esc_attr($ext)."'>";
									}
								}
								$deep_output = "#html5video{ position:relative;float:left;width:100%; }";
								deep_set_custom_inline_css($deep_output);
								echo "</video>";
							break;
							case "youtube":
								echo "<div id='the_movies' class='vendor ".esc_attr(get_post_meta($postid, "videoSource_value", true))."'></div>";
								foreach ($vid as $v){
									echo "<div class='v_links'>https://www.youtube.com/embed/".esc_attr($v)."?autoplay=1&amp;wmode=transparent&amp;autohide=1&amp;showinfo=0&amp;rel=0</div>";	
								}
								break;
							case "vimeo":
								echo "<div id='the_movies' class='vendor ".esc_attr(get_post_meta($postid, "videoSource_value", true))."'></div>";
								foreach ($vid as $v){
									echo "<div class='v_links'>https://player.vimeo.com/video/".esc_attr($v)."?autoplay=1&amp;title=0&amp;byline=0&amp;portrait=0</div>";	
								}
								break;
						}
						
						$deep_inline_script .= '
							jQuery(document).ready(function(){
							"use strict";
						';
						if (get_post_meta($postid, "videoSource_value", true) != "embed" && get_post_meta($postid, "videoSource_value", true) != "media"){
							$deep_inline_script .= '
							var aux_html = "<iframe src=\'"+jQuery(".v_links").eq(0).html()+"\' width=\'560\' height=\'349\' frameborder=\'0\' webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>";
							jQuery("#the_movies").html(aux_html).fitVids();
							';
						}
						$deep_inline_script .= '
							jQuery("#the_movies").css({"position":"relative","float":"left","width":"100%"}).siblings(".the_content").css({"display":"inline-block","width":"100%"});
							if (jQuery("#the_movies").siblings(".v_links").length > 1){
								  jQuery("#the_movies").siblings(".movies-nav").remove();
								  var aux_html = "<ul class=\'flex-direction-nav movies-nav\'><li><a class=\'prev\' href=\'javascript:;\'></a></li><li><a class=\'next\' href=\'javascript:;\'></a></li></ul>";
								jQuery("#the_movies").append(aux_html);
								  jQuery("#the_movies .flex-direction-nav").css({
									  "position": "absolute",
									  "width":"100%",
									  "top":"50%",
								  }).find("li").css({"margin":0,"padding":0}).find("a").css({"display":"inline-block", "position":"relative", "opacity":1});
								  jQuery("#the_movies .flex-direction-nav li").eq(0).css("float","left");
								  jQuery("#the_movies .flex-direction-nav li").eq(1).css("float","right");
								  
								  jQuery("#the_movies").siblings(".current_movie").remove();
								  jQuery("#the_movies").after("<div hidden class=\'current_movie boldway_hidden\'>0</div>");
								  
								  jQuery(".movies-nav").find(".prev").on("click",function(e){
									  e.preventDefault();
									  var index = parseInt(jQuery(".current_movie").html());
									  var nextIndex = 0;
									  if (index == 0) nextIndex = jQuery("#the_movies").siblings(".v_links").length - 1;
									  else nextIndex = index-1;
									  jQuery("#the_movies iframe").attr("src", jQuery("#the_movies").siblings(".v_links").eq(nextIndex).html() );
									  jQuery("#the_movies").siblings(".current_movie").html(nextIndex);
									  
								  });
								  jQuery(".movies-nav").find(".next").on("click",function(e){
									  e.preventDefault();
									  var index = parseInt(jQuery(".current_movie").html());
									  var nextIndex = 0;
									  if (index == jQuery("#the_movies").siblings(".v_links").length - 1) nextIndex = 0;
									  else nextIndex = index+1;
									  jQuery("#the_movies iframe").attr("src", jQuery("#the_movies").siblings(".v_links").eq(nextIndex).html() );
									  jQuery("#the_movies").siblings(".current_movie").html(nextIndex);
				
								  });
							  }
						';
						$deep_inline_script .= '
							});
						';
					break;
					
					case "gallery":
						$slider = get_post_meta($postid,'gallery_slider_value',true);
						if ($slider != '-1'){
							if (substr($slider, 0, 10) === "revSlider_"){
								?>
								<div class="gallery_container">
									<?php
										if (!function_exists('putRevSlider')){
											echo esc_html__('Please install the missing plugin - Revolution Slider.', 'deep');
										} else {
											putRevSlider(substr($slider, 10));
										}
									?>
								</div>
								<?php
							} else {
								?>
								<div class="gallery_container">
									<?php
										if (!function_exists('masterslider')){
											echo esc_html__('Please install the missing plugin - MasterSlider.', 'deep');
										} else {
											echo do_shortcode( '[masterslider alias="'.substr($slider, 13).'"]' );
										}
									?>
								</div>
								<?php
							}
						}
					break;
					
					case "quote":
						?>
						<div class="post-quote">
							<blockquote><i class="fa fa-quote-left"></i> <?php echo wp_kses(get_post_meta($postid, 'quote_text_value', true), 'post'); ?> <i class="fa fa-quote-right"></i></blockquote>
							<span class="author-quote">-- <?php echo wp_kses(get_post_meta($postid, 'quote_author_value', true), 'post'); ?> --</span>
						</div>
						<?php
					break;
				}

				?>
				
				<?php
				
				if (get_post_meta( $postid , 'boldway_single_display_metas_value' , true ) == "yes" && (get_post_meta( $postid , 'boldway_single_display_metas_where_value' , true ) != 'pagetitle' && get_post_meta( $postid , 'boldway_single_display_metas_where_value' , true ) != '')){
					
					if (get_post_meta($postid, "deep_enable_custom_pagetitle_options_value", true) == "no" || !get_post_meta($postid, "deep_enable_custom_pagetitle_options_value", true)) $tcolor = get_option("deep".'_header_text_color');
					else $tcolor = get_post_meta($postid, "deep_header_text_color_value", true);
					
					
					?>
					<div class="metas-container">
						<div class="align-metas-center">
							
							<?php
								$metas = get_post_meta( $postid , 'boldway_single_metas_value' , true );
								if ($metas=="") $metas = "date,author,tags,categories";
								$metas = explode(",", $metas);
								if (!empty($metas)){
										
										$firstMeta = true;
										foreach ($metas as $meta){
										switch ($meta){
											case "date":
												?>
												<p class="blog-date deep-apply-tcolor"><i class="mi-clock"></i><?php echo get_the_date(); ?></p>
												<?php
											break;
											case "author":
												
												?>
												<p><a class="the_author deep-apply-tcolor" href="<?php echo get_author_posts_url( get_the_author_meta('ID') ); ?>"><i class="mi-user"></i><?php  esc_html(the_author_meta('display_name')); ?></a></p>
												<?php
											break;
											case "tags":
												$posttags = get_the_tags();
												if ($posttags) {
													
													$first = true;
													echo '<p class="deep-apply-tcolor"><i class="mi-folder"></i> ';
													
													foreach($posttags as $tag) {
														if ($tag->name != "uncategorized"){
															if ($first){
																echo "<a class='the_tags' href='".esc_url( get_term_link($tag) )."'>".esc_html($tag->name)."</a>"; 
																$first = false;
															} else {
																echo "<span>, </span><a class='the_tags' href='".esc_url( get_term_link($tag) )."'>".esc_html($tag->name)."</a>";
															}
														}
													  }
													  echo '</p>';
												}
											break;
											case "categories":
												$postcats = get_the_category();
												if ($postcats) {
													
													$first = true;
													echo '<p class="deep-apply-tcolor"><i class="mi-folder"></i> ';
													
													
													foreach($postcats as $cat) {
														if ($cat->name != "uncategorized"){
															if ($first){
																echo "<a class='the_cats' href='".esc_url( get_term_link($cat) )."'>".esc_html($cat->name)."</a>"; 
																$first = false;
															} else {
																echo "<span>, </span><a class='the_cats' href='".esc_url( get_term_link($cat) )."'>".esc_html($cat->name)."</a>"; 
															}	
														}
													  }
													  echo '</p>';
												}
											break;
											case "comments":
												
												echo '<p class="deep-apply-tcolor"><i class="mi-message"></i> ';
												printf( _nx( 'One Comment', '%1$s Comments', get_comments_number(), 'comments title', 'deep' ), number_format_i18n( get_comments_number() ) );
												echo '</p>';
											break;
											
										}
										
									}
								}
							?>
						</div>
					</div>
					<?php
				}
				?>
<!-- 				<div class="the_title"><h2><?php echo wp_kses(the_title(), 'post'); ?></h2></div> -->
			
				
				<div class="the_content">
					<?php 
						$content = get_the_content(get_the_ID());
						
						$boldway_theme_main_color = "#".get_option('deep_style_color');
						$content = str_replace( '__USE_THEME_MAIN_COLOR__', $boldway_theme_main_color, $content );
						
						$content = apply_filters('the_content', $content); 
						deep_content_shortcoder($content);
						
						$content = wp_kses_no_null( $content, array( 'slash_zero' => 'keep' ) );
						$content = wp_kses_normalize_entities($content);
						echo wp_kses_hook($content, 'post', array()); // WP changed the order of these funcs and added args to wp_kses_hook
						
						$shortcodes_custom_css = get_post_meta( get_the_ID(), '_wpb_shortcodes_custom_css', true );
						if ( isset($shortcodes_custom_css) && ! empty( $shortcodes_custom_css ) ) {
							deep_set_custom_inline_css($shortcodes_custom_css);
						}
						
						$args = array(
							'before'           => '<div class="navigation margin-top-0px"><div class="des-pages"><span class="pages current">' . esc_html__('Post Pages:', 'deep') . '</span>',
							'after'            => '</div></div>',
							'link_before'      => '<div class="postpagelinks">',
							'link_after'       => '</div>',
							'next_or_number'   => 'number',
							'nextpagelink'     => esc_html__('Next page','deep'),
							'previouspagelink' => esc_html__('Previous page','deep'),
							'pagelink'         => '%',
							'echo'             => 1
						); 
						wp_link_pages($args); 
					?>

				</div>    
				
			</div> <!-- end of .postcontent -->
			
		</article> <!-- end of post -->
		
	<?php
		return $deep_inline_script;
	}
	