<?php
/**
 * Blog Post Main File.
 *
 * @package INVENTIVE
 * @author  Themekalia
 * @version 1.0
 */

get_header();
$options = inventive_WSH()->option();

$data    = \INVENTIVE\Includes\Classes\Common::instance()->data( 'single' )->get();
$layout = $data->get( 'layout' );
$sidebar = $data->get( 'sidebar' );
$layout = ( $layout ) ? $layout : 'full';
$sidebar = ( $sidebar ) ? $sidebar : '';
if (is_active_sidebar( $sidebar )) {$layout = 'right';} else{$layout = 'full';}
$class = ( !$layout || $layout == 'full' ) ? 'col-xs-12 col-sm-12 col-md-12 col-lg-12' : 'col-lg-8 col-md-12 col-sm-12';


if ( class_exists( '\Elementor\Plugin' ) && $data->get( 'tpl-type' ) == 'e') {
	
	while(have_posts()) {
	   the_post();
	   the_content();
    }

} else {
?>

<?php if ( $data->get( 'enable_banner' ) ) : ?>
	<?php do_action( 'inventive_banner', $data );?>
<?php else:?>
<!-- Page Title -->
<section class="page-title">
    <?php if( $data->get( 'banner' ) ){?><div class="bg-layer" style="background-image: url('<?php echo esc_url( $data->get( 'banner' ) ); ?>');"></div><?php };?>
    <div class="auto-container">
        <div class="content-box">
            <h1><?php if ($data->get('title')) { echo wp_kses($data->get('title'), true); } else { the_title(); } ?></h1>
            <ul class="bread-crumb clearfix">
                <?php echo inventive_the_breadcrumb(); ?>
            </ul>
        </div>
    </div>
</section>
<!-- End Page Title -->
<?php endif;?>

<!-- sidebar-page-container -->
<section class="sidebar-page-container inner_page">
    <div class="auto-container">
        <div class="row">   	
        	
            <!-- Left sidebar -->
			<?php if( $data->get( 'layout' ) == 'left' ): ?>
			<div class="col-lg-4 col-md-12 col-sm-12 sidebar-side">
                <div class="blog-sidebar default-sidebar pt_60 pb_50">
                    <?php dynamic_sidebar( $sidebar ); ?>
                </div>
            </div>
			<?php endif; ?>
            
            <!-- Main Content -->
            <div class="content-side <?php echo esc_attr( $class ); ?> <?php if ( $data->get( 'layout' ) == 'left' ) echo 'left-sidebar'; elseif ( $data->get( 'layout' ) == 'right' ) echo 'right-sidebar'; ?>">				                               	
                
                <?php while ( have_posts() ) : the_post(); ?>
                <div class="shape_right_border"></div>
                <div class="blog-details-content pt_100 pb_100">
                	<div class="thm-unit-test"> 
                		<div class="news_details_block">
                            <div class="inner-box">
                                <div class="post_title_box mb_30">
                                    <?php if( has_category() || function_exists('bunch_share_us_two')){ ?>
                                    <div class="post_tag_box">
                                        <?php if( has_category() ){ ?><div class="post_tag"><i class="far fa-folder-open"></i> <?php the_category(', '); ?></div><?php } ?>
                                        <?php if(function_exists('bunch_share_us_two')):?>
                                        <div class="shear_btn">
                                            <span class="icon-share"></span>
                                            <ul class="shear_social_icon">
                                                <?php echo bunch_share_us_two(get_the_id(),$post->post_name );?>
                                            </ul>
                                        </div>
                                        <?php endif;?>
                                    </div>
                                    <?php } ?>
                                    <?php if(! $options->get( 'single_post_author' ) || $options->get( 'single_post_date' ) || $options->get( 'single_post_comments' ) ){ ?>
                                    <ul class="post-info">
                                        <?php if(! $options->get( 'single_post_author' ) ){ ?><li class="admin"><i class="far fa-user"></i> <?php the_author(); ?></li><?php } ?>
                                        <?php if(! $options->get( 'single_post_date' ) ){ ?><li class="post-date"><i class="far fa-calendar"></i> <?php echo get_the_date(); ?></li><?php } ?>
                                        <?php if(! $options->get( 'single_post_comments' ) ){ ?><li class="post-comment"><i class="far fa-comment"></i> <?php comments_number( wp_kses(__('0 Comments' , 'inventive'), true), wp_kses(__('1 Comment' , 'inventive'), true), wp_kses(__('% Comments' , 'inventive'), true)); ?></li><?php } ?>
                                    </ul>
                                    <?php } ?>
                                </div>
                                <?php if( has_post_thumbnail() ){?>
                                <figure class="post_image mb_40">
                                    <?php the_post_thumbnail('full'); ?>
                                </figure>
                                <?php };?>                                
                            </div>                            
                        </div>
                        
                        <div class="text"><?php the_content(); ?></div>
                        <div class="clearfix"></div>
                        <?php wp_link_pages(array('before'=>'<div class="paginate-links mt_40">'.esc_html__('Pages: ', 'inventive'), 'after' => '</div>', 'link_before'=>'<span>', 'link_after'=>'</span>')); ?>
                        
                        <?php if(has_tag()){ ?>
                        <div class="post_tag mt_40">
                            <h6><i class="far fa-tag"></i><?php esc_html_e('Post Tags', 'inventive'); ?></h6>
                            <ul  class="post_tag_list">
                                <?php the_tags( '<li>', '</li><li> ', '</li>' ); ?>
                            </ul>
                        </div>                        
                        <?php } ?>
                        
                        <?php if( $options->get( 'single_post_author_box' ) ):?>
                        <div class="post_author_box">
                            <?php if($avatar = get_avatar(get_the_author_meta('ID')) !== FALSE): ?>
                            <div class="author_thumb">
                                <?php echo get_avatar(get_the_author_meta('ID'), 150); ?>
                            </div>
                            <?php endif; ?>
                            <div class="author_info">
                                <span class="post_by"><?php esc_html_e('Post By','inventive'); ?></span>
                                <h4 class="author_name"><?php the_author(); ?></h4>
                                <p><?php the_author_meta( 'description', get_the_author_meta('ID') ); ?></p>
                                <div><a href="" class="read_more_1_btn"><span class="icon-diagonal-arrow-1"></span><?php esc_html_e('Read All Post','inventive'); ?></a></div>
                                <?php if( $options->get( 'single_post_author_links' ) ):?>
                                <ul class="social_links">
                                    <?php echo inventive_get_social_icon(); ?>
                                </ul>
                                <?php endif; ?>
                            </div>
                        </div>
                        <?php endif;?>
                        
                        <?php if((get_previous_post()) || (get_next_post())): ?>
                        <div class="post-nav-btn">
                            <div class="post-btn">
                                <?php global $post; $prev_post = get_previous_post();
									if (!empty($prev_post)):
								?>
                                <div class="single-btn prev-btn">
                                    <div class="link_btn"><a href="<?php echo esc_url(get_the_permalink($prev_post->ID)); ?>"><span class="icon-diagonal-arrow-1"></span><?php esc_html_e('Prev Post','inventive'); ?></a></div>
                                    <h6><a href="<?php echo esc_url(get_the_permalink($prev_post->ID)); ?>"><?php echo wp_kses_post($prev_post->post_title); ?></a></h6>
                                </div>
                                <?php endif ?>
								<?php global $post; $next_post = get_next_post();
                                    if (!empty($next_post)):
                                ?>
                                <div class="single-btn next-btn">
                                    <div class="link_btn"><a href="<?php echo esc_url(get_the_permalink($next_post->ID)); ?>"><span class="icon-diagonal-arrow-1"></span><?php esc_html_e('Next Post','inventive'); ?></a></div>
                                    <h6><a href="<?php echo esc_url(get_the_permalink($next_post->ID)); ?>"><?php echo wp_kses_post($next_post->post_title); ?></a></h6>
                                </div>
                                <?php endif ?>
                            </div>
                            <?php global $post; $prev_post = get_previous_post();
									if (!empty($prev_post)):
								?>
                            <div class="btn-box">
                                <a href="<?php echo esc_url(get_the_permalink($prev_post->ID)); ?>"><span><?php esc_html_e('Back to Blog Post','inventive'); ?></span></a>
                            </div>
                            <?php endif ?>
                        </div>
                    	<?php endif;?>
                        
                    	<!--End post-details-->
                        <?php comments_template(); ?>
                    
                    </div>
                </div>
                <!--End thm-unit-test-->
                <?php endwhile; ?>				
            </div>
        	
            <!-- Right sidebar -->
			<?php if( $data->get( 'layout' ) == 'right' ): ?>
			<div class="col-lg-4 col-md-12 col-sm-12 sidebar-side">
                <div class="blog-sidebar default-sidebar pt_60 pb_50">
                    <?php dynamic_sidebar( $sidebar ); ?>
                </div>
            </div>
			<?php endif; ?>
            
        </div>
    </div>
</section>
<!--End blog area-->

<?php }
get_footer();
