<?php
/**
 * The default template for displaying Single Document
 *
 * @package WordPress
 * @subpackage Charity
 * @since Charity 1.0
 */
?>
<?php
	the_post();
	$wplook_pid = $post->ID;
	$wplook_page_meta 			=  get_post_meta($wplook_pid);
	$wplook_document_file 		=  isset($wplook_page_meta['wpl_document_file'][0]) ? $wplook_page_meta['wpl_document_file'][0] : "";
	$wplook_document_size 		=  isset($wplook_page_meta['wpl_document_file_size'][0]) ? $wplook_page_meta['wpl_document_file_size'][0] : "";
	$wplook_document_page 		=  isset($wplook_page_meta['wpl_document_pages'][0]) ? $wplook_page_meta['wpl_document_pages'][0] : "";
	$wplook_sidebar_position 	=  isset($wplook_page_meta['wpl_cpt_sidebar_position'][0]) ? $wplook_page_meta['wpl_cpt_sidebar_position'][0] : "right";
	$wplook_page_sidebar  		=  (isset($wplook_page_meta['wpl_cpt_sidebar_select'][0]) && $wplook_page_meta['wpl_cpt_sidebar_select'][0] != '') ? $wplook_page_meta['wpl_cpt_sidebar_select'][0] : "document-1";
	$wplook_page_header 		=  (isset($wplook_page_meta['wpl_page_header'][0]) && $wplook_page_meta['wpl_page_header'][0] != '') ? $wplook_page_meta['wpl_page_header'][0] : false;

 ?>
<?php get_header(); ?>

	<div class="main">
		<div class="main-head">
			<div class="main-head-image fullscreener">
				<?php
					if ( $wplook_page_header ) {
						echo '<img class="hide" src="'. esc_url( $wplook_page_header ).'">';
					}?>
			</div><!-- /.main-head-image fullscreener -->

			<div class="main-head-content">
				<div class="grid-container">
					<div class="grid-x grid-margin-x">
						<div class="cell small-12">
							<h1 class="main-title main-title-alt"><?php the_title(); ?></h1><!-- /.main-title main-title-alt -->
							<?php if (ot_get_option('wpl_breadcrumbs_status') == 'on') : ?>
								<ul class="breadcrumbs">
									<?php wplook_breadcrumbs(); ?>
								</ul><!-- /.breadcrumbs -->
							<?php endif; ?>
						</div><!-- /.cell small-12 -->
					</div><!-- /.grid-x grid-margin-x -->
				</div><!-- /.grid-container -->
			</div><!-- /.main-head-content -->
		</div><!-- /.main-head -->
		<div class="main-body">
			<div class="grid-container">
				<div class="grid-x grid-margin-x">
					<div class="cell small-12 <?php if ( $wplook_sidebar_position == 'right') { echo "large-8";} elseif ( $wplook_sidebar_position == 'disable' ) {echo "large-12"; } else { echo " large-8 right";} ?>">
						<div class="content">
							<article id="post-<?php the_ID(); ?>" <?php post_class('post post-single post-document'); ?>>
								<div class="post-body">
									<div class="entry" itemprop="articleBody">
										<?php the_content(); ?>
									</div>
								</div>
							</article>
						</div><!-- /.content -->
					</div><!-- /.cell large-8 -->

				<?php if ( $wplook_sidebar_position != 'disable') { ?>
					<div id="sidebar" class="cell large-3 large-offset-1">
						<div class="sidebar">

	 						<div class="widget widget-download">
								<div class="widget-body">
									<div class="doc-cover">
										<?php
											if ( has_post_thumbnail() ) { ?>
												<?php
													$featured_img_url = get_the_post_thumbnail_url(get_the_ID(),'full');
													echo '<a href="'.esc_url($featured_img_url).'" class="fresco">';
														the_post_thumbnail('document-thumb');
													echo '</a>';
												?>
											<?php }
										?>
									</div>
									<?php
										if ($wplook_document_file != '') {
											echo '<div class="button-download"><a href="'.esc_url( $wplook_document_file ).'" class="button" download>'.__('Download Now', 'charity-wpl').'</a></div>';
										}
									?>
								</div><!-- /.widget-body -->
							</div><!-- /.widget widget-donate -->

							<div class="widget widget-details">
								<div class="widget-head">
									<h4 class="widget-title"><?php _e('Details', 'charity-wpl' ); ?></h4><!-- /.widget-title -->
								</div><!-- /.widget-head -->

								<div class="widget-body single-cause-meta">
									<ul class="side-nav">
										<?php
											if ($wplook_document_page != '') {
												echo '<li><i class="far fa-file-alt"></i> '.$wplook_document_page.'</li>';
											}
											if ($wplook_document_size != '') {
												echo '<li><i class="fas fa-file-alt"></i> '.$wplook_document_size.'</li>';
											}
										?>
										<li>
											<i class="far fa-calendar-alt"></i>

											<?php the_date(); ?>
										</li>
									</ul><!-- /.side-nav -->
								</div><!-- /.widget-body -->
							</div><!-- /.widget widget-details -->

							<?php dynamic_sidebar( $wplook_page_sidebar ); ?>
						</div><!-- /.sidebar -->
					</div><!-- /.cell large-3 push-large-1 -->
				<?php } ?>
			</div><!-- /.grid-x grid-margin-x -->
		</div><!-- /.grid-container -->
		</div><!-- /.main-body -->
	</div><!-- /.main -->

<?php get_footer(); ?>
